Source-Changes-D archive

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

Re: lint warnings



Am 27.06.2022 um 20:20 schrieb Christos Zoulas:
In article <68ea25e4-a22b-4fbc-af8c-30c4195d2f24%gmx.de@localhost>,
Roland Illig  <roland.illig%gmx.de@localhost> wrote:
27.06.2022 01:20:20 Christos Zoulas <christos%astron.com@localhost>:

In article <20220624201621.EF2AFFB1B%cvs.NetBSD.org@localhost>,
Roland Illig <source-changes-d%NetBSD.org@localhost> wrote:
-=-=-=-=-=-

Module Name:    src
Committed By:   rillig
Date:       Fri Jun 24 20:16:21 UTC 2022

Modified Files:
     src/tests/usr.bin/xlint/lint1: msg_247.c
     src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: do not warn about pointer cast between sockaddr variants

My expectation of lint is that it warns me about possible bugs, and
casting between the sockaddr variants is required by the API, therefore
I don't see a point in flagging it as a possible bug.

Or would you rather fix all the current warnings by adding an
intermediate cast to 'void *'? That would be a lot of work, plus the
intermediate cast can hide other typos.

There is no intermediate cast needed; you can just cast the sockaddr flavor
to (void *) or (const void *).

This '(void *)' or '(const void *)' is exactly what I meant with
'intermediate cast'. This cast would also hide casts between completely
unrelated pointer types, therefore I prefer the direct cast from one
sockaddr pointer to another.

Lint warns about the direct casts in all cases that seem dubious, while
it treats a cast chain involving '(void *)' as an 'I know what I'm
doing' from the author. This exact behavior makes sense to me.

... cast from 'pointer to array[20] of double' to 'pointer
to double': I don't see how that could be dangerous ...

... I was thinking to wrap them all up into a pedantic flag instead.

Did you mean this as 'I will implement this pedantic flag', or rather as
'you should implement this'? Right now, I won't do that because I'm
lacking any good examples that would demonstrate the usefulness of this
new flag. If you add that flag, could you add a few examples to the
existing tests? Having these examples is much easier than digging
through the code, trying to find examples retrospectively 25 years later. :)

Roland


Home | Main Index | Thread Index | Old Index