diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2012-07-11 12:03:56 -0700 |
---|---|---|
committer | Stephen Hemminger <shemminger@vyatta.com> | 2012-07-11 12:03:56 -0700 |
commit | 6cb7ad8d0bd51e178ec25222251d2e842b9e5aa0 (patch) | |
tree | b67eed808db970f899c32b69f72fb64cbbc66c53 | |
parent | 8ebd82645a8503ec1b8464586e5c19c18c009f06 (diff) | |
download | vyatta-cfg-6cb7ad8d0bd51e178ec25222251d2e842b9e5aa0.tar.gz vyatta-cfg-6cb7ad8d0bd51e178ec25222251d2e842b9e5aa0.zip |
Minor code cleanup
1. Make local functions static
2. Use C standard for function with no-args versus old K&R style
3. Make some arguments const
-rw-r--r-- | src/cli_def.l | 6 | ||||
-rw-r--r-- | src/cli_new.c | 15 | ||||
-rw-r--r-- | src/common/unionfs.c | 28 | ||||
-rw-r--r-- | src/common/unionfs.h | 2 |
4 files changed, 26 insertions, 25 deletions
diff --git a/src/cli_def.l b/src/cli_def.l index 806112f..820a7a4 100644 --- a/src/cli_def.l +++ b/src/cli_def.l @@ -89,7 +89,7 @@ append_str(char *text) } static int -return_action() +return_action(void) { *action_ptr = 0; yy_cli_parse_lval.strp = strdup(action_buf); @@ -465,7 +465,7 @@ RE_ACT_FIELD (help|syntax|commit|delete|update|activate|create|begin|end|enumera %% static void -init_bufs() +init_bufs(void) { action_buf = malloc(BUF_INCREMENT); action_ptr = action_buf; @@ -482,7 +482,7 @@ init_bufs() } int -yy_cli_def_lex() +yy_cli_def_lex(void) { if (!action_buf) { init_bufs(); diff --git a/src/cli_new.c b/src/cli_new.c index a7cd122..f045ba5 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -295,7 +295,7 @@ get_shell_command_output(const char *cmd, char *buf, unsigned int buf_size) #define COMMIT_CMD "/opt/vyatta/sbin/my_commit" void -release_config_lock() +release_config_lock(void) { unlink(LOCK_FILE); /* error ignored */ @@ -303,7 +303,7 @@ release_config_lock() /* try to clean up orphaned lock file. return -1 if failed */ static int -try_lock_cleanup() +try_lock_cleanup(void) { char buf[128]; char proc[128]; @@ -388,7 +388,7 @@ create_lock_file(int try_cleanup) } int -get_config_lock() +get_config_lock(void) { int fd = -1; FILE *lfile = NULL; @@ -970,7 +970,7 @@ static int change_var_value(const char* var_reference,const char* value, int act return ret; } -int system_out(char *command, const char *prepend_msg, boolean eloc); +static int system_out(char *command, const char *prepend_msg, boolean eloc); /**************************************************** check_syn: @@ -978,7 +978,8 @@ int system_out(char *command, const char *prepend_msg, boolean eloc); returns TRUE if all checks are OK, returns FALSE if check fails. ****************************************************/ -static boolean check_syn_func(vtw_node *cur,const char *prepend_msg,boolean format,const char* func,int line) +static boolean check_syn_func(vtw_node *cur, const char *prepend_msg, + boolean format, const char* func, int line) { int status; int ret; @@ -2126,7 +2127,7 @@ redirect_output() } int -restore_output() +restore_output(void) { if ((dup2(out_fd, STDOUT_FILENO) == -1) || (dup2(err_fd, STDERR_FILENO) == -1)) { @@ -2135,7 +2136,7 @@ restore_output() return 0; } -int +static int system_out(char *cmd, const char *prepend_msg, boolean eloc) { int pfd[2]; diff --git a/src/common/unionfs.c b/src/common/unionfs.c index 2d8bddd..d8b7626 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -60,7 +60,7 @@ sys_cp(const char *src_file, const char *dst_file) } static inline void -sys_umount_session() +sys_umount_session(void) { if (umount(get_mdirp()) != 0) { perror("umount"); @@ -68,7 +68,7 @@ sys_umount_session() } static inline void -sys_mount_session() +sys_mount_session(void) { char mopts[MAX_LENGTH_DIR_PATH * 2]; snprintf(mopts, MAX_LENGTH_DIR_PATH * 2, "dirs=%s=rw:%s=ro", @@ -81,16 +81,16 @@ sys_mount_session() void set_path(char *path, boolean config); -struct VyattaNode* +static struct VyattaNode* copy_vyatta_node(struct VyattaNode* vn); -void +static void get_term_data_values(GNode *node); -void +static void dlist_test_func(GQuark key_id,gpointer data,gpointer user_data); -GNode* +static GNode* insert_sibling_in_order(GNode *parent, GNode *child); static gboolean @@ -119,7 +119,7 @@ piecewise_copy(GNode *root_node, boolean test_mode); * * This should allow a combined data/config tree **/ -char* +static char * get_config_path(GNode *node) { if (node == NULL) { @@ -168,7 +168,7 @@ get_config_path(GNode *node) /** * **/ -void +static void retrieve_data(char* rel_data_path, GNode *node, const char* root, NODE_OPERATION op) { @@ -514,7 +514,7 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root, * **/ GNode* -common_get_local_session_data() +common_get_local_session_data(void) { //get root directory char *data_path = malloc(sizeof(char)*MAX_LENGTH_DIR_PATH); @@ -541,7 +541,7 @@ common_get_local_session_data() * **/ boolean -value_exists(char *path) +value_exists(const char *path) { char buf[MAX_LENGTH_DIR_PATH]; sprintf(buf, "%s/%s",path,VAL_NAME); @@ -887,7 +887,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) /** * **/ -struct VyattaNode* +static struct VyattaNode* copy_vyatta_node(struct VyattaNode* vn) { struct VyattaNode *new_vn = calloc(1,sizeof(struct VyattaNode)); @@ -919,7 +919,7 @@ copy_vyatta_node(struct VyattaNode* vn) /** * **/ -void +static void get_term_data_values(GNode *node) { struct VyattaNode* vn = (struct VyattaNode*)node->data; @@ -1020,7 +1020,7 @@ get_term_data_values(GNode *node) /** * **/ -void +static void dlist_test_func(GQuark key_id,gpointer data,gpointer user_data) { if (key_id == 0) { @@ -1079,7 +1079,7 @@ dlist_test_func(GQuark key_id,gpointer data,gpointer user_data) /** * **/ -GNode* +static GNode* insert_sibling_in_order(GNode *parent, GNode *child) { //find alphabetical order to insert child into sibling diff --git a/src/common/unionfs.h b/src/common/unionfs.h index 6437e2a..8ce50af 100644 --- a/src/common/unionfs.h +++ b/src/common/unionfs.h @@ -20,7 +20,7 @@ extern "C" { #define MAX_LENGTH_HELP_STR 4096 boolean -value_exists(char *path); +value_exists(const char *path); struct PriData { unsigned long _pri; |