Reconcile: Fix clang warning
authorOlivier Goffart <ogoffart@woboq.com>
Thu, 9 Apr 2015 13:06:48 +0000 (15:06 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Thu, 9 Apr 2015 13:06:48 +0000 (15:06 +0200)
csync_reconcile.c:159:26: warning: address of array 'tmp->path' will always evaluate to 'true' [-Wpointer-bool-conversion]
                if( tmp->path ) {
                ~~  ~~~~~^~~~

csync_file_stat_s::path is an array so it is never null
What was meant here is to check if the string was not empty

csync/src/csync_reconcile.c

index 8ceb8577bb8f8206ddf7e14d9491061e7402d4da..861910f5d183cd2e2915137cfe0f6c7f8e9aff3f 100644 (file)
@@ -156,8 +156,8 @@ static int _csync_merge_algorithm_visitor(void *obj, void *data) {
             }
 
             if( tmp ) {
-                if( tmp->path ) {
-                    len = strlen( tmp->path );
+                len = strlen( tmp->path );
+                if( len > 0 ) {
                     h = c_jhash64((uint8_t *) tmp->path, len, 0);
                     /* First, check that the file is NOT in our tree (another file with the same name was added) */
                     node = c_rbtree_find(ctx->current == REMOTE_REPLICA ? ctx->remote.tree : ctx->local.tree, &h);