All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: long <tlnguyen@snoqualmie.dp.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@atrey.karlin.mff.cuni.cz,
	tom.l.nguyen@intel.com
Subject: Re: [PATCH 2/6] PCI Express Advanced Error Reporting Driver
Date: Fri, 11 Mar 2005 23:25:23 -0800	[thread overview]
Message-ID: <20050312072523.GC11236@kroah.com> (raw)
In-Reply-To: <200503120013.j2C0DXcK020305@snoqualmie.dp.intel.com>

On Fri, Mar 11, 2005 at 04:13:33PM -0800, long wrote:
> +static ssize_t aer_sysfs_consume_show(struct device_driver *dev, char *buf)
> +{
> +	return aer_fsprint_record(buf);
> +}
> +                  	
> +static ssize_t aer_sysfs_status_show(struct device_driver *dev, char *buf)
> +{
> +	return aer_fsprint_devices(buf);
> +}
> +                  	

Why call wrapper functions that only do one thing?  Why have this extra
layer of indirection that is not needed from what I can tell?

> +static ssize_t aer_sysfs_verbose_show(struct device_driver *dev, char *buf)
> +{
> +	return sprintf(buf, "Verbose display set to %d\n", 
> +		aer_get_verbose());				
> +}

Just echo the value, don't print out pretty strings :)

> +static ssize_t aer_sysfs_verbose_store(struct device_driver *drv, 	
> +					const char *buf, size_t count)  
> +{                            
> +	aer_set_verbose(buf[0] - 0x30);			
> +	return count;							
> +}

Oh, that's a problem waiting to happen... Please validate the user
provided value before acting on it.

> +static ssize_t aer_sysfs_auto_show(struct device_driver *dev, char *buf)
> +{
> +	return sprintf(buf, "Automatic reporting is %s\n", 		
> +		(aer_get_auto_mode()) ? "on" : "off");  			
> +}

Again, just print on/off.

> +static ssize_t aer_sysfs_auto_store(struct device_driver *drv, 	
> +					const char *buf, size_t count)          
> +{                            
> +	aer_set_auto_mode(buf[0] - 0x30);			
> +	return count;							
> +}

Also validate this.

thanks,

greg k-h

  reply	other threads:[~2005-03-12  8:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-12  0:13 [PATCH 2/6] PCI Express Advanced Error Reporting Driver long
2005-03-12  7:25 ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-03-14 18:18 Nguyen, Tom L

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=20050312072523.GC11236@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=tlnguyen@snoqualmie.dp.intel.com \
    --cc=tom.l.nguyen@intel.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 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.