staging/lustre/lnet: correctly casts value for arithmetic
PATCH 1/1 staging/lustre/lnet: correctly casts value for arithmetic
----- Original Message -----
From: [email protected]
To: lidza.louina at oracle.com
Cc: devel at driverdev.osuosl.org, andreas.dilger at intel.com, lustre-devel at lists.lustre.org, gregkh at linuxfoundation.org
Sent: Thursday, June 23, 2016 11:11:06 AM GMT -08:00 US/Canada Pacific
Subject: Re: [lustre-devel] [PATCH] staging/lustre/lnet: correctly casts value for arithmetic
Quoted 2 lines · Lidza Louina
The smatch warning was "
drivers/staging/lustre/lnet/lnet/api-ni.c:516lnet_res_lh_initialize()warn: should '1 << ibits' be a 64 bit type?"
I think you misinterpreted it, it has nothing to do with the addition.
What it actually means is:
1 is a 32bit integer, you do a right shift by some variable number of bits. So please check if there's risk to overflow the 32 bits unexpectedly.
The way to fix this warning is to replace 1 with 1ULL (unsigned long long) and that is fine to do as a way of future proofing this stuff even if it's not yet broken yet, I guess.
Ahh, okay, I see what you're saying and I see what I did wrong.
I'm going to update the patch to:
- rec->rec_lh_cookie += 1 << ibits;
+ rec->rec_lh_cookie += (1ULL << ibits);
Lidza
Quoted 14 lines
Quoted 13 lines
hash = (lh->lh_cookie >> ibits) & LNET_LH_HASH_MASK;Signature · 8 lines
1.9.1 _______________________________________________ lustre-devel mailing list lustre-devel at lists.lustre.org http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org