netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dccp: Fix compile warning in probe code.
@ 2011-12-01 19:46 David Miller
  2011-12-03  2:52 ` Gerrit Renker
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2011-12-01 19:46 UTC (permalink / raw)
  To: netdev; +Cc: gerrit, gerrit


Commit 1386be55e32a3c5d8ef4a2b243c530a7b664c02c ("dccp: fix
auto-loading of dccp(_probe)") fixed a bug but created a new
compiler warning:

net/dccp/probe.c: In function ‘dccpprobe_init’:
net/dccp/probe.c:166:2: warning: the omitted middle operand in ?: will always be ‘true’, suggest explicit middle operand [-Wparentheses]

try_then_request_module() is built for situations where the
"existence" test is some lookup function that returns a non-NULL
object on success, and with a reference count of some kind held.

Here we're looking for a success return of zero from the jprobe
registry.

Instead of fighting the way try_then_request_module() works, simply
open code what we want to happen in a local helper function.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/dccp/probe.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 33d0e62..0a8d6eb 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -152,6 +152,17 @@ static const struct file_operations dccpprobe_fops = {
 	.llseek  = noop_llseek,
 };
 
+static __init int setup_jprobe(void)
+{
+	int ret = register_jprobe(&dccp_send_probe);
+
+	if (ret) {
+		request_module("dccp");
+		ret = register_jprobe(&dccp_send_probe);
+	}
+	return ret;
+}
+
 static __init int dccpprobe_init(void)
 {
 	int ret = -ENOMEM;
@@ -163,8 +174,7 @@ static __init int dccpprobe_init(void)
 	if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops))
 		goto err0;
 
-	try_then_request_module((ret = register_jprobe(&dccp_send_probe)) == 0,
-				"dccp");
+	ret = setup_jprobe();
 	if (ret)
 		goto err1;
 
-- 
1.7.7.3


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

* Re: [PATCH] dccp: Fix compile warning in probe code.
  2011-12-01 19:46 [PATCH] dccp: Fix compile warning in probe code David Miller
@ 2011-12-03  2:52 ` Gerrit Renker
  0 siblings, 0 replies; 2+ messages in thread
From: Gerrit Renker @ 2011-12-03  2:52 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Acked-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>

I have compiled and tested this and added the patch to the test tree.
Thanks for the improvement.

| --- a/net/dccp/probe.c
| +++ b/net/dccp/probe.c
| @@ -152,6 +152,17 @@ static const struct file_operations dccpprobe_fops = {
|  	.llseek  = noop_llseek,
|  };
|  
| +static __init int setup_jprobe(void)
| +{
| +	int ret = register_jprobe(&dccp_send_probe);
| +
| +	if (ret) {
| +		request_module("dccp");
| +		ret = register_jprobe(&dccp_send_probe);
| +	}
| +	return ret;
| +}
| +
|  static __init int dccpprobe_init(void)
|  {
|  	int ret = -ENOMEM;
| @@ -163,8 +174,7 @@ static __init int dccpprobe_init(void)
|  	if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops))
|  		goto err0;
|  
| -	try_then_request_module((ret = register_jprobe(&dccp_send_probe)) == 0,
| -				"dccp");
| +	ret = setup_jprobe();
|  	if (ret)
|  		goto err1;
|  
| -- 
| 1.7.7.3
| 
| 

-- 

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

end of thread, other threads:[~2011-12-03  2:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-01 19:46 [PATCH] dccp: Fix compile warning in probe code David Miller
2011-12-03  2:52 ` Gerrit Renker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).