Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: use simpler upper bound for length in Buf...



details:   https://anonhg.NetBSD.org/src/rev/d0f8e3ab0bb8
branches:  trunk
changeset: 1021875:d0f8e3ab0bb8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jun 21 19:59:58 2021 +0000

description:
make: use simpler upper bound for length in Buf_AddInt

No functional change.

diffstat:

 usr.bin/make/buf.c |  13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)

diffs (34 lines):

diff -r d8dcdcd4f2a6 -r d0f8e3ab0bb8 usr.bin/make/buf.c
--- a/usr.bin/make/buf.c        Mon Jun 21 19:52:17 2021 +0000
+++ b/usr.bin/make/buf.c        Mon Jun 21 19:59:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.c,v 1.51 2021/01/30 21:18:14 rillig Exp $  */
+/*     $NetBSD: buf.c,v 1.52 2021/06/21 19:59:58 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -75,7 +75,7 @@
 #include "make.h"
 
 /*     "@(#)buf.c      8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: buf.c,v 1.51 2021/01/30 21:18:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: buf.c,v 1.52 2021/06/21 19:59:58 rillig Exp $");
 
 /* Make space in the buffer for adding at least 16 more bytes. */
 void
@@ -122,14 +122,7 @@
 void
 Buf_AddInt(Buffer *buf, int n)
 {
-       enum {
-               bits = sizeof(int) * CHAR_BIT,
-               max_octal_digits = (bits + 2) / 3,
-               max_decimal_digits = /* at most */ max_octal_digits,
-               max_sign_chars = 1,
-               str_size = max_sign_chars + max_decimal_digits + 1
-       };
-       char str[str_size];
+       char str[sizeof(int) * CHAR_BIT + 1];
 
        size_t len = (size_t)snprintf(str, sizeof str, "%d", n);
        Buf_AddBytes(buf, str, len);



Home | Main Index | Thread Index | Old Index