Module Name: src
Committed By: rillig
Date: Mon Jun 21 19:59:58 UTC 2021
Modified Files:
src/usr.bin/make: buf.c
Log Message:
make: use simpler upper bound for length in Buf_AddInt
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/make/buf.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/buf.c
diff -u src/usr.bin/make/buf.c:1.51 src/usr.bin/make/buf.c:1.52
--- src/usr.bin/make/buf.c:1.51 Sat Jan 30 21:18:14 2021
+++ src/usr.bin/make/buf.c Mon Jun 21 19:59:58 2021
@@ -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 @@ Buf_AddStr(Buffer *buf, const char *str)
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);