diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-07-29 13:55:09 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-07-29 13:55:09 -0700 |
commit | 92c2f4a177cdb77aab262f71c87257e840f4a43c (patch) | |
tree | 6913e31ecc7c02d250254249cf866eae43ed0dc2 /src | |
parent | 4215394e00c9c6e9d36293112f30b1ed45654b71 (diff) | |
download | vyatta-cfg-92c2f4a177cdb77aab262f71c87257e840f4a43c.tar.gz vyatta-cfg-92c2f4a177cdb77aab262f71c87257e840f4a43c.zip |
Add annotation to cli functions
Use gcc annotations for noreturn and printf like formats
Diffstat (limited to 'src')
-rw-r--r-- | src/cli_new.c | 15 | ||||
-rw-r--r-- | src/cli_val.h | 27 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/cli_new.c b/src/cli_new.c index 34f8af0..33430bd 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -110,7 +110,7 @@ char *cli_operation_name = NULL; printf("echo \"bla-bla-bla%s\";", sptr) note very important ';' as the end of the format */ -void bye(char *msg, ...) +void bye(const char *msg, ...) { va_list ap; @@ -135,7 +135,7 @@ void bye(char *msg, ...) which are executed as eval `command` in order to modify BASH env */ -void print_msg(char *msg, ...) +void print_msg(const char *msg, ...) { va_list ap; @@ -367,7 +367,7 @@ get_config_lock() return ret; } -void internal_error(int line, char *file) +void internal_error(int line, const char *file) { printf("\n\nInternal Error at line %d in %s\n", line, file); exit (-1); @@ -802,7 +802,7 @@ int char2val(vtw_def *def, char *value, valstruct *valp) compare two values per cond returns result of comparison ****************************************************/ -boolean val_cmp(valstruct *left, valstruct *right, vtw_cond_e cond) +boolean val_cmp(const valstruct *left, const valstruct *right, vtw_cond_e cond) { unsigned int left_parts[9], right_parts[9]; vtw_type_e val_type; @@ -2118,12 +2118,7 @@ const char *type_to_name(vtw_type_e type) { } } -#if 1 -void -dump_log(int argc, char **argv) -{ -} -#else +#ifdef CLI_DEBUG void dump_log(int argc, char **argv) { int i; diff --git a/src/cli_val.h b/src/cli_val.h index fa30479..e190dd1 100644 --- a/src/cli_val.h +++ b/src/cli_val.h @@ -171,22 +171,26 @@ extern char *my_strdup(const char *s, const char *name); extern valstruct str2val(char *cp); extern void dump_tree(vtw_node *node, int lev); extern void dump_def(vtw_def *defp); -extern boolean val_cmp(valstruct *left, valstruct *right, vtw_cond_e cond); -extern void out_of_memory(void); +extern boolean val_cmp(const valstruct *left, const valstruct *right, + vtw_cond_e cond); +extern void out_of_memory(void) __attribute__((noreturn)); extern void subtract_values(char **lhs, const char *rhs); extern boolean validate_value(vtw_def *def, char *value); -extern void internal_error(int line, char *file); +extern void internal_error(int line, const char *file) + __attribute__((noreturn)); extern void done(void); extern void del_value(vtw_def *defp, char *cp); -extern void bye(char *msg, ...); -extern void print_msg(char *msg, ...); +extern void bye(const char *msg, ...) + __attribute__((format(printf, 1, 2), noreturn)); +extern void print_msg(const char *msg, ...) + __attribute__((format(printf, 1, 2))); extern void switch_path(first_seg *seg); extern void vtw_sort(valstruct *valp, vtw_sorted *sortp); extern void free_val(valstruct *val); extern void my_free(void *ptr); extern void touch(void); -extern void dump_log(int argc, char **argv); + extern const char *type_to_name(vtw_type_e type); extern boolean execute_list(vtw_node *cur, vtw_def *def); extern void touch_dir(const char *dp); @@ -197,7 +201,7 @@ extern void free_path(vtw_path *path); void mark_paths(vtw_mark *markp); void restore_paths(vtw_mark *markp); -extern int get_config_lock(); +extern int get_config_lock(void); #define VTWERR_BADPATH -2 #define VTWERR_OK 0 @@ -217,14 +221,15 @@ extern int out_fd; extern FILE *out_stream; extern FILE *err_stream; -extern int initialize_output(); +extern int initialize_output(void); /*** debug ***/ #undef CLI_DEBUG #ifdef CLI_DEBUG -#define DPRINT(...) printf(__VA_ARGS__) +#define DPRINT(fmt, arg...) printf(fmt, #arg) +extern void dump_log(int argc, char **argv); #else -#define DPRINT(...) +#define DPRINT(fmt, arg...) while (0) { printf(fmt, ##arg); } +#define dump_log(argc, argv) #endif - #endif |