X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Freadahead%2Freadahead-analyze.c;h=e24b2a32985d041439afc709ffa16e1c3166f828;hp=fb50ad371e8da1d2b7fba01a9e0a9eb505d2930a;hb=268d944e44bea60d5c498cb24a8629f012aac055;hpb=3b0810c53c6adfa2f436540369b8969ae75d7fcf diff --git a/src/readahead/readahead-analyze.c b/src/readahead/readahead-analyze.c index fb50ad371..e24b2a329 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; + FILE _cleanup_fclose_ *pack = NULL; int a; int missing = 0; - off_t tsize = 0; + size_t tsize = 0; if (!pack_path) pack_path = "/.readahead"; @@ -105,7 +105,7 @@ int main_analyze(const char *pack_path) { } if (stat(path, &st) == 0) { - off_t size; + size_t size; if (sections == 0) size = st.st_size; @@ -114,10 +114,10 @@ int main_analyze(const char *pack_path) { tsize += size; - printf(" %4d%% (%2d) %12ld: %s\n", - sections ? (int)(size / st.st_size * 100.0) : 100, + printf(" %4zd%% (%2d) %12zd: %s\n", + sections && st.st_size ? size * 100 / st.st_size : 100, sections ? sections : 1, - (unsigned long)size, + size, path); } else { printf(" %4dp (%2d) %12s: %s (MISSING)\n", @@ -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, @@ -143,8 +141,6 @@ int main_analyze(const char *pack_path) { return EXIT_SUCCESS; - fail: - fclose(pack); return EXIT_FAILURE; }