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

Dennis Schafroth dennis at schafroth.dk
Sat Jan 31 17:19:25 UTC 2015


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;


cheers, 
:-Dennis 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gluster.org/pipermail/gluster-devel/attachments/20150131/6048c8ed/attachment.html>


More information about the Gluster-devel mailing list