Commit Graph

42 Commits

Author SHA1 Message Date
João Valverde 79c3a77752 Add macros to control lemon diagnostics
Rename flex macros using parenthesis (mostly a style issue):

DIAG_OFF_FLEX -> DIAG_OFF_FLEX()
DIAG_ON_FLEX  -> DIAG_ON_FLEX()

Use the same kind of construct with lemon generated code using
DIAG_OFF_LEMON() and DIAG_ON_LEMON(). Use %include and %code
directives to enforce the desired order with generated code
in the middle in between pragmas.

Fix a clang-specific pragma to use DIAG_OFF_CLANG().

DIAG_OFF(unreachable-code) -> DIAG_OFF_CLANG(unreachable-code).

Apparently GCC is ignoring the -Wunreachable flag, that's why
it did not trigger an unknown pragma warning. From [1}:

  The -Wunreachable-code has been removed, because it was unstable: it
  relied on the optimizer, and so different versions of gcc would warn
  about different code.  The compiler still accepts and ignores the
  command line option so that existing Makefiles are not broken.  In some
  future release the option will be removed entirely. - Ian

[1] https://gcc.gnu.org/legacy-ml/gcc-help/2011-05/msg00360.html
2022-11-20 10:11:27 +00:00
João Valverde 59c082c046 Add new global header wireshark.h with guideline
Remove ws_diag_control.h from config.h because that was a workaround
for the lack of a public global header. Fix the resultant build errors.
2021-10-22 06:41:44 +00:00
Guy Harris 72b57ac4ef Use DIAG_OFF_FLEX/DIAG_ON_FLEX more consistently.
Add warning C4267 (size_t to int conversion) with MSVC to DIAG_OFF_FLEX.

Addd -Wshorten-64-to-32 with Clang and GCC to DIAG_OFF_FLEX.

Don't explicitly use #pragma to turn off warnings; use DIAG_OFF_FLEX for
all of them.

If we use DIAG_OFF_FLEX, use DIAG_ON_FLEX, even if we have no section of
entirely included code at the end.

Change-Id: Ibfd44e8954704e9a8bcb1bd8e54f31d28357fffb
Reviewed-on: https://code.wireshark.org/review/25817
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-16 19:54:16 +00:00
Gerald Combs 010c73daa6 Disable warning C4267 in generated files.
Disable warning C4267 in Visual C++ in order to squelch the following
warnings:

   125>dtd_parse.c(1699): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\buildbot\builders\windows-x86-64-petri-dish\windows-x86-64-petri-dish\build\cmbuild\epan\epan.vcxproj]
   125>diam_dict.c(2348): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\buildbot\builders\windows-x86-64-petri-dish\windows-x86-64-petri-dish\build\cmbuild\epan\epan.vcxproj]
   125>C:/buildbot/builders/windows-x86-64-petri-dish/windows-x86-64-petri-dish/build/cmbuild/epan/uat_load.c(1476): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\buildbot\builders\windows-x86-64-petri-dish\windows-x86-64-petri-dish\build\cmbuild\epan\epan.vcxproj]
   130>wimaxasncp_dict.c(2103): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\buildbot\builders\windows-x86-64-petri-dish\windows-x86-64-petri-dish\build\cmbuild\plugins\epan\wimaxasncp\wimaxasncp.vcxproj]

Change-Id: Ie29ae096e5a8b5037abaf3f2aa97754260f4cace
Reviewed-on: https://code.wireshark.org/review/25800
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-15 05:30:48 +00:00
Ahmad Fatoum 9d49e13166 Remove superfluous null-checks before strdup/free
NULL checks were removed for following free functions:

- g_free "If mem is NULL it simply returns"
  https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free

- g_slist_free(_full)? "NULL is considered to be the empty list"
  https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html

- g_strfreev "If str_array is NULL, this function simply returns."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev

- g_slice_free "If mem is NULL, this macro does nothing."
  https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free

- g_match_info_free "not NULL... otherwise does nothing"
  https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free

- dfilter_free defined in Wireshark code. Returns early when passed NULL
  epan/dfilter/dfilter.c

They were also removed around calls to g_strdup where applicable:

- g_strdup "If str is NULL it returns NULL."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup

Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04
Reviewed-on: https://code.wireshark.org/review/23406
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-15 12:38:51 +00:00
João Valverde 8615e78630 Disable flex-generated [-Wsign-compare] warnings
Change-Id: Iace0462e6bb50573f3e4603f7a19e4b7ee1f9733
Reviewed-on: https://code.wireshark.org/review/23541
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-19 10:06:07 +00:00
Guy Harris 6f37317539 Include config.h at the very beginning of all Flex scanners.
That way, if we #define anything for large file support, that's done
before we include any system header files that either depend on that
definition or that define it themselves if it's not already defined.

Change-Id: I9b07344151103be337899dead44d6960715d6813
Reviewed-on: https://code.wireshark.org/review/19035
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-02 21:02:10 +00:00
Guy Harris 59816ef00c Make the Flex scanners and YACC parser in libraries reentrant.
master-branch libpcap now generates a reentrant Flex scanner and
Bison/Berkeley YACC parser for capture filter expressions, so it
requires versions of Flex and Bison/Berkeley YACC that support that.

