svn commit: r213662 - in head: sbin/geom/class/concat sbin/geom/class/eli sbin/geom/class/journal sbin/geom/class/mirror sbin/geom/class/part sbin/geom/class/raid3 sbin/geom/class/shsec sbin/geom/c...

Andrey V. Elsukov ae at FreeBSD.org
Sat Oct 9 20:20:28 UTC 2010


Author: ae
Date: Sat Oct  9 20:20:27 2010
New Revision: 213662
URL: http://svn.freebsd.org/changeset/base/213662

Log:
  Replace strlen(_PATH_DEV) with sizeof(_PATH_DEV) - 1.
  
  Suggested by:	kib
  Approved by:	kib (mentor)
  MFC after:	5 days

Modified:
  head/sbin/geom/class/concat/geom_concat.c
  head/sbin/geom/class/eli/geom_eli.c
  head/sbin/geom/class/journal/geom_journal.c
  head/sbin/geom/class/mirror/geom_mirror.c
  head/sbin/geom/class/part/geom_part.c
  head/sbin/geom/class/raid3/geom_raid3.c
  head/sbin/geom/class/shsec/geom_shsec.c
  head/sbin/geom/class/stripe/geom_stripe.c
  head/sbin/geom/class/virstor/geom_virstor.c
  head/sys/geom/part/g_part.c
  head/sys/geom/virstor/g_virstor.c

Modified: head/sbin/geom/class/concat/geom_concat.c
==============================================================================
--- head/sbin/geom/class/concat/geom_concat.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/concat/geom_concat.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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);

Modified: head/sbin/geom/class/eli/geom_eli.c
==============================================================================
--- head/sbin/geom/class/eli/geom_eli.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/eli/geom_eli.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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 _. */

Modified: head/sbin/geom/class/journal/geom_journal.c
==============================================================================
--- head/sbin/geom/class/journal/geom_journal.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/journal/geom_journal.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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);

Modified: head/sbin/geom/class/mirror/geom_mirror.c
==============================================================================
--- head/sbin/geom/class/mirror/geom_mirror.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/mirror/geom_mirror.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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);

Modified: head/sbin/geom/class/part/geom_part.c
==============================================================================
--- head/sbin/geom/class/part/geom_part.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/part/geom_part.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -187,8 +187,8 @@ find_geom(struct gclass *classp, const c
 {
 	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);

Modified: head/sbin/geom/class/raid3/geom_raid3.c
==============================================================================
--- head/sbin/geom/class/raid3/geom_raid3.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/raid3/geom_raid3.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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) {

Modified: head/sbin/geom/class/shsec/geom_shsec.c
==============================================================================
--- head/sbin/geom/class/shsec/geom_shsec.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/shsec/geom_shsec.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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);

Modified: head/sbin/geom/class/stripe/geom_stripe.c
==============================================================================
--- head/sbin/geom/class/stripe/geom_stripe.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/stripe/geom_stripe.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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);

Modified: head/sbin/geom/class/virstor/geom_virstor.c
==============================================================================
--- head/sbin/geom/class/virstor/geom_virstor.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sbin/geom/class/virstor/geom_virstor.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -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);

Modified: head/sys/geom/part/g_part.c
==============================================================================
--- head/sys/geom/part/g_part.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sys/geom/part/g_part.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -305,8 +305,8 @@ g_part_parm_geom(struct gctl_req *req, c
 	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 *re
 	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);

Modified: head/sys/geom/virstor/g_virstor.c
==============================================================================
--- head/sys/geom/virstor/g_virstor.c	Sat Oct  9 20:06:35 2010	(r213661)
+++ head/sys/geom/virstor/g_virstor.c	Sat Oct  9 20:20:27 2010	(r213662)
@@ -316,8 +316,8 @@ virstor_ctl_add(struct gctl_req *req, st
 			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,
 			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++) {


More information about the svn-src-head mailing list