[U-Boot] [PATCH 3/6] stdio: dm: Make stdio_devices[] local
    Marek Vasut 
    marex at denx.de
       
    Sun Sep  2 02:02:51 CEST 2012
    
    
  
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
    
    
More information about the U-Boot
mailing list