We might as well do the same.  For libwiretap, it means we could
actually have multiple K12 text or Ascend/Lucent text files open at the
same time.  For libwireshark, it might not be as useful, as we only read
configuration files at startup (which should only happen once, in one
thread) or on demand (in which case, if we ever support multiple threads
running libwireshark, we'd need a mutex to ensure that only one file
reads it), but it's still the right thing to do.

We also require a version of Flex that can write out a header file, so
we change the runlex script to generate the header file ourselves. This
means we require a version of Flex new enough to support --header-file.

Clean up some other stuff encountered in the process.

Change-Id: Id23078c6acea549a52fc687779bb55d715b55c16
Reviewed-on: https://code.wireshark.org/review/14719
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-03 22:21:29 +00:00
Guy Harris f51bad11d7 Use noyywrap rather than defining our own yywrap functions.
Tweak lemonflex-tail.inc to fix an issue this reveals.

It appears that, at least on the buildbots, the Visual Studio compiler
no longer issues warnings for the code generated with %option noyywrap.

Change-Id: Id64d56f1ae8a79d0336488a4a50518da1f511497
Reviewed-on: https://code.wireshark.org/review/12433
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-05 08:06:50 +00:00
Guy Harris ce22578996 Don't include io.h in Flex scanners - they're not interactive.
We don't have any Flex scanners that support an interactive command-line
interface, so none of our scanners are, or need to be, interactive.
Mark text2pcap's scanner as not interactive.

That means none of our scanners should call isatty(), so they don't have
any need to include <io.h> on Windows; remove that include from the
Lucent/Ascent text capture scanner.

Update a comment to reflect that what matters isn't whether we can read
from a terminal or whether we actually do so, what matters is whether
they read *interactively* from a terminal (if you want to run text2pcap
reading from the standard input and type at it, be my guest).

Change-Id: I59979d1fdb37e1913125a400963ff7a3fa6b9bbd
Reviewed-on: https://code.wireshark.org/review/11587
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-06 01:14:31 +00:00
Guy Harris 8482173e5a Make some variables size_t, as values of that width are assigned to it.
(I'd say "as values of that *type* are assigned to it", but the "len"
field of a GString is of type "gsize", and, for some unknown reason, the
GLib folks, rather than just using size_t, which is required by C89 to
be available, invented their own "gsize" type, defined as "long", which
happens to be narrower than "size_t" on LLP64 platforms such as 64-bit
Windows.  Sigh....)

This squelches some compiler warnings.

Change-Id: Ifca1300297b2e9b777fb2c426dda822ba157cfe5
Reviewed-on: https://code.wireshark.org/review/4014
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-06 18:45:53 +00:00
Dario Lombardo 627de38a80 Removed SVN Id from epan dir.
Change-Id: I487a3451344796447f0d5621b993cc89c29e93b5
Reviewed-on: https://code.wireshark.org/review/2383
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-19 19:46:22 +00:00
Gerald Combs 02eea9378e More shorten-64-to-32 warnings.
svn path=/trunk/; revision=54106
2013-12-14 19:23:34 +00:00
Anders Broman 5a85b7fed2 [-Wmissing-prototypes]
Use explicit casts.

svn path=/trunk/; revision=48338
2013-03-16 08:52:09 +00:00
Guy Harris ebacca89a7 Add %option noinput to a bunch of Flex files, as we aren't using the
input() routine and thus don't need to have it generated - and as it
produces warnings of a routine defined but not used, we don't want to
have it generated.

Squelch a casting-const-away warning.

svn path=/trunk/; revision=47613
2013-02-10 19:13:07 +00:00
Guy Harris e92f2f398d Constify the name member of a struct _proto_xmlpi_attr, to squelch
warnings.

svn path=/trunk/; revision=47561
2013-02-08 09:09:29 +00:00
Bill Meier b9f950e33f Fix several [-Wshadow] warnings;
svn path=/trunk/; revision=46194
2012-11-26 01:30:41 +00:00
Bill Meier 37bab5e89d Replace use of deprecated g_strdown() by g_ascii_strdown();
Found when compiling with -DG_DISABLE_DEPRECATED

svn path=/trunk/; revision=38469
2011-08-11 03:10:11 +00:00
Gerald Combs 15f33eecbf Disable warnings-as-errors for Flex-generated output. Add a couple of gsize
casts.

svn path=/trunk/; revision=28002
2009-04-08 18:08:25 +00:00
Luis Ontanon 42c3239a1a luis.ontanon@gmail.com => luis@ontanon.org
svn path=/trunk/; revision=25937
2008-08-05 21:03:46 +00:00
Bill Meier fe5c2d9820 g_string_sprintf --> g_string_printf and g_string_sprintfa --> g_string_append_printf
svn path=/trunk/; revision=25276
2008-05-11 18:33:49 +00:00
Guy Harris a6815b1070 All versions of GLib 2.x come with g_ascii_strcasecmp(), and we require
GLib 2.x; we don't have to check for its presence and supply a
replacement if it's missing.

