[Gluster-devel] Error in dht-common.c?

Pranith Kumar Karampuri pkarampu at redhat.com
Sun Feb 1 10:27:13 UTC 2015


On 01/31/2015 10:49 PM, Dennis Schafroth wrote:
> Hi
>
> when compiling dht-common.c with clang (on mac, but I dont think that 
> matters) some warnings seem to reveal an error:
>
>   CC       dht-common.lo
> *dht-common.c:2997:57: **warning: **size argument in 'strncmp' call is 
> a comparison [-Wmemsize-comparison]*
>                          strlen (GF_XATTR_LOCKINFO_KEY) != 0))) {
> *          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~*
> *dht-common.c:2996:17: **note: *did you mean to compare the result of 
> 'strncmp' instead?
>             && (strncmp (key, GF_XATTR_LOCKINFO_KEY,
> *^*
> *dht-common.c:2997:26: **note: *explicitly cast the argument to size_t 
> to silence this warning
>                          strlen (GF_XATTR_LOCKINFO_KEY) != 0))) {
> *          ^*
> (size_t)(                          )
>
> I believe that the a parentes is misplaced, so the code is doing
>
> strncmp(key, GF_XATTR_LOCKINFO_KEY, 0)
>
> I think the following patch moves the paretens the correct place:
>
> *--- a/xlators/cluster/dht/src/dht-common.c*
> *+++ b/xlators/cluster/dht/src/dht-common.c*
> @@ -2994,7 +2994,7 @@ dht_fgetxattr (call_frame_t *frame, xlator_t *this,
>          if ((fd->inode->ia_type == IA_IFDIR)
>             && key
>              && (strncmp (key, GF_XATTR_LOCKINFO_KEY,
> - strlen (GF_XATTR_LOCKINFO_KEY) != 0))) {
> + strlen (GF_XATTR_LOCKINFO_KEY)) != 0)) {
>                  cnt = local->call_cnt = layout->cnt;
>          } else {
>                  cnt = local->call_cnt  = 1;
Thanks for submitting the patch. Gave +1 already. One of the maintainers 
of dht will pick it up.

Pranith
>
>
> cheers,
> :-Dennis
>
>
>
> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at gluster.org
> http://www.gluster.org/mailman/listinfo/gluster-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gluster.org/pipermail/gluster-devel/attachments/20150201/88edcdbf/attachment.html>


More information about the Gluster-devel mailing list