]> git.sur5r.net Git - i3/i3status/commitdiff
Merge pull request #208 from stapelberg/warning
authorIngo Bürk <admin@airblader.de>
Wed, 8 Mar 2017 21:26:33 +0000 (22:26 +0100)
committerGitHub <noreply@github.com>
Wed, 8 Mar 2017 21:26:33 +0000 (22:26 +0100)
remove useless checks (we use char, not unsigned char)

src/print_disk_info.c

index d343fb89c1b94abe09271feb02a87da78c3235c1..3be81eaa604d409a75233bcf7963f97bd9f4b511 100644 (file)
@@ -141,16 +141,20 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
          * we consider the device not mounted. */
         mounted = false;
     } else {
+        char *sanitized = sstrdup(path);
+        if (sanitized[strlen(sanitized) - 1] == '/')
+            sanitized[strlen(sanitized) - 1] = '\0';
         FILE *mntentfile = setmntent("/etc/mtab", "r");
         struct mntent *m;
 
         while ((m = getmntent(mntentfile)) != NULL) {
-            if (strcmp(m->mnt_dir, path) == 0) {
+            if (strcmp(m->mnt_dir, sanitized) == 0) {
                 mounted = true;
                 break;
             }
         }
         endmntent(mntentfile);
+        free(sanitized);
     }
 #endif