Get rid of an unremoved reference in epan/dtd_parse.l.

svn path=/trunk/; revision=25197
2008-04-29 16:24:22 +00:00
Bill Meier 0d4b874b44 Bug 2493: Fix (Part 2):
To prevent Windows compiler errors when using flex 2.5.35.
 Fixes "missing unistd.h" and yywrap "mismatched parameter" warnings
 [Upcoming Part 3: ignore 'signed /unsigned mismatch' errors]

svn path=/trunk/; revision=25173
2008-04-25 17:40:29 +00:00
Guy Harris 9c89cdaaa3 strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est.  Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).

In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.

We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot.  This causes strings that should
match not to match.

This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.

svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
Guy Harris 5be4499ad1 Add a script as a front-end for Flex, to work around various problems,
such as the fact that Flex strips all but the last component of the "-o"
argument, and that it doesn't generate a header file to declare routines
the generated lexical analyzer defines.  Use that script when building
lexical analyzers, and, for each lexical analyzer, include the generated
header file in the generated analyzer.

svn path=/trunk/; revision=22446
2007-08-04 02:13:52 +00:00
Guy Harris 968d363f11 Add comments to various %option items to explain what they're doing.
Move the %options to the beginning if they weren't already there, and
put them in the same order in all files.

Add "prefix=" options to .l files that don't already have them, so we
don't have to pass a "-P" option.

Add "never-interactive" and "noyywrap" options to our lexical analyzers,
to remove extra isatty() checks and to eliminate the need for yywrap()
from the Flex library.

Get rid of %option nostdinit - that's the default.

Add .l.c: rules to Makefile.am files, replacing the rules for specific
.l files.  Have those rules all check that $(LEX) is set.

Update the address for the FSF.

svn path=/trunk/; revision=22424
2007-07-30 20:22:37 +00:00
Luis Ontanon 27556d141a two minor leaks
svn path=/trunk/; revision=20443
2007-01-15 20:14:00 +00:00
Luis Ontanon ca6a9a7d13 solve both issues pointed out in:
http://wireshark.org/lists/ethereal-dev/200605/msg02351.html

- dtd_parse.l:
   be more liberal on what a name can be (a number now can be a name)

- packet-xml.c
  if proto-name is given use it instead of the root element name as prefix for generated fields


svn path=/trunk/; revision=19903
2006-11-15 18:40:37 +00:00
Luis Ontanon a472c767a2 a better regex for names in DTDs
svn path=/trunk/; revision=18795
2006-07-26 22:54:48 +00:00
Luis Ontanon ba3a83a475 allow for some uppercasing in names.
"fix" for Bug 1010


svn path=/trunk/; revision=18773
2006-07-20 17:23:58 +00:00
Anders Broman 9aa99b16fe Ethereal->Wireshark
svn path=/trunk/; revision=18248
2006-05-29 20:44:06 +00:00
Ronnie Sahlberg f0b33a4789 ethereal->wireshark updates
svn path=/trunk/; revision=18206
2006-05-22 08:14:01 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Luis Ontanon 770aa5678b "./dtd_parse.l", line 167: warning, rule cannot be matched
the . matches one char as {special_char} does so {special_char} won't have been matched. change that for a non ">"

svn path=/trunk/; revision=16153
2005-10-07 08:36:23 +00:00
Luis Ontanon f1b498587b remove location from dtd_build_data_t avoiding to (double) free it.
svn path=/trunk/; revision=16147
2005-10-06 22:01:52 +00:00
Luis Ontanon 3cf75fd6bb get rid of most dtd leaks.
There's just one left I'm aware of (the doctype name).


svn path=/trunk/; revision=15990
2005-09-24 19:03:35 +00:00
Guy Harris d90a1a4ac6 Make the private variables for various lexical analyzers static, so
that we don't have all the lexical analyzers in libethereal share them
(note that they're already static in radius_dict.l, so they weren't
sharing with any other lexical analyzer), and so that OS X 10.3.9's
run-time linker doesn't get upset at finding them defined in libethereal
and the MATE plugin.

Fix up indentation.

svn path=/trunk/; revision=15961
2005-09-22 18:39:25 +00:00
Gerald Combs 5cb2a5e162 Fix a couple of errors found by valgrind.
svn path=/trunk/; revision=15900
2005-09-20 17:24:23 +00:00
Luis Ontanon c943320721 avoid freeing the last location twice.
add some #ifed out code to help debugging the parser


svn path=/trunk/; revision=15884
2005-09-20 00:31:53 +00:00
Luis Ontanon 4c14b12c25 Because there's more than just text in XML...
DTDs are imported to create fields


svn path=/trunk/; revision=15851
2005-09-17 17:05:46 +00:00
Guy Harris 019ed9005f Add a header file to declare routines defined in lexer and used in
parser, or vice versa.

svn path=/trunk/; revision=15769
2005-09-12 19:32:35 +00:00
Luis Ontanon 96326c0b86 the dtd parser (still missing the glue) and few fixes to packet-xml.c
svn path=/trunk/; revision=15745
2005-09-10 17:29:15 +00:00