From: Tom Tromey Date: Sat, 11 Dec 2021 22:10:14 +0000 (-0700) Subject: Make n_spaces return a const char * X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dde238e063376f96d52ff27f11b31a447ddbdfea;p=binutils-gdb.git Make n_spaces return a const char * n_spaces keeps the spaces in a static buffer. If a caller overwrites these, it may give an incorrect result to a subsequent caller. So, make the return type const to help avoid this outcome. --- diff --git a/gdb/utils.c b/gdb/utils.c index e27a8818b94..ea0f65c10e4 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2303,7 +2303,7 @@ puts_unfiltered (const char *string) /* Return a pointer to N spaces and a null. The pointer is good until the next call to here. */ -char * +const char * n_spaces (int n) { char *t; diff --git a/gdb/utils.h b/gdb/utils.h index 6f3a70213a4..f6fd32faf90 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -473,7 +473,7 @@ extern void print_spaces (int, struct ui_file *); extern void print_spaces_filtered (int, struct ui_file *); -extern char *n_spaces (int); +extern const char *n_spaces (int); extern void fputstr_filtered (const char *str, int quotr, struct ui_file * stream);