lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1412015484.4302.51.camel@joe-AO725>
Date:	Mon, 29 Sep 2014 11:31:24 -0700
From:	Joe Perches <joe@...ches.com>
To:	Thibaut Robert <thibaut.robert@...il.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Michalis Pappas <mpappas@...tmail.fm>,
	Davide Gianforte <davide@...gisdave.org>,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Staging: gdm72xx: fix coding style

On Mon, 2014-09-29 at 20:15 +0200, Thibaut Robert wrote:
> This patch remove a checkstyle warning in netlink_k.c.
> Note: This is my homework of the day.

The "Note: " line isn't useful for a commit message.
Neither is the checkpatch warning bit.

Maybe the commit message could be something like:
"Remove unnecessary else after return".

> diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c
[]
> @@ -147,12 +147,11 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
>  
>  	if (!ret) {
>  		return len;
> -	} else {
> -		if (ret != -ESRCH) {
> -			pr_err("netlink_broadcast g=%d, t=%d, l=%d, r=%d\n",
> -			       group, type, len, ret);
> -		}
> -		ret = 0;
>  	}
> -	return ret;
> +
> +	if (ret != -ESRCH) {
> +		pr_err("netlink_broadcast g=%d, t=%d, l=%d, r=%d\n",
> +		       group, type, len, ret);
> +	}

OK, but you don't need the braces around the pr_err.

My preference is to also fix the typo in the function
and would be something like:
---
 drivers/staging/gdm72xx/netlink_k.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c
index 9bf00e6..43d2a49 100644
--- a/drivers/staging/gdm72xx/netlink_k.c
+++ b/drivers/staging/gdm72xx/netlink_k.c
@@ -120,9 +120,9 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
 	struct nlmsghdr *nlh;
 	int ret = 0;
 
-	if (group > ND_MAX_GROUP) {
-		pr_err("Group %d is invalied.\n", group);
-		pr_err("Valid group is 0 ~ %d.\n", ND_MAX_GROUP);
+	if (group < 0 || group > ND_MAX_GROUP) {
+		pr_err("Invalid group %d (valid groups are 0 to %d)\n",
+		       group, ND_MAX_GROUP);
 		return -EINVAL;
 	}
 
@@ -144,15 +144,12 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
 	NETLINK_CB(skb).dst_group = 0;
 
 	ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC);
-
-	if (!ret) {
+	if (!ret)
 		return len;
-	} else {
-		if (ret != -ESRCH) {
-			pr_err("netlink_broadcast g=%d, t=%d, l=%d, r=%d\n",
-			       group, type, len, ret);
-		}
-		ret = 0;
-	}
-	return ret;
+
+	if (ret != -ESRCH)
+		pr_err("netlink_broadcast g=%d, t=%d, l=%d, r=%d\n",
+		       group, type, len, ret);
+
+	return 0;
 }



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