Skip to contentSkip to conversation

IB/srp: replace custom implementation of hex2bin()

PATCH Applied Andy Shevchenko 3 participants 3 messages Dec 11, 2017 1 message not in the archive

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

PATCH 1/1 IB/srp: replace custom implementation of hex2bin()

From: Andy Shevchenko <[email protected]>

There is no need to have a duplication of the generic library, i.e. hex2bin().

Replace the open coded variant.

---
 drivers/infiniband/ulp/srp/ib_srp.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +3 -10
index 972d4b3c5223..62d88212c1b0 100644
@@ -3110,7 +3110,6 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
 {
 	char *options, *sep_opt;
 	char *p;
-	char dgid[3];
 	substring_t args[MAX_OPT_ARGS];
 	int opt_mask = 0;
 	int token;
@@ -3162,16 +3161,10 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
 				goto out;
 			}
 
-			for (i = 0; i < 16; ++i) {
-				strlcpy(dgid, p + i * 2, sizeof(dgid));
-				if (sscanf(dgid, "%hhx",
-					   &target->orig_dgid.raw[i]) < 1) {
-					ret = -EINVAL;
-					kfree(p);
-					goto out;
-				}
-			}
+			ret = hex2bin(target->orig_dgid.raw, p, 16);
 			kfree(p);
+			if (ret < 0)
+				goto out;
 			break;
 
 		case SRP_OPT_PKEY:
Signature · 6 lines
2.15.0

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20171211130505.34631-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]

#2 lore raw

T24gTW9uLCAyMDE3LTEyLTExIGF0IDE1OjA1ICswMjAwLCBBbmR5IFNoZXZjaGVua28gd3JvdGU6 DQo+IEZyb206IEFuZHkgU2hldmNoZW5rbyA8YW5keS5zaGV2Y2hlbmtvQGdtYWlsLmNvbT4NCj4g DQo+IFRoZXJlIGlzIG5vIG5lZWQgdG8gaGF2ZSBhIGR1cGxpY2F0aW9uIG9mIHRoZSBnZW5lcmlj IGxpYnJhcnksIGkuZS4NCj4gaGV4MmJpbigpLg0KPiANCj4gUmVwbGFjZSB0aGUgb3BlbiBjb2Rl ZCB2YXJpYW50Lg0KDQpBY2tlZC1ieTogQmFydCBWYW4gQXNzY2hlIDxiYXJ0LnZhbmFzc2NoZUB3 ZGMuY29tPg0KDQo=
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to a message not in the archive
Quoted 11 lines · Andy Shevchenko

From: Andy Shevchenko <[email protected]>

There is no need to have a duplication of the generic library, i.e. hex2bin().

Replace the open coded variant.

 drivers/infiniband/ulp/srp/ib_srp.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

applied to for-next, thanks

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html