Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please eliminate the warnings #16

Open
fhaverkamp opened this issue Apr 12, 2016 · 0 comments
Open

Please eliminate the warnings #16

fhaverkamp opened this issue Apr 12, 2016 · 0 comments

Comments

@fhaverkamp
Copy link

When trying to build your code I get a huge number of warnings. This makes me a little afraid that if you miss one which is actually a bug, you run code which might be unreliable. Maybe enable -Werror and fix all you find.

There are format string problems, missing include files e.g. unistd.h at various places and therefore missing prototypes. Not checking return values of read, write, fscanf and potentially other functions etc.
Also comparing signed and unsigned values, castings of not matching sizes, cast pointers to integer types, etc.

htxmp_new.c:437:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
void tresult = (void *)th_rc ; / thread join status _/
hxfpatmp_new.c:262:11: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration]
if (close(fildes) != 0)
misc.c:603:19: warning: passing argument 2 of ‘strcpy’ from incompatible pointer type [-Wincompatible-pointer-types]
strcpy(loc_msg,ptr);
In file included from config_rw.c:27:0:
/usr/include/unistd.h:353:12: note: expected ‘int’ but argument is of type ‘FILE * {aka struct _IO_FILE *}’
extern int close (int __fd);
int ioctl_linux(char *str,int command, struct device_struct *dev_struct)
{
int rc;
FILE fd;
fd = open("/dev/miscchar", O_RDWR);
if (fd < 0)
{
printf("\nerror opening file in user fn ioctl_linux\n");
return -1;
}
/printf("calling dev_struct bus=%d\n",dev_struct->bus_num);/
if(command == 0)
rc = ioctl(fd, MIOPCFGET,dev_struct);
/_printf("rc= %d\n",rc);
/
close(fd);
return rc;

}
Uuhhhh. fd should be really int. In such a case you are probably lucky, but you might miss negative return codes in case of problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant