Module Name: src Committed By: rillig Date: Sat Apr 17 16:58:05 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_135.c msg_135.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: do not warn about alignment when casting from incomplete struct This removes a bunch of technically correct but practically useless warnings from the regular NetBSD build. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_135.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_135.exp cvs rdiff -u -r1.276 -r1.277 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_135.c diff -u src/tests/usr.bin/xlint/lint1/msg_135.c:1.6 src/tests/usr.bin/xlint/lint1/msg_135.c:1.7 --- src/tests/usr.bin/xlint/lint1/msg_135.c:1.6 Sat Apr 17 16:52:09 2021 +++ src/tests/usr.bin/xlint/lint1/msg_135.c Sat Apr 17 16:58:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_135.c,v 1.6 2021/04/17 16:52:09 rillig Exp $ */ +/* $NetBSD: msg_135.c,v 1.7 2021/04/17 16:58:04 rillig Exp $ */ # 3 "msg_135.c" // Test for message: converting '%s' to '%s' may cause alignment problem [135] @@ -28,6 +28,10 @@ struct complete { * from the publicly visible, incomplete 'struct lhash_st' to a private * implementation type such as 'struct lhash_st_OPENSSL_STRING'. * + * Before tree.c 1.277 from 2021-04-17, lint warned about this, even though + * there was not enough evidence that there really was an alignment problem, + * resulting in many false positives. + * * See openssl/lhash.h. */ void @@ -35,6 +39,6 @@ pointer_to_structs(struct incomplete *in { struct complete *complete; - complete = (struct complete *)incomplete; /* expect: 135 */ + complete = (struct complete *)incomplete; sink(complete); } Index: src/tests/usr.bin/xlint/lint1/msg_135.exp diff -u src/tests/usr.bin/xlint/lint1/msg_135.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_135.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_135.exp:1.4 Sat Apr 17 16:52:09 2021 +++ src/tests/usr.bin/xlint/lint1/msg_135.exp Sat Apr 17 16:58:04 2021 @@ -1,3 +1,2 @@ msg_135.c(15): warning: converting 'pointer to const unsigned char' to 'pointer to const unsigned int' may cause alignment problem [135] -msg_135.c(38): warning: converting 'pointer to incomplete struct incomplete' to 'pointer to struct complete' may cause alignment problem [135] msg_135.c(20): warning: struct incomplete never defined [233] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.276 src/usr.bin/xlint/lint1/tree.c:1.277 --- src/usr.bin/xlint/lint1/tree.c:1.276 Sat Apr 10 18:06:53 2021 +++ src/usr.bin/xlint/lint1/tree.c Sat Apr 17 16:58:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.276 2021/04/10 18:06:53 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.277 2021/04/17 16:58:04 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.276 2021/04/10 18:06:53 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.277 2021/04/17 16:58:04 rillig Exp $"); #endif #include <float.h> @@ -2081,7 +2081,8 @@ check_pointer_conversion(tnode_t *tn, ty return; } - if (hflag && alignment_in_bits(nstp) > alignment_in_bits(ostp)) { + if (hflag && alignment_in_bits(nstp) > alignment_in_bits(ostp) && + !is_incomplete(ostp)) { /* converting '%s' to '%s' may cause alignment problem */ warning(135, type_name(otp), type_name(ntp)); }