chiark / gitweb /
resolved: when there's already somebody listening on the LLMNR ports, simple disable...
[elogind.git] / src / readahead / readahead-analyze.c
index 8f1d7f9c4fa188442c67585c47e88bf0660361df..76db3cb7e4b8dc0be437e291d9bf8e3d0c0797cb 100644 (file)
 
 int main_analyze(const char *pack_path) {
         char line[LINE_MAX];
-        FILE *pack;
+        _cleanup_fclose_ FILE *pack = NULL;
         int a;
         int missing = 0;
-        off_t tsize = 0;
+        size_t tsize = 0;
 
         if (!pack_path)
                 pack_path = "/.readahead";
@@ -114,11 +114,11 @@ int main_analyze(const char *pack_path) {
 
                         tsize += size;
 
-                        printf("  %4d%% (%2d) %12ld: %s\n",
-                                sections ? (int)(size / st.st_size * 100.0) : 100,
-                                sections ? sections : 1,
-                                (unsigned long)size,
-                                path);
+                        printf("  %4jd%% (%2d) %12jd: %s\n",
+                               (intmax_t) (sections && st.st_size ? size * 100 / st.st_size : 100),
+                               sections ? sections : 1,
+                               (intmax_t) size,
+                               path);
                 } else {
                         printf("  %4dp (%2d) %12s: %s (MISSING)\n",
                                 sections ? pages : -1,
@@ -130,12 +130,10 @@ int main_analyze(const char *pack_path) {
 
         }
 
-        fclose(pack);
-
         printf("\nHOST:    %s"
                "TYPE:    %c\n"
                "MISSING: %d\n"
-               "TOTAL:   %ld\n",
+               "TOTAL:   %zu\n",
                line,
                a,
                missing,
@@ -144,6 +142,5 @@ int main_analyze(const char *pack_path) {
         return EXIT_SUCCESS;
 
 fail:
-        fclose(pack);
         return EXIT_FAILURE;
 }