Changes to use attributes for noreturn and printf-like functions

This commit is contained in:
Landon Curt Noll
2022-01-22 02:48:50 -08:00
parent 3f177f2d81
commit 1658343227
5 changed files with 9 additions and 13 deletions

7
decl.h
View File

@@ -94,12 +94,5 @@
#endif
/* Perform printf-style argument type checking for known compilers */
#ifdef __GNUC__
# define PRINTF_FORMAT(fmt_idx, arg_idx) __attribute__ \
((format (printf, fmt_idx, arg_idx)))
#else
# define PRINTF_FORMAT(fmt_idx, arg_idx)
#endif
#endif /* !INCLUDE_DECL_H */

2
hist.c
View File

@@ -137,7 +137,7 @@ S_FUNC void uppercase_word(void);
S_FUNC void lowercase_word(void);
S_FUNC void ignore_char(void);
S_FUNC void arrow_key(void);
S_FUNC void quit_calc(void);
S_FUNC void quit_calc(void) __attribute__((noreturn));
STATIC FUNC funcs[] =

View File

@@ -175,8 +175,8 @@ E_FUNC void inittokens(void);
E_FUNC int tokenmode(int flag);
E_FUNC int gettoken(void);
E_FUNC void rescantoken(void);
E_FUNC void scanerror(int, char *, ...) PRINTF_FORMAT(2, 3);
E_FUNC void warning(char *, ...) PRINTF_FORMAT(1, 2);
E_FUNC void scanerror(int, char *, ...) __attribute__((format(printf, 2, 3)));
E_FUNC void warning(char *, ...) __attribute__((format(printf, 1, 2)));
#endif /* !INCLUDE_TOKEN_H */

View File

@@ -1411,7 +1411,7 @@ zlog10(ZVALUE z, BOOL *was_10_power)
do {
rel = zrel(*zp, z);
if (rel == 0) {
/* quick exit - we match a tenpower entry */
/* quick return - we match a tenpower entry */
if (was_10_power != NULL) {
*was_10_power = TRUE;
}

View File

@@ -41,6 +41,7 @@
# include "longbits.h"
# include "byteswap.h"
# include "have_stdlib.h"
# include "attribute.h"
#else
# include <calc/decl.h>
# include <calc/alloc.h>
@@ -48,6 +49,7 @@
# include <calc/longbits.h>
# include <calc/byteswap.h>
# include <calc/have_stdlib.h>
# include <calc/attribute.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
@@ -625,13 +627,14 @@ E_FUNC char *math_getdivertedio(void);
E_FUNC int math_setmode(int mode);
E_FUNC int math_setmode2(int mode);
E_FUNC LEN math_setdigits(LEN digits);
E_FUNC void math_fmt(char *, ...) PRINTF_FORMAT(1, 2);
E_FUNC void math_fmt(char *, ...) __attribute__((format(printf, 1, 2)));
/*
* The error routine.
*/
E_FUNC void math_error(char *, ...) PRINTF_FORMAT(1, 2);
E_FUNC void math_error(char *, ...) \
__attribute__((format(printf, 1, 2))) __attribute__((noreturn));
/*