[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: Re: Re: missing format string in applets/usage_pod.c
From:       Laszlo Papp <lpapp () kde ! org>
Date:       2014-08-18 19:13:54
Message-ID: CAOMwXhPk_Zz3Mb_b7ydZ2YYRUopERz-Qt78Xa83WuzZLRc7aow () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Mon, Aug 18, 2014 at 7:50 PM, Cathey, Jim <jcathey@ciena.com> wrote:

> I don't like warnings on perfectly legal C.
>
> Promoting them to errors is even worse.
>
>
>
> That said, even with all this crap, provided
>
> that the strings are *constant* and don't contain
>
> substitutions the compiler has nothing to
>
> complain about.
>

It is not just about the warning and error, but the actual usage, too: if
you do not need a placeholder, why would you use printf in the first place?
It is not really meant for that. f/puts, on the other hand, were
established for that. While, it is "perfectly legal" C, like so many other
things that C sadly allows, it does not make much sense to me either. Note
that "perfectly legal" can be quite far from "perfectly reasonable".


>
>
> -- Jim
>
>
>
> *From:* busybox-bounces@busybox.net [mailto:busybox-bounces@busybox.net] *On
> Behalf Of *Tanguy Pruvot
> *Sent:* Thursday, August 14, 2014 6:45 AM
> *To:* Laszlo Papp
> *Cc:* waldeck@gmx.de; busybox
> *Subject:* Re: Re: Re: missing format string in applets/usage_pod.c
>
>
>
> its the same with bionic libc (arm)
>
>
>
> printf("test") is ok but not printf(buf) with char buf[] = "test";
> printf("%s", buf) is ok
>
>
>
> 2014-08-14 15:29 GMT+02:00 Laszlo Papp <lpapp@kde.org>:
>
> Sorry, the list was left out at some point due to my mistake ... See below.
>
>
>
> On Thu, Aug 14, 2014 at 2:28 PM, Laszlo Papp <lpapp@kde.org> wrote:
>
> On Thu, Aug 14, 2014 at 2:04 PM, <waldeck@gmx.de> wrote:
>
> Hi Laszlo,
>
>
> > Cannot reproduce with -Wall -Wpedantic -Wextra.
>
> Did you notice:
>
> applets/usage_pod.c:74:3: error: format not a string literal and no format
> arguments
> [-Werror=format-security]
>
> ^^^^^^^^^^^^^^^^?
>
>
>
> Hmm, yes, but I got used to that -Wall -Wpedantic -Wextra would cover the
> cases that need to be checked. I am not sure this option respects the C
> language though.
>
>
>
> Anyway, I guess I learnt something new today, thanks. :-)
>
>
>
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
>
>

