Module Name:    src
Committed By:   rillig
Date:           Mon Aug 10 19:20:34 UTC 2020

Modified Files:
        src/usr.bin/make: str.c

Log Message:
make(1): fix integer type in str_concat


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/make/str.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.56 src/usr.bin/make/str.c:1.57
--- src/usr.bin/make/str.c:1.56	Sun Aug  9 10:24:02 2020
+++ src/usr.bin/make/str.c	Mon Aug 10 19:20:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.56 2020/08/09 10:24:02 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.57 2020/08/10 19:20:33 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.56 2020/08/09 10:24:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.57 2020/08/10 19:20:33 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char     sccsid[] = "@(#)str.c	5.8 (Berkeley) 6/1/90";
 #else
-__RCSID("$NetBSD: str.c,v 1.56 2020/08/09 10:24:02 rillig Exp $");
+__RCSID("$NetBSD: str.c,v 1.57 2020/08/10 19:20:33 rillig Exp $");
 #endif
 #endif				/* not lint */
 #endif
@@ -85,8 +85,7 @@ __RCSID("$NetBSD: str.c,v 1.56 2020/08/0
 
 /*-
  * str_concat --
- *	concatenate the two strings, inserting a space or slash between them,
- *	freeing them if requested.
+ *	concatenate the two strings, inserting a space or slash between them.
  *
  * returns --
  *	the resulting string in allocated space.
@@ -94,15 +93,9 @@ __RCSID("$NetBSD: str.c,v 1.56 2020/08/0
 char *
 str_concat(const char *s1, const char *s2, int flags)
 {
-	int len1, len2;
-	char *result;
-
-	/* get the length of both strings */
-	len1 = strlen(s1);
-	len2 = strlen(s2);
-
-	/* allocate length plus separator plus EOS */
-	result = bmake_malloc((unsigned int)(len1 + len2 + 2));
+	size_t len1 = strlen(s1);
+	size_t len2 = strlen(s2);
+	char *result = bmake_malloc(len1 + 1 + len2 + 1);
 
 	/* copy first string into place */
 	memcpy(result, s1, len1);

Reply via email to