fixes more if statements and some warnings

Tue, 26 Mar 2019 18:11:34 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 26 Mar 2019 18:11:34 +0100
changeset 539
8deb52292c99
parent 538
a7402e35ad87
child 540
d18f92483945

fixes more if statements and some warnings

dav/finfo.c file | annotate | diff | comparison | revisions
dav/main.c file | annotate | diff | comparison | revisions
dav/scfg.c file | annotate | diff | comparison | revisions
dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/finfo.c	Tue Mar 26 18:02:40 2019 +0100
+++ b/dav/finfo.c	Tue Mar 26 18:11:34 2019 +0100
@@ -49,7 +49,7 @@
         return FINFO_DATE|FINFO_OWNER|FINFO_MODE;
     }
     
-    size_t count = 0;
+    ssize_t count = 0;
     sstr_t *fs = sstrsplit(s, SC(","), &count);
     
     char *err = NULL;
@@ -97,7 +97,7 @@
     DavXmlNode *content = NULL;
     DavXmlNode *last = NULL;
     
-    if(finfo & FINFO_DATE == FINFO_DATE) {
+    if((finfo & FINFO_DATE) == FINFO_DATE) {
         char str[32];
         struct tm *date = gmtime(&s->st_mtime);
         strftime(str, 32, "%a, %d %b %Y %H:%M:%S GMT", date);
@@ -106,10 +106,10 @@
         last = mtime;
     }
 #ifndef _WIN32
-    if(finfo & FINFO_OWNER == FINFO_OWNER) {
+    if((finfo & FINFO_OWNER) == FINFO_OWNER) {
         // TODO
     }
-    if(finfo & FINFO_MODE == FINFO_MODE) {
+    if((finfo & FINFO_MODE) == FINFO_MODE) {
         mode_t mode = s->st_mode & 07777;
         char str[32];
         snprintf(str, 32, "%o", (int)mode);
--- a/dav/main.c	Tue Mar 26 18:02:40 2019 +0100
+++ b/dav/main.c	Tue Mar 26 18:11:34 2019 +0100
@@ -1524,7 +1524,7 @@
     if(resource_set_finfo(fpath, res, finfo)) {
         fprintf(stderr, "Cannot set finfo: %s.\n", strerror(errno));
     }
-    if(finfo & FINFO_XATTR == FINFO_XATTR) {
+    if((finfo & FINFO_XATTR) == FINFO_XATTR) {
         XAttributes *xattr = file_get_attributes(fpath);
         if(xattr) {
             resource_set_xattr(res, xattr);
--- a/dav/scfg.c	Tue Mar 26 18:02:40 2019 +0100
+++ b/dav/scfg.c	Tue Mar 26 18:11:34 2019 +0100
@@ -530,10 +530,10 @@
     dir->lock_timeout = lock_timeout;
     dir->metadata = metadata;
     dir->splitconfig = splitconfig;
-    if(metadata & FINFO_MODE == FINFO_MODE) {
+    if((metadata & FINFO_MODE) == FINFO_MODE) {
         dir->db_settings = DB_STORE_MODE;
     }
-    if(metadata & FINFO_OWNER == FINFO_OWNER) {
+    if((metadata & FINFO_OWNER) == FINFO_OWNER) {
         dir->db_settings |= DB_STORE_OWNER;
     }
     
--- a/dav/sync.c	Tue Mar 26 18:02:40 2019 +0100
+++ b/dav/sync.c	Tue Mar 26 18:11:34 2019 +0100
@@ -884,7 +884,7 @@
         }
         
         // check if extended attributes have changed
-        if(dir->metadata & FINFO_XATTR == FINFO_XATTR) {
+        if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
             DavXmlNode *xattr = dav_get_property_ns(res, DAV_NS, "xattributes");
             char *xattr_hash = get_xattr_hash(xattr);
             if(nullstrcmp(xattr_hash, local->xattr_hash)) {
@@ -895,7 +895,7 @@
         
         // check if finfo has changed
         DavXmlNode *finfo = dav_get_property_ns(res, DAV_NS, "finfo");
-        if(dir->metadata & FINFO_MODE == FINFO_MODE) {
+        if((dir->metadata & FINFO_MODE) == FINFO_MODE) {
             FileInfo f;
             finfo_get_values(finfo, &f);
             if(f.mode_set && f.mode != local->mode) {
@@ -1981,20 +1981,20 @@
             res->metadata_updated = res->tags_updated;
         }
         
-        if(dir->metadata & FINFO_MODE == FINFO_MODE) {
+        if((dir->metadata & FINFO_MODE) == FINFO_MODE) {
             if(db_res->mode != res->mode) {
                 res->finfo_updated = 1;
                 res->metadata_updated = 1;
             }
         }
-        if(dir->metadata & FINFO_OWNER == FINFO_OWNER) {
+        if((dir->metadata & FINFO_OWNER) == FINFO_OWNER) {
             if(db_res->uid != res->uid || db_res->gid != res->gid) {
                 res->finfo_updated = 1;
                 res->metadata_updated = 1;
             }
         }
         
-        if(dir->metadata & FINFO_XATTR == FINFO_XATTR) {
+        if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
             char *path = util_concat_path(dir->path, db_res->path);
             XAttributes *xattr = file_get_attributes(path);
             // test if xattr are added, removed or changed
@@ -2241,7 +2241,7 @@
     if(fileinfo) {
         FileInfo f;
         finfo_get_values(fileinfo, &f);
-        if(dir->metadata & FINFO_DATE == FINFO_DATE && f.date_set) {
+        if((dir->metadata & FINFO_DATE) == FINFO_DATE && f.date_set) {
             // set mtime
             struct utimbuf t;
             t.actime = f.last_modified;
@@ -2251,7 +2251,7 @@
                 ret = 1;
             }
         }
-        if(dir->metadata & FINFO_MODE == FINFO_MODE && f.mode_set) {
+        if((dir->metadata & FINFO_MODE) == FINFO_MODE && f.mode_set) {
             // set mode
             if(chmod(path, f.mode)) {
                 fprintf(stderr, "chmod failed for file: %s : %s\n", path, strerror(errno));
@@ -3937,7 +3937,7 @@
 void sync_print_get_file_err(const char *path, int err) {
     switch(err) {
         case 1: fprintf(stderr, "File %s: not found\n", path); break;
-        case 2: fprintf(stderr, "File %s: permission denied\n"); break;
+        case 2: fprintf(stderr, "File %s: permission denied\n", path); break;
         case 3: fprintf(stderr, "File %s: stat failed: %s\n", path, strerror(errno)); break;
         case 4: fprintf(stderr, "File %s is not in any syncdir\n", path); break;
         case 5: fprintf(stderr, "File %s is in multiple syncdirs\n", path); break;

mercurial