git: f65f23e90da8 - stable/12 - libsa: make single bit bitfields unsigned to avoid clang 16 warning
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 22 Apr 2023 09:01:13 UTC
The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=f65f23e90da89a517dada5a4f330b181833e7a6b commit f65f23e90da89a517dada5a4f330b181833e7a6b Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2023-04-17 16:15:57 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2023-04-22 09:00:01 +0000 libsa: make single bit bitfields unsigned to avoid clang 16 warning Clang 16 introduced a warning about single bit bitfields in structs, which is triggered by a declaration in libsa's tftp.c: stand/libsa/tftp.c:382:20: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] h->islastblock = 1; /* very short file */ ^ ~ stand/libsa/tftp.c:432:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] h->islastblock = 1; /* EOF */ ^ ~ Signed one-bit bitfields can only have values -1 and 0, but the intent here is to use the field as a boolean, so make it unsigned. MFC after: 3 days (cherry picked from commit 1a3ccb8f1552977e1b264e3b89d1fba8e717dad8) --- stand/libsa/tftp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/libsa/tftp.c b/stand/libsa/tftp.c index 22e03ab58da1..8436bab31ae1 100644 --- a/stand/libsa/tftp.c +++ b/stand/libsa/tftp.c @@ -103,8 +103,8 @@ static int is_open = 0; struct tftp_handle { struct iodesc *iodesc; int currblock; /* contents of lastdata */ - int islastblock:1; /* flag */ - int tries:4; /* number of read attempts */ + unsigned int islastblock:1; /* flag */ + unsigned int tries:4; /* number of read attempts */ int validsize; int off; char *path; /* saved for re-requests */