Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Aug 2018 02:09:14 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r337366 - stable/11/usr.bin/sed
Message-ID:  <201808060209.w7629E3M022850@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Mon Aug  6 02:09:14 2018
New Revision: 337366
URL: https://svnweb.freebsd.org/changeset/base/337366

Log:
  MFC r336926:
  sed: unsign some indexes to fix sign-compare warnings.
  
  Hinted by:	OpenBSD (CVS 1.32)

Modified:
  stable/11/usr.bin/sed/extern.h
  stable/11/usr.bin/sed/process.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/sed/extern.h
==============================================================================
--- stable/11/usr.bin/sed/extern.h	Mon Aug  6 01:08:43 2018	(r337365)
+++ stable/11/usr.bin/sed/extern.h	Mon Aug  6 02:09:14 2018	(r337366)
@@ -39,7 +39,7 @@ extern struct s_appends *appends;
 extern regmatch_t *match;
 extern size_t maxnsub;
 extern u_long linenum;
-extern int appendnum;
+extern unsigned int appendnum;
 extern int aflag, eflag, nflag;
 extern const char *fname, *outfname;
 extern FILE *infile, *outfile;

Modified: stable/11/usr.bin/sed/process.c
==============================================================================
--- stable/11/usr.bin/sed/process.c	Mon Aug  6 01:08:43 2018	(r337365)
+++ stable/11/usr.bin/sed/process.c	Mon Aug  6 02:09:14 2018	(r337366)
@@ -77,8 +77,8 @@ static void		 regsub(SPACE *, char *, char *);
 static int		 substitute(struct s_command *);
 
 struct s_appends *appends;	/* Array of pointers to strings to append. */
-static int appendx;		/* Index into appends array. */
-int appendnum;			/* Size of appends array. */
+static unsigned int appendx;	/* Index into appends array. */
+unsigned int appendnum;		/* Size of appends array. */
 
 static int lastaddr;		/* Set by applies if last address of a range. */
 static int sdone;		/* If any substitutes since last line input. */
@@ -382,7 +382,7 @@ substitute(struct s_command *cp)
 	regex_t *re;
 	regoff_t slen;
 	int lastempty, n;
-	size_t le = 0;
+	regoff_t le = 0;
 	char *s;
 
 	s = ps;
@@ -547,13 +547,13 @@ static void
 flush_appends(void)
 {
 	FILE *f;
-	int count, i;
+	unsigned int count, idx;
 	char buf[8 * 1024];
 
-	for (i = 0; i < appendx; i++)
-		switch (appends[i].type) {
+	for (idx = 0; idx < appendx; idx++)
+		switch (appends[idx].type) {
 		case AP_STRING:
-			fwrite(appends[i].s, sizeof(char), appends[i].len,
+			fwrite(appends[idx].s, sizeof(char), appends[idx].len,
 			    outfile);
 			break;
 		case AP_FILE:
@@ -565,7 +565,7 @@ flush_appends(void)
 			 * would be truly bizarre, but possible.  It's probably
 			 * not that big a performance win, anyhow.
 			 */
-			if ((f = fopen(appends[i].s, "r")) == NULL)
+			if ((f = fopen(appends[idx].s, "r")) == NULL)
 				break;
 			while ((count = fread(buf, sizeof(char), sizeof(buf), f)))
 				(void)fwrite(buf, sizeof(char), count, outfile);



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