X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Freadahead%2Freadahead-analyze.c;h=76db3cb7e4b8dc0be437e291d9bf8e3d0c0797cb;hb=0bba8d6eb74466bc708a4453130b99b5b4e0254c;hp=8f1d7f9c4fa188442c67585c47e88bf0660361df;hpb=8b38f3cc3eb73adf9536cb73d0f319e60d42ea0c;p=elogind.git diff --git a/src/readahead/readahead-analyze.c b/src/readahead/readahead-analyze.c index 8f1d7f9c4..76db3cb7e 100644 --- a/src/readahead/readahead-analyze.c +++ b/src/readahead/readahead-analyze.c @@ -34,10 +34,10 @@ 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; }