Message ID | 20210708151827.21430-4-dwagner@suse.de |
---|---|
State | New |
Headers | show |
Series | Fix a few fallouts | expand |
On Thu, 8 Jul 2021, Daniel Wagner wrote: > gcc complains with "‘sprintf’ output between 2 and 12 bytes" but > the buffer is only 10 bytes long. Update the buffer size to hold > the complete range of [-2147483648, 2147483646]. > > Signed-off-by: Daniel Wagner <dwagner@suse.de> > --- > src/sched_deadline/cyclicdeadline.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c > index ffefa9e6fecb..8447424273ee 100644 > --- a/src/sched_deadline/cyclicdeadline.c > +++ b/src/sched_deadline/cyclicdeadline.c > @@ -1092,7 +1092,7 @@ int main(int argc, char **argv) > > /* Default cpu to use is the last one */ > if (!all_cpus && !setcpu) { > - setcpu_buf = malloc(10); > + setcpu_buf = malloc(12); > if (!setcpu_buf) > fatal("malloc"); > sprintf(setcpu_buf, "%d", cpu_count - 1); > -- > 2.32.0 > > Signed-off-by: John Kacur <jkacur@redhat.com> I applied this but there are others. git grep PRIu64 src/oslat/oslat.c: snprintf(bucket_name, sizeof(bucket_name), "%03"PRIu64 src/oslat/oslat.c: putfield(bucket_name, t[i].buckets[j], PRIu64, src/oslat/oslat.c: putfield("Minimum", t[i].minlat, PRIu64, " (us)"); src/oslat/oslat.c: putfield("Maximum", t[i].maxlat, PRIu64, " (us)"); src/oslat/oslat.c: putfield("Max-Min", t[i].maxlat - t[i].minlat, PRIu64, " (us)"); src/oslat/oslat.c: fprintf(f, " \"min\": %" PRIu64 ",\n", t[i].minlat); src/oslat/oslat.c: fprintf(f, " \"max\": %" PRIu64 ",\n", t[i].maxlat); src/oslat/oslat.c: fprintf(f, " \"%" PRIu64 "\": %" PRIu64, src/oslat/oslat.c: printf("Workload mem: \t\t%"PRIu64" (KiB)\n", src/pi_tests/pi_stress.c: printf(" runtime %" PRIu64 " deadline %" PRIu64 " period %" PRIu64 "\n",
On Thu, 8 Jul 2021, Daniel Wagner wrote: > gcc complains with "‘sprintf’ output between 2 and 12 bytes" but > the buffer is only 10 bytes long. Update the buffer size to hold > the complete range of [-2147483648, 2147483646]. > > Signed-off-by: Daniel Wagner <dwagner@suse.de> > --- > src/sched_deadline/cyclicdeadline.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c > index ffefa9e6fecb..8447424273ee 100644 > --- a/src/sched_deadline/cyclicdeadline.c > +++ b/src/sched_deadline/cyclicdeadline.c > @@ -1092,7 +1092,7 @@ int main(int argc, char **argv) > > /* Default cpu to use is the last one */ > if (!all_cpus && !setcpu) { > - setcpu_buf = malloc(10); > + setcpu_buf = malloc(12); > if (!setcpu_buf) > fatal("malloc"); > sprintf(setcpu_buf, "%d", cpu_count - 1); > -- > 2.32.0 > > Signed-off-by: John Kacur <jkacur@redhat.com>
On Fri, Jul 09, 2021 at 02:01:35PM -0400, John Kacur wrote:
> I applied this but there are others.
All those variables are defined as uint64_t, hence the PRIu64 is
correct.
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index ffefa9e6fecb..8447424273ee 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -1092,7 +1092,7 @@ int main(int argc, char **argv) /* Default cpu to use is the last one */ if (!all_cpus && !setcpu) { - setcpu_buf = malloc(10); + setcpu_buf = malloc(12); if (!setcpu_buf) fatal("malloc"); sprintf(setcpu_buf, "%d", cpu_count - 1);
gcc complains with "‘sprintf’ output between 2 and 12 bytes" but the buffer is only 10 bytes long. Update the buffer size to hold the complete range of [-2147483648, 2147483646]. Signed-off-by: Daniel Wagner <dwagner@suse.de> --- src/sched_deadline/cyclicdeadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)