lkml.org 
[lkml]   [2014]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] net-sysfs: Report link speed as signed integer
Mon, Jun 02, 2014 at 04:25:15PM CEST, mprivozn@redhat.com wrote:
>The link speed is available at /sys/class/net/$nic/speed.
>However, the speed is printed in unsigned integer format. This
>makes userspace applications read an incorrect value (which
>moreover changes through several architectures) while in fact
>'-1' should be reported.
>
>Before the change:
> # cat /sys/class/net/eth0/speed
> 4294967295
>
>After the change:
> # cat /sys/class/net/eth0/speed
> -1
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> net/core/net-sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>index 1cac29e..99afdea 100644
>--- a/net/core/net-sysfs.c
>+++ b/net/core/net-sysfs.c
>@@ -173,7 +173,7 @@ static ssize_t speed_show(struct device *dev,
> if (netif_running(netdev)) {
> struct ethtool_cmd cmd;
> if (!__ethtool_get_settings(netdev, &cmd))
>- ret = sprintf(buf, fmt_udec, ethtool_cmd_speed(&cmd));
>+ ret = sprintf(buf, fmt_dec, ethtool_cmd_speed(&cmd));

I wonder why this should be signed. What -1 means? What driver reports
this?

> }
> rtnl_unlock();
> return ret;
>--
>2.0.0
>


\
 
 \ /
  Last update: 2014-06-02 17:21    [W:0.709 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site