Wireshark mailing list archives

Re: Error in Wireshark (tshark.c:646)


From: Pascal Quantin <pascal.quantin () gmail com>
Date: Thu, 20 Apr 2017 14:05:43 +0200

2017-04-20 14:03 GMT+02:00 Pascal Quantin <pascal.quantin () gmail com>:

Hi Rémy,

2017-04-20 13:57 GMT+02:00 Remy Leone <remy.leone () inria fr>:

Hello,

I've noticed that master broke recently:
tshark.c:646:24: error: variable ‘exp_pdu_filename’ might be clobbered by
‘longjmp’ or ‘vfork’ [-Werror=clobbered]
   const char          *exp_pdu_filename = NULL;
                        ^
Is a fix on the way? How could this bug passed through CI ?


This kind of warnings is highly dependent on the compiler version used.
That's why it was not spotted so far, and why you are the first one to
report the issue (for example I'm using gcc 6.3.1 and I do not have this
warning).
Does replacing the line by the code below allows you to build?
const volatile char *exp_pdu_filename = NULL;


Short answer: it will not as it will create other errors:

/mnt/data/tools/wireshark/git/tshark.c: In function ‘main’:
/mnt/data/tools/wireshark/git/tshark.c:1902:24: error: passing argument 1
of ‘open’ discards ‘volatile’ qualifier from pointer target type
[-Werror=discarded-qualifiers]
       exp_fd = ws_open(exp_pdu_filename, O_WRONLY | O_CREAT | O_TRUNC |
O_BINARY, 0644);
                        ^~~~~~~~~~~~~~~~
In file included from /mnt/data/tools/wireshark/git/wsutil/file_util.h:40:0,
                 from /mnt/data/tools/wireshark/git/tshark.c:61:
/usr/include/fcntl.h:181:12: note: expected ‘const char *’ but argument is
of type ‘const volatile char *’
 extern int open (const char *__file, int __oflag, ...) __nonnull ((1));
            ^~~~
/mnt/data/tools/wireshark/git/tshark.c:1913:48: error: passing argument 2
of ‘cfile_open_failure_message’ discards ‘volatile’ qualifier from pointer
target type [-Werror=discarded-qualifiers]
           cfile_open_failure_message("TShark", exp_pdu_filename, err, NULL,
                                                ^~~~~~~~~~~~~~~~
In file included from /mnt/data/tools/wireshark/git/tshark.c:92:0:
/mnt/data/tools/wireshark/git/ui/failure_message.h:41:13: note: expected
‘const char *’ but argument is of type ‘const volatile char *’
 extern void cfile_open_failure_message(const char *progname,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/data/tools/wireshark/git/tshark.c:1981:41: error: passing argument 1
of ‘cfile_close_failure_message’ discards ‘volatile’ qualifier from pointer
target type [-Werror=discarded-qualifiers]
             cfile_close_failure_message(exp_pdu_filename, err);
                                         ^~~~~~~~~~~~~~~~
In file included from /mnt/data/tools/wireshark/git/tshark.c:92:0:
/mnt/data/tools/wireshark/git/ui/failure_message.h:93:13: note: expected
‘const char *’ but argument is of type ‘const volatile char *’
 extern void cfile_close_failure_message(const char *filename, int err);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors



BR,
Pascal.

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: