Skip to content

Please eliminate the warnings #16

Description

@fhaverkamp

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions