DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses
@ 2020-07-30 15:27 Andy Shevchenko
  2020-07-30 17:34 ` kernel test robot
  2020-07-31  1:32 ` Sven Van Asbroeck
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-07-30 15:27 UTC (permalink / raw)
  To: Sven Van Asbroeck, devel, Greg Kroah-Hartman; +Cc: Andy Shevchenko

Convert to %pM instead of using custom code.

While here, replace one time use structure by buffer on stack.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/staging/fieldbus/anybuss/hms-profinet.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/hms-profinet.c b/drivers/staging/fieldbus/anybuss/hms-profinet.c
index 31c43a0a5776..505480fb281d 100644
--- a/drivers/staging/fieldbus/anybuss/hms-profinet.c
+++ b/drivers/staging/fieldbus/anybuss/hms-profinet.c
@@ -26,10 +26,6 @@
  * exactly as advertised.
  */
 
-struct msg_mac_addr {
-	u8 addr[6];
-};
-
 struct profi_priv {
 	struct fieldbus_dev fbdev;
 	struct anybuss_client *client;
@@ -59,17 +55,13 @@ static int profi_id_get(struct fieldbus_dev *fbdev, char *buf,
 			size_t max_size)
 {
 	struct profi_priv *priv = container_of(fbdev, struct profi_priv, fbdev);
-	struct msg_mac_addr response;
+	u8 mac[ETH_ALEN];
 	int ret;
 
-	ret = anybuss_recv_msg(priv->client, 0x0010, &response,
-			       sizeof(response));
+	ret = anybuss_recv_msg(priv->client, 0x0010, &mac, sizeof(mac));
 	if (ret < 0)
 		return ret;
-	return snprintf(buf, max_size, "%02X:%02X:%02X:%02X:%02X:%02X\n",
-		response.addr[0], response.addr[1],
-		response.addr[2], response.addr[3],
-		response.addr[4], response.addr[5]);
+	return snprintf(buf, max_size, "%pM\n", mac);
 }
 
 static bool profi_enable_get(struct fieldbus_dev *fbdev)
-- 
2.27.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses
  2020-07-30 15:27 [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses Andy Shevchenko
@ 2020-07-30 17:34 ` kernel test robot
  2020-07-31  1:32 ` Sven Van Asbroeck
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-07-30 17:34 UTC (permalink / raw)
  To: Andy Shevchenko, Sven Van Asbroeck, devel, Greg Kroah-Hartman
  Cc: Andy Shevchenko, kbuild-all


[-- Attachment #1: Type: text/plain, Size: 2231 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/staging-fieldbus-Use-pM-format-specifier-for-MAC-addresses/20200730-232835
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git d8a0f85d394a0cc5dec2b290ebcf8ed3cfdc1a70
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/staging/fieldbus/anybuss/hms-profinet.c: In function 'profi_id_get':
>> drivers/staging/fieldbus/anybuss/hms-profinet.c:58:9: error: 'ETH_ALEN' undeclared (first use in this function)
      58 |  u8 mac[ETH_ALEN];
         |         ^~~~~~~~
   drivers/staging/fieldbus/anybuss/hms-profinet.c:58:9: note: each undeclared identifier is reported only once for each function it appears in
   drivers/staging/fieldbus/anybuss/hms-profinet.c:58:5: warning: unused variable 'mac' [-Wunused-variable]
      58 |  u8 mac[ETH_ALEN];
         |     ^~~
>> drivers/staging/fieldbus/anybuss/hms-profinet.c:65:1: warning: control reaches end of non-void function [-Wreturn-type]
      65 | }
         | ^

vim +/ETH_ALEN +58 drivers/staging/fieldbus/anybuss/hms-profinet.c

    53	
    54	static int profi_id_get(struct fieldbus_dev *fbdev, char *buf,
    55				size_t max_size)
    56	{
    57		struct profi_priv *priv = container_of(fbdev, struct profi_priv, fbdev);
  > 58		u8 mac[ETH_ALEN];
    59		int ret;
    60	
    61		ret = anybuss_recv_msg(priv->client, 0x0010, &mac, sizeof(mac));
    62		if (ret < 0)
    63			return ret;
    64		return snprintf(buf, max_size, "%pM\n", mac);
  > 65	}
    66	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 55834 bytes --]

[-- Attachment #3: Type: text/plain, Size: 169 bytes --]

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses
  2020-07-30 15:27 [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses Andy Shevchenko
  2020-07-30 17:34 ` kernel test robot
@ 2020-07-31  1:32 ` Sven Van Asbroeck
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Van Asbroeck @ 2020-07-31  1:32 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: devel, Greg Kroah-Hartman

Hi Andy, thank you for the patch ! See below.

On Thu, Jul 30, 2020 at 11:27 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> -struct msg_mac_addr {
> -       u8 addr[6];
> -};

I would prefer to keep this structure. It's conceptually important,
because it describes the binary layout of a message going to a
peripheral.

Perhaps you can still print using %pM by doing:
printf("%pM\n", response.addr) ?

> @@ -59,17 +55,13 @@ static int profi_id_get(struct fieldbus_dev *fbdev, char *buf,
>                         size_t max_size)
>  {
>         struct profi_priv *priv = container_of(fbdev, struct profi_priv, fbdev);
> -       struct msg_mac_addr response;
> +       u8 mac[ETH_ALEN];
>         int ret;
>
> -       ret = anybuss_recv_msg(priv->client, 0x0010, &response,
> -                              sizeof(response));
> +       ret = anybuss_recv_msg(priv->client, 0x0010, &mac, sizeof(mac));

Should the address-of operator (&) be present in &mac ?
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 15:27 [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses Andy Shevchenko
2020-07-30 17:34 ` kernel test robot
2020-07-31  1:32 ` Sven Van Asbroeck

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git