Skip to contentSkip to conversation

Use formatting of module name in SUNRPC

PATCH In review Alex Riesen 3 participants 3 messages May 27, 2009 – Jun 23, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use formatting of module name in SUNRPC

Besides, the old code caused gcc-4.3.3 to produce the warning:
"format not a string literal and no format arguments"

---
 net/sunrpc/xprt.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
net/sunrpc/xprt.c +1 -4
index 06ca058..82f62fd 100644
@@ -162,7 +162,6 @@ EXPORT_SYMBOL_GPL(xprt_unregister_transport);
 int xprt_load_transport(const char *transport_name)
 {
 	struct xprt_class *t;
-	char module_name[sizeof t->name + 5];
 	int result;
 
 	result = 0;
@@ -174,9 +173,7 @@ int xprt_load_transport(const char *transport_name)
 		}
 	}
 	spin_unlock(&xprt_list_lock);
-	strcpy(module_name, "xprt");
-	strncat(module_name, transport_name, sizeof t->name);
-	result = request_module(module_name);
+	result = request_module("xprt%s", transport_name);
 out:
 	return result;
 }
Signature · 1 line
1.6.3.1.197.g41544
#1 lore raw
Quoted 21 lines · Alex Riesen

Besides, the old code caused gcc-4.3.3 to produce the warning:
"format not a string literal and no format arguments"

---
  net/sunrpc/xprt.c |    5 +----
  1 files changed, 1 insertions(+), 4 deletions(-)
net/sunrpc/xprt.c +0 -1
index 06ca058..82f62fd 100644
@@ -162,7 +162,6 @@ EXPORT_SYMBOL_GPL(xprt_unregister_transport);
  int xprt_load_transport(const char *transport_name)
  {
  	struct xprt_class *t;
-	char module_name[sizeof t->name + 5];
  	int result;
 
  	result = 0;

net/sunrpc/xprt.c int xprt_load_transport(const char *transport_name) · line 179

Quoted 10 lines
net/sunrpc/xprt.c +1 -3
@@ -174,9 +173,7 @@ int xprt_load_transport(const char *transport_name)
  		}
  	}
  	spin_unlock(&xprt_list_lock);
-	strcpy(module_name, "xprt");
-	strncat(module_name, transport_name, sizeof t->name);
-	result = request_module(module_name);
+	result = request_module("xprt%s", transport_name);
  out:
  	return result;
  }

Never saw the warning while compiling, but I'm fine with the proposed change, besides, it's cleaner. Ack.

Tom.

#2 lore raw
In reply to Alex Riesen
Quoted 21 lines · Alex Riesen

Besides, the old code caused gcc-4.3.3 to produce the warning:
"format not a string literal and no format arguments"

---
 net/sunrpc/xprt.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
net/sunrpc/xprt.c +0 -1
index 06ca058..82f62fd 100644
@@ -162,7 +162,6 @@ EXPORT_SYMBOL_GPL(xprt_unregister_transport);
 int xprt_load_transport(const char *transport_name)
 {
 	struct xprt_class *t;
-	char module_name[sizeof t->name + 5];
 	int result;
 
 	result = 0;

net/sunrpc/xprt.c int xprt_load_transport(const char *transport_name) · line 179

Quoted 10 lines
net/sunrpc/xprt.c +1 -3
@@ -174,9 +173,7 @@ int xprt_load_transport(const char *transport_name)
 		}
 	}
 	spin_unlock(&xprt_list_lock);
-	strcpy(module_name, "xprt");
-	strncat(module_name, transport_name, sizeof t->name);
-	result = request_module(module_name);
+	result = request_module("xprt%s", transport_name);
 out:
 	return result;
 }

Trond, are you planning to take this one through your tree?

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs