The NetBSD Project

CVS log for src/tests/usr.bin/xlint/lint1/msg_259.c

[BACK] Up to [cvs.NetBSD.org] / src / tests / usr.bin / xlint / lint1

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.23 / (download) - annotate - [select for diffs], Sun Jul 9 10:42:07 2023 UTC (9 months, 1 week ago) by rillig
Branch: MAIN
CVS Tags: HEAD
Changes since 1.22: +25 -25 lines
Diff to previous 1.22 (colored) to selected 1.14 (colored)

lint: remove redundant '#' after 'argument' in diagnostics

Revision 1.22 / (download) - annotate - [select for diffs], Tue Mar 28 14:44:35 2023 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored) to selected 1.14 (colored)

lint: warn about extern declarations outside headers

https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html

Revision 1.21 / (download) - annotate - [select for diffs], Fri Jun 17 18:54:53 2022 UTC (22 months ago) by rillig
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10
Changes since 1.20: +2 -2 lines
Diff to previous 1.20 (colored) to selected 1.14 (colored)

tests/lint: make 'expect+-' comments stricter

Previously, the expectations from these comments were already satisfied
if the expectation occurred somewhere in the actual message from lint.
This meant that the prefix 'error:' or 'warning:' could be omitted from
the 'expect' comment.  These omissions were hard to see in a manual
review.  Now any omissions must be visually marked with '...'.

The test msg_342 now reports its messages properly as being in the file
msg_342.c, rather than msg_341.c.  This had been a copy-and-paste
mistake.

Revision 1.20 / (download) - annotate - [select for diffs], Fri Apr 15 21:50:07 2022 UTC (2 years ago) by rillig
Branch: MAIN
Changes since 1.19: +2 -2 lines
Diff to previous 1.19 (colored) to selected 1.14 (colored)

lint: in C99 mode, do not warn about non-prototype conversions

Message 259 is "argument #%d is converted from '%s' to '%s' due to
prototype", and it is intended to warn about compatibility between
traditional C where functions had no prototypes and standard C where
functions have prototypes.

Running lint in C99 mode is further away from traditional C than running
lint in C90 mode, so that warning doesn't make sense for C99.  There are
still some inconsistencies in the 5 language version modes that lint
offers:

	-t		for traditional C
	(no option)	for migrating traditional C to C90
	-s		for C90 code
	-S		for C99 code
	-Ac11		for C11 code

By disabling warning 259 in C99 mode, a typical NetBSD build produces
14.500 fewer warnings than before, of about 100.000 total.

Message 259 overlaps with message 298 "conversion from '%s' to '%s' may
lose accuracy, arg #%d", and in some cases of potentially lossy
conversions, lint now produces none of these messages.  In some other
cases, these warnings were reported redundantly.  The cases where
message 298 makes sense will be added back later, as needed.

Revision 1.19 / (download) - annotate - [select for diffs], Thu Sep 2 17:55:27 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.18: +48 -26 lines
Diff to previous 1.18 (colored) to selected 1.14 (colored)

lint: align tests for message 259, clarify its purpose

Revision 1.18 / (download) - annotate - [select for diffs], Thu Sep 2 17:29:19 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.17: +1 -3 lines
Diff to previous 1.17 (colored) to selected 1.14 (colored)

lint: fix unintended warning for converting long long to signed char

Revision 1.17 / (download) - annotate - [select for diffs], Thu Sep 2 17:26:43 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.16: +73 -1 lines
Diff to previous 1.16 (colored) to selected 1.14 (colored)

tests/lint: demonstrate unintended prototype warning for signed char

Revision 1.16 / (download) - annotate - [select for diffs], Tue Aug 31 19:26:23 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.15: +6 -1 lines
Diff to previous 1.15 (colored) to selected 1.14 (colored)

tests/lint: add cross-references to message 297

The check for lossy integer conversions is already implemented, it's
just not activated in the default NetBSD build.

Revision 1.15 / (download) - annotate - [select for diffs], Tue Aug 31 18:59:26 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.14: +11 -7 lines
Diff to previous 1.14 (colored)

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI.  The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago.  In the meantime, almost all code has migrated to
using function prototypes.  With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible.  The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.

Revision 1.14 / (download) - annotate - [selected], Tue Aug 31 18:15:56 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.13: +99 -33 lines
Diff to previous 1.13 (colored)

tests/lint: add missing test cases for integer conversions

While adding the missing test cases, I re-read the comments and
discarded several of them, since converting a signed value to an
unsigned type can be lossy as well, which warrants a warning.

Revision 1.13 / (download) - annotate - [select for diffs], Mon Aug 30 18:33:37 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.12: +13 -1 lines
Diff to previous 1.12 (colored) to selected 1.14 (colored)

tests/lint: test passing sizeof(int) to parameter type 'unsigned int'

Seen in usr.sbin/inetd/inetd.c, which calls getnameinfo and passes
sizeof(buf).

