mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 16:23:04 +00:00
style: prefer snprintf to sprintf
* src/symtab.c (dummy_symbol_get): There's no need for the buffer to be so big and static. Use snprintf for safety.
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
# gnulib modules used by this package.
|
# gnulib modules used by this package.
|
||||||
gnulib_modules='
|
gnulib_modules='
|
||||||
argmatch array-list assert
|
argmatch array-list assert assure
|
||||||
bitsetv
|
bitsetv
|
||||||
calloc-posix close closeout config-h c-strcase
|
calloc-posix close closeout config-h c-strcase
|
||||||
configmake
|
configmake
|
||||||
|
|||||||
1
lib/.gitignore
vendored
1
lib/.gitignore
vendored
@@ -318,3 +318,4 @@
|
|||||||
/rename.c
|
/rename.c
|
||||||
/rmdir.c
|
/rmdir.c
|
||||||
/same-inode.h
|
/same-inode.h
|
||||||
|
/assure.h
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
|
#include <assure.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
|
||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
@@ -865,9 +866,9 @@ dummy_symbol_get (location loc)
|
|||||||
{
|
{
|
||||||
/* Incremented for each generated symbol. */
|
/* Incremented for each generated symbol. */
|
||||||
static int dummy_count = 0;
|
static int dummy_count = 0;
|
||||||
static char buf[256];
|
char buf[32];
|
||||||
|
int len = snprintf (buf, sizeof buf, "$@%d", ++dummy_count);
|
||||||
sprintf (buf, "$@%d", ++dummy_count);
|
assure (len < sizeof buf);
|
||||||
symbol *sym = symbol_get (buf, loc);
|
symbol *sym = symbol_get (buf, loc);
|
||||||
sym->content->class = nterm_sym;
|
sym->content->class = nterm_sym;
|
||||||
sym->content->number = nvars++;
|
sym->content->number = nvars++;
|
||||||
|
|||||||
Reference in New Issue
Block a user