All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/6] stdio: dm: Make stdio_devices[] local
Date: Sun, 2 Sep 2012 02:02:51 +0200	[thread overview]
Message-ID: <201209020202.51744.marex@denx.de> (raw)
In-Reply-To: <5042962F.4060706@googlemail.com>

Dear Andreas Bie?mann,

> Dear Marek Vasut,

Heh, this Dear $recipient became really popular :-)

[...]

> return is not required here ..
> 
> >  }
> >  
> >  static inline void console_puts(int file, const char *s)
> >  {
> > 
> > -	stdio_devices[file]->puts(s);
> > +	struct stdio_dev *dev = stdio_get_fd(file);
> > +	if (dev)
> > +		return dev->puts(s);
> 
> .. and here

Thanks!

> >  }
> >  
> >  static inline void console_printdevs(int file)
> >  {
> > 
> > -	printf("%s\n", stdio_devices[file]->name);
> > +	struct stdio_dev *dev = stdio_get_fd(file);
> > +	if (dev)
> > +		printf("%s\n", dev->name);
> > 
> >  }
> >  
> >  static inline void console_doenv(int file, struct stdio_dev *dev)
> > 
> > @@ -592,27 +604,28 @@ int console_init_f(void)
> > 
> >  void stdio_print_current_devices(void)
> >  {
> >  #ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
> > 
> > +	struct stdio_dev *sio;
> > 
> >  	/* Print information */
> >  	puts("In:    ");
> > 
> > -	if (stdio_devices[stdin] == NULL) {
> > +	sio = stdio_get_fd(stdin);
> > +	if (sio == NULL)
> > 
> >  		puts("No input devices available!\n");
> > 
> > -	} else {
> > -		printf ("%s\n", stdio_devices[stdin]->name);
> > -	}
> > +	else
> > +		printf("%s\n", sio->name);
> > 
> >  	puts("Out:   ");
> > 
> > -	if (stdio_devices[stdout] == NULL) {
> > +	sio = stdio_get_fd(stdout);
> 
> Isn't sio still set properly here ...

It is, but it still can be NULL. Also notice the argument differs, first it's 
stdin, then stdout and lastly stderr

> > +	if (sio == NULL)
> > 
> >  		puts("No output devices available!\n");
> > 
> > -	} else {
> > -		printf ("%s\n", stdio_devices[stdout]->name);
> > -	}
> > +	else
> > +		printf("%s\n", sio->name);
> > 
> >  	puts("Err:   ");
> > 
> > -	if (stdio_devices[stderr] == NULL) {
> > +	sio = stdio_get_fd(stderr);
> 
> .. and here?
> 
> > +	if (sio == NULL)
> 
> Side note: in your newly introduced checks you use just
> 
>  if (sio) {
>  ...
> 
> Why check explicitly for NULL here? I personally favor 'if (!sio)'.

Compat reason really ... I didn't wanted to introduce more change than necessary 
... incremental patching can be done indeed ;-)

> >  		puts("No error devices available!\n");
> > 
> > -	} else {
> > -		printf ("%s\n", stdio_devices[stderr]->name);
> > -	}
> > +	else
> > +		printf("%s\n", sio->name);

Thanks for the review :)

> Best regards
> 
> Andreas Bie?mann

  reply	other threads:[~2012-09-02  0:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-31 22:44 [U-Boot] [PATCH 0/6] stdio: Clean up Marek Vasut
2012-08-31 22:44 ` [U-Boot] [PATCH 1/6] stdio: dm: Remove dead code in console.c Marek Vasut
2012-08-31 22:44 ` [U-Boot] [PATCH 2/6] stdio: dm: Add accessors to stdio_devices[] Marek Vasut
2012-08-31 22:44 ` [U-Boot] [PATCH 3/6] stdio: dm: Make stdio_devices[] local Marek Vasut
2012-09-01 20:14   ` Marek Vasut
2012-09-01 23:11   ` Andreas Bießmann
2012-09-02  0:02     ` Marek Vasut [this message]
2012-09-02  8:12       ` Wolfgang Denk
2012-08-31 22:44 ` [U-Boot] [PATCH 4/6] stdio: dm: Add stdio_fd_to_name() call Marek Vasut
2012-08-31 22:44 ` [U-Boot] [PATCH 5/6] stdio: dm: Use stdio_fd_to_name() call to localize stdio_names Marek Vasut
2012-08-31 22:44 ` [U-Boot] [PATCH 6/6] stdio: dm: Optimize stdio_print_current_devices() Marek Vasut
2012-09-01 12:17 ` [U-Boot] [PATCH 0/6] stdio: Clean up Wolfgang Denk
2012-09-01 14:19   ` Marek Vasut
2012-09-01 16:33     ` Wolfgang Denk
2012-09-01 16:57       ` Marek Vasut
2012-09-01 20:00         ` Wolfgang Denk
2012-09-01 20:12           ` Marek Vasut

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=201209020202.51744.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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.