Replace strlen(_PATH_DEV) with sizeof(_PATH_DEV) - 1.
Suggested by: kib Approved by: kib (mentor) MFC after: 5 days
This commit is contained in:
parent
0061fd332c
commit
ab9dd3ef58
@ -153,8 +153,8 @@ concat_label(struct gctl_req *req)
|
||||
if (!hardcode)
|
||||
bzero(md.md_provider, sizeof(md.md_provider));
|
||||
else {
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
name += strlen(_PATH_DEV);
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
name += sizeof(_PATH_DEV) - 1;
|
||||
strlcpy(md.md_provider, name, sizeof(md.md_provider));
|
||||
}
|
||||
md.md_provsize = g_get_mediasize(name);
|
||||
|
@ -776,8 +776,8 @@ eli_init(struct gctl_req *req)
|
||||
const char *p = prov;
|
||||
unsigned int i;
|
||||
|
||||
if (strncmp(p, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
p += strlen(_PATH_DEV);
|
||||
if (strncmp(p, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
p += sizeof(_PATH_DEV) - 1;
|
||||
snprintf(backfile, sizeof(backfile), "%s%s.eli",
|
||||
GELI_BACKUP_DIR, p);
|
||||
/* Replace all / with _. */
|
||||
|
@ -269,8 +269,8 @@ journal_label(struct gctl_req *req)
|
||||
if (!hardcode)
|
||||
bzero(md.md_provider, sizeof(md.md_provider));
|
||||
else {
|
||||
if (strncmp(str, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
str += strlen(_PATH_DEV);
|
||||
if (strncmp(str, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
str += sizeof(_PATH_DEV) - 1;
|
||||
strlcpy(md.md_provider, str, sizeof(md.md_provider));
|
||||
}
|
||||
journal_metadata_encode(&md, sector);
|
||||
|
@ -247,8 +247,8 @@ mirror_label(struct gctl_req *req)
|
||||
if (!hardcode)
|
||||
bzero(md.md_provider, sizeof(md.md_provider));
|
||||
else {
|
||||
if (strncmp(str, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
str += strlen(_PATH_DEV);
|
||||
if (strncmp(str, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
str += sizeof(_PATH_DEV) - 1;
|
||||
strlcpy(md.md_provider, str, sizeof(md.md_provider));
|
||||
}
|
||||
mirror_metadata_encode(&md, sector);
|
||||
|
@ -187,8 +187,8 @@ find_geom(struct gclass *classp, const char *name)
|
||||
{
|
||||
struct ggeom *gp;
|
||||
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
name += strlen(_PATH_DEV);
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
name += sizeof(_PATH_DEV) - 1;
|
||||
LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
|
||||
if (strcmp(gp->lg_name, name) == 0)
|
||||
return (gp);
|
||||
|
@ -244,8 +244,8 @@ raid3_label(struct gctl_req *req)
|
||||
if (!hardcode)
|
||||
bzero(md.md_provider, sizeof(md.md_provider));
|
||||
else {
|
||||
if (strncmp(str, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
str += strlen(_PATH_DEV);
|
||||
if (strncmp(str, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
str += sizeof(_PATH_DEV) - 1;
|
||||
strlcpy(md.md_provider, str, sizeof(md.md_provider));
|
||||
}
|
||||
if (verify && md.md_no == md.md_all - 1) {
|
||||
|
@ -172,8 +172,8 @@ shsec_label(struct gctl_req *req)
|
||||
if (!hardcode)
|
||||
bzero(md.md_provider, sizeof(md.md_provider));
|
||||
else {
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
name += strlen(_PATH_DEV);
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
name += sizeof(_PATH_DEV) - 1;
|
||||
strlcpy(md.md_provider, name, sizeof(md.md_provider));
|
||||
}
|
||||
shsec_metadata_encode(&md, sector);
|
||||
|
@ -197,8 +197,8 @@ stripe_label(struct gctl_req *req)
|
||||
if (!hardcode)
|
||||
bzero(md.md_provider, sizeof(md.md_provider));
|
||||
else {
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
name += strlen(_PATH_DEV);
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
name += sizeof(_PATH_DEV) - 1;
|
||||
strlcpy(md.md_provider, name, sizeof(md.md_provider));
|
||||
}
|
||||
stripe_metadata_encode(&md, sector);
|
||||
|
@ -144,7 +144,7 @@ static void
|
||||
pathgen(const char *name, char *path, size_t size)
|
||||
{
|
||||
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) != 0)
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) != 0)
|
||||
snprintf(path, size, "%s%s", _PATH_DEV, name);
|
||||
else
|
||||
strlcpy(path, name, size);
|
||||
@ -375,7 +375,7 @@ virstor_label(struct gctl_req *req)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
fd = open(name, O_RDWR);
|
||||
else {
|
||||
sprintf(param, "%s%s", _PATH_DEV, name);
|
||||
@ -453,8 +453,8 @@ virstor_label(struct gctl_req *req)
|
||||
bzero(md.provider, sizeof(md.provider));
|
||||
else {
|
||||
/* convert "/dev/something" to "something" */
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0) {
|
||||
strlcpy(md.provider, name + strlen(_PATH_DEV),
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) {
|
||||
strlcpy(md.provider, name + sizeof(_PATH_DEV) - 1,
|
||||
sizeof(md.provider));
|
||||
} else
|
||||
strlcpy(md.provider, name, sizeof(md.provider));
|
||||
@ -509,7 +509,7 @@ virstor_clear(struct gctl_req *req)
|
||||
"Not fully done (can't clear metadata).");
|
||||
continue;
|
||||
}
|
||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
fd = open(name, O_RDWR);
|
||||
else {
|
||||
sprintf(param, "%s%s", _PATH_DEV, name);
|
||||
|
@ -305,8 +305,8 @@ g_part_parm_geom(struct gctl_req *req, const char *name, struct g_geom **v)
|
||||
gname = gctl_get_asciiparam(req, name);
|
||||
if (gname == NULL)
|
||||
return (ENOATTR);
|
||||
if (strncmp(gname, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
gname += strlen(_PATH_DEV);
|
||||
if (strncmp(gname, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
gname += sizeof(_PATH_DEV) - 1;
|
||||
LIST_FOREACH(gp, &g_part_class.geom, geom) {
|
||||
if (!strcmp(gname, gp->name))
|
||||
break;
|
||||
@ -329,8 +329,8 @@ g_part_parm_provider(struct gctl_req *req, const char *name,
|
||||
pname = gctl_get_asciiparam(req, name);
|
||||
if (pname == NULL)
|
||||
return (ENOATTR);
|
||||
if (strncmp(pname, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
pname += strlen(_PATH_DEV);
|
||||
if (strncmp(pname, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
pname += sizeof(_PATH_DEV) - 1;
|
||||
pp = g_provider_by_name(pname);
|
||||
if (pp == NULL) {
|
||||
gctl_error(req, "%d %s '%s'", EINVAL, name, pname);
|
||||
|
@ -316,8 +316,8 @@ virstor_ctl_add(struct gctl_req *req, struct g_class *cp)
|
||||
g_topology_unlock();
|
||||
return;
|
||||
}
|
||||
if (strncmp(prov_name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
prov_name += strlen(_PATH_DEV);
|
||||
if (strncmp(prov_name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
prov_name += sizeof(_PATH_DEV) - 1;
|
||||
|
||||
pp = g_provider_by_name(prov_name);
|
||||
if (pp == NULL) {
|
||||
@ -574,8 +574,8 @@ virstor_ctl_remove(struct gctl_req *req, struct g_class *cp)
|
||||
gctl_error(req, "Error fetching argument '%s'", param);
|
||||
return;
|
||||
}
|
||||
if (strncmp(prov_name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
||||
prov_name += strlen(_PATH_DEV);
|
||||
if (strncmp(prov_name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||
prov_name += sizeof(_PATH_DEV) - 1;
|
||||
|
||||
found = -1;
|
||||
for (j = 0; j < sc->n_components; j++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user