From: Gregory Alfonso Date: Tue, 6 Dec 2022 23:30:25 +0000 (-0800) Subject: [count] Use correct integral type X-Git-Tag: upstream/17.0.6~25038 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=08ca2dc6896e36ce8fa614854f07a59e97794d39;p=platform%2Fupstream%2Fllvm.git [count] Use correct integral type Make the types consistent with each other, and return size_t instead of a long int. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D126121 --- diff --git a/llvm/utils/count/count.c b/llvm/utils/count/count.c index 0aacafe..7149c14 100644 --- a/llvm/utils/count/count.c +++ b/llvm/utils/count/count.c @@ -10,7 +10,7 @@ #include int main(int argc, char **argv) { - unsigned Count, NumLines, NumRead; + size_t Count, NumLines, NumRead; char Buffer[4096], *End; if (argc != 2) { @@ -18,7 +18,7 @@ int main(int argc, char **argv) { return 2; } - Count = strtol(argv[1], &End, 10); + Count = strtoul(argv[1], &End, 10); if (*End != '\0' && End != argv[1]) { fprintf(stderr, "%s: invalid count argument '%s'\n", argv[0], argv[1]); return 2; @@ -26,7 +26,7 @@ int main(int argc, char **argv) { NumLines = 0; do { - unsigned i; + size_t i; NumRead = fread(Buffer, 1, sizeof(Buffer), stdin); @@ -41,7 +41,7 @@ int main(int argc, char **argv) { } if (Count != NumLines) { - fprintf(stderr, "Expected %d lines, got %d.\n", Count, NumLines); + fprintf(stderr, "Expected %zu lines, got %zu.\n", Count, NumLines); return 1; }