All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lekensteyn <lekensteyn at gmail.com>
To: powertop@lists.01.org
Subject: Re: [Powertop] [PATCH] Use printf, not sprintf, to print messages to stdout.
Date: Thu, 21 Jun 2012 21:42:02 +0200	[thread overview]
Message-ID: <1715014.OogSz8kVBe@al> (raw)
In-Reply-To: 20120621191441.GA3476@swordfish.datadirect.datadirectnet.com

[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]

On Thursday 21 June 2012 22:14:41 Sergey Senozhatsky wrote:
> On (06/16/12 18:14), Magnus Fromreide wrote:
> > This undos the last printf->sprintf change from 8fd54ace.
> > 
> > Signed-off-by: Magnus Fromreide <magfr(a)lysator.liu.se>
> > ---
> > 
> >  src/main.cpp |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/main.cpp b/src/main.cpp
> > index 880d745..a2d8700 100644
> > --- a/src/main.cpp
> > +++ b/src/main.cpp
> > @@ -229,7 +229,7 @@ void one_measurement(int seconds, char *workload)
> > 
> >  void out_of_memory()
> >  {
> >  
> >  	reset_display();
> > 
> > -	sprintf("%s...\n",_("PowerTOP is out of memory. PowerTOP is 
Aborting"));
> > +	printf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting"));
> > 
> >  	abort();
> >  
> >  }
> > 
> > @@ -458,7 +458,7 @@ int main(int argc, char **argv)
> > 
> >  #ifndef DISABLE_NCURSES
> >  
> >  	endwin();
> >  
> >  #endif
> > 
> > -	sprintf("%s\n", _("Leaving PowerTOP"));
> > +	printf("%s\n", _("Leaving PowerTOP"));
> > 
> >  	end_process_data();
> >  	clear_process_data();
> 
> Oh, good catch!
> 
> Looks like changes were introduced by commit
> 8fd54ace0a398cd155bf0af620c85d0105778f6a.

That commit contains more abuse of sprintf:
https://github.com/fenrus75/powertop/commit/8fd54ace0a398cd155bf0af620c85d0105778f6a#L1L102
Writing to a constant string is not going to work, eh?

Peter

             reply	other threads:[~2012-06-21 19:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21 19:42 Lekensteyn [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-06-22 16:13 [Powertop] [PATCH] Use printf, not sprintf, to print messages to stdout Chris Ferron
2012-06-22  8:49 Magnus Fromreide
2012-06-21 19:48 Magnus Fromreide
2012-06-21 19:14 Sergey Senozhatsky
2012-06-21 19:07 Magnus Fromreide
2012-06-16 16:14 Magnus Fromreide

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1715014.OogSz8kVBe@al \
    --to=powertop@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.