Commit Graph

25 Commits

Author SHA1 Message Date
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Nicolas Williams
a6e6916c1c Fix warning in sl compiler output
Use a cast through uintptr_t to un-const rather than a cast through
unsigned long.  This was caught by the Appeyor Windows build.
2019-01-02 13:56:04 -05:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Roland C. Dowdeswell
cc47c8fa7b Turn on -Wextra -Wno-sign-compare -Wno-unused-paramter and fix issues.
We turn on a few extra warnings and fix the fallout that occurs
when building with --enable-developer.  Note that we get different
warnings on different machines and so this will be a work in
progress.  So far, we have built on NetBSD/amd64 5.99.64 (which
uses gcc 4.5.3) and Ubuntu 10.04.3 LTS (which uses gcc 4.4.3).

Notably, we fixed

	1.  a lot of missing structure initialisers,

	2.  unchecked return values for functions that glibc
	    marks as __attribute__((warn-unused-result)),

	3.  made minor modifications to slc and asn1_compile
	    which can generate code which generates warnings,
	    and

	4.  a few stragglers here and there.

We turned off the extended warnings for many programs in appl/ as
they are nearing the end of their useful lifetime, e.g.  rsh, rcp,
popper, ftp and telnet.

Interestingly, glibc's strncmp() macro needed to be worked around
whereas the function calls did not.

We have not yet tried this on 32 bit platforms, so there will be
a few more warnings when we do.
2012-02-20 19:45:41 +00:00
Jeffrey Altman
c3f6a65da2 slc: correct 'min_args' and 'max_args' processing
The 'min_args' and 'max_args' values were ignored whenever
an 'argument' value was not present as a child of the 'command'.
'argument' values are often specified as children of the 'option'
value when more than one 'option' is an argument.

This patchset counts the number of 'argument' values specified
under a 'command' regardless of the level at which it appears.
If there are any 'argument' values, the 'min_args' and 'max_args'
are used to generate validation code for the 'command'.

Change-Id: Idc6129b4ff29914ac990f693b4dba51a30bdc971
2011-07-27 19:55:28 -04:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Love Hornquist Astrand
99bc078d46 better support for name in options 2010-11-24 16:21:26 -08:00
Asanka C. Herath
e84b73370c Avoid conflicting malloc/free declarations in Bison 2010-11-24 15:33:28 -05:00
Love Hörnquist Åstrand
1ee6bd7248 drop RCSID
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24357 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:30:49 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
58227c2f5f negative flags defaults to on
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23683 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-08-25 11:11:58 +00:00
Love Hörnquist Åstrand
b6bcedddb2 (main): also fclose yyin.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20767 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-01 11:24:52 +00:00
Johan Danielsson
9edd1cef2a use table lookup for types instead of inline list
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16678 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-01-31 16:49:08 +00:00
Love Hörnquist Åstrand
08e64c0d1b (gen_wrapper): use the generated version of name for function, if no
function is is used, also use the generated name for the structure
name.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15774 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-07-27 15:00:40 +00:00
Love Hörnquist Åstrand
ab59af8c86 fix a merge error
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15436 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-16 19:55:03 +00:00
Love Hörnquist Åstrand
20040163c5 rename optind to optidx, rename variables to avoid shadowing
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15431 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-16 19:30:18 +00:00
Love Hörnquist Åstrand
cb151443a9 include <config.h> since defines _GNU_SOURCE if needed, avoid asprintf warning
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14845 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-04-19 10:28:28 +00:00
Love Hörnquist Åstrand
6cf1196acf include <roken.h>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14520 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-01-21 09:10:57 +00:00
Love Hörnquist Åstrand
7da05fbefb cast argument to isalnum to unsigned char
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14508 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-01-09 04:23:58 +00:00
Johan Danielsson
cdef504282 add support for "strings" and "negative-flag" types, plus some
usability tweaks and bug fixes


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14251 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-09-22 16:09:19 +00:00
Johan Danielsson
ceae987caf add min_args/max_args checking
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14022 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-07-05 11:28:50 +00:00
Love Hörnquist Åstrand
8a986d309a pull in <stdlib.h> and <vers.h> to avoid warnings
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13971 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-06-21 20:59:25 +00:00
Johan Danielsson
3cc8ea1b60 add simple command+option compiler
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13969 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-06-21 19:10:59 +00:00