git: 5cc19c2f6c68 - stable/13 - bsnmp: 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:00:53 UTC
The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5cc19c2f6c68afd557c6888b22095054a4b4e419 commit 5cc19c2f6c68afd557c6888b22095054a4b4e419 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2023-04-17 16:11:56 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2023-04-22 08:58:56 +0000 bsnmp: 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 bsnmp's snmpd.h: contrib/bsnmp/snmpd/trans_lsock.c:271:21: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] peer->input.stream = 1; ^ ~ 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 b740e02500ca248e1096cf745a17d2a8fcc44fed) --- contrib/bsnmp/snmpd/snmpd.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/bsnmp/snmpd/snmpd.h b/contrib/bsnmp/snmpd/snmpd.h index 48a7b44a04b2..394a4f4736d6 100644 --- a/contrib/bsnmp/snmpd/snmpd.h +++ b/contrib/bsnmp/snmpd/snmpd.h @@ -152,12 +152,12 @@ struct port_input { int fd; /* socket */ void *id; /* evSelect handle */ - int stream : 1; /* stream socket */ - int cred : 1; /* want credentials */ + u_int stream : 1; /* stream socket */ + u_int cred : 1; /* want credentials */ struct sockaddr *peer; /* last received packet */ socklen_t peerlen; - int priv : 1; /* peer is privileged */ + u_int priv : 1; /* peer is privileged */ u_char *buf; /* receive buffer */ size_t buflen; /* buffer length */