coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

factor vs printf failure


From: Jim Meyering
Subject: factor vs printf failure
Date: Thu, 25 Jun 2015 07:38:43 -0700

Hi Pádraig,

I noticed that a recent change accumulates the return value of printf
into a variable of type size_t:

+static size_t n_out; /* How much data we've written to stdout.  */
+
...
-    printf ("%"PRIuMAX, t0);
+    n_out += printf ("%"PRIuMAX, t0);

The problem is that when printf fails, it returns a negative int,
which will be mapped to a very large size_t value in this case.
When printf fails we don't really care about how buffering
is done (that's the purpose of n_out), but it's worth at least
a comment, if only to forestall reports from static analyzers.

Thanks for all of your work,

Jim



reply via email to

[Prev in Thread] Current Thread [Next in Thread]