[PATCH] D126121: [count] Use correct integral type
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 15:30:40 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08ca2dc6896e: [count] Use correct integral type (authored by gAlfonso-bit, committed by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126121/new/
https://reviews.llvm.org/D126121
Files:
llvm/utils/count/count.c
Index: llvm/utils/count/count.c
===================================================================
--- llvm/utils/count/count.c
+++ llvm/utils/count/count.c
@@ -10,7 +10,7 @@
#include <stdio.h>
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 @@
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 @@
NumLines = 0;
do {
- unsigned i;
+ size_t i;
NumRead = fread(Buffer, 1, sizeof(Buffer), stdin);
@@ -41,7 +41,7 @@
}
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126121.480651.patch
Type: text/x-patch
Size: 963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221206/5fffa319/attachment.bin>
More information about the llvm-commits
mailing list