* [PATCH] Use proper print formatter in main function in fixincl.c
@ 2018-12-20 2:49 Nicholas Krause
2018-12-20 21:07 ` Joseph Myers
0 siblings, 1 reply; 9+ messages in thread
From: Nicholas Krause @ 2018-12-20 2:49 UTC (permalink / raw)
To: gcc-patches
This fixes the bug id, 71176 to use the proper known
code print formatter type, %lu for size_t rather than
%d which is considered best pratice for print statements.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
fixincludes/fixincl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fixincludes/fixincl.c b/fixincludes/fixincl.c
index 6dba2f6e830..4e3010df0a6 100644
--- a/fixincludes/fixincl.c
+++ b/fixincludes/fixincl.c
@@ -159,10 +159,10 @@ main (int argc, char** argv)
tSCC zFmt[] =
"\
Processed %5d files containing %d bytes \n\
-Applying %5d fixes to %d files\n\
+Applying %5lu fixes to %d files\n\
Altering %5d of them\n";
- fprintf (stderr, zFmt, process_ct, ttl_data_size, apply_ct,
+ fprintf (stderr, zFmt, process_ct, (unsigned long int) ttl_data_size, apply_ct,
fixed_ct, altered_ct);
}
#endif /* DO_STATS */
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Use proper print formatter in main function in fixincl.c
2018-12-20 2:49 [PATCH] Use proper print formatter in main function in fixincl.c Nicholas Krause
@ 2018-12-20 21:07 ` Joseph Myers
2018-12-20 22:19 ` nick
0 siblings, 1 reply; 9+ messages in thread
From: Joseph Myers @ 2018-12-20 21:07 UTC (permalink / raw)
To: Nicholas Krause; +Cc: gcc-patches
This is still changing the wrong format specifier (the one corresponding
to apply_ct, which is an int).
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Use proper print formatter in main function in fixincl.c
2018-12-20 21:07 ` Joseph Myers
@ 2018-12-20 22:19 ` nick
0 siblings, 0 replies; 9+ messages in thread
From: nick @ 2018-12-20 22:19 UTC (permalink / raw)
To: Joseph Myers; +Cc: gcc-patches
On 2018-12-20 4:02 p.m., Joseph Myers wrote:
> This is still changing the wrong format specifier (the one corresponding
> to apply_ct, which is an int).
>
Sorry for the dumb mistakes as I seem to have miscounted the variables over
in my understanding of the code.
I will resend again and sorry for wasting your time Joseph,
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Use proper print formatter in main function in fixincl.c
2019-01-07 16:02 ` NightStrike
@ 2019-01-07 16:04 ` Jonathan Wakely
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Wakely @ 2019-01-07 16:04 UTC (permalink / raw)
To: NightStrike; +Cc: Nicholas Krause, GCC Patches
On 07/01/19 11:01 -0500, NightStrike wrote:
>On Mon, Jan 7, 2019 at 10:57 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>>
>> On 20/12/18 17:23 -0500, Nicholas Krause wrote:
>> >This fixes the bug id, 71176 to use the proper known
>> >code print formatter type, %lu for size_t rather than
>> >%d which is considered best pratice for print statements.
>>
>> Well the proper specifier for size_t is %zu, but since you cast to
>> unsigned long then %lu is right.
>
>Wouldn't the right fix be to not cast to unsigned long and use %zu?
That was added in C99 and so is not part of C++98. GCC only requires a
C++98 compiler (and library).
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Use proper print formatter in main function in fixincl.c
2019-01-07 15:57 ` Jonathan Wakely
@ 2019-01-07 16:02 ` NightStrike
2019-01-07 16:04 ` Jonathan Wakely
0 siblings, 1 reply; 9+ messages in thread
From: NightStrike @ 2019-01-07 16:02 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Nicholas Krause, GCC Patches
On Mon, Jan 7, 2019 at 10:57 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On 20/12/18 17:23 -0500, Nicholas Krause wrote:
> >This fixes the bug id, 71176 to use the proper known
> >code print formatter type, %lu for size_t rather than
> >%d which is considered best pratice for print statements.
>
> Well the proper specifier for size_t is %zu, but since you cast to
> unsigned long then %lu is right.
Wouldn't the right fix be to not cast to unsigned long and use %zu?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Use proper print formatter in main function in fixincl.c
2018-12-20 22:27 Nicholas Krause
@ 2019-01-07 15:57 ` Jonathan Wakely
2019-01-07 16:02 ` NightStrike
0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2019-01-07 15:57 UTC (permalink / raw)
To: Nicholas Krause; +Cc: gcc-patches
On 20/12/18 17:23 -0500, Nicholas Krause wrote:
>This fixes the bug id, 71176 to use the proper known
>code print formatter type, %lu for size_t rather than
>%d which is considered best pratice for print statements.
Well the proper specifier for size_t is %zu, but since you cast to
unsigned long then %lu is right.
>Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
>---
> fixincludes/fixincl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/fixincludes/fixincl.c b/fixincludes/fixincl.c
>index 6dba2f6e830..5b8b77a77f0 100644
>--- a/fixincludes/fixincl.c
>+++ b/fixincludes/fixincl.c
>@@ -158,11 +158,11 @@ main (int argc, char** argv)
> if (VLEVEL( VERB_PROGRESS )) {
> tSCC zFmt[] =
> "\
>-Processed %5d files containing %d bytes \n\
>+Processed %5d files containing %lu bytes \n\
> Applying %5d fixes to %d files\n\
> Altering %5d of them\n";
>
>- fprintf (stderr, zFmt, process_ct, ttl_data_size, apply_ct,
>+ fprintf (stderr, zFmt, process_ct, (unsigned int long) ttl_data_size, apply_ct,
I'd expect "unsigned long" not "unsigned int long".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Use proper print formatter in main function in fixincl.c
@ 2018-12-20 22:27 Nicholas Krause
2019-01-07 15:57 ` Jonathan Wakely
0 siblings, 1 reply; 9+ messages in thread
From: Nicholas Krause @ 2018-12-20 22:27 UTC (permalink / raw)
To: gcc-patches
This fixes the bug id, 71176 to use the proper known
code print formatter type, %lu for size_t rather than
%d which is considered best pratice for print statements.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
fixincludes/fixincl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fixincludes/fixincl.c b/fixincludes/fixincl.c
index 6dba2f6e830..5b8b77a77f0 100644
--- a/fixincludes/fixincl.c
+++ b/fixincludes/fixincl.c
@@ -158,11 +158,11 @@ main (int argc, char** argv)
if (VLEVEL( VERB_PROGRESS )) {
tSCC zFmt[] =
"\
-Processed %5d files containing %d bytes \n\
+Processed %5d files containing %lu bytes \n\
Applying %5d fixes to %d files\n\
Altering %5d of them\n";
- fprintf (stderr, zFmt, process_ct, ttl_data_size, apply_ct,
+ fprintf (stderr, zFmt, process_ct, (unsigned int long) ttl_data_size, apply_ct,
fixed_ct, altered_ct);
}
#endif /* DO_STATS */
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Use proper print formatter in main function in fixincl.c
2018-12-19 23:35 Nicholas Krause
@ 2018-12-20 0:20 ` Joseph Myers
0 siblings, 0 replies; 9+ messages in thread
From: Joseph Myers @ 2018-12-20 0:20 UTC (permalink / raw)
To: Nicholas Krause; +Cc: gcc-patches
This patch is wrong for multiple reasons (the %d you're changing is for an
int argument, so is correct as-is, and %lu is not portable for size_t, so
since we may not be able to assume C99 %zu on the host you'd need to cast
the ttl_data_size argument explicitly to unsigned long int to use %lu for
it).
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Use proper print formatter in main function in fixincl.c
@ 2018-12-19 23:35 Nicholas Krause
2018-12-20 0:20 ` Joseph Myers
0 siblings, 1 reply; 9+ messages in thread
From: Nicholas Krause @ 2018-12-19 23:35 UTC (permalink / raw)
To: gcc-patches
This fixes the bug id, 71176 to use the proper known
code print formatter type, %lu for size_t rather than
%d which is considered best pratice for print statements.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
fixincludes/fixincl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fixincludes/fixincl.c b/fixincludes/fixincl.c
index 6dba2f6e830..8e16a2f7792 100644
--- a/fixincludes/fixincl.c
+++ b/fixincludes/fixincl.c
@@ -159,7 +159,7 @@ main (int argc, char** argv)
tSCC zFmt[] =
"\
Processed %5d files containing %d bytes \n\
-Applying %5d fixes to %d files\n\
+Applying %5d fixes to %lu files\n\
Altering %5d of them\n";
fprintf (stderr, zFmt, process_ct, ttl_data_size, apply_ct,
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-01-07 16:04 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 2:49 [PATCH] Use proper print formatter in main function in fixincl.c Nicholas Krause
2018-12-20 21:07 ` Joseph Myers
2018-12-20 22:19 ` nick
-- strict thread matches above, loose matches on Subject: below --
2018-12-20 22:27 Nicholas Krause
2019-01-07 15:57 ` Jonathan Wakely
2019-01-07 16:02 ` NightStrike
2019-01-07 16:04 ` Jonathan Wakely
2018-12-19 23:35 Nicholas Krause
2018-12-20 0:20 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).