From: Daniel Ottavio Date: Sat, 20 Aug 2005 19:20:29 +0000 (+0000) Subject: * amd/sun_map.c: Clean up #defines X-Git-Tag: before-clocktime-fixes~16 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=407598788ec0b2809710a1bf5370842c5f5387a3;p=am-utils-6.0.git * amd/sun_map.c: Clean up #defines (sun_entry2amd) : Verify that the key and entry values passed are not NULL. Free the Sun entry struct when done. * amd/sun_map.h: Add some "not implemented yet" comments to the map and mmap structures. * amd/sun_map_parse.y: Removed automap include functionality, it will need to be re-implemented using a pre-processor. Clean up fucntion calls. --- diff --git a/ChangeLog b/ChangeLog index 16659c7..8659eff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-08-20 Daniel P. Ottavio + + * amd/sun_map.c: Clean up #defines + (sun_entry2amd) : Verify that the key and entry values passed are + not NULL. Free the Sun entry struct when done. + + * amd/sun_map.h: Add some "not implemented yet" comments to the + map and mmap structures. + + * amd/sun_map_parse.y: Removed automap include functionality, it + will need to be re-implemented using a pre-processor. + Clean up fucntion calls. + 2005-08-16 Daniel P. Ottavio * amd/sun2amd.c (sun2amd_convert): If the input line is too long diff --git a/amd/sun_map.c b/amd/sun_map.c index ce2ff0f..d65a6c7 100644 --- a/amd/sun_map.c +++ b/amd/sun_map.c @@ -76,14 +76,6 @@ sun_list_add(struct sun_list *list, qelem *item) * Sun2Amd conversion routines */ -/* - * A set of string Sun fstypes. - */ -#define SUN_NFS_TYPE "nfs" -#define SUN_HSFS_TYPE "hsfs" /* CD fs */ -#define SUN_AUTOFS_TYPE "autofs" -#define SUN_CACHEFS_TYPE "cachefs" - /* * AMD entry keywords */ @@ -98,6 +90,13 @@ sun_list_add(struct sun_list *list, qelem *item) #define AMD_MAP_FS_KW "fs:=${map};" /* set the mount map as current map */ #define AMD_MAP_PREF_KW "pref:=${key};" /* set the mount map as current map */ +/* + * A set of string Sun fstypes. + */ +#define SUN_NFS_TYPE "nfs" +#define SUN_HSFS_TYPE "hsfs" /* CD fs */ +#define SUN_AUTOFS_TYPE "autofs" +#define SUN_CACHEFS_TYPE "cachefs" #define SUN_KEY_SUB "&" /* Sun key subsitution */ @@ -527,7 +526,18 @@ sun_entry2amd(const char *key, const char *s_entry_str) { char *retval = NULL; char line_buff[INFO_MAX_LINE_LEN]; - struct sun_entry *s_entry; + struct sun_entry *s_entry = NULL; + + /* For now the key should no be NULL. */ + if (key == NULL) { + plog(XLOG_ERROR,"Sun key value was null"); + goto err; + } + /* The Sun entry string should never be NULL. */ + if (s_entry == NULL) { + plog(XLOG_ERROR,"Sun entry value was null"); + goto err; + } /* Parse the sun entry line. */ s_entry = sun_map_parse_read(s_entry_str); @@ -584,5 +594,8 @@ sun_entry2amd(const char *key, const char *s_entry_str) } err: + if (s_entry != NULL) { + XFREE(s_entry); + } return retval; } diff --git a/amd/sun_map.h b/amd/sun_map.h index bbd04da..8c8b527 100644 --- a/amd/sun_map.h +++ b/amd/sun_map.h @@ -83,7 +83,11 @@ struct sun_entry { struct sun_mountpt *mountpt_list; /* list of mount points */ }; -/* automount map file */ +/* + * automount map file + * + * XXX: Only a place holder structure, not implemented yet. + */ struct sun_map { qelem head; /* link-list header */ char *path; /* directory path of the map file */ @@ -95,7 +99,11 @@ struct sun_map { struct sun_entry *entry_list; /* list of 'struct s2a_entry' */ }; -/* master map file */ +/* + * master map file + * + * XXX: Only a place holder structure, not implemented yet. + */ struct sun_mmap { qelem head; /* link-list header */ struct sun_opt *include_list; /* list of included master maps */ diff --git a/amd/sun_map_parse.y b/amd/sun_map_parse.y index dfad387..86fa7cd 100644 --- a/amd/sun_map_parse.y +++ b/amd/sun_map_parse.y @@ -62,7 +62,6 @@ extern int sun_map_parse(void); struct sun_entry *sun_map_parse_read(const char *); static struct sun_list *sun_entry_list = NULL; -static struct sun_list *sun_include_list = NULL; static struct sun_list *sun_opt_list = NULL; static struct sun_list *sun_host_list = NULL; static struct sun_list *sun_location_list = NULL; @@ -75,7 +74,6 @@ static char *tmpFsType = NULL; * list structure. If the structure is NULL than a new instance is * returned. */ -static struct sun_list *get_sun_include_list(); static struct sun_list *get_sun_opt_list(); static struct sun_list *get_sun_host_list(); static struct sun_list *get_sun_location_list(); @@ -127,7 +125,7 @@ entry : locations { sun_location_list = NULL; /* Add this entry to the entry list. */ - sun_list_add(get_sun_entry_list(),(qelem *)entry); + sun_list_add(get_sun_entry_list(), (qelem *)entry); } | '-' options WSPACE locations { @@ -162,7 +160,7 @@ entry : locations { sun_opt_list = NULL; /* Add this entry to the entry list. */ - sun_list_add(get_sun_entry_list(),(qelem *)entry); + sun_list_add(get_sun_entry_list(), (qelem *)entry); } | mountpoints { @@ -183,7 +181,7 @@ entry : locations { mountpt_list = NULL; /* Add this entry to the entry list. */ - sun_list_add(get_sun_entry_list(),(qelem *)entry); + sun_list_add(get_sun_entry_list(), (qelem *)entry); } | '-' options WSPACE mountpoints { @@ -219,15 +217,7 @@ entry : locations { sun_opt_list = NULL; /* Add this entry to the entry list. */ - sun_list_add(get_sun_entry_list(),(qelem *)entry); -} - -| '+' WORD { - - struct sun_opt *include = CALLOC(struct sun_opt); - include->str = strdup($2); - - sun_list_add(get_sun_include_list(),(qelem *)include); + sun_list_add(get_sun_entry_list(), (qelem *)entry); } ; @@ -255,7 +245,7 @@ mountpoint : WORD WSPACE location { mountpt->path = strdup($1); /* Add this mountpt to the mountpt list. */ - sun_list_add(get_mountpt_list(),(qelem *)mountpt); + sun_list_add(get_mountpt_list(), (qelem *)mountpt); } | WORD WSPACE '-' options WSPACE location { @@ -287,7 +277,7 @@ mountpoint : WORD WSPACE location { mountpt->path = strdup($1); /* Add this mountpt to the mountpt list. */ - sun_list_add(get_mountpt_list(),(qelem *)mountpt); + sun_list_add(get_mountpt_list(), (qelem *)mountpt); } ; @@ -315,7 +305,7 @@ location : hosts ':' WORD { location->path = strdup($3); /* Add this location to the location list. */ - sun_list_add(get_sun_location_list(),(qelem *)location); + sun_list_add(get_sun_location_list(), (qelem *)location); } | ':' WORD { @@ -328,7 +318,7 @@ location : hosts ':' WORD { location->path = strdup($2); /* Add this location to the location list. */ - sun_list_add(get_sun_location_list(),(qelem *)location); + sun_list_add(get_sun_location_list(), (qelem *)location); } ; @@ -371,7 +361,7 @@ weight : '(' WORD ')' { host->weight = val; /* Add this host to the host list. */ - sun_list_add(get_sun_host_list(),(qelem *)host); + sun_list_add(get_sun_host_list(), (qelem *)host); } ; @@ -403,7 +393,7 @@ option : WORD { struct sun_opt *opt = CALLOC(struct sun_opt); opt->str = strdup($1); /* Add this opt to the opt list. */ - sun_list_add(get_sun_opt_list(),(qelem *)opt); + sun_list_add(get_sun_opt_list(), (qelem *)opt); } } @@ -451,16 +441,6 @@ sun_map_parse_read(const char *map_data) } -static struct sun_list * -get_sun_include_list(void) -{ - if (sun_include_list == NULL) { - sun_include_list = CALLOC(struct sun_list); - } - return sun_include_list; -} - - static struct sun_list * get_sun_entry_list(void) {