Fix printf format mismatch for unsigned long variables

Use %lu instead of %ld for unsigned long iteration counters in report()
functions. Using %ld for unsigned long is undefined behavior per the C
standard.

Affected files: arith.c, dhry_1.c, hanoi.c, pipe.c, syscall.c
This commit is contained in:
wangxp006
2026-05-13 23:15:41 +08:00
parent 681f19d317
commit cea458897c
5 changed files with 5 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ volatile unsigned long iter;
/* this function is called when the alarm expires */
void report()
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
fprintf(stderr,"COUNT|%lu|1|lps\n", iter);
exit(0);
}

View File

@@ -44,7 +44,7 @@ volatile unsigned long Run_Index;
void report()
{
fprintf(stderr,"COUNT|%ld|1|lps\n", Run_Index);
fprintf(stderr,"COUNT|%lu|1|lps\n", Run_Index);
exit(0);
}

View File

@@ -32,7 +32,7 @@ long cnt;
void report()
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
fprintf(stderr,"COUNT|%lu|1|lps\n", iter);
exit(0);
}

View File

@@ -31,7 +31,7 @@ unsigned long iter;
void report()
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
fprintf(stderr,"COUNT|%lu|1|lps\n", iter);
exit(0);
}

View File

@@ -36,7 +36,7 @@ unsigned long iter;
void report()
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
fprintf(stderr,"COUNT|%lu|1|lps\n", iter);
exit(0);
}