Message ID | 20110402100043.GA5890@kamineko.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 4/2/11, Mattia Dongili <malattia@linux.it> wrote: > --- a/drivers/platform/x86/sony-laptop.c > +++ b/drivers/platform/x86/sony-laptop.c > @@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct > platform_device *pd) > static int sony_find_snc_handle(int handle) > { > int i; > + > + /* not initialized yet, return early */ > + if (!handles) > + return -1; -1 is -EPERM. That's not the right error code here. Maybe -EINVAL? regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, Apr 02, 2011 at 02:55:38PM +0300, Dan Carpenter wrote: > On 4/2/11, Mattia Dongili <malattia@linux.it> wrote: > > --- a/drivers/platform/x86/sony-laptop.c > > +++ b/drivers/platform/x86/sony-laptop.c > > @@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct > > platform_device *pd) > > static int sony_find_snc_handle(int handle) > > { > > int i; > > + > > + /* not initialized yet, return early */ > > + if (!handles) > > + return -1; > > -1 is -EPERM. That's not the right error code here. Maybe -EINVAL? this error is not propagated to userspace. If necessary I can review all error codes in the sony-laptop internal functions (where -1 is a fairly common return code for error conditions). I remember a discussion on LKML recently about error codes but I'm not sure what the outcome was (if any).
On 4/2/11, Mattia Dongili <malattia@linux.it> wrote: > On Sat, Apr 02, 2011 at 02:55:38PM +0300, Dan Carpenter wrote: >> On 4/2/11, Mattia Dongili <malattia@linux.it> wrote: >> > --- a/drivers/platform/x86/sony-laptop.c >> > +++ b/drivers/platform/x86/sony-laptop.c >> > @@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct >> > platform_device *pd) >> > static int sony_find_snc_handle(int handle) >> > { >> > int i; >> > + >> > + /* not initialized yet, return early */ >> > + if (!handles) >> > + return -1; >> >> -1 is -EPERM. That's not the right error code here. Maybe -EINVAL? > > this error is not propagated to userspace. If necessary I can review all > error codes in the sony-laptop internal functions (where -1 is a fairly > common return code for error conditions). That would be good, but it's going beyond the call of duty. The main thing is to not introduce new slop. > > I remember a discussion on LKML recently about error codes but I'm not > sure what the outcome was (if any). > People sometimes think -1 is a generic error code, but it's not. It has a specific wrong meaning. In fact, -1 is never the right error code. It's should either be -EPERM, or the appropriate error code. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index b2ce172..7082c55 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c @@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct platform_device *pd) static int sony_find_snc_handle(int handle) { int i; + + /* not initialized yet, return early */ + if (!handles) + return -1; + for (i = 0; i < 0x10; i++) { if (handles->cap[i] == handle) { dprintk("found handle 0x%.4x (offset: 0x%.2x)\n",