From 3ec4fd29ffb815365c09f74e6b727f0541cfef4f Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Fri, 12 Aug 2005 02:28:38 +0000 Subject: [PATCH] * amd/sun_map_parse.y: instead of using a custom FOO_alloc() function, use Amd's CALLOC(struct FOO) macro. * amd/sun_map.h: remove extern definitions to functions no longer needed. * amd/sun_map.c: removed superfluous *_alloc() functions, some of which caused conflicts with same-named symbols in the parser (since we rename 'yyalloc' to 'sun_map_alloc'). --- ChangeLog | 10 ++++ amd/sun_map.c | 137 +------------------------------------------- amd/sun_map.h | 8 --- amd/sun_map_parse.y | 36 ++++++------ 4 files changed, 29 insertions(+), 162 deletions(-) diff --git a/ChangeLog b/ChangeLog index a091e45..9cd1e96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2005-08-11 Erez Zadok + * amd/sun_map_parse.y: instead of using a custom FOO_alloc() + function, use Amd's CALLOC(struct FOO) macro. + + * amd/sun_map.h: remove extern definitions to functions no longer + needed. + + * amd/sun_map.c: removed superfluous *_alloc() functions, some of + which caused conflicts with same-named symbols in the parser + (since we rename 'yyalloc' to 'sun_map_alloc'). + * configure.in: keep AC_INIT on same line, for nightly snapshot build script. diff --git a/amd/sun_map.c b/amd/sun_map.c index acc3f01..fe5c38c 100644 --- a/amd/sun_map.c +++ b/amd/sun_map.c @@ -50,141 +50,6 @@ #include -/* - * Allocate a sun_mmap struct. - * - * return - sun_amap* on success, NULL no memory - */ -struct sun_mmap * -sun_mmap_alloc(void) -{ - struct sun_mmap *retval; - - retval = (struct sun_mmap *) xmalloc(sizeof(struct sun_mmap)); - memset(retval, 0, sizeof(struct sun_mmap)); - - return retval; -} - - -/* - * Allocate a sun_map struct. - * - * return - sun_map* on success, NULL no memory - */ -struct sun_map * -sun_map_alloc(void) -{ - struct sun_map *retval; - - retval = (struct sun_map *) xmalloc(sizeof(struct sun_map)); - memset(retval, 0, sizeof(struct sun_map)); - - return retval; -} - - -/* - * Allocate a sun_entry struct. - * - * return - sun_entry* on success, NULL no memory - */ -struct sun_entry * -sun_entry_alloc(void) -{ - struct sun_entry *retval; - - retval = (struct sun_entry *) xmalloc(sizeof(struct sun_entry)); - memset(retval, 0, sizeof(struct sun_entry)); - - return retval; -} - - -/* - * Allocate a sun_mountpt - * - * return - sun_mountpt* on success, NULL no memory - */ -struct sun_mountpt * -sun_mountpt_alloc(void) -{ - struct sun_mountpt *retval; - - retval = (struct sun_mountpt *) xmalloc(sizeof(struct sun_mountpt)); - memset(retval, 0, sizeof(struct sun_mountpt)); - - return retval; -} - - -/* - * Allocate a sun_location struct. - * - * return sun_location* on sucess, NULL no memory - */ -struct sun_location * -sun_location_alloc(void) -{ - struct sun_location *retval; - - retval = (struct sun_location *) xmalloc(sizeof(struct sun_location)); - memset(retval, 0, sizeof(struct sun_location)); - - return retval; -} - - -/* - * Allocate a sun_host struct. - * - * return sun_host* on sucess, NULL no memory - */ -struct sun_host * -sun_host_alloc(void) -{ - struct sun_host *retval; - retval = (struct sun_host *) xmalloc(sizeof(struct sun_host)); - - memset(retval, 0, sizeof(struct sun_host)); - - return retval; -} - - -/* - * Allocate a sun_opt struct. - * - * return sun_opt* on sucess, NULL no memory - */ -struct sun_opt * -sun_opt_alloc(void) -{ - struct sun_opt *retval; - - retval = (struct sun_opt *) xmalloc(sizeof(struct sun_opt)); - memset(retval, 0, sizeof(struct sun_opt)); - - return retval; -} - - -/* - * Allocate a sun_list struct. - * - * return sun_list* on sucess, NULL no memory - */ -struct sun_list * -sun_list_alloc(void) -{ - struct sun_list *retval; - - retval = (struct sun_list *) xmalloc(sizeof(struct sun_list)); - memset(retval, 0, sizeof(struct sun_list)); - - return retval; -} - /* * Add a data pointer to the end of the list. @@ -360,7 +225,7 @@ sun_entry2amd(const char *a_entry) } } else { - plog(XLOG_INFO,"No SUN fstype specified defaulting to NFS."); + plog(XLOG_INFO, "No SUN fstype specified defaulting to NFS."); } diff --git a/amd/sun_map.h b/amd/sun_map.h index de6a9f0..76a0880 100644 --- a/amd/sun_map.h +++ b/amd/sun_map.h @@ -112,15 +112,7 @@ struct sun_list { * EXTERNS */ extern char *sun_entry2amd(const char *); -extern struct sun_entry *sun_entry_alloc(void); extern struct sun_entry *sun_map_parse_read(const char *); -extern struct sun_host *sun_host_alloc(void); -extern struct sun_list *sun_list_alloc(void); -extern struct sun_location *sun_location_alloc(void); -extern struct sun_map *sun_map_alloc(void); -extern struct sun_mmap *sun_mmap_alloc(void); -extern struct sun_mountpt *sun_mountpt_alloc(void); -extern struct sun_opt *sun_opt_alloc(void); extern void sun_list_add(struct sun_list *, qelem *); #endif /* not _SUN_MAP_H */ diff --git a/amd/sun_map_parse.y b/amd/sun_map_parse.y index c420179..bf8bdb7 100644 --- a/amd/sun_map_parse.y +++ b/amd/sun_map_parse.y @@ -111,7 +111,7 @@ entry : locations { struct sun_entry *entry; /* allocate an entry */ - entry = sun_entry_alloc(); + entry = CALLOC(struct sun_entry); /* * Assign the global location list to this entry and reset the @@ -131,7 +131,7 @@ entry : locations { struct sun_list *list; struct sun_entry *entry; - entry = sun_entry_alloc(); + entry = CALLOC(struct sun_entry); /* An fstype may have been defined in the 'options'. */ if(tmpFsType != NULL) { @@ -167,7 +167,7 @@ entry : locations { struct sun_entry *entry; /* allocate an entry */ - entry = sun_entry_alloc(); + entry = CALLOC(struct sun_entry); /* * Assign the global mountpt list to this entry and reset the global @@ -188,7 +188,7 @@ entry : locations { struct sun_entry *entry; /* allocate an entry */ - entry = sun_entry_alloc(); + entry = CALLOC(struct sun_entry); /* An fstype may have been defined in the 'options'. */ if(tmpFsType != NULL) { @@ -220,7 +220,7 @@ entry : locations { | '+' WORD { - struct sun_opt *include = sun_opt_alloc(); + struct sun_opt *include = CALLOC(struct sun_opt); include->str = strdup($2); sun_list_add(get_sun_include_list(),(qelem *)include); @@ -237,7 +237,7 @@ mountpoint : WORD WSPACE location { struct sun_mountpt *mountpt; /* allocate a mountpt */ - mountpt = sun_mountpt_alloc(); + mountpt = CALLOC(struct sun_mountpt); /* * Assign the global loaction list to this entry and reset the @@ -260,7 +260,7 @@ mountpoint : WORD WSPACE location { struct sun_mountpt *mountpt; /* allocate a mountpt */ - mountpt = sun_mountpt_alloc(); + mountpt = CALLOC(struct sun_mountpt); /* * Assign the global loaction list to this entry and reset the @@ -297,7 +297,7 @@ location : hosts ':' WORD { struct sun_location *location; /* allocate a new location */ - location = sun_location_alloc(); + location = CALLOC(struct sun_location); /* * Assign the global opt list to this entry and reset the global @@ -319,7 +319,7 @@ location : hosts ':' WORD { struct sun_location *location; /* allocate a new location */ - location = sun_location_alloc(); + location = CALLOC(struct sun_location); location->path = strdup($2); @@ -335,7 +335,7 @@ hosts : host host : WORD { /* allocate a new host */ - struct sun_host *host = sun_host_alloc(); + struct sun_host *host = CALLOC(struct sun_host); host->name = strdup($1); @@ -360,7 +360,7 @@ weight : '(' WORD ')' { int val; /* allocate a new host */ - struct sun_host *host = sun_host_alloc(); + struct sun_host *host = CALLOC(struct sun_host); val = atoi($2); @@ -384,7 +384,7 @@ option : "fstype=" WORD { /* all other fs options */ | WORD { - struct sun_opt *opt = sun_opt_alloc(); + struct sun_opt *opt = CALLOC(struct sun_opt); opt->str = strdup($1); /* Add this opt to the opt list. */ @@ -422,7 +422,7 @@ static struct sun_list * get_sun_include_list(void) { if (sun_include_list == NULL) { - sun_include_list = sun_list_alloc(); + sun_include_list = CALLOC(struct sun_list); } return sun_include_list; } @@ -432,7 +432,7 @@ static struct sun_list * get_sun_entry_list(void) { if (sun_entry_list == NULL) { - sun_entry_list = sun_list_alloc(); + sun_entry_list = CALLOC(struct sun_list); } return sun_entry_list; } @@ -442,7 +442,7 @@ static struct sun_list * get_mountpt_list(void) { if (mountpt_list == NULL) { - mountpt_list = sun_list_alloc(); + mountpt_list = CALLOC(struct sun_list); } return mountpt_list; } @@ -452,7 +452,7 @@ static struct sun_list * get_sun_location_list(void) { if (sun_location_list == NULL) { - sun_location_list = sun_list_alloc(); + sun_location_list = CALLOC(struct sun_list); } return sun_location_list; } @@ -462,7 +462,7 @@ static struct sun_list * get_sun_host_list(void) { if (sun_host_list == NULL) { - sun_host_list = sun_list_alloc(); + sun_host_list = CALLOC(struct sun_list); } return sun_host_list; } @@ -472,7 +472,7 @@ static struct sun_list * get_sun_opt_list(void) { if (sun_opt_list == NULL) { - sun_opt_list = sun_list_alloc(); + sun_opt_list = CALLOC(struct sun_list); } return sun_opt_list; } -- 2.43.0