time: Fix signedness bug in sysfs_get_uname() and its callers
authorPatrick Palka <patrick@parcs.ath.cx>
Fri, 11 Oct 2013 17:11:55 +0000 (13:11 -0400)
committerJohn Stultz <john.stultz@linaro.org>
Fri, 18 Oct 2013 23:45:58 +0000 (16:45 -0700)
sysfs_get_uname() is erroneously declared as returning size_t even
though it may return a negative value, specifically -EINVAL.  Its
callers then check whether its return value is less than zero and indeed
that is never the case for size_t.

This patch changes sysfs_get_uname() to return ssize_t and makes sure
its callers use ssize_t accordingly.

Signed-off-by: Patrick Palka <patrick@parcs.ath.cx>
[jstultz: Didn't apply cleanly, as a similar partial fix was also applied
so had to resolve the collisions]
Signed-off-by: John Stultz <john.stultz@linaro.org>
kernel/time/clockevents.c
kernel/time/clocksource.c
kernel/time/tick-internal.h

index 38959c86678987d0306548b73c03b9413c68b321..30554b9fb1f7af1e83bc5f4c31073d566a74c2c3 100644 (file)
@@ -584,7 +584,7 @@ static ssize_t sysfs_unbind_tick_dev(struct device *dev,
                                     const char *buf, size_t count)
 {
        char name[CS_NAME_LEN];
-       size_t ret = sysfs_get_uname(buf, name, count);
+       ssize_t ret = sysfs_get_uname(buf, name, count);
        struct clock_event_device *ce;
 
        if (ret < 0)
index c9317e14aae6cfab03d1c9566a9de3b5cc78a0fa..ba3e502c955a4e00311a15c187072e13b79b91bd 100644 (file)
@@ -909,7 +909,7 @@ sysfs_show_current_clocksources(struct device *dev,
        return count;
 }
 
-size_t sysfs_get_uname(const char *buf, char *dst, size_t cnt)
+ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt)
 {
        size_t ret = cnt;
 
index bc906cad709b1dad2f1e3c75fa4ec32a81dc99a7..18e71f7fbc2a546c7c060abe4ceb1820062dd3a8 100644 (file)
@@ -31,7 +31,7 @@ extern void tick_install_replacement(struct clock_event_device *dev);
 
 extern void clockevents_shutdown(struct clock_event_device *dev);
 
-extern size_t sysfs_get_uname(const char *buf, char *dst, size_t cnt);
+extern ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt);
 
 /*
  * NO_HZ / high resolution timer shared code
This page took 0.027693 seconds and 5 git commands to generate.