As noted by clang -Wshift-sign-overflow, the expression "1<<31"
overflows the signed int type, giving undefined behavior.
Use an unsigned type to make the result of the shift defined
behavior by the C99 standard.
Also change an instance of "1<<31" that was checking for whether the
most significant bit was set, as it's still undefined behavior.
Change-Id: I8cf9443aa92470181044fc3b63d491da18ff5e34
Reviewed-on: http://gerrit.openafs.org/11301
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
tval = hval & (NHASHENT - 1);
if (tval == 0)
return tval;
- else if (hval >= 1<<31)
+ else if (hval >= 1u<<31)
tval = NHASHENT - tval;
return tval;
}
/* These bits are used when calling SetFieldsEntry. */
%#define PR_SF_ALLBITS 0xff /* set all access bits */
-%#define PR_SF_NGROUPS (1<<31) /* set field limiting group creation */
-%#define PR_SF_NUSERS (1<<30) /* " " foreign users " */
+%#define PR_SF_NGROUPS (1u<<31) /* set field limiting group creation */
+%#define PR_SF_NUSERS (1u<<30) /* " " foreign users " */
typedef char prname[PR_MAXNAMELEN];
typedef prname namelist<>;
* meet the needs of xdr and rpc based on tcp.
*/
-#define LAST_FRAG ((afs_uint32)(1 << 31))
+#define LAST_FRAG ((afs_uint32)(1u << 31))
typedef struct rec_strm {
caddr_t tcp_handle;