Strange warnings with gcc 4.1.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is with libvirt from CVS.  They don't look like errors to me though...

------------
In function ‘open’,
    inlined from ‘readFile’ at virsh.c:850:
/usr/include/bits/fcntl2.h:45: error: call to ‘__open_too_many_args’ declared with attribute error: open can be called either with 2 or 3 arguments, not more /usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments

The code in question is:

    if ((fd = open(filename, O_RDONLY)) == -1) {

Not a newly created file, so mode isn't needed AFAICS.

------------
In function ‘read’,
    inlined from ‘readFile’ at virsh.c:864:
/usr/include/bits/unistd.h:43: warning: call to ‘__read_chk_warn’ declared with attribute warning: read called with bigger length than size of the destination buffer

The code in question is:

        char buffer[1024];
        char *new;
        int ret;

        if ((ret = read(fd, buffer, sizeof(buffer))) == 0)
            break;

Also seems correct to me.

------------
Other warnings:

virsh.c: In function ‘cmdSchedinfo’:
virsh.c:1138: warning: ‘weight’ may be used uninitialized in this function
virsh.c:1140: warning: ‘cap’ may be used uninitialized in this function

For some reason gcc appears to have lots its ability to do the data flow analysis to find out that these warnings are bogus. In any case the fix is trivial:

Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.105
diff -u -r1.105 virsh.c
--- src/virsh.c 6 Nov 2007 09:41:18 -0000       1.105
+++ src/virsh.c 7 Nov 2007 12:37:07 -0000
@@ -1135,9 +1135,9 @@
     int nr_inputparams = 0;
     int inputparams = 0;
     int weightfound = 0;
-    int weight;
+    int weight = 0;
     int capfound = 0;
-    int cap;
+    int cap = 0;
     char str_weight[] = "weight";
     char str_cap[]    = "cap";
     int ret_val = FALSE;

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]