Revision 1.12 / (download) - annotate - [select for diffs], Sat Aug 21 11:58:12 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.11: +16 -1 lines
Diff to previous 1.11 (colored) to selected 1.14 (colored)

tests/lint: add more test cases for lossy integer conversion

Revision 1.11 / (download) - annotate - [select for diffs], Sat Aug 21 11:50:57 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored) to selected 1.14 (colored)

tests/lint: guard against typos in test environment configuration

Some tests had "lint1-only-if" without a trailing colon, others included
the trailing colon.  The tests that included the trailing colon were run
even though they were supposed to be skipped, and they failed, as could
be expected.

To prevent further typos, always require the trailing colon, just as in
"lint1-flags" and fail fast on unknown "lint1" comments.

Revision 1.10 / (download) - annotate - [select for diffs], Sat Aug 21 11:19:38 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.9: +26 -1 lines
Diff to previous 1.9 (colored) to selected 1.14 (colored)

tests/lint: add tests for conversion from signed to unsigned

Revision 1.9 / (download) - annotate - [select for diffs], Sun Jul 4 17:32:24 2021 UTC (2 years, 9 months ago) by rillig
Branch: MAIN
Changes since 1.8: +9 -4 lines
Diff to previous 1.8 (colored) to selected 1.14 (colored)

tests/lint: align tests for argument conversion to each other

Revision 1.8 / (download) - annotate - [select for diffs], Tue Jun 29 13:58:13 2021 UTC (2 years, 9 months ago) by rillig
Branch: MAIN
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored) to selected 1.14 (colored)

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated.  All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char.  On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".

Revision 1.7 / (download) - annotate - [select for diffs], Tue Jun 29 09:19:17 2021 UTC (2 years, 9 months ago) by rillig
Branch: MAIN
Changes since 1.6: +2 -1 lines
Diff to previous 1.6 (colored) to selected 1.14 (colored)

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on.  This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.

Revision 1.6 / (download) - annotate - [select for diffs], Thu Feb 4 07:39:39 2021 UTC (3 years, 2 months ago) by rillig
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.5: +2 -2 lines
Diff to previous 1.5 (colored) to selected 1.14 (colored)

lint: update message text for 259 in test

That's the one place that is not checked for matching the actual message
by my usual pre-commit checks.

Revision 1.5 / (download) - annotate - [select for diffs], Thu Feb 4 06:55:00 2021 UTC (3 years, 2 months ago) by rillig
Branch: MAIN
Changes since 1.4: +3 -3 lines
Diff to previous 1.4 (colored) to selected 1.14 (colored)

lint: add back "due to prototype" to message 259

That message is only supposed to warn about compatibility to traditional
C, in case the function should ever be compiled without its prototype
being in effect.  All other type checks are supposed to be in another
function, as documented, but that type check misses to report a few
error-prone type combinations (long to char, long to int).

30 years after the introduction of prototypes with C90, almost all
existing code uses prototypes.  The warning has thus lost most of its
usefulness and can rather be confusing since a conversion from 'char' to
'long' is not problematic with prototypes in action, and the probability
of the code being backported to a pre-C90 compiler is diminishingly
small.

The words "due to prototype" now serve as a hint again.  The proper fix
could be to suppress this warning in C99 mode since that's far enough
from traditional C.

Revision 1.4 / (download) - annotate - [select for diffs], Sun Jan 31 14:05:00 2021 UTC (3 years, 2 months ago) by rillig
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored) to selected 1.14 (colored)

lint: reword message 259 about function argument conversion

The words "due to prototype" are an anachronism from the 1990s.
Nowadays every function is defined using a prototype, which makes these
words redundant.

Revision 1.3 / (download) - annotate - [select for diffs], Sun Jan 31 13:56:14 2021 UTC (3 years, 2 months ago) by rillig
Branch: MAIN
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored) to selected 1.14 (colored)

lint: make warning about function argument conversion more detailed

For every conversion it is useful to know both the source and the target
type since these are not always obvious from the code.

The only surprise is the warning in d_gcc_extension.  The conversion
there is from 'double' to 'long double', which is a lossless conversion.
This may be a bug in lint.

Revision 1.2 / (download) - annotate - [select for diffs], Sat Jan 30 22:07:31 2021 UTC (3 years, 2 months ago) by rillig
Branch: MAIN
Changes since 1.1: +20 -3 lines
Diff to previous 1.1 (colored) to selected 1.14 (colored)

lint: add test for message 259 about implicit conversions

Revision 1.1 / (download) - annotate - [select for diffs], Sat Jan 2 10:22:44 2021 UTC (3 years, 3 months ago) by rillig
Branch: MAIN
Diff to selected 1.14 (colored)

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality.  Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so.  Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh.  All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case.  Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many.  The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.




CVSweb <webmaster@jp.NetBSD.org>