From 00b85fab9f6d699fefe2560d9cf990fdb126e354 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 19 Jul 2021 16:36:14 +0800 Subject: [PATCH] Fix warning triggered by enforcing const on function names table. --- eval.c | 6 +++--- eval.h | 2 +- exec.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/eval.c b/eval.c index 9b17ddd..5b06a06 100644 --- a/eval.c +++ b/eval.c @@ -316,12 +316,12 @@ void varinit(void) * * @fname: name of function to evaluate. */ -static char *gtfun( char *fname) { +static const char *gtfun( char *fname) { unsigned fnum ; /* index to function to eval */ char *arg1 ; /* value of first argument */ char *arg2 ; /* value of second argument */ char *arg3 ; /* last argument */ - char *retstr ; /* return value */ + const char *retstr ; /* return value */ int low, high ; /* binary search indexes */ /* look the function up in the function table */ @@ -1206,7 +1206,7 @@ int is_it_cmd( char *token) { * * char *token; token to evaluate */ -char *getval(char *token) +const char *getval(char *token) { int status; /* error return */ struct buffer *bp; /* temp buffer pointer */ diff --git a/eval.h b/eval.h index 701c2b8..e6fac0d 100644 --- a/eval.h +++ b/eval.h @@ -19,7 +19,7 @@ int is_it_cmd( char *token) ; void varinit( void) ; int setvar( int f, int n) ; -char *getval( char *token) ; +const char *getval( char *token) ; int stol( char *val) ; char *mklower( char *str) ; diff --git a/exec.c b/exec.c index bef62b7..db51781 100644 --- a/exec.c +++ b/exec.c @@ -348,7 +348,6 @@ boolean gettokval( char *tok, int size) { char *getnewtokval( void) { char *tmpbuf ; - char *tmpval ; char *valbuf ; /* grab token and advance past */ @@ -357,7 +356,7 @@ char *getnewtokval( void) { return NULL ; /* evaluate it */ - tmpval = getval( tmpbuf) ; + const char *tmpval = getval( tmpbuf) ; valbuf = malloc( strlen( tmpval) + 1 ) ; if( valbuf != NULL) strcpy( valbuf, tmpval) ;