mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: "Vegard Nossum" <vegard.nossum@gmail.com>
Cc: trivial@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] init: Fix printk format strings
Date: Thu, 11 Oct 2007 09:01:03 -0700	[thread overview]
Message-ID: <20071011090103.5c4bad43.randy.dunlap@oracle.com> (raw)
In-Reply-To: <19f34abd0710110855t58084c62ne3e09227727b7c61@mail.gmail.com>

On Thu, 11 Oct 2007 17:55:16 +0200 Vegard Nossum wrote:

> On 10/11/07, Randy Dunlap <randy.dunlap@oracle.com> wrote:
> > On Thu, 11 Oct 2007 08:17:02 +0200 Vegard Nossum wrote:
> >
> > > This makes sure printk format strings are string literals containing no
> > > more than a single line.
> >
> > Each patch needs justification (unless it is blatantly obvious).
> >
> >
> > > Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
> > > ---
> > >  init/calibrate.c        |    4 +++-
> > >  init/do_mounts_initrd.c |    5 ++++-
> > >  init/main.c             |    2 +-
> > >  3 files changed, 8 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
> > > index fd4fc12..ad6174c 100644
> > > --- a/init/do_mounts_initrd.c
> > > +++ b/init/do_mounts_initrd.c
> > > @@ -98,7 +98,10 @@ static void __init handle_initrd(void)
> > >                       error = sys_ioctl(fd, BLKFLSBUF, 0);
> > >                       sys_close(fd);
> > >               }
> > > -             printk(!error ? "okay\n" : "failed\n");
> > > +             if(error)
> > > +                     printk("failed\n");
> > > +             else
> > > +                     printk("okay\n");
> > >       }
> > >  }
> >
> > Why this one?
> > and if it must change, use:
> >                 if (error)
> > but I see little need for the change.
> 
> Oops about the space. And it's to make the format string a constant
> literal. If it isn't, you are going to run into trouble with options
> to remove printks at compile-time based on log-level token. I realize
> it's not really an issue at this point in time, but I assume that it
> will eventually make its way into the kernel in some way or another.

so would this be OK?

		printk("%s\n", error ? "failed" : "okay");


---
~Randy

  reply	other threads:[~2007-10-11 16:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-11  6:17 Vegard Nossum
2007-10-11 15:40 ` Randy Dunlap
2007-10-11 15:55   ` Vegard Nossum
2007-10-11 16:01     ` Randy Dunlap [this message]
2007-10-11 16:09       ` Vegard Nossum
2007-10-11 16:20         ` Randy Dunlap
2007-10-11 17:21 ` Johannes Weiner
2007-10-11 19:15   ` Vegard Nossum

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=20071011090103.5c4bad43.randy.dunlap@oracle.com \
    --to=randy.dunlap@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@kernel.org \
    --cc=vegard.nossum@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome