Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Apr 2016 06:11:25 +0000 (UTC)
From:      Marcelo Araujo <araujo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298390 - head/sbin/fdisk_pc98
Message-ID:  <201604210611.u3L6BPEv050502@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: araujo
Date: Thu Apr 21 06:11:24 2016
New Revision: 298390
URL: https://svnweb.freebsd.org/changeset/base/298390

Log:
  Simplify the get_type() function.
  
  Submitted by:	bde
  Discussed with:	bde, jhb and pfg
  MFC after:	2 weeks.

Modified:
  head/sbin/fdisk_pc98/fdisk.c

Modified: head/sbin/fdisk_pc98/fdisk.c
==============================================================================
--- head/sbin/fdisk_pc98/fdisk.c	Thu Apr 21 05:47:47 2016	(r298389)
+++ head/sbin/fdisk_pc98/fdisk.c	Thu Apr 21 06:11:24 2016	(r298390)
@@ -854,17 +854,11 @@ string(const char *str, char **ans)
 static const char *
 get_type(int type)
 {
-	int	numentries = nitems(part_types);
-	int	counter = 0;
-	struct	part_type *ptr = part_types;
+	size_t i;
 
-
-	while(counter < numentries) {
-		if(ptr->type == (type & 0x7f))
-			return(ptr->name);
-		ptr++;
-		counter++;
-	}
+	for (i = 0; i < nitems(part_types); i++)
+		if(part_types[i].type == (type & 0x7f))
+			return(part_types[i].name);
 	return("unknown");
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604210611.u3L6BPEv050502>