[Attachment #5 (text/html)]

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 18, 2014 \
at 7:50 PM, Cathey, Jim <span dir="ltr">&lt;<a href="mailto:jcathey@ciena.com" \
target="_blank">jcathey@ciena.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-US"><div><p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">I \
don&#39;t like warnings on perfectly legal C.<u></u><u></u></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Promoting \
them to errors is even worse.<u></u><u></u></span></p><p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> \
<u></u></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">That \
said, even with all this crap, provided<u></u><u></u></span></p><p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">that \
the strings are <i>constant</i> and don&#39;t contain<u></u><u></u></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">substitutions \
the compiler has nothing to<u></u><u></u></span></p><p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">complain \
about.</span></p> </div></div></blockquote><div><br></div><div>It is not just about \
the warning and error, but the actual usage, too: if you do not need a placeholder, \
why would you use printf in the first place? It is not really meant for that. f/puts, \
on the other hand, were established for that. While, it is &quot;perfectly \
legal&quot; C, like so many other things that C sadly allows, it does not make much \
sense to me either. Note that &quot;perfectly legal&quot; can be quite far from \
&quot;perfectly reasonable&quot;.<br> </div><div>  </div><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-US"><div><p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u><u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> \
<u></u></span></p><p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">-- \
Jim<u></u><u></u></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> \
<u></u></span></p><p class="MsoNormal"><b><span \
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span \
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a \
href="mailto:busybox-bounces@busybox.net" \
target="_blank">busybox-bounces@busybox.net</a> [mailto:<a \
href="mailto:busybox-bounces@busybox.net" \
target="_blank">busybox-bounces@busybox.net</a>] <b>On Behalf Of </b>Tanguy \
Pruvot<br> <b>Sent:</b> Thursday, August 14, 2014 6:45 AM<br><b>To:</b> Laszlo \
Papp<br><b>Cc:</b> <a href="mailto:waldeck@gmx.de" \
target="_blank">waldeck@gmx.de</a>; busybox<br><b>Subject:</b> Re: Re: Re: missing \
format string in applets/usage_pod.c<u></u><u></u></span></p> <div><div class="h5"><p \
class="MsoNormal"><u></u>  <u></u></p><div><p class="MsoNormal">its the same with \
bionic libc (arm)<u></u><u></u></p><div><p class="MsoNormal"><u></u>  \
<u></u></p></div><div><p class="MsoNormal">printf(&quot;test&quot;) is ok but not \
printf(buf) with char buf[] = &quot;test&quot;; printf(&quot;%s&quot;, buf) is \
ok<u></u><u></u></p> </div></div><div><p class="MsoNormal" \
style="margin-bottom:12.0pt"><u></u>  <u></u></p><div><p class="MsoNormal">2014-08-14 \
15:29 GMT+02:00 Laszlo Papp &lt;<a href="mailto:lpapp@kde.org" \
target="_blank">lpapp@kde.org</a>&gt;:<u></u><u></u></p> <div><p \
class="MsoNormal">Sorry, the list was left out at some point due to my mistake ... \
See below.<u></u><u></u></p><div><p class="MsoNormal" \
style="margin-bottom:12.0pt"><u></u>  <u></u></p><div><p class="MsoNormal">On Thu, \
Aug 14, 2014 at 2:28 PM, Laszlo Papp &lt;<a href="mailto:lpapp@kde.org" \
target="_blank">lpapp@kde.org</a>&gt; wrote:<u></u><u></u></p> <div><div><div><div><p \
class="MsoNormal">On Thu, Aug 14, 2014 at 2:04 PM, &lt;<a \
href="mailto:waldeck@gmx.de" target="_blank">waldeck@gmx.de</a>&gt; \
wrote:<u></u><u></u></p><p class="MsoNormal">Hi Laszlo,<u></u><u></u></p> <div><p \
class="MsoNormal" style="margin-bottom:12.0pt"><br>&gt; Cannot reproduce with -Wall \
-Wpedantic -Wextra.<u></u><u></u></p></div><p class="MsoNormal">Did you \
notice:<u></u><u></u></p><div><p class="MsoNormal">applets/usage_pod.c:74:3: error: \
format not a string literal and no format arguments<br> \
[-Werror=format-security]<u></u><u></u></p></div><p \
class="MsoNormal">^^^^^^^^^^^^^^^^?<u></u><u></u></p><div><p \
class="MsoNormal"><u></u>  <u></u></p></div></div><div><p class="MsoNormal">Hmm, yes, \
but I got used to that -Wall -Wpedantic -Wextra would cover the cases that need to be \
checked. I am not sure this option respects the C language though.<u></u><u></u></p> \
</div><div><p class="MsoNormal"><u></u>  <u></u></p></div><div><p \
class="MsoNormal">Anyway, I guess I learnt something new today, thanks. \
:-)<u></u><u></u></p></div></div></div></div></div><p class="MsoNormal"><u></u>  \
<u></u></p> </div></div><p \
class="MsoNormal"><br>_______________________________________________<br>busybox \
mailing list<br><a href="mailto:busybox@busybox.net" \
target="_blank">busybox@busybox.net</a><br><a \
href="http://lists.busybox.net/mailman/listinfo/busybox" \
target="_blank">http://lists.busybox.net/mailman/listinfo/busybox</a><u></u><u></u></p>
 </div><p class="MsoNormal"><u></u>  \
<u></u></p></div></div></div></div></div></blockquote></div><br></div></div>



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic