c

What is the meaning of this splint warning and what might I be doing wrong?

This is the line of code: bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[2]); Running splint 3.1.2 generates this warning: cpfs.h:21:74: Function parameter times declared as manifest array (size constant is meaningless) A formal parameter is declared as an array with size. The size of the...

Splint barfs on __thread, which is part of C99

Running splint matt@stanley:~/cpfs$ splint -paramuse +gnuextensions cpfs.c Halts on this line: __thread int cpfs_errno; With a parse error: cpfs.c:127:13: Parse Error: Non-function declaration: __thread : int. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue. Checking the documentatio...

C: Throw error on parameter check or let it hit the fan ?

Hi everyone, I have a simple design(?) question. I'm writing a simple program, that has a couple of functions that look like these. float foo (float* m,size_t n){ float result; //do some calculations, for example a sum return result / n; } I have a couple of questions on this, with no intention of re opening some holy ...

increment value of int being pointed to by pointer

I have an int pointer (int *count) if i want to increment the integer being pointed at using ++ I thought I would call *count++; However, I am getting a build warning "expression result unused". I can call *count += 1; But, I would like to know how to use the ++. Any ideas? ...

a problem with pointers in C

I have never been good at playing with pointers in C. But this time I would like to ask for your help to resolve my problems with pointers. I have a function here to push a value into a stack. void StackPush(stackT *stackPtr, stackElementT element){ stackNodeT* node = (stackNodeT *) malloc(sizeof(stackNodeT)); if (node == NULL){ ...

synchronizing between send/recv in sockets

I have a server thats sending out data records as strings of varying length(for eg, 79,80,81,82) I want to be able to receive exactly one record at a time.I've delimited records with a (r) but because I dont know howmany bytes I have to receive, It sometimes merges records and makes it difficult for me to process. ...

Why does CPU access memory on a word boundary?

Hi experts~ I heard a lot that data should be properly aligned in memory for better access efficiency. CPU access memory on a word boundary. So in the following scenario, the CPU has to make 2 memory accesses to get a single word. Supposing: 1 word = 4 bytes ("|" stands for word boundary. "o" stands for byte boundary) |----o----o...

books on state machine development

Hello, gcc 4.4.3 gcc c89 I have started to go into the world of state machines using c. I have to develop on for my job. I am just wondering if there are any good book in developing state machines development in C. Recently I bought a book called "Data Structures in C". Excellent book as it explains in very simple terms and doesn't g...

Command Line to see the contents Shared Object Module(lib*.so)

What is the command line to see the contents of a Shared Object module (lib*.so)? Like how we use: ar -t lib*.a for archives(lib*.a) and it displays all the object files in the library. EDIT1 Example ar -t lib*.a gives me a display: asset.o sldep.o ...

socket max number of sends?

Is there a maximum on the number of sends on a socket? My sends work upto about 480 sends after which it starts returning -1 I'm using visual studio 2008 vc++ and socket programming using ACE. ...

C and memory alignment for a binary protocol

I will use this code as an example: typedef struct __attribute__((aligned(XXX),packed)) { uint16_t type; uint32_t id_index; } a_msg; void write_func(){ a_mesg mymsg mymsg.type = htons(1); mymsg.id_index = htonl(5); write(sock_fd, &mymsg, sizeof(a_mesg)); } void read_func(){ a_mesg mymsg read(sock_fd, &mymsg, si...

Free char pointer in c

I am trying to find out filetypes using c code, here is the code char *get_file_type(char *path, char *filename) { FILE *fp; char command[100]; char file_details[100]; char *filetype; sprintf(command, "file -i %s%s", path, filename); fp = popen(command, "r"); if (fp == NULL) { printf("Failed to run c...

Unknown open() flag passed by execve()

When executing a bash script located on my FUSE filesystem, an open() call is made with these flags: debug,cpfsfuse.c(62),cpfs_fuse_open: path "/make.sh", flags 0100040 The flags (0100040) should correspond to those passed in parameter 2 of open(). The unknown flag originates from an execve() call: matt@stanley:~/cpfs/dir$ strace -f ....

Best way for Background processing in PHP based application

I am working on a huge php application with Zend framework, in that project we need to process files and create thumbnails for images, videos, documents for which we are using imagemagick, ffmpeg, openoffice in background process. To make the process optimized and fast with minimum resources I am thinking of implementing this process usi...

Http posting a comment to wordpress in c

Hi.I can't post comment to wordpress page in c using curl.I tried formadd but it didn't happen again. <input id="author" name="author" type="text" value="" size="30" aria-required="true"> <input id="email" name="email" type="text" value="" size="30" aria-required="true"> <input id="url" name="url" type="text" value="" size="30"> <textar...

Persistence tools in C

I am looking for comfortable mechanisms for storing/restoring dynamically created data on disk. Data is a network of objects, interconnected by indexes or pointers. ...

shared memory across compilers?

Hi, I have to start off by saying I have very little idea on this topic so humor me if i seem ignorant. Due to the problem of having to use a vc++ library in a g++ compiled program, I built a local server-client system where the server is compiled in vc++ and the client in g++ and they interact through sockets. A lot of data transfer o...

Is there any way to follow the bottom-up approach in C?

Usually, the C language uses a top-down approach, and C++ uses a bottom-up approach. Is it necessary to follow these approaches? Can I follow a bottom-up approach in C? If so... how? ...

Exit functions in C

What is the difference between exit(), _exit() and _Exit() in C? How do I decide which to use? On bash, man 2 exit gave me the page _EXIT(2), whereas man 3 exit gave the page EXIT(3). ...

How can I delete a file pointed to by a FILE* in C?

#include<stdio.h> int main() { FILE* fp; fp = fopen("temp.txt", "w"); fprintf(fp, "Hello, World!\n"); // remove("temp.txt"); this requires the filename as an argument // removefile(fp); <--- is something like this possible? return 0; } The remove function (defined in stdio.h) takes the file name as a p...