Module Name: src
Committed By: joerg
Date: Fri May 15 18:28:36 UTC 2015
Modified Files:
src/sys/dev/iscsi: iscsi_main.c
Log Message:
Don't pre-compute string sizes in a relatively cold function.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/iscsi/iscsi_main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/iscsi/iscsi_main.c
diff -u src/sys/dev/iscsi/iscsi_main.c:1.13 src/sys/dev/iscsi/iscsi_main.c:1.14
--- src/sys/dev/iscsi/iscsi_main.c:1.13 Fri May 15 16:24:30 2015
+++ src/sys/dev/iscsi/iscsi_main.c Fri May 15 18:28:36 2015
@@ -228,28 +228,19 @@ iscsi_detach(device_t self, int flags)
typedef struct quirktab_t {
const char *tgt;
- size_t tgtlen;
const char *iqn;
- size_t iqnlen;
uint32_t quirks;
} quirktab_t;
static const quirktab_t quirktab[] = {
- { "StarWind", 8,
- "iqn.2008-08.com.starwindsoftware", 32,
- PQUIRK_ONLYBIG },
- { "UNH", 3,
- "iqn.2002-10.edu.unh.", 20,
- PQUIRK_NOBIGMODESENSE |
- PQUIRK_NOMODESENSE |
- PQUIRK_NOSYNCCACHE },
- { "NetBSD", 6,
- "iqn.1994-04.org.netbsd.", 23,
- 0 },
- { "Unknown", 7,
- "unknown", 7,
- 0 },
- { NULL, 0, NULL, 0, 0 }
+ { "StarWind", "iqn.2008-08.com.starwindsoftware", PQUIRK_ONLYBIG },
+ { "UNH", "iqn.2002-10.edu.unh.",
+ PQUIRK_NOBIGMODESENSE |
+ PQUIRK_NOMODESENSE |
+ PQUIRK_NOSYNCCACHE },
+ { "NetBSD", "iqn.1994-04.org.netbsd.", 0 },
+ { "Unknown", "unknown", 0 },
+ { NULL, NULL, 0 }
};
/* loop through the quirktab looking for a match on target name */
@@ -257,14 +248,17 @@ static const quirktab_t *
getquirks(const char *iqn)
{
const quirktab_t *qp;
+ size_t iqnlen, quirklen;
- if (iqn == NULL) {
+ if (iqn == NULL)
iqn = "unknown";
- }
+ iqnlen = strlen(iqn);
for (qp = quirktab ; qp->iqn ; qp++) {
- if (strncmp(qp->iqn, iqn, qp->iqnlen) == 0) {
+ quirklen = strlen(qp->iqn);
+ if (quirklen > iqnlen)
+ continue;
+ if (memcmp(qp->iqn, iqn, quirklen) == 0)
break;
- }
}
return qp;
}