diff --git a/.gitignore b/.gitignore index 2f73b3c6f3..794442400c 100644 --- a/.gitignore +++ b/.gitignore @@ -440,3 +440,10 @@ src/tools/test/printjob/test_printjob src/tools/test/printserverdb/test_printserverdb src/tools/test/printtracking/test_printtracking src/tools/test/tracejob/test_tracejob +.project +.cproject +cscope.out +*.orig +*.rej +*.patch +coverage_results.file diff --git a/configure.ac b/configure.ac index fc216db5f6..acd6b7db1c 100644 --- a/configure.ac +++ b/configure.ac @@ -69,13 +69,16 @@ dnl be created in the include directory. AM_CONFIG_HEADER([src/include/pbs_config.h]) dnl -dnl Find our svn revision number for program outputs +dnl Find our git revision hash for program outputs dnl -AC_PATH_PROG(svnversioncommand, svnversion) -if test "X$svnversioncommand" != "X" && test `$svnversioncommand -n '.'` != "exported"; then - AC_DEFINE_UNQUOTED(SVN_VERSION, ["`svnversion -n`"], [repository svn version]) +githash="`git rev-parse HEAD`" +success=$? +if test "X$success" != "X0" ; then + AC_DEFINE_UNQUOTED(GIT_HASH, ["$githash"], [repository svn version]) else - AC_DEFINE_UNQUOTED(SVN_VERSION, ["unknown"], [repository svn version]) + dnl current hash is a file checked in to the git repo in the base directory + dnl containing the most recent hash + AC_DEFINE_UNQUOTED(GIT_HASH, ["`cat current_hash`"], [repository svn version]) fi diff --git a/current_hash b/current_hash new file mode 100644 index 0000000000..f6c65a02d7 --- /dev/null +++ b/current_hash @@ -0,0 +1 @@ +39f78e588b3a47a6c7bed1004ec7b5d0ccf24288 diff --git a/parse_cov_results.py b/parse_cov_results.py index 78fcc9d220..9bd4964980 100755 --- a/parse_cov_results.py +++ b/parse_cov_results.py @@ -3,17 +3,22 @@ import sys import getopt import re +import os # re patterns for the following line: # TOTALCOV -- '../../MConfig.c': Lines(1020) - executed:1.37% # line_prog = re.compile(".*TOTALCOV -- '\.\./\.\./(.*)': Lines\(([0-9]+)\)- executed:(.+)%.*") +count_pat = re.compile(r'.*[fF]ailures?:\s*(\d+),\s*[eE]rrors?: (\d+)') +loc_pat = re.compile(r"Entering directory `(.*)'$") # Given file name, open and parse it, expecting output generated by 'gcov' coverage tool # argument: file path to gcov output file # argument: Diction to store results from the file def process_file(file, report): + root = '' if (file != None): + root = os.path.dirname(os.path.abspath(file)) try: input = open(file, 'r', 1) except IOError as (errno, strerror): @@ -31,11 +36,28 @@ def process_file(file, report): # # Remember the file name until we encounter its corresponding 'Lines executed' line # When we get both, add to the Dictionary and reset the file name + errors_written = False filename = None for line in input.readlines(): result = line_prog.search(line) if result != None: report[result.group(1)] = [result.group(3), result.group(2)] + else: + m = loc_pat.search(line) + if m: + filename = m.group(1) + if root: + filename = filename[len(root) + 1:] + else: + m = count_pat.search(line) + if m: + if int(m.group(1)) or int(m.group(2)): + if not errors_written: + sys.stderr.write('\nSOME TESTS DID NOT PASS.\n\n') + errors_written = True + sys.stderr.write('%s\n %s\n' % (filename, line.rstrip())) + if errors_written: + sys.stderr.write('\n') input.close() diff --git a/src/cmds/pbsnodes.c b/src/cmds/pbsnodes.c index d7a0ec7c73..2f64018bf9 100644 --- a/src/cmds/pbsnodes.c +++ b/src/cmds/pbsnodes.c @@ -712,7 +712,7 @@ int main( if ((optarg != NULL) && !strcmp(optarg, "version")) { fprintf(stderr, "Version: %s\nRevision: %s\n", - PACKAGE_VERSION, SVN_VERSION); + PACKAGE_VERSION, GIT_HASH); exit(0); } diff --git a/src/cmds/qstat.c b/src/cmds/qstat.c index 7be9cc09d1..4e1c6b6245 100644 --- a/src/cmds/qstat.c +++ b/src/cmds/qstat.c @@ -2207,7 +2207,7 @@ int main( if ((optarg != NULL) && !strcmp(optarg, "version")) { fprintf(stderr, "Version: %s\nRevision: %s\n", - PACKAGE_VERSION, SVN_VERSION); + PACKAGE_VERSION, GIT_HASH); exit(0); } diff --git a/src/cmds/qsub_functions.c b/src/cmds/qsub_functions.c index 66f54d6028..0d885c5055 100644 --- a/src/cmds/qsub_functions.c +++ b/src/cmds/qsub_functions.c @@ -4043,7 +4043,7 @@ void process_early_opts( TShowAbout_exit(); else if (strcmp(name, "version") == 0) { - fprintf(stderr, "version: %s\n", PACKAGE_VERSION); + fprintf(stderr, "Version: %s\nRevision: %s\n", PACKAGE_VERSION, GIT_HASH); exit(0); } } diff --git a/src/cmds/test/qsub_functions/scaffolding.c b/src/cmds/test/qsub_functions/scaffolding.c index c617ad4328..b37f0099e6 100644 --- a/src/cmds/test/qsub_functions/scaffolding.c +++ b/src/cmds/test/qsub_functions/scaffolding.c @@ -65,7 +65,7 @@ int locate_job(char *job_id, char *parent_server, char *located_server) exit(1); } -void port_forwarder( struct pfwdsock *socks, int (*connfunc)(char *, int, char *), char *phost, int pport, char *EMsg) +void port_forwarder( struct pfwdsock *socks, int (*connfunc)(char *, long, char *), char *phost, int pport, char *EMsg) { fprintf(stderr, "The call to port_forwarder to be mocked!!\n"); exit(1); @@ -77,7 +77,7 @@ int cnt2server(char *SpecServer) exit(1); } -int x11_connect_display( char *display, int alsounused, char *EMsg) +int x11_connect_display( char *display, long alsounused, char *EMsg) { fprintf(stderr, "The call to x11_connect_display to be mocked!!\n"); exit(1); diff --git a/src/daemon_client/trq_auth_daemon.c b/src/daemon_client/trq_auth_daemon.c index 8145b992d9..d19b7d800d 100644 --- a/src/daemon_client/trq_auth_daemon.c +++ b/src/daemon_client/trq_auth_daemon.c @@ -164,7 +164,7 @@ int daemonize_trqauthd(char *server_ip, int server_port, void *(*process_meth)(v { openlog("daemonize_trqauthd", LOG_PID | LOG_NOWAIT, LOG_DAEMON); syslog(LOG_ALERT, "Failed to create client_logs directory: errno: %d", errno); - log_err(errno,"daemonize_trqauthd", (char *)"Failed to create client_logs directory"); + log_err(errno,"daemonize_trqauthd", "Failed to create client_logs directory"); closelog(); } pthread_mutex_lock(log_mutex); diff --git a/src/include/attribute.h b/src/include/attribute.h index 5fa05a419d..091af951c6 100644 --- a/src/include/attribute.h +++ b/src/include/attribute.h @@ -209,10 +209,10 @@ typedef struct pbs_attribute pbs_attribute; struct attribute_def { - char *at_name; - int (*at_decode)(pbs_attribute *patr, char *name, char *rn, char *val, int perm); + const char *at_name; + int (*at_decode)(pbs_attribute *patr, const char *name, char *rn, char *val, int perm); int (*at_encode)(pbs_attribute *pattr, tlist_head *phead, - char *aname, char *rsname, int mode, int perm); + const char *aname, const char *rsname, int mode, int perm); int (*at_set)(pbs_attribute *pattr, pbs_attribute *new_attr, enum batch_op); int (*at_comp)(pbs_attribute *pattr, pbs_attribute *with); void (*at_free)(pbs_attribute *pattr); @@ -343,7 +343,7 @@ extern long attr_ifelse_long(pbs_attribute *, pbs_attribute *, long); extern void free_null(pbs_attribute *attr); extern void free_noop(pbs_attribute *attr); extern svrattrl *attrlist_alloc(int szname, int szresc, int szval); -extern svrattrl *attrlist_create(char *aname, char *rname, int szval); +extern svrattrl *attrlist_create(const char *aname, const char *rname, int szval); extern void free_attrlist(tlist_head *attrhead); extern int attr_atomic_set(svrattrl *plist, pbs_attribute *old, pbs_attribute *new_attr, attribute_def *pdef, int limit, @@ -353,51 +353,51 @@ extern int attr_atomic_node_set(svrattrl *plist, pbs_attribute *old, int unkn, int privil, int *badattr); extern void attr_atomic_kill(pbs_attribute *temp, attribute_def *pdef, int); -int decode_b(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_c(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_l(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_ll(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_size(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_str(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_time(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_arst(pbs_attribute *patr, char *name, char *rn, char *val, int); +int decode_b(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_c(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_l(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_ll(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_size(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_str(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_time(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_arst(pbs_attribute *patr, const char *name, char *rn, char *val, int); int decode_arst_direct(pbs_attribute *patr, char *val); -int decode_arst_merge(pbs_attribute *,char *,char *,char *); -int decode_resc(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_depend(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_hold(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_uacl(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_unkn(pbs_attribute *patr, char *name, char *rn, char *val, int); -int decode_tv(pbs_attribute *patr, char *name, char *rescn, char *val, int); +int decode_arst_merge(pbs_attribute *,const char *,char *,char *); +int decode_resc(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_depend(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_hold(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_uacl(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_unkn(pbs_attribute *patr, const char *name, char *rn, char *val, int); +int decode_tv(pbs_attribute *patr, const char *name, char *rescn, char *val, int); -int encode_b(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_c(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_l(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_ll(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_size(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_str(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_time(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_arst(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_resc(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_inter(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_unkn(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_depend(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_hold(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); -int encode_tv(pbs_attribute *attr, tlist_head *phead, char *atname, - char *rsname, int mode, int perm); +int encode_b(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_c(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_l(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_ll(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_size(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_str(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_time(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_arst(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_resc(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_inter(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_unkn(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_depend(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_hold(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); +int encode_tv(pbs_attribute *attr, tlist_head *phead, const char *atname, + const char *rsname, int mode, int perm); extern int set_b(pbs_attribute *attr, pbs_attribute *new_attr, enum batch_op); @@ -447,10 +447,10 @@ struct dynamic_string; extern int acl_check(pbs_attribute *, char *canidate, int type); int acl_check_my_array_string(struct array_strings *, char *, int); -extern char *arst_string(char *str, pbs_attribute *pattr); +extern char *arst_string(const char *str, pbs_attribute *pattr); extern void attrl_fixlink(tlist_head *svrattrl); -extern void recov_acl(pbs_attribute *, attribute_def *, char *, char *); -extern int save_acl(pbs_attribute *, attribute_def *, char *, char *); +extern void recov_acl(pbs_attribute *, attribute_def *, const char *, const char *); +extern int save_acl(pbs_attribute *, attribute_def *, const char *, const char *); extern int save_attr(attribute_def *, pbs_attribute *, int, int, char *, size_t *, size_t); extern int save_attr_xml(attribute_def *, pbs_attribute *, int, int); extern int write_buffer(char *,int,int); @@ -458,14 +458,14 @@ extern int size_to_str(struct size_value,char *,int); extern int attr_to_str(struct dynamic_string *ds, attribute_def *,struct pbs_attribute,int); extern int str_to_attr(char *,char *,struct pbs_attribute *,struct attribute_def *); -extern int encode_state(pbs_attribute *, tlist_head *, char *, char *, int, int); -extern int encode_props(pbs_attribute*, tlist_head*, char*, char*, int, int); -extern int encode_jobs(pbs_attribute*, tlist_head*, char*, char*, int, int); -extern int encode_ntype(pbs_attribute*, tlist_head*, char*, char*, int, int); -extern int decode_state(pbs_attribute*, char*, char*, char*, int); -extern int decode_props(pbs_attribute*, char*, char*, char*, int); -extern int decode_ntype(pbs_attribute*, char*, char*, char*, int); -extern int decode_null(pbs_attribute*, char*, char*, char*, int); +extern int encode_state(pbs_attribute *, tlist_head *, const char *, const char *, int, int); +extern int encode_props(pbs_attribute*, tlist_head*, const char*, const char*, int, int); +extern int encode_jobs(pbs_attribute*, tlist_head*, const char*, const char*, int, int); +extern int encode_ntype(pbs_attribute*, tlist_head*, const char*, const char*, int, int); +extern int decode_state(pbs_attribute*, const char*, char*, char*, int); +extern int decode_props(pbs_attribute*, const char*, char*, char*, int); +extern int decode_ntype(pbs_attribute*, const char*, char*, char*, int); +extern int decode_null(pbs_attribute*, const char*, char*, char*, int); extern int comp_null(pbs_attribute*, pbs_attribute*); extern int count_substrings(char*, int*); extern int set_node_state(pbs_attribute*, pbs_attribute*, enum batch_op); @@ -495,7 +495,7 @@ extern int job_radix_action (pbs_attribute *new_attr, void *pobj, int actmode) /* Token manipulation functions */ -extern int decode_tokens(pbs_attribute *, char *, char *, char *, int); +extern int decode_tokens(pbs_attribute *, const char *, char *, char *, int); int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y); diff --git a/src/include/batch_request.h b/src/include/batch_request.h index 18b91c5a2a..4b45d177f6 100644 --- a/src/include/batch_request.h +++ b/src/include/batch_request.h @@ -410,7 +410,7 @@ extern batch_request_holder brh; batch_request *alloc_br (int type); extern void reply_ack (struct batch_request *); -extern void req_reject (int code, int aux, struct batch_request *, char *, char *); +extern void req_reject (int code, int aux, struct batch_request *, const char *, const char *); extern void reply_badattr (int code, int aux, svrattrl *, struct batch_request *); extern void reply_text (struct batch_request *, int code, char *text); extern int reply_jobid (struct batch_request *, char *, int); diff --git a/src/include/cmds.h b/src/include/cmds.h index fa9d7d67d2..d63a5343d2 100644 --- a/src/include/cmds.h +++ b/src/include/cmds.h @@ -124,7 +124,7 @@ int parse_equal_string(char *, char **, char **); int parse_jobid(char *, char **, char **, char **); int prepare_path(char *, char*,char *); void prt_error(char *, char *, int); -void set_attr(struct attrl **, char *, char *); +void set_attr(struct attrl **, const char *, const char *); int set_resources(struct attrl **, char *, int); int cnt2server(char *server); void prt_job_err(char *, int, char *); diff --git a/src/include/csv.h b/src/include/csv.h index a85f7025d9..bbd9358812 100644 --- a/src/include/csv.h +++ b/src/include/csv.h @@ -7,8 +7,8 @@ extern int csv_length(char *csv_str); extern char *csv_nth(char *csv_str, int n); -extern char *csv_find_string(char *csv_str, char *search_str); -extern char *csv_find_value(char *csv_str, char *search_str); +extern char *csv_find_string(char *csv_str, const char *search_str); +extern char *csv_find_value(char *csv_str, const char *search_str); /* Note that csv_nth returns a pointer to a static buffer */ diff --git a/src/include/mom_func.h b/src/include/mom_func.h index 95f57e30f8..9018bef4c2 100644 --- a/src/include/mom_func.h +++ b/src/include/mom_func.h @@ -103,8 +103,8 @@ struct var_table struct sig_tbl { - char *sig_name; - int sig_val; + const char *sig_name; + int sig_val; }; #define NUM_LCL_ENV_VAR 10 @@ -198,13 +198,13 @@ extern void post_resume(job *, int); #endif /* _CRAY */ -extern void bld_env_variables(struct var_table *, char *, char *); +extern void bld_env_variables(struct var_table *, const char *, const char *); extern int expand_path(job *,char *,int,char *); extern pid_t fork_me(int sock); extern int get_la(double *); extern void init_abort_jobs(int); extern int init_groups(char *, int, int, int *); -int kill_job(job *, int sig, const char *killer_id_name, char *why_killed_reason); +int kill_job(job *, int sig, const char *killer_id_name, const char *why_killed_reason); extern void mom_deljob(job *); extern void mom_freenodes(job *); extern void scan_for_exiting(); @@ -242,7 +242,7 @@ extern struct passwd *check_pwd(job *); extern int task_save(task *) ; extern void DIS_rpp_reset(void); extern void checkret(char **, long); -extern char *get_job_envvar(job *, char *); +extern char *get_job_envvar(job *, const char *); extern int mom_open_socket_to_jobs_server(job* pjob, const char *id, void *(*message_hander)(void *)); void clear_servers(); diff --git a/src/include/net_connect.h b/src/include/net_connect.h index 251c94a586..b3e50bbc74 100644 --- a/src/include/net_connect.h +++ b/src/include/net_connect.h @@ -200,7 +200,7 @@ int get_connecthost(int sock, char *, int); void set_localhost_name(char *, size_t); pbs_net_t get_hostaddr(int *, char *); int get_fullhostname(char *, char *, int, char *); -unsigned int get_svrport(char *, char *, unsigned int); +unsigned int get_svrport(const char *, const char *, unsigned int); int init_network(unsigned int, void *(*readfunc)(void *)); void net_close(int); int wait_request(time_t waittime, long *); diff --git a/src/include/pbs_ifl.h b/src/include/pbs_ifl.h index 2751b451a7..fb4f406e20 100644 --- a/src/include/pbs_ifl.h +++ b/src/include/pbs_ifl.h @@ -691,7 +691,7 @@ char *trq_get_if_name(void); /* used by Moab */ int closerm(int); char *getreq(int); -unsigned int get_svrport(char *, char *, unsigned int); +unsigned int get_svrport(const char *, const char *, unsigned int); int openrm(char *, unsigned int); int addreq(int, char *); int pbs_stagein(int, char *, char *, char *); diff --git a/src/include/pbs_job.h b/src/include/pbs_job.h index d02ca9e5c4..558344ce2d 100644 --- a/src/include/pbs_job.h +++ b/src/include/pbs_job.h @@ -617,7 +617,7 @@ struct job time_t ji_checkpoint_next; /* next checkpoint time */ time_t ji_sampletim; /* last usage sample time, irix only */ pid_t ji_momsubt; /* pid of mom subtask */ - int (*ji_mompost)(); /* ptr to post processing func */ + int (*ji_mompost)(struct job *pJob,int exitVal); /* ptr to post processing func */ struct batch_request *ji_preq; /* hold request until finish_exec */ int ji_numnodes; /* number of nodes (at least 1) */ @@ -757,6 +757,22 @@ void garbage_collect_recycling(); ** nodes assigned to the job. */ + +typedef struct taskfix + { + char ti_parentjobid[PBS_MAXSVRJOBID+1]; + tm_node_id ti_parentnode; + tm_task_id ti_parenttask; + tm_task_id ti_task; /* task's taskid */ + int ti_status; /* status of task */ + pid_t ti_sid; /* session id */ + int ti_exitstat; /* exit status */ + union + { + int ti_hold[16]; /* reserved space */ + } ti_u; + } taskfix; + typedef struct task { job *ti_job; /* pointer to owning job */ @@ -767,20 +783,7 @@ typedef struct task tlist_head ti_obits; /* list of obit events */ tlist_head ti_info; /* list of named info */ - struct taskfix - { - char ti_parentjobid[PBS_MAXSVRJOBID+1]; - tm_node_id ti_parentnode; - tm_task_id ti_parenttask; - tm_task_id ti_task; /* task's taskid */ - int ti_status; /* status of task */ - pid_t ti_sid; /* session id */ - int ti_exitstat; /* exit status */ - union - { - int ti_hold[16]; /* reserved space */ - } ti_u; - } ti_qs; + taskfix ti_qs; } task; @@ -1076,7 +1079,6 @@ dir so that job can be restarted */ #define JOB_EXEC_STDOUTFAIL -9 /* could not create/open stdout stderr files */ #define JOB_EXEC_OVERLIMIT -10 -extern void add_dest(job *); extern void depend_clrrdy(job *); extern int depend_on_que(pbs_attribute *, void *, int); extern int depend_on_exec(job *); @@ -1103,7 +1105,7 @@ extern char *prefix_std_file(job *, dynamic_string *, int); extern char *add_std_filename(job *, char *, int, dynamic_string *); extern int set_jobexid(job *, pbs_attribute *, char *); extern int site_check_user_map(job *, char *, char *, int); -int svr_dequejob(char *, int); +int svr_dequejob(job *, int); extern int svr_enquejob(job *, int, int); extern void svr_evaljobstate(job *, int *, int *, int); extern void svr_mailowner(job *, int, int, char *); diff --git a/src/include/pbs_nodes.h b/src/include/pbs_nodes.h index 28460023ac..435b8a50db 100644 --- a/src/include/pbs_nodes.h +++ b/src/include/pbs_nodes.h @@ -593,8 +593,6 @@ void reinitialize_node_iterator(node_iterator *); struct prop *init_prop(char *pname); int initialize_pbsnode(struct pbsnode *, char *pname, u_long *pul, int ntype); int hasprop(struct pbsnode *pnode, struct prop *props); -int unlock_node(struct pbsnode *the_node, const char *id, char *msg, int logging); -int lock_node(struct pbsnode *the_node, const char *id, char *msg, int logging); void update_node_state(struct pbsnode *np, int newstate); int is_job_on_node(struct pbsnode *np, char *jobid); void *sync_node_jobs(void *vp); diff --git a/src/include/port_forwarding.h b/src/include/port_forwarding.h index 0700eaa253..c3fa68a925 100644 --- a/src/include/port_forwarding.h +++ b/src/include/port_forwarding.h @@ -33,10 +33,10 @@ struct pfwdsock char buff[BUF_SIZE]; }; -void port_forwarder(struct pfwdsock *, int(*connfunc)(char *phost, int pport, char *), char*, int, char *); +void port_forwarder(struct pfwdsock *, int(*connfunc)(char *phost, long pport, char *), char*, int, char *); void set_nodelay(int); int connect_local_xsocket(u_int); -int x11_connect_display(char *, int, char *); +int x11_connect_display(char *, long, char *); #endif /* END PORT_FORWARDING_H */ diff --git a/src/include/resmon.h b/src/include/resmon.h index c8cd42e254..2b0e0b68e7 100644 --- a/src/include/resmon.h +++ b/src/include/resmon.h @@ -92,11 +92,11 @@ struct rm_attribute ** for the name in question. */ -typedef char *(*confunc)(struct rm_attribute *); +typedef const char *(*confunc)(struct rm_attribute *); struct config { - char *c_name; + const char *c_name; union { confunc c_func; diff --git a/src/include/resource.h b/src/include/resource.h index 7e601f3119..d9aed88bc2 100644 --- a/src/include/resource.h +++ b/src/include/resource.h @@ -118,9 +118,9 @@ typedef struct resource typedef struct resource_def { - char *rs_name; - int (*rs_decode)(pbs_attribute *, char *, char *, char *, int); - int (*rs_encode)(pbs_attribute *, tlist_head *, char *, char *, int, int); + const char *rs_name; + int (*rs_decode)(pbs_attribute *, const char *, char *, char *, int); + int (*rs_encode)(pbs_attribute *, tlist_head *, const char *, const char *, int, int); int (*rs_set)(pbs_attribute *, pbs_attribute *, enum batch_op); int (*rs_comp)(pbs_attribute *, pbs_attribute *); void (*rs_free)(pbs_attribute *); @@ -143,7 +143,7 @@ extern resource_def *svr_resc_def; extern int svr_resc_size; extern resource *add_resource_entry(pbs_attribute *, resource_def *); -extern resource_def *find_resc_def(resource_def *, char *, int); +extern resource_def *find_resc_def(resource_def *, const char *, int); extern resource *find_resc_entry(pbs_attribute *, resource_def *); /* END resource.h */ diff --git a/src/include/site_job_attr_def.h b/src/include/site_job_attr_def.h new file mode 100644 index 0000000000..4d7fa262b1 --- /dev/null +++ b/src/include/site_job_attr_def.h @@ -0,0 +1,111 @@ +/* +* OpenPBS (Portable Batch System) v2.3 Software License +* +* Copyright (c) 1999-2000 Veridian Information Solutions, Inc. +* All rights reserved. +* +* --------------------------------------------------------------------------- +* For a license to use or redistribute the OpenPBS software under conditions +* other than those described below, or to purchase support for this software, +* please contact Veridian Systems, PBS Products Department ("Licensor") at: +* +* www.OpenPBS.org +1 650 967-4675 sales@OpenPBS.org +* 877 902-4PBS (US toll-free) +* --------------------------------------------------------------------------- +* +* This license covers use of the OpenPBS v2.3 software (the "Software") at +* your site or location, and, for certain users, redistribution of the +* Software to other sites and locations. Use and redistribution of +* OpenPBS v2.3 in source and binary forms, with or without modification, +* are permitted provided that all of the following conditions are met. +* After December 31, 2001, only conditions 3-6 must be met: +* +* 1. Commercial and/or non-commercial use of the Software is permitted +* provided a current software registration is on file at www.OpenPBS.org. +* If use of this software contributes to a publication, product, or +* service, proper attribution must be given; see www.OpenPBS.org/credit.html +* +* 2. Redistribution in any form is only permitted for non-commercial, +* non-profit purposes. There can be no charge for the Software or any +* software incorporating the Software. Further, there can be no +* expectation of revenue generated as a consequence of redistributing +* the Software. +* +* 3. Any Redistribution of source code must retain the above copyright notice +* and the acknowledgment contained in paragraph 6, this list of conditions +* and the disclaimer contained in paragraph 7. +* +* 4. Any Redistribution in binary form must reproduce the above copyright +* notice and the acknowledgment contained in paragraph 6, this list of +* conditions and the disclaimer contained in paragraph 7 in the +* documentation and/or other materials provided with the distribution. +* +* 5. Redistributions in any form must be accompanied by information on how to +* obtain complete source code for the OpenPBS software and any +* modifications and/or additions to the OpenPBS software. The source code +* must either be included in the distribution or be available for no more +* than the cost of distribution plus a nominal fee, and all modifications +* and additions to the Software must be freely redistributable by any party +* (including Licensor) without restriction. +* +* 6. All advertising materials mentioning features or use of the Software must +* display the following acknowledgment: +* +* "This product includes software developed by NASA Ames Research Center, +* Lawrence Livermore National Laboratory, and Veridian Information +* Solutions, Inc. +* Visit www.OpenPBS.org for OpenPBS software support, +* products, and information." +* +* 7. DISCLAIMER OF WARRANTY +* +* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ANY EXPRESS +* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT +* ARE EXPRESSLY DISCLAIMED. +* +* IN NO EVENT SHALL VERIDIAN CORPORATION, ITS AFFILIATED COMPANIES, OR THE +* U.S. GOVERNMENT OR ANY OF ITS AGENCIES BE LIABLE FOR ANY DIRECT OR INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* This license will be governed by the laws of the Commonwealth of Virginia, +* without reference to its choice of law rules. +*/ + +/* + * Place holder for site supplied additions to the array of + * site job attribute definitions, see server/job_attr_def.c + * + * Array elements must be of the form: + * { "name", + * decode_Func, + * encode_Func, + * set_Func, + * comp_Func, + * free_Func, + * action_routine, + * permissions, + * ATR_TYPE_*, + * PARENT_TYPE_JOB + * }, + * + * Matching entry must be added in site_job_attr_enum.h + */ + +{ "x", + decode_str, + encode_str, + set_str, + comp_str, + free_str, + NULL_FUNC, + READ_WRITE, + ATR_TYPE_STR, + PARENT_TYPE_JOB + }, + diff --git a/src/include/utils.h b/src/include/utils.h index 7ddeb4e8a4..826e12ad87 100644 --- a/src/include/utils.h +++ b/src/include/utils.h @@ -142,14 +142,14 @@ extern int is_whitespace (char); extern int write_buffer (char *,int,int); /* utility functions in u_mu.c */ -int MUSNPrintF (char **, int *, char *, ...); -int MUStrNCat (char **, int *, char *); +int MUSNPrintF (char **, int *, const char *, ...); +int MUStrNCat (char **, int *, const char *); int MUSleep (long); int MUReadPipe (char *, char *, int); int is_whitespace (char); char *trim(char *); -char *threadsafe_tokenizer(char **str, char *delims); -int safe_strncat(char *, char *, size_t); +char *threadsafe_tokenizer(char **str, const char *delims); +int safe_strncat(char *, const char *, size_t); unsigned int get_random_number(); /* MXML functions from u_MXML.c */ diff --git a/src/include/work_task.h b/src/include/work_task.h index d589114f3c..600b67646b 100644 --- a/src/include/work_task.h +++ b/src/include/work_task.h @@ -152,7 +152,6 @@ work_task *next_task(all_tasks *,int *); -extern struct work_task *set_task(enum work_type, long event, void (*func)(), void *param, int); extern void clear_task(struct work_task *ptask); extern void dispatch_task(struct work_task *); extern void delete_task(struct work_task *ptask); diff --git a/src/lib/Libattr/attr_fn_arst.c b/src/lib/Libattr/attr_fn_arst.c index 20fef7e0c3..a0ad1b5d9f 100644 --- a/src/lib/Libattr/attr_fn_arst.c +++ b/src/lib/Libattr/attr_fn_arst.c @@ -265,7 +265,7 @@ int decode_arst_direct( int decode_arst( pbs_attribute *patr, /* O (modified) */ - char *name, /* I pbs_attribute name (notused) */ + const char *name, /* I pbs_attribute name (notused) */ char *rescn, /* I resource name (notused) */ char *val, /* I pbs_attribute value */ int perm) /* only used for resources */ @@ -330,7 +330,7 @@ int decode_arst( int decode_arst_merge( pbs_attribute *patr, /* O (modified) */ - char *name, /* I pbs_attribute name (notused) */ + const char *name, /* I pbs_attribute name (notused) */ char *rescn, /* I resource name (notused) */ char *val) /* I pbs_attribute value */ @@ -418,8 +418,8 @@ int encode_arst( pbs_attribute *attr, /* I ptr to pbs_attribute to encode */ tlist_head *phead, /* O ptr to head of attrlist list */ - char *atname, /* I pbs_attribute name */ - char *rsname, /* I resource name or NULL (optional) */ + const char *atname, /* I pbs_attribute name */ + const char *rsname, /* I resource name or NULL (optional) */ int mode, /* I encode mode */ int perm) /* only used for resources */ @@ -992,7 +992,7 @@ void free_arst( char *arst_string( - char *str, + const char *str, pbs_attribute *pattr) { diff --git a/src/lib/Libattr/attr_fn_arst.h b/src/lib/Libattr/attr_fn_arst.h index 2a981c3c05..856034b71d 100644 --- a/src/lib/Libattr/attr_fn_arst.h +++ b/src/lib/Libattr/attr_fn_arst.h @@ -6,11 +6,11 @@ int decode_arst_direct( struct pbs_attribute *patr, char *val); -int decode_arst( struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_arst( struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int decode_arst_merge( struct pbs_attribute *patr, char *name, char *rescn, char *val); +int decode_arst_merge( struct pbs_attribute *patr, const char *name, char *rescn, char *val); -int encode_arst( pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_arst( pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_arst( struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); @@ -18,4 +18,4 @@ int comp_arst( struct pbs_attribute *attr, struct pbs_attribute *with); void free_arst( struct pbs_attribute *attr); -char *arst_string( char *str, pbs_attribute *pattr); +char *arst_string( const char *str, pbs_attribute *pattr); diff --git a/src/lib/Libattr/attr_fn_b.c b/src/lib/Libattr/attr_fn_b.c index 774db88889..a1ece928bb 100644 --- a/src/lib/Libattr/attr_fn_b.c +++ b/src/lib/Libattr/attr_fn_b.c @@ -127,7 +127,7 @@ static char false_val[] = ATR_FALSE; int decode_b( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -186,8 +186,8 @@ int encode_b( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of pbs_attribute list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_b.h b/src/lib/Libattr/attr_fn_b.h index 5695c74302..23aa746586 100644 --- a/src/lib/Libattr/attr_fn_b.h +++ b/src/lib/Libattr/attr_fn_b.h @@ -4,9 +4,9 @@ #include "list_link.h" /* tlist_head */ #include "pbs_ifl.h" /* batch_op */ -int decode_b(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_b(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_b(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_b(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_b(pbs_attribute *attr, pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_fn_c.c b/src/lib/Libattr/attr_fn_c.c index be5c5cf508..d77c9776f6 100644 --- a/src/lib/Libattr/attr_fn_c.c +++ b/src/lib/Libattr/attr_fn_c.c @@ -123,7 +123,7 @@ int decode_c( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -157,8 +157,8 @@ int encode_c( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_c.h b/src/lib/Libattr/attr_fn_c.h index 621a764c5f..2037da2789 100644 --- a/src/lib/Libattr/attr_fn_c.h +++ b/src/lib/Libattr/attr_fn_c.h @@ -4,9 +4,9 @@ #include "list_link.h" /* tlist_head */ #include "pbs_ifl.h" /* batch_op */ -int decode_c( pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_c( pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_c( pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_c( pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_c(struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_fn_hold.c b/src/lib/Libattr/attr_fn_hold.c index 383bbffdf4..e6d199c6df 100644 --- a/src/lib/Libattr/attr_fn_hold.c +++ b/src/lib/Libattr/attr_fn_hold.c @@ -110,7 +110,7 @@ int decode_hold( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name - unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -172,8 +172,8 @@ int encode_hold( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist */ - char *atname, /* name of pbs_attribute */ - char *rsname, /* resource name or null */ + const char *atname, /* name of pbs_attribute */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_hold.h b/src/lib/Libattr/attr_fn_hold.h index b940b80d1f..ebddd56cb1 100644 --- a/src/lib/Libattr/attr_fn_hold.h +++ b/src/lib/Libattr/attr_fn_hold.h @@ -3,9 +3,9 @@ #include "attribute.h" /* pbs_attribute */ #include "list_link.h" /* tlist_head */ -int decode_hold( pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_hold( pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_hold( pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_hold( pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int comp_hold(struct pbs_attribute *attr, struct pbs_attribute *with); diff --git a/src/lib/Libattr/attr_fn_intr.c b/src/lib/Libattr/attr_fn_intr.c index 8eb15ef310..838039185f 100644 --- a/src/lib/Libattr/attr_fn_intr.c +++ b/src/lib/Libattr/attr_fn_intr.c @@ -134,8 +134,8 @@ int encode_inter( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of pbs_attribute list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_intr.h b/src/lib/Libattr/attr_fn_intr.h index 06850d073e..eff1b195c7 100644 --- a/src/lib/Libattr/attr_fn_intr.h +++ b/src/lib/Libattr/attr_fn_intr.h @@ -3,5 +3,5 @@ #include "attribute.h" /* pbs_attribute */ #include "list_link.h" /* tlist_head */ -int encode_inter( pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_inter( pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); diff --git a/src/lib/Libattr/attr_fn_l.c b/src/lib/Libattr/attr_fn_l.c index a4416b39dc..e9d6e6d339 100644 --- a/src/lib/Libattr/attr_fn_l.c +++ b/src/lib/Libattr/attr_fn_l.c @@ -122,7 +122,7 @@ int decode_l( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -175,8 +175,8 @@ int encode_l( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_l.h b/src/lib/Libattr/attr_fn_l.h index b8f5759e36..5075f800cf 100644 --- a/src/lib/Libattr/attr_fn_l.h +++ b/src/lib/Libattr/attr_fn_l.h @@ -4,9 +4,9 @@ #include "list_link.h" /* tlist_head */ #include "pbs_ifl.h" /* batch_op */ -int decode_l( pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_l( pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_l( pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_l( pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_l(struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_fn_ll.c b/src/lib/Libattr/attr_fn_ll.c index c34db2f4e9..8f36e1894e 100644 --- a/src/lib/Libattr/attr_fn_ll.c +++ b/src/lib/Libattr/attr_fn_ll.c @@ -48,7 +48,7 @@ int decode_ll( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -88,8 +88,8 @@ int encode_ll( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_ll.h b/src/lib/Libattr/attr_fn_ll.h index 366337ab3c..c78dfcf8ca 100644 --- a/src/lib/Libattr/attr_fn_ll.h +++ b/src/lib/Libattr/attr_fn_ll.h @@ -4,9 +4,9 @@ #include "list_link.h" /* tlist_head */ #include "pbs_ifl.h" /* batch_op */ -int decode_ll(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_ll(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_ll(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_ll(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_ll(struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_fn_resc.c b/src/lib/Libattr/attr_fn_resc.c index 52df53d09e..6ec092caf3 100644 --- a/src/lib/Libattr/attr_fn_resc.c +++ b/src/lib/Libattr/attr_fn_resc.c @@ -137,7 +137,7 @@ int comp_resc_nc; /* count of resources not compared */ int decode_resc( pbs_attribute *patr, /* Modified on Return */ - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* I resource name - is used here */ char *val, /* resource value */ int perm) /* access permissions */ @@ -240,8 +240,8 @@ int encode_resc( pbs_attribute *attr, /* ptr to pbs_attribute to encode */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name, null on call */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name, null on call */ int mode, /* encode mode */ int ac_perm) /* access permissions */ @@ -512,7 +512,7 @@ int comp_resc2( resource *wiresc; int rc; int comp_ret = 0; - char *LimitName; + const char *LimitName; comp_resc_gt = 0; comp_resc_eq = 0; @@ -718,7 +718,7 @@ void free_resc( resource_def *find_resc_def( resource_def *rscdf, /* address of array of resource_def structs */ - char *name, /* name of resource */ + const char *name, /* name of resource */ int limit) /* number of members in resource_def array */ { diff --git a/src/lib/Libattr/attr_fn_resc.h b/src/lib/Libattr/attr_fn_resc.h index 25ee6b5ce3..c5085cad33 100644 --- a/src/lib/Libattr/attr_fn_resc.h +++ b/src/lib/Libattr/attr_fn_resc.h @@ -5,9 +5,9 @@ #include "pbs_ifl.h" /* batch_op */ #include "resource.h" /* resource_def */ -int decode_resc(struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_resc(struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_resc(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int ac_perm); +int encode_resc(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int ac_perm); int set_resc(struct pbs_attribute *old, struct pbs_attribute *new, enum batch_op op); @@ -17,7 +17,7 @@ int comp_resc2(struct pbs_attribute *attr, struct pbs_attribute *with, int IsQue void free_resc(pbs_attribute *pattr); -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit); +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit); resource *find_resc_entry(pbs_attribute *pattr, resource_def *rscdf); diff --git a/src/lib/Libattr/attr_fn_size.c b/src/lib/Libattr/attr_fn_size.c index 8e46dce0da..87cd3106c5 100644 --- a/src/lib/Libattr/attr_fn_size.c +++ b/src/lib/Libattr/attr_fn_size.c @@ -129,7 +129,7 @@ int normalize_size(struct size_value *a, struct size_value *b, int decode_size( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -174,8 +174,8 @@ int encode_size( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name (optional) */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name (optional) */ int mode, /* encode mode (not used) */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_size.h b/src/lib/Libattr/attr_fn_size.h index e3e7b8f2e5..513c2a6f9c 100644 --- a/src/lib/Libattr/attr_fn_size.h +++ b/src/lib/Libattr/attr_fn_size.h @@ -4,9 +4,9 @@ #include "list_link.h" /* tlist_head */ #include "pbs_ifl.h" /* batch_op */ -int decode_size(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_size(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_size(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_size(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_size(struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_fn_str.c b/src/lib/Libattr/attr_fn_str.c index f9e06d1418..33ff394045 100644 --- a/src/lib/Libattr/attr_fn_str.c +++ b/src/lib/Libattr/attr_fn_str.c @@ -125,7 +125,7 @@ int decode_str( pbs_attribute *patr, /* (I modified, allocated ) */ - char *name, /* (I - optional) pbs_attribute name */ + const char *name, /* (I - optional) pbs_attribute name */ char *rescn, /* resource name - unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -185,8 +185,8 @@ int encode_str( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist */ - char *atname, /* name of pbs_attribute */ - char *rsname, /* resource name or null */ + const char *atname, /* name of pbs_attribute */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_str.h b/src/lib/Libattr/attr_fn_str.h index 09da8eced1..306f348729 100644 --- a/src/lib/Libattr/attr_fn_str.h +++ b/src/lib/Libattr/attr_fn_str.h @@ -4,9 +4,9 @@ #include "list_link.h" /* tlist_head */ #include "pbs_ifl.h" /* batch_op */ -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_str(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_str(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_str(struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_fn_time.c b/src/lib/Libattr/attr_fn_time.c index 453f3ddcc3..d85492582f 100644 --- a/src/lib/Libattr/attr_fn_time.c +++ b/src/lib/Libattr/attr_fn_time.c @@ -125,7 +125,7 @@ int decode_time( pbs_attribute *patr, /* I/O (modified) */ - char *name, /* I - pbs_attribute name (not used) */ + const char *name, /* I - pbs_attribute name (not used) */ char *rescn, /* I - resource name (not used) */ char *val, /* I - pbs_attribute value */ int perm) /* only used for resources */ @@ -268,8 +268,8 @@ int encode_time( pbs_attribute *attr, /* ptr to pbs_attribute (value in attr->at_val.at_long) */ tlist_head *phead, /* head of attrlist list (optional) */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name (optional) */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name (optional) */ int mode, /* encode mode (not used) */ int perm) /* only used for resources */ @@ -283,7 +283,7 @@ int encode_time( int sec; char *pv; - if (attr == NULL) + if ((attr == NULL)||(phead == NULL)) { /* FAILURE */ @@ -313,29 +313,20 @@ int encode_time( ct = strlen(cvnbuf); - if (phead != NULL) - { - pal = attrlist_create(atname, rsname, ct+1); - - if (pal == NULL) - { - /* FAILURE */ + pal = attrlist_create(atname, rsname, ct+1); - return(-1); - } + if (pal == NULL) + { + /* FAILURE */ - memcpy(pal->al_value, cvnbuf, ct); + return(-1); + } - pal->al_flags = attr->at_flags; + memcpy(pal->al_value, cvnbuf, ct); - append_link(phead, &pal->al_link, pal); - } - else - { - /* Is this right? Copy time to the name of the attr? */ - snprintf(atname, strlen(atname), "%s", cvnbuf); - } + pal->al_flags = attr->at_flags; + append_link(phead, &pal->al_link, pal); /* SUCCESS */ return(1); diff --git a/src/lib/Libattr/attr_fn_time.h b/src/lib/Libattr/attr_fn_time.h index a1b7a758b1..d6d4622a76 100644 --- a/src/lib/Libattr/attr_fn_time.h +++ b/src/lib/Libattr/attr_fn_time.h @@ -3,8 +3,8 @@ #include "attribute.h" /* pbs_attribute */ #include "list_link.h" /* tlist_head */ -int decode_time(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_time(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_time(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_time(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); diff --git a/src/lib/Libattr/attr_fn_tokens.c b/src/lib/Libattr/attr_fn_tokens.c index f29c043215..f813187c72 100644 --- a/src/lib/Libattr/attr_fn_tokens.c +++ b/src/lib/Libattr/attr_fn_tokens.c @@ -21,7 +21,7 @@ int decode_tokens( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_tokens.h b/src/lib/Libattr/attr_fn_tokens.h index ee429c0e77..c045917ab1 100644 --- a/src/lib/Libattr/attr_fn_tokens.h +++ b/src/lib/Libattr/attr_fn_tokens.h @@ -2,5 +2,5 @@ #include "attribute.h" /* pbs_attribute */ -int decode_tokens(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_tokens(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); diff --git a/src/lib/Libattr/attr_fn_tv.c b/src/lib/Libattr/attr_fn_tv.c index a741dc7759..2f3b07f5c6 100644 --- a/src/lib/Libattr/attr_fn_tv.c +++ b/src/lib/Libattr/attr_fn_tv.c @@ -126,7 +126,7 @@ int timeval_subtract( struct timeval *result, struct timeval *x, struct timeval int decode_tv( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name*/ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -209,8 +209,8 @@ int encode_tv( pbs_attribute *attr, /* ptr to pbs_attribute (value in attr->at_val.at_long) */ tlist_head *phead, /* head of attrlist list (optional) */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name (optional) */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name (optional) */ int mode, /* endcode mode (not used) */ int perm) /* only used for resources */ @@ -223,7 +223,7 @@ int encode_tv( svrattrl *pal; - if ( attr == NULL ) + if (( attr == NULL )||(phead == NULL)) { /* FAILURE */ return(-1); @@ -242,27 +242,19 @@ int encode_tv( ct = strlen(cvnbuf); - if (phead != NULL) - { - pal = attrlist_create(atname, rsname, ct+1); - - if (pal == NULL) - { - /* FAILURE */ - return(-1); - } - - memcpy(pal->al_value, cvnbuf, ct); - - pal->al_flags = attr->at_flags; - - append_link(phead, &pal->al_link, pal); - } - else - { - /* Is this right? time to attr name? */ - snprintf(atname, strlen(atname) - 1, "%s", cvnbuf); - } + pal = attrlist_create(atname, rsname, ct+1); + + if (pal == NULL) + { + /* FAILURE */ + return(-1); + } + + memcpy(pal->al_value, cvnbuf, ct); + + pal->al_flags = attr->at_flags; + + append_link(phead, &pal->al_link, pal); return(1); } diff --git a/src/lib/Libattr/attr_fn_tv.h b/src/lib/Libattr/attr_fn_tv.h index 7d03b45011..a507165fdc 100644 --- a/src/lib/Libattr/attr_fn_tv.h +++ b/src/lib/Libattr/attr_fn_tv.h @@ -7,9 +7,9 @@ int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y); -int decode_tv(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_tv(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_tv(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_tv(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_tv(struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_fn_unkn.c b/src/lib/Libattr/attr_fn_unkn.c index a532152bbb..e7cb991ca4 100644 --- a/src/lib/Libattr/attr_fn_unkn.c +++ b/src/lib/Libattr/attr_fn_unkn.c @@ -129,7 +129,7 @@ int decode_unkn( pbs_attribute *patr, /* May be Modified on Return */ - char *name, + const char *name, char *rescn, char *value, int perm) /* only used for resources */ @@ -193,8 +193,8 @@ int encode_unkn( pbs_attribute *attr, /* ptr to pbs_attribute to encode */ tlist_head *phead, /* list to place entry in */ - char *atname, /* pbs_attribute name, not used here */ - char *rsname, /* resource name, not used here */ + const char *atname, /* pbs_attribute name, not used here */ + const char *rsname, /* resource name, not used here */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_fn_unkn.h b/src/lib/Libattr/attr_fn_unkn.h index 330058b67e..b296ae8eaf 100644 --- a/src/lib/Libattr/attr_fn_unkn.h +++ b/src/lib/Libattr/attr_fn_unkn.h @@ -4,9 +4,9 @@ #include "list_link.h" /* tlist_head */ #include "pbs_ifl.h" /* batch_op */ -int decode_unkn(pbs_attribute *patr, char *name, char *rescn, char *value, int perm); +int decode_unkn(pbs_attribute *patr, const char *name, char *rescn, char *value, int perm); -int encode_unkn(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_unkn(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_unkn(struct pbs_attribute *old, struct pbs_attribute *new, enum batch_op op); diff --git a/src/lib/Libattr/attr_func.c b/src/lib/Libattr/attr_func.c index 8ed94ed84e..945e7dd062 100644 --- a/src/lib/Libattr/attr_func.c +++ b/src/lib/Libattr/attr_func.c @@ -147,8 +147,8 @@ void clear_attr( static int str_nc_cmp( - char *s1, /* I */ - char *s2) /* I */ + const char *s1, /* I */ + const char *s2) /* I */ { do @@ -362,9 +362,9 @@ svrattrl *attrlist_alloc( svrattrl *attrlist_create( - char *aname, /* I - pbs_attribute name */ - char *rname, /* I - resource name if needed or null */ - int vsize) /* I - size of resource value */ + const char *aname, /* I - pbs_attribute name */ + const char *rname, /* I - resource name if needed or null */ + int vsize) /* I - size of resource value */ { svrattrl *pal; diff --git a/src/lib/Libattr/attr_func.h b/src/lib/Libattr/attr_func.h index 29a56ea19d..6a71e05e73 100644 --- a/src/lib/Libattr/attr_func.h +++ b/src/lib/Libattr/attr_func.h @@ -17,7 +17,7 @@ int comp_null(struct pbs_attribute *attr, struct pbs_attribute *with); svrattrl *attrlist_alloc(int szname, int szresc, int szval); -svrattrl *attrlist_create(char *aname, char *rname, int vsize); +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize); void free_attrlist(tlist_head *pattrlisthead); diff --git a/src/lib/Libattr/attr_node_func.c b/src/lib/Libattr/attr_node_func.c index d66226d06f..6ab1818a57 100644 --- a/src/lib/Libattr/attr_node_func.c +++ b/src/lib/Libattr/attr_node_func.c @@ -95,7 +95,6 @@ #include "pbs_nodes.h" #include "pbs_error.h" #include "log.h" -#include "../Liblog/pbs_log.h" #if SYSLOG #include #endif @@ -149,16 +148,16 @@ static int set_nodeflag(char*, short*); static struct node_state { short bit; - char *name; + const char *name; } ns[] = { - {INUSE_UNKNOWN, (char *)ND_state_unknown}, - {INUSE_DOWN, (char *)ND_down}, - {INUSE_OFFLINE, (char *)ND_offline}, - {INUSE_RESERVE, (char *)ND_reserve}, - {INUSE_JOB, (char *)ND_job_exclusive}, - {INUSE_BUSY, (char *)ND_busy}, + {INUSE_UNKNOWN, ND_state_unknown}, + {INUSE_DOWN, ND_down}, + {INUSE_OFFLINE, ND_offline}, + {INUSE_RESERVE, ND_reserve}, + {INUSE_JOB, ND_job_exclusive}, + {INUSE_BUSY, ND_busy}, {0, NULL} }; @@ -300,8 +299,8 @@ int encode_state( pbs_attribute *pattr, /*struct pbs_attribute being encoded */ tlist_head *ph, /*head of a list of "svrattrl" structs which are to be returned*/ - char *aname, /*pbs_attribute's name */ - char *rname, /*resource's name (null if none) */ + const char *aname, /*pbs_attribute's name */ + const char *rname, /*resource's name (null if none) */ int mode, /*mode code, unused here */ int perm) /* only used for resources */ @@ -381,8 +380,8 @@ int encode_ntype( pbs_attribute *pattr, /*struct pbs_attribute being encoded */ tlist_head *ph, /*head of a list of "svrattrl" */ - char *aname, /*pbs_attribute's name */ - char *rname, /*resource's name (null if none) */ + const char *aname, /*pbs_attribute's name */ + const char *rname, /*resource's name (null if none) */ int mode, /*mode code, unused here */ int perm) /* only used for resources */ @@ -443,8 +442,8 @@ int encode_jobs( pbs_attribute *pattr, /*struct pbs_attribute being encoded */ tlist_head *ph, /*head of a list of "svrattrl" structs which are to be returned*/ - char *aname, /*pbs_attribute's name */ - char *rname, /*resource's name (null if none) */ + const char *aname, /*pbs_attribute's name */ + const char *rname, /*resource's name (null if none) */ int mode, /*mode code, unused here */ int perm) /* only used for resources */ @@ -554,7 +553,7 @@ int encode_jobs( int decode_state( pbs_attribute *pattr, /* I (modified) */ - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -664,7 +663,7 @@ int decode_state( int decode_ntype( pbs_attribute *pattr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ diff --git a/src/lib/Libattr/attr_node_func.h b/src/lib/Libattr/attr_node_func.h index 43d81cfd7b..473e0e46aa 100644 --- a/src/lib/Libattr/attr_node_func.h +++ b/src/lib/Libattr/attr_node_func.h @@ -8,15 +8,15 @@ int PNodeStateToString(int SBM, char *Buf, int BufSize); -int encode_state(pbs_attribute *pattr, tlist_head *ph, char *aname, char *rname, int mode, int perm); +int encode_state(pbs_attribute *pattr, tlist_head *ph, const char *aname, const char *rname, int mode, int perm); -int encode_ntype(pbs_attribute *pattr, tlist_head *ph, char *aname, char *rname, int mode, int perm); +int encode_ntype(pbs_attribute *pattr, tlist_head *ph, const char *aname, const char *rname, int mode, int perm); -int encode_jobs(pbs_attribute *pattr, tlist_head *ph, char *aname, char *rname, int mode, int perm); +int encode_jobs(pbs_attribute *pattr, tlist_head *ph, const char *aname, const char *rname, int mode, int perm); -int decode_state(pbs_attribute *pattr, char *name, char *rescn, char *val, int perm); +int decode_state(pbs_attribute *pattr, const char *name, char *rescn, char *val, int perm); -int decode_ntype(pbs_attribute *pattr, char *name, char *rescn, char *val, int perm); +int decode_ntype(pbs_attribute *pattr, const char *name, char *rescn, char *val, int perm); void free_prop_list(struct prop *prop); diff --git a/src/lib/Libattr/test/attr_fn_arst/scaffolding.c b/src/lib/Libattr/test/attr_fn_arst/scaffolding.c index ccfbec1ff8..cbdc64be2f 100644 --- a/src/lib/Libattr/test/attr_fn_arst/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_arst/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_b/scaffolding.c b/src/lib/Libattr/test/attr_fn_b/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_b/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_b/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_c/scaffolding.c b/src/lib/Libattr/test/attr_fn_c/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_c/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_c/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_hold/scaffolding.c b/src/lib/Libattr/test/attr_fn_hold/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_hold/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_hold/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_intr/scaffolding.c b/src/lib/Libattr/test/attr_fn_intr/scaffolding.c index ae60cf37a1..bcae38354b 100644 --- a/src/lib/Libattr/test/attr_fn_intr/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_intr/scaffolding.c @@ -6,14 +6,14 @@ #include "list_link.h" /* tlist_head */ -int encode_b(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_b(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_b needs to be mocked!!\n"); exit(1); } -int encode_l(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_l(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_l needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_l/scaffolding.c b/src/lib/Libattr/test/attr_fn_l/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_l/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_l/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_ll/scaffolding.c b/src/lib/Libattr/test/attr_fn_ll/scaffolding.c index 49a6c1dd94..8a99fded71 100644 --- a/src/lib/Libattr/test/attr_fn_ll/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_ll/scaffolding.c @@ -3,8 +3,7 @@ #include #include "attribute.h" /* svrattrl */ - -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_size/scaffolding.c b/src/lib/Libattr/test/attr_fn_size/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_size/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_size/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_str/scaffolding.c b/src/lib/Libattr/test/attr_fn_str/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_str/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_str/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_time/scaffolding.c b/src/lib/Libattr/test/attr_fn_time/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_time/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_time/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_tokens/scaffolding.c b/src/lib/Libattr/test/attr_fn_tokens/scaffolding.c index e4e04c2c49..8d584febcb 100644 --- a/src/lib/Libattr/test/attr_fn_tokens/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_tokens/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* pbs_attribute */ -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_str needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_tv/scaffolding.c b/src/lib/Libattr/test/attr_fn_tv/scaffolding.c index 49a6c1dd94..75fbb20744 100644 --- a/src/lib/Libattr/test/attr_fn_tv/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_tv/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_fn_unkn/scaffolding.c b/src/lib/Libattr/test/attr_fn_unkn/scaffolding.c index 91ebfaf418..eb0545c0c7 100644 --- a/src/lib/Libattr/test/attr_fn_unkn/scaffolding.c +++ b/src/lib/Libattr/test/attr_fn_unkn/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libattr/test/attr_node_func/scaffolding.c b/src/lib/Libattr/test/attr_node_func/scaffolding.c index 454fe79707..d3810fe4f5 100644 --- a/src/lib/Libattr/test/attr_node_func/scaffolding.c +++ b/src/lib/Libattr/test/attr_node_func/scaffolding.c @@ -4,7 +4,7 @@ #include "attribute.h" /* svrattrl */ -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); @@ -16,7 +16,7 @@ void append_link(tlist_head *head, list_link *new_link, void *pobj) exit(1); } -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_record needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libcmds/get_server.c b/src/lib/Libcmds/get_server.c index 5f91f4f817..75a32a98ff 100644 --- a/src/lib/Libcmds/get_server.c +++ b/src/lib/Libcmds/get_server.c @@ -99,6 +99,8 @@ int TShowAbout_exit(void) fprintf(stderr, "Version: %s\n", PACKAGE_VERSION); + fprintf(stderr, "Revision: %s\n", GIT_HASH); + exit(0); } /* END TShowAbout_exit() */ diff --git a/src/lib/Libcmds/lib_cmds.h b/src/lib/Libcmds/lib_cmds.h index 21697b38fb..92dd0f1928 100644 --- a/src/lib/Libcmds/lib_cmds.h +++ b/src/lib/Libcmds/lib_cmds.h @@ -55,7 +55,7 @@ int prepare_path(char *path_in, char *path_out, char *host); void prt_job_err(char *cmd, int connect, char *id); /* from file set_attr.c */ -void set_attr(struct attrl **attrib, char *attrib_name, char *attrib_value); +void set_attr(struct attrl **attrib, const char *attrib_name, const char *attrib_value); /* from file set_resource.c */ int set_resources(struct attrl **attrib, char *resources, int add); diff --git a/src/lib/Libcmds/set_attr.c b/src/lib/Libcmds/set_attr.c index 50a3b28220..0ccb0bc036 100644 --- a/src/lib/Libcmds/set_attr.c +++ b/src/lib/Libcmds/set_attr.c @@ -95,8 +95,8 @@ void set_attr( struct attrl **attrib, /* I */ - char *attrib_name, /* I */ - char *attrib_value) /* I */ + const char *attrib_name, /* I */ + const char *attrib_value) /* I */ { diff --git a/src/lib/Libcsv/csv.c b/src/lib/Libcsv/csv.c index 0ac55eb02b..15729198f4 100644 --- a/src/lib/Libcsv/csv.c +++ b/src/lib/Libcsv/csv.c @@ -100,7 +100,7 @@ char *csv_nth(char *csv_str, int n) * Search a csv list for an entry that matches a specified search string. */ char * -csv_find_string(char *csv_str, char *search_str) +csv_find_string(char *csv_str, const char *search_str) { int i; int nitems; @@ -144,7 +144,7 @@ csv_find_string(char *csv_str, char *search_str) * pointer to the start of the value string. */ char * -csv_find_value(char *csv_str, char *search_str) +csv_find_value(char *csv_str, const char *search_str) { char *cp; char *vp; diff --git a/src/lib/Libcsv/csv.h b/src/lib/Libcsv/csv.h index 402ef0bfd0..deb2a134f0 100644 --- a/src/lib/Libcsv/csv.h +++ b/src/lib/Libcsv/csv.h @@ -4,6 +4,6 @@ int csv_length(char *csv_str); char *csv_nth(char *csv_str, int n); -char * csv_find_string(char *csv_str, char *search_str); +char * csv_find_string(char *csv_str, const char *search_str); -char * csv_find_value(char *csv_str, char *search_str); +char * csv_find_value(char *csv_str, const char *search_str); diff --git a/src/lib/Libifl/dec_rpys.c b/src/lib/Libifl/dec_rpys.c index 24eb4fc342..38b2f3ef90 100644 --- a/src/lib/Libifl/dec_rpys.c +++ b/src/lib/Libifl/dec_rpys.c @@ -100,7 +100,6 @@ #include "dis.h" #include "batch_request.h" #include "tcp.h" /* tcp_chan */ -#include "../Liblog/pbs_log.h" #include "log.h" int decode_DIS_replySvr( diff --git a/src/lib/Libifl/get_svrport.c b/src/lib/Libifl/get_svrport.c index 88ca36bf79..3d2b4268c4 100644 --- a/src/lib/Libifl/get_svrport.c +++ b/src/lib/Libifl/get_svrport.c @@ -93,8 +93,8 @@ unsigned int get_svrport( - char *service_name, - char *ptype, + const char *service_name, + const char *ptype, unsigned int pdefault) /* in host byte order */ { diff --git a/src/lib/Libifl/lib_ifl.h b/src/lib/Libifl/lib_ifl.h index 58cbf0aaef..2d1a413291 100644 --- a/src/lib/Libifl/lib_ifl.h +++ b/src/lib/Libifl/lib_ifl.h @@ -213,7 +213,7 @@ int encode_DIS_reply(struct tcp_chan *chan, struct batch_reply *reply); int encode_DIS_svrattrl(struct tcp_chan *chan, svrattrl *psattl); /* get_svrport.c */ -unsigned int get_svrport(char *service_name, char *ptype, unsigned int pdefault); +unsigned int get_svrport(const char *service_name, const char *ptype, unsigned int pdefault); /* list_link.c */ void insert_link(struct list_link *old, struct list_link *new_link, void *pobj, int position); diff --git a/src/lib/Libifl/pbsD_connect.c b/src/lib/Libifl/pbsD_connect.c index b8efafef74..bbac7ecdd7 100644 --- a/src/lib/Libifl/pbsD_connect.c +++ b/src/lib/Libifl/pbsD_connect.c @@ -121,7 +121,6 @@ #include "dis.h" #include "net_connect.h" #include "log.h" /* log */ -#include "../Liblog/log_event.h" /* log_event */ #include "../Libnet/lib_net.h" /* socket_* */ #include "../Libifl/lib_ifl.h" /* AUTH_TYPE_IFF, DIS_* */ #include "pbs_constants.h" /* LOCAL_IP */ @@ -335,8 +334,8 @@ char *PBS_get_server( if (dflt_port == 0) { dflt_port = get_svrport( - (char *)PBS_BATCH_SERVICE_NAME, - (char *)"tcp", + PBS_BATCH_SERVICE_NAME, + "tcp", PBS_BATCH_SERVICE_PORT); } @@ -430,7 +429,7 @@ int PBSD_munge_authenticate( { /* read failed */ local_errno = errno; - log_err(local_errno, __func__, (char *)"error reading pipe in PBSD_munge_authenticate"); + log_err(local_errno, __func__, "error reading pipe in PBSD_munge_authenticate"); return -1; } diff --git a/src/lib/Libifl/tcp_dis.c b/src/lib/Libifl/tcp_dis.c index 1887c2a130..5a240308f7 100644 --- a/src/lib/Libifl/tcp_dis.c +++ b/src/lib/Libifl/tcp_dis.c @@ -97,7 +97,6 @@ #include "../Libdis/lib_dis.h" #include "dis_init.h" #include "log.h" -#include "../Liblog/pbs_log.h" #include "../Libutils/u_lock_ctl.h" #include "../Libnet/lib_net.h" /* socket_* */ @@ -256,7 +255,7 @@ int tcp_read( newsize = (tdis_buf_len + *read_len) * 2; if ((ptr = (char *)calloc(1, newsize+1)) == NULL) { - log_err(ENOMEM,__func__,(char *)"Could not allocate memory to read buffer"); + log_err(ENOMEM,__func__,"Could not allocate memory to read buffer"); rc = PBSE_MEM_MALLOC; free(new_data); return rc; @@ -668,7 +667,7 @@ struct tcp_chan * DIS_tcp_setup( if ((chan = (struct tcp_chan *)calloc(1, sizeof(struct tcp_chan))) == NULL) { - log_err(ENOMEM, (char *)"DIS_tcp_setup", (char *)"calloc failure"); + log_err(ENOMEM, "DIS_tcp_setup", "calloc failure"); return(NULL); } @@ -680,7 +679,7 @@ struct tcp_chan * DIS_tcp_setup( if ((tp->tdis_thebuf = (char *)calloc(1, THE_BUF_SIZE+1)) == NULL) { free(chan); - log_err(errno,(char *)"DIS_tcp_setup",(char *)"calloc failure"); + log_err(errno,"DIS_tcp_setup","calloc failure"); return(NULL); } @@ -693,7 +692,7 @@ struct tcp_chan * DIS_tcp_setup( { free(chan->readbuf.tdis_thebuf); free(chan); - log_err(errno,(char *)"DIS_tcp_setup",(char *)"calloc failure"); + log_err(errno,"DIS_tcp_setup","calloc failure"); return(NULL); } diff --git a/src/lib/Libifl/test/dec_rpys/scaffolding.c b/src/lib/Libifl/test/dec_rpys/scaffolding.c index 7a89d5a188..0e4c9e7d2a 100644 --- a/src/lib/Libifl/test/dec_rpys/scaffolding.c +++ b/src/lib/Libifl/test/dec_rpys/scaffolding.c @@ -41,7 +41,7 @@ int disrsi(int stream, int *retval) exit(1); } -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { } diff --git a/src/lib/Libifl/test/pbsD_connect/scaffolding.c b/src/lib/Libifl/test/pbsD_connect/scaffolding.c index 4087e2cbe7..0dc011a6a2 100644 --- a/src/lib/Libifl/test/pbsD_connect/scaffolding.c +++ b/src/lib/Libifl/test/pbsD_connect/scaffolding.c @@ -10,7 +10,7 @@ char pbs_current_user[PBS_MAXUSER]; time_t pbs_tcp_timeout = 20; -unsigned int get_svrport(char *service_name, char *ptype, unsigned int pdefault) +unsigned int get_svrport(const char *service_name, const char *ptype, unsigned int pdefault) { fprintf(stderr, "The call to get_svrport needs to be mocked!!\n"); exit(1); @@ -86,7 +86,7 @@ int socket_write(int socket, char *data, int data_len) exit(1); } -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_event needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libifl/test/tcp_dis/scaffolding.c b/src/lib/Libifl/test/tcp_dis/scaffolding.c index 9c0a2c1f49..d0d294feea 100644 --- a/src/lib/Libifl/test/tcp_dis/scaffolding.c +++ b/src/lib/Libifl/test/tcp_dis/scaffolding.c @@ -27,7 +27,7 @@ int unlock_tcp_table() exit(1); } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libifl/test/trq_auth/scaffolding.c b/src/lib/Libifl/test/trq_auth/scaffolding.c index 0cdcb0c5d5..a0a34dc9f4 100644 --- a/src/lib/Libifl/test/trq_auth/scaffolding.c +++ b/src/lib/Libifl/test/trq_auth/scaffolding.c @@ -87,4 +87,4 @@ int get_hostaddr_hostent_af( return(0); } -void log_record(int eventtype, int objclass, const char *objname, char *text) {} +void log_record(int eventtype, int objclass, const char *objname, const char *text) {} diff --git a/src/lib/Libifl/tm.c b/src/lib/Libifl/tm.c index 54bd7e01ce..c78c8cf91d 100644 --- a/src/lib/Libifl/tm.c +++ b/src/lib/Libifl/tm.c @@ -170,8 +170,10 @@ static event_info *event_hash[EVENT_HASH]; /* ** Find an event number or return a NULL. */ -static event_info * -find_event(tm_event_t x) +event_info *find_event( + + tm_event_t x) + { event_info *ep; @@ -187,10 +189,11 @@ find_event(tm_event_t x) /* ** Delete an event. */ -static void -del_event(event_info *ep) - { +void del_event( + + event_info *ep) + { /* unlink event from hash list */ if (ep->e_prev) ep->e_prev->e_next = ep->e_next; @@ -245,8 +248,8 @@ del_event(event_info *ep) /* ** Create a new event number. */ -static tm_event_t -new_event(void) +tm_event_t new_event(void) + { static tm_event_t next_event = TM_NULL_EVENT + 1; event_info *ep; @@ -275,8 +278,12 @@ new_event(void) /* ** Link new event number into the above hash table. */ -static void -add_event(tm_event_t event, tm_node_id node, int type, void *info) +void add_event( + + tm_event_t event, + tm_node_id node, + int type, + void *info) { event_info *ep, **head; @@ -322,8 +329,10 @@ static task_info *task_hash[TASK_HASH]; /* ** Find a task table entry for a given task number or return a NULL. */ -static task_info * -find_task(tm_task_id x) +task_info *find_task( + + tm_task_id x) + { task_info *tp; @@ -340,8 +349,12 @@ find_task(tm_task_id x) ** Create a new task entry and link it into the above hash ** table. */ -static tm_task_id -new_task(char *jobid, tm_node_id node, tm_task_id task) +tm_task_id new_task( + + char *jobid, + tm_node_id node, + tm_task_id task) + { task_info *tp, **head; @@ -559,8 +572,8 @@ static int localmom(void) static int startcom( - int com, - tm_event_t event, + int com, + tm_event_t event, struct tcp_chan **pchan) { @@ -943,6 +956,7 @@ int tm_obit( tm_task_id tid, /* in */ int *obitval, /* out */ tm_event_t *event) /* out */ + { int rc = TM_SUCCESS; task_info *tp; @@ -1002,14 +1016,14 @@ struct taskhold ** is a valid node number, it returns the event that the list of ** tasks on is available. */ -int -tm_taskinfo( - tm_node_id node, /* in */ +int tm_taskinfo( + + tm_node_id node, /* in */ tm_task_id *tid_list, /* out */ - int list_size, /* in */ - int *ntasks, /* out */ - tm_event_t *event /* out */ -) + int list_size, /* in */ + int *ntasks, /* out */ + tm_event_t *event) /* out */ + { struct taskhold *thold; struct tcp_chan *chan = NULL; @@ -1053,11 +1067,11 @@ tm_taskinfo( ** Returns the job-relative node number that holds or held . In ** case of an error, it returns TM_ERROR_NODE. */ -int -tm_atnode( - tm_task_id tid, /* in */ - tm_node_id *node /* out */ -) +int tm_atnode( + + tm_task_id tid, /* in */ + tm_node_id *node) /* out */ + { task_info *tp; @@ -1085,12 +1099,13 @@ struct reschold ** is available. It returns ERROR_EVENT otherwise. */ int tm_rescinfo( - tm_node_id node, /* in */ - char *resource, /* out */ - int len, /* in */ + + tm_node_id node, /* in */ + char *resource, /* out */ + int len, /* in */ tm_event_t *event) /* out */ - { + { struct reschold *rhold; struct tcp_chan *chan = NULL; @@ -1125,7 +1140,10 @@ int tm_rescinfo( add_event(*event, node, TM_RESOURCES, (void *)rhold); return TM_SUCCESS; - } + } /* END tm_rescinfo() */ + + + /* ** Posts the first of a copy of * within MOM on @@ -1133,13 +1151,13 @@ int tm_rescinfo( ** non-NULL, it returns the event that the effort to post * ** is complete. It returns ERROR_EVENT otherwise. */ -int -tm_publish( - char *name, /* in */ - void *info, /* in */ - int len, /* in */ - tm_event_t *event /* out */ -) +int tm_publish( + + char *name, /* in */ + void *info, /* in */ + int len, /* in */ + tm_event_t *event) /* out */ + { int rc = TM_SUCCESS; struct tcp_chan *chan = NULL; @@ -1173,7 +1191,7 @@ tm_publish( DIS_tcp_cleanup(chan); return rc; - } + } /* tm_publish() */ struct infohold { @@ -1187,18 +1205,18 @@ struct infohold ** is a valid task, it returns the event that the ** string specifying the info posted by is available. */ -int -tm_subscribe( - tm_task_id tid, /* in */ - char *name, /* in */ - void *info, /* out */ - int len, /* in */ - int *info_len, /* out */ - tm_event_t *event /* out */ -) +int tm_subscribe( + + tm_task_id tid, /* in */ + char *name, /* in */ + void *info, /* out */ + int len, /* in */ + int *info_len,/* out */ + tm_event_t *event) /* out */ + { - int rc = TM_SUCCESS; - task_info *tp; + int rc = TM_SUCCESS; + task_info *tp; struct tcp_chan *chan = NULL; struct infohold *ihold; diff --git a/src/lib/Liblog/chk_file_sec.c b/src/lib/Liblog/chk_file_sec.c index 6de0083583..14dd077178 100644 --- a/src/lib/Liblog/chk_file_sec.c +++ b/src/lib/Liblog/chk_file_sec.c @@ -403,13 +403,13 @@ int IamRoot() if (!load_netapi (hNetapi,hAdvapi)) { - log_err(-1, "IamRoot", (char *)"Cann`t load netapi32.dll and advapi32.dll libraries\n"); + log_err(-1, "IamRoot", "Cann`t load netapi32.dll and advapi32.dll libraries\n"); return 0; } if (netgetdcname (NULL, NULL, (void *) &servername) != ERROR_SUCCESS) { - log_err(-1, "IamRoot",(char *)"Cann`t get the name of the primary domain controller\n"); + log_err(-1, "IamRoot","Cann`t get the name of the primary domain controller\n"); } uid=getuid(); @@ -419,14 +419,14 @@ int IamRoot() if ((p = getpwuid(uid))==NULL) { - log_err(-1, "IamRoot", (char *)"WARNING!!! No password entry for currient user. Check your /etc/passwd file.\n"); + log_err(-1, "IamRoot", "WARNING!!! No password entry for currient user. Check your /etc/passwd file.\n"); return 0; } if (check_local_user_privileges(p->pw_name,0) || check_domain_user_privileges(servername,p->pw_name,0)) return 1; - log_err(-1, "IamRoot", (char *)"WARNING!!! Must be run with Administrator privileges.\n"); + log_err(-1, "IamRoot", "WARNING!!! Must be run with Administrator privileges.\n"); return 0; } @@ -458,7 +458,7 @@ int IamUser() return 1; } - log_err(-1, "IamUser", (char *)"WARNING!!! Check your /etc/group and /etc/passwd files.\n"); + log_err(-1, "IamUser", "WARNING!!! Check your /etc/group and /etc/passwd files.\n"); return 0; } /* END IamUser() */ @@ -481,11 +481,11 @@ int IamUserByName(char *userName) if (IamAdminByName(userName)) { sprintf(buff, "WARNING!!! Can`t run job with Administrator privileges. Your should limit preveleges for \"%s\"!",userName); - log_err(-1, "IamUserByName", (char *)buff); + log_err(-1, "IamUserByName", buff); return 0; } sprintf(buff, "WARNING!!! Can`t find user \"%s\"!",userName); - log_err(-1, "IamUserByName", (char *)buff); + log_err(-1, "IamUserByName", buff); return 0; } @@ -525,7 +525,7 @@ int IamRoot() int chk_file_sec( - char *path, /* path to check */ + const char *path, /* path to check */ int isdir, /* 1 = path is directory, 0 = file */ int sticky, /* allow write on directory if sticky set */ int disallow, /* perm bits to disallow */ @@ -763,7 +763,7 @@ int chk_file_sec( } else { - log_err(rc, "chk_file_sec", (char *)"calloc failed"); + log_err(rc, "chk_file_sec", "calloc failed"); } } else diff --git a/src/lib/Liblog/chk_file_sec.h b/src/lib/Liblog/chk_file_sec.h index b853771bb4..11f89e6c6b 100644 --- a/src/lib/Liblog/chk_file_sec.h +++ b/src/lib/Liblog/chk_file_sec.h @@ -16,4 +16,4 @@ int IamUserByName(char *userName); int IamRoot(); #endif -int chk_file_sec( char *path, int isdir, int sticky, int disallow, int fullpath, char *SEMsg); +int chk_file_sec( const char *path, int isdir, int sticky, int disallow, int fullpath, char *SEMsg); diff --git a/src/lib/Liblog/log_event.c b/src/lib/Liblog/log_event.c index ec2d58d722..791f304285 100644 --- a/src/lib/Liblog/log_event.c +++ b/src/lib/Liblog/log_event.c @@ -129,7 +129,7 @@ void log_event( int eventtype, int objclass, const char *objname, - char *text) + const char *text) { if (((eventtype & PBSEVENT_FORCE) == 0) && diff --git a/src/lib/Liblog/log_event.h b/src/lib/Liblog/log_event.h index a22ef7555e..ec57e834ab 100644 --- a/src/lib/Liblog/log_event.h +++ b/src/lib/Liblog/log_event.h @@ -1,4 +1,4 @@ #include "license_pbs.h" /* See here for the software license */ -void log_event(int eventtype, int objclass, const char *objname, char *text); +void log_event(int eventtype, int objclass, const char *objname, const char *text); diff --git a/src/lib/Liblog/pbs_log.c b/src/lib/Liblog/pbs_log.c index e737d87919..9a65939dbb 100644 --- a/src/lib/Liblog/pbs_log.c +++ b/src/lib/Liblog/pbs_log.c @@ -156,17 +156,17 @@ pthread_mutex_t *job_log_mutex; * the order of these names MUST match the defintions of * PBS_EVENTCLASS_* in log.h */ -static char *class_names[] = +static const char *class_names[] = { - (char *)"n/a", - (char *)"Svr", - (char *)"Que", - (char *)"Job", - (char *)"Req", - (char *)"Fil", - (char *)"Act", - (char *)"node", - (char *)"trqauthd" + "n/a", + "Svr", + "Que", + "Job", + "Req", + "Fil", + "Act", + "node", + "trqauthd" }; /* External functions called */ @@ -286,8 +286,8 @@ static char *mk_job_log_name( int log_init( - char *suffix, /* I (optional) */ - char *hostname) /* I (optional) */ + const char *suffix, /* I (optional) */ + const char *hostname) /* I (optional) */ { if (suffix != NULL) @@ -388,8 +388,8 @@ int log_open( log_record( PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, - (char *)"Log", - (char *)"Log opened"); + "Log", + "Log opened"); pthread_mutex_lock(log_mutex); @@ -418,7 +418,7 @@ int job_log_open( if (job_log_opened > 0) { - log_err(-1, (char *)__func__, (char *)"job log already open"); + log_err(-1, __func__, "job log already open"); return(1); /* already open */ } @@ -436,7 +436,7 @@ int job_log_open( else if (*filename != '/') { sprintf(err_log, "must use absolute file path: %s", filename); - log_err(-1, (char *)__func__, err_log); + log_err(-1, __func__, err_log); return(-1); /* must be absolute path */ } @@ -445,7 +445,7 @@ int job_log_open( job_log_opened = -1; /* note that open failed */ sprintf(err_log, "could not open %s ", filename); - log_err(errno, (char *)__func__, err_log); + log_err(errno, __func__, err_log); return(-1); } @@ -456,7 +456,7 @@ int job_log_open( if (job_log_opened < 0) { close(fds); - log_err(errno, __func__, (char *)"failed to dup job log file descriptor"); + log_err(errno, __func__, "failed to dup job log file descriptor"); return(-1); } @@ -707,7 +707,7 @@ const char *log_get_severity_string( /* record job information of completed job to job log */ -int log_job_record(char *buf) +int log_job_record(const char *buf) { struct tm *ptm; struct tm tmpPtm; @@ -727,7 +727,7 @@ int log_job_record(char *buf) if (job_log_opened < 1) { - log_err(-1, __func__, (char *)"job_log_opened < 1"); + log_err(-1, __func__, "job_log_opened < 1"); pthread_mutex_unlock(job_log_mutex); return(-1); } @@ -892,7 +892,7 @@ void log_record( if (logfile != NULL) { pthread_mutex_unlock(log_mutex); - log_err(rc, __func__, (char *)"PBS cannot write to its log"); + log_err(rc, __func__, "PBS cannot write to its log"); fclose(logfile); pthread_mutex_lock(log_mutex); } @@ -928,7 +928,7 @@ void log_close( PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "Log", - (char *)"Log closed"); + "Log closed"); pthread_mutex_lock(log_mutex); } @@ -966,7 +966,7 @@ void job_log_close( PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "Log", - (char *)"Log closed"); + "Log closed"); } fclose(joblogfile); @@ -1197,7 +1197,7 @@ void log_roll( if (err != 0) { - log_err(err, "log_roll", (char *)"error while rollng logs"); + log_err(err, "log_roll", "error while rollng logs"); } else { @@ -1205,7 +1205,7 @@ void log_roll( PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "Log", - (char *)"Log Rolled"); + "Log Rolled"); } return; @@ -1318,7 +1318,7 @@ void job_log_roll( if (err != 0) { - log_err(err, "log_roll", (char *)"error while rollng logs"); + log_err(err, "log_roll", "error while rollng logs"); } else { @@ -1326,7 +1326,7 @@ void job_log_roll( PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "Job Log", - (char *)"Job Log Rolled"); + "Job Log Rolled"); } pthread_mutex_unlock(job_log_mutex); @@ -1365,14 +1365,14 @@ long log_size(void) pthread_mutex_unlock(log_mutex); /* log_err through log_ext will lock the log_mutex, so release log_mutex before calling log_err */ - log_err(errno, "log_size", (char *)"PBS cannot fstat logfile"); + log_err(errno, "log_size", "PBS cannot fstat logfile"); return(0); } if (!log_opened) { pthread_mutex_unlock(log_mutex); - log_err(EAGAIN, "log_size", (char *)"PBS cannot find size of log file because logfile has not been opened"); + log_err(EAGAIN, "log_size", "PBS cannot find size of log file because logfile has not been opened"); return(0); } @@ -1406,7 +1406,7 @@ long job_log_size(void) { /* FAILURE */ - log_err(errno, __func__, (char *)"PBS cannot fstat joblogfile"); + log_err(errno, __func__, "PBS cannot fstat joblogfile"); pthread_mutex_unlock(job_log_mutex); return(0); diff --git a/src/lib/Liblog/pbs_log.h b/src/lib/Liblog/pbs_log.h index 4062e52524..2e7ffe5a90 100644 --- a/src/lib/Liblog/pbs_log.h +++ b/src/lib/Liblog/pbs_log.h @@ -4,19 +4,19 @@ #include "log.h" -int log_init(char *suffix, char *hostname); +int log_init(const char *suffix, const char *hostname); int log_open(char *filename, char *directory); int job_log_open(char *filename, char *directory); -void log_err(int errnum, const char *routine, char *text); +void log_err(int errnum, const char *routine, const char *text); -void log_ext(int errnum, const char *routine, char *text, int severity); +void log_ext(int errnum, const char *routine, const char *text, int severity); -int log_job_record(char *buf); +int log_job_record(const char *buf); -void log_record(int eventtype, int objclass, const char *objname, char *text); +void log_record(int eventtype, int objclass, const char *objname, const char *text); void log_close(int msg); diff --git a/src/lib/Liblog/setup_env.c b/src/lib/Liblog/setup_env.c index fd6884637f..3927f391ae 100644 --- a/src/lib/Liblog/setup_env.c +++ b/src/lib/Liblog/setup_env.c @@ -223,7 +223,7 @@ int setup_env( err: - log_err(-1, "setup_env", (char *)"could not set up the environment"); + log_err(-1, "setup_env", "could not set up the environment"); return(-1); } /* END setup_env() */ diff --git a/src/lib/Liblog/test/chk_file_sec/scaffolding.c b/src/lib/Liblog/test/chk_file_sec/scaffolding.c index 33a0bc6ca7..e52fd685c9 100644 --- a/src/lib/Liblog/test/chk_file_sec/scaffolding.c +++ b/src/lib/Liblog/test/chk_file_sec/scaffolding.c @@ -2,7 +2,7 @@ #include #include -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Liblog/test/log_event/scaffolding.c b/src/lib/Liblog/test/log_event/scaffolding.c index d87b114529..63ebed7559 100644 --- a/src/lib/Liblog/test/log_event/scaffolding.c +++ b/src/lib/Liblog/test/log_event/scaffolding.c @@ -2,7 +2,7 @@ #include #include -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_record needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Liblog/test/pbs_messages/scaffolding.c b/src/lib/Liblog/test/pbs_messages/scaffolding.c index 33a0bc6ca7..e52fd685c9 100644 --- a/src/lib/Liblog/test/pbs_messages/scaffolding.c +++ b/src/lib/Liblog/test/pbs_messages/scaffolding.c @@ -2,7 +2,7 @@ #include #include -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Liblog/test/setup_env/scaffolding.c b/src/lib/Liblog/test/setup_env/scaffolding.c index ba0d21407b..5118f59c6f 100644 --- a/src/lib/Liblog/test/setup_env/scaffolding.c +++ b/src/lib/Liblog/test/setup_env/scaffolding.c @@ -2,7 +2,7 @@ #include #include -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libnet/lib_net.h b/src/lib/Libnet/lib_net.h index 523b82692d..a181ef3200 100644 --- a/src/lib/Libnet/lib_net.h +++ b/src/lib/Libnet/lib_net.h @@ -89,10 +89,10 @@ char *netaddr_pbs_net_t(pbs_net_t ipadd); void net_add_close_func(int, void (*func)(int)); /* from file port_forwarding.c */ -void port_forwarder(struct pfwdsock *socks, int (*connfunc)(char *, int, char *), char *phost, int pport, char *EMsg); +void port_forwarder(struct pfwdsock *socks, int (*connfunc)(char *, long, char *), char *phost, int pport, char *EMsg); void set_nodelay(int fd); int connect_local_xsocket(u_int dnr); -int x11_connect_display(char *display, int alsounused, char *EMsg); +int x11_connect_display(char *display, long alsounused, char *EMsg); /* from file rm.c */ /* static int addrm(int stream); */ diff --git a/src/lib/Libnet/net_server.c b/src/lib/Libnet/net_server.c index 2c9c210fee..063987a73a 100644 --- a/src/lib/Libnet/net_server.c +++ b/src/lib/Libnet/net_server.c @@ -618,7 +618,7 @@ int wait_request( free(SelectSet); - log_err(errno, __func__, (char *)"Unable to select sockets to read requests"); + log_err(errno, __func__, "Unable to select sockets to read requests"); return(-1); } /* END else (errno == EINTR) */ diff --git a/src/lib/Libnet/port_forwarding.c b/src/lib/Libnet/port_forwarding.c index 52cd9cc05d..a4947d51ed 100644 --- a/src/lib/Libnet/port_forwarding.c +++ b/src/lib/Libnet/port_forwarding.c @@ -31,7 +31,7 @@ void port_forwarder( struct pfwdsock *socks, - int (*connfunc)(char *, int, char *), + int (*connfunc)(char *, long, char *), char *phost, int pport, char *EMsg) /* O */ @@ -296,7 +296,7 @@ int connect_local_xsocket( int x11_connect_display( char *display, - int alsounused, + long alsounused, char *EMsg) /* O */ { diff --git a/src/lib/Libnet/rm.c b/src/lib/Libnet/rm.c index e6b7acff27..fe9ae27369 100644 --- a/src/lib/Libnet/rm.c +++ b/src/lib/Libnet/rm.c @@ -190,7 +190,7 @@ int openrm( { if (gotport == 0) { - gotport = get_svrport((char *)PBS_MANAGER_SERVICE_NAME, (char *)"tcp", + gotport = get_svrport(PBS_MANAGER_SERVICE_NAME, "tcp", PBS_MANAGER_SERVICE_PORT); } /* END if (gotport == 0) */ @@ -364,8 +364,6 @@ static int startcom( { /* NOTE: cannot resolve log_err */ - /* log_err(ret,"startcom - diswsi error",(char *)dis_emsg[ret]); */ - *local_errno = errno; } diff --git a/src/lib/Libnet/server_core.c b/src/lib/Libnet/server_core.c index 279a7da387..0f3af256e7 100644 --- a/src/lib/Libnet/server_core.c +++ b/src/lib/Libnet/server_core.c @@ -137,7 +137,7 @@ int start_listener( } pthread_attr_destroy(&t_attr); log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, "net_srvr", - (char *)"Socket close of network listener requested"); + "Socket close of network listener requested"); } close(listen_socket); @@ -271,7 +271,7 @@ int start_listener_addrinfo( } pthread_attr_destroy(&t_attr); log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, "net_srvr", - (char *)"Socket close of network listener requested"); + "Socket close of network listener requested"); } close(listen_socket); diff --git a/src/lib/Libnet/test/get_hostaddr/scaffolding.c b/src/lib/Libnet/test/get_hostaddr/scaffolding.c index 6a9c813c67..23bc5ac2a3 100644 --- a/src/lib/Libnet/test/get_hostaddr/scaffolding.c +++ b/src/lib/Libnet/test/get_hostaddr/scaffolding.c @@ -9,7 +9,7 @@ int pbs_errno; pthread_mutex_t *log_mutex; -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_event needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libnet/test/net_common/scaffolding.c b/src/lib/Libnet/test/net_common/scaffolding.c index aeae21da77..941e5a5883 100644 --- a/src/lib/Libnet/test/net_common/scaffolding.c +++ b/src/lib/Libnet/test/net_common/scaffolding.c @@ -33,6 +33,6 @@ struct sockaddr_in *get_cached_addrinfo( time_t pbs_tcp_timeout; -void log_record(int eventtype, int eventclass, const char *caller, char *msg) +void log_record(int eventtype, int eventclass, const char *caller, const char *msg) { } diff --git a/src/lib/Libnet/test/net_server/scaffolding.c b/src/lib/Libnet/test/net_server/scaffolding.c index 4db42619c7..707e460e3a 100644 --- a/src/lib/Libnet/test/net_server/scaffolding.c +++ b/src/lib/Libnet/test/net_server/scaffolding.c @@ -17,7 +17,7 @@ char *get_cached_nameinfo( return(NULL); } -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_event needs to be mocked!!\n"); exit(1); @@ -47,13 +47,13 @@ int get_fdset_size(void) exit(1); } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); } -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libnet/test/rm/scaffolding.c b/src/lib/Libnet/test/rm/scaffolding.c index f2ee6e6adf..09beb9ce69 100644 --- a/src/lib/Libnet/test/rm/scaffolding.c +++ b/src/lib/Libnet/test/rm/scaffolding.c @@ -7,7 +7,7 @@ int pbs_errno; const char *dis_emsg[10]; -unsigned int get_svrport(char *service_name, char *ptype, unsigned int pdefault) +unsigned int get_svrport(const char *service_name, const char *ptype, unsigned int pdefault) { fprintf(stderr, "The call to get_svrport needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libnet/test/server_core/scaffolding.c b/src/lib/Libnet/test/server_core/scaffolding.c index 9c87047041..45f38d9e27 100644 --- a/src/lib/Libnet/test/server_core/scaffolding.c +++ b/src/lib/Libnet/test/server_core/scaffolding.c @@ -17,7 +17,7 @@ int socket_get_tcp() exit(1); } -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_event needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libsite/test/site_check_u/scaffolding.c b/src/lib/Libsite/test/site_check_u/scaffolding.c index bf36244673..9239e195c2 100644 --- a/src/lib/Libsite/test/site_check_u/scaffolding.c +++ b/src/lib/Libsite/test/site_check_u/scaffolding.c @@ -25,7 +25,7 @@ struct pbsnode *find_nodebyname( char *nodename) exit(1); } -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_event needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libutils/lib_utils.h b/src/lib/Libutils/lib_utils.h index e3795880e6..9c2707cffd 100644 --- a/src/lib/Libutils/lib_utils.h +++ b/src/lib/Libutils/lib_utils.h @@ -104,9 +104,9 @@ int read_tcp_reply(struct tcp_chan *chan, int protocol, int version, int command /* u_mu.c */ int is_whitespace(char c); -int MUSNPrintF(char **BPtr, int *BSpace, char *Format, ...); +int MUSNPrintF(char **BPtr, int *BSpace, const char *Format, ...); -int MUStrNCat(char **BPtr, int *BSpace, char *Src); +int MUStrNCat(char **BPtr, int *BSpace, const char *Src); int MUSleep(long SleepDuration); diff --git a/src/lib/Libutils/test/u_hash_map/scaffolding.c b/src/lib/Libutils/test/u_hash_map/scaffolding.c index a04184e459..4ff3725ceb 100644 --- a/src/lib/Libutils/test/u_hash_map/scaffolding.c +++ b/src/lib/Libutils/test/u_hash_map/scaffolding.c @@ -61,7 +61,7 @@ hash_table_t *create_hash(int size) void free_resizable_array(resizable_array *ra) {} -void log_err(int errnum, const char *routine, char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} int remove_hash(hash_table_t *ht, char *key) { diff --git a/src/lib/Libutils/test/u_lock_ctl/scaffolding.c b/src/lib/Libutils/test/u_lock_ctl/scaffolding.c index 413218a991..e64e112733 100644 --- a/src/lib/Libutils/test/u_lock_ctl/scaffolding.c +++ b/src/lib/Libutils/test/u_lock_ctl/scaffolding.c @@ -2,13 +2,13 @@ #include #include /* fprintf */ -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); } -void log_record(int eventtype, int objclass, char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libutils/test/u_mom_hierarchy/scaffolding.c b/src/lib/Libutils/test/u_mom_hierarchy/scaffolding.c index 1411368266..ae8babb1c8 100644 --- a/src/lib/Libutils/test/u_mom_hierarchy/scaffolding.c +++ b/src/lib/Libutils/test/u_mom_hierarchy/scaffolding.c @@ -64,7 +64,7 @@ long disrsl(int stream, int *retval) exit(1); } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); @@ -82,7 +82,7 @@ int socket_get_tcp_priv() exit(1); } -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { } diff --git a/src/lib/Libutils/test/u_mu/scaffolding.c b/src/lib/Libutils/test/u_mu/scaffolding.c index b3c3994a20..f9f6546081 100644 --- a/src/lib/Libutils/test/u_mu/scaffolding.c +++ b/src/lib/Libutils/test/u_mu/scaffolding.c @@ -2,7 +2,7 @@ #include #include -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libutils/test/u_mu/test_u_mu.h b/src/lib/Libutils/test/u_mu/test_u_mu.h index dfaae70c66..d9bdd7abdd 100644 --- a/src/lib/Libutils/test/u_mu/test_u_mu.h +++ b/src/lib/Libutils/test/u_mu/test_u_mu.h @@ -2,8 +2,7 @@ #ifndef _U_MU_CT_H #define _U_MU_CT_H #include - -char *threadsafe_tokenizer(char **str, char *delims); +#include "utils.h" #define U_MU_SUITE 1 Suite *u_mu_suite(); diff --git a/src/lib/Libutils/test/u_resizable_array/scaffolding.c b/src/lib/Libutils/test/u_resizable_array/scaffolding.c index b3c3994a20..f9f6546081 100644 --- a/src/lib/Libutils/test/u_resizable_array/scaffolding.c +++ b/src/lib/Libutils/test/u_resizable_array/scaffolding.c @@ -2,7 +2,7 @@ #include #include -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libutils/test/u_threadpool/scaffolding.c b/src/lib/Libutils/test/u_threadpool/scaffolding.c index 29593d99b5..4342044c19 100644 --- a/src/lib/Libutils/test/u_threadpool/scaffolding.c +++ b/src/lib/Libutils/test/u_threadpool/scaffolding.c @@ -2,15 +2,15 @@ #include #include -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); } -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libutils/test/u_users/scaffolding.c b/src/lib/Libutils/test/u_users/scaffolding.c index 6ad7eb5088..3c3b18b72a 100644 --- a/src/lib/Libutils/test/u_users/scaffolding.c +++ b/src/lib/Libutils/test/u_users/scaffolding.c @@ -6,7 +6,7 @@ char log_buffer[LOG_BUF_SIZE]; -void log_ext(int errnum, const char *routine, char *text, int severity) +void log_ext(int errnum, const char *routine, const char *text, int severity) { fprintf(stderr, "The call to log_ext needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libutils/test/u_xml/scaffolding.c b/src/lib/Libutils/test/u_xml/scaffolding.c index b6722965d0..2fee93be05 100644 --- a/src/lib/Libutils/test/u_xml/scaffolding.c +++ b/src/lib/Libutils/test/u_xml/scaffolding.c @@ -2,7 +2,7 @@ #include #include -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/lib/Libutils/u_hash_map.c b/src/lib/Libutils/u_hash_map.c index 327f086d55..edb21147db 100644 --- a/src/lib/Libutils/u_hash_map.c +++ b/src/lib/Libutils/u_hash_map.c @@ -182,7 +182,7 @@ int add_to_hash_map( if ((index = insert_thing(hm->hm_ra, obj)) == -1) { rc = ENOMEM; - log_err(rc, __func__, (char *)"Memory failure"); + log_err(rc, __func__, "Memory failure"); } else add_hash(hm->hm_ht, index, key); diff --git a/src/lib/Libutils/u_lock_ctl.c b/src/lib/Libutils/u_lock_ctl.c index ad2c04572f..ee86be5c68 100644 --- a/src/lib/Libutils/u_lock_ctl.c +++ b/src/lib/Libutils/u_lock_ctl.c @@ -84,7 +84,7 @@ int lock_startup() { if (pthread_mutex_lock(locks->startup) != 0) { - log_err(-1,"mutex_lock",(char *)"ALERT: cannot lock startup mutex!\n"); + log_err(-1,"mutex_lock","ALERT: cannot lock startup mutex!\n"); return(PBSE_MUTEX); } } @@ -101,7 +101,7 @@ int unlock_startup() { if (pthread_mutex_unlock(locks->startup) != 0) { - log_err(-1,"mutex_unlock",(char *)"ALERT: cannot unlock startup mutex!\n"); + log_err(-1,"mutex_unlock","ALERT: cannot unlock startup mutex!\n"); return(PBSE_MUTEX); } @@ -124,7 +124,7 @@ int lock_conn_table() if (pthread_mutex_lock(locks->conn_table) != 0) { - log_err(-1,"mutex_lock",(char *)"ALERT: cannot lock conn_table mutex!\n"); + log_err(-1,"mutex_lock","ALERT: cannot lock conn_table mutex!\n"); return(PBSE_MUTEX); } } @@ -140,7 +140,7 @@ int unlock_conn_table() { if (pthread_mutex_unlock(locks->conn_table) != 0) { - log_err(-1, "mutex_unlock", (char *)"ALERT: cannot unlock conn_table mutex!\n"); + log_err(-1, "mutex_unlock", "ALERT: cannot unlock conn_table mutex!\n"); return(PBSE_MUTEX); } @@ -162,7 +162,7 @@ int lock_ss() if (pthread_mutex_lock(locks->setup_save) != 0) { - log_err(-1,"mutex_lock",(char *)"ALERT: cannot lock setup_save mutex!\n"); + log_err(-1,"mutex_lock","ALERT: cannot lock setup_save mutex!\n"); return(PBSE_MUTEX); } } @@ -178,7 +178,7 @@ int unlock_ss() { if (pthread_mutex_unlock(locks->setup_save) != 0) { - log_err(-1,"mutex_unlock",(char *)"ALERT: cannot unlock setup_save mutex!\n"); + log_err(-1,"mutex_unlock","ALERT: cannot unlock setup_save mutex!\n"); return(PBSE_MUTEX); } @@ -192,7 +192,7 @@ int lock_node( struct pbsnode *the_node, const char *id, - char *msg, + const char *msg, int logging) { @@ -233,7 +233,7 @@ int unlock_node( struct pbsnode *the_node, const char *id, - char *msg, + const char *msg, int logging) { diff --git a/src/lib/Libutils/u_lock_ctl.h b/src/lib/Libutils/u_lock_ctl.h index 91fab371fa..7528c11e6f 100644 --- a/src/lib/Libutils/u_lock_ctl.h +++ b/src/lib/Libutils/u_lock_ctl.h @@ -42,9 +42,9 @@ int lock_ss(); int unlock_ss(); -int lock_node(struct pbsnode *the_node, const char *method_name, char *msg, int logging); +int lock_node(struct pbsnode *the_node, const char *method_name, const char *msg, int logging); -int unlock_node(struct pbsnode *the_node, const char *method_name, char *msg, int logging); +int unlock_node(struct pbsnode *the_node, const char *method_name, const char *msg, int logging); int lock_cntr_init(); diff --git a/src/lib/Libutils/u_mom_hierarchy.c b/src/lib/Libutils/u_mom_hierarchy.c index 0a2203112f..bf2d9c5e76 100644 --- a/src/lib/Libutils/u_mom_hierarchy.c +++ b/src/lib/Libutils/u_mom_hierarchy.c @@ -298,26 +298,11 @@ int tcp_connect_sockaddr( char *err_msg = NULL; char local_err_buf[LOCAL_LOG_BUF]; char *tmp_ip = NULL; - /* - int stream = socket(AF_INET,SOCK_STREAM,0); - - if (stream < 0) - { - log_err(errno,id,"Failed when trying to open tcp connection - socket() failed"); - } - else if (setsockopt(stream,SOL_SOCKET,SO_REUSEADDR,&i,sizeof(i)) < 0) - { - log_err(errno,id,"Failed when trying to open tcp connection - setsockopt() failed"); - } - else if (bindresvport(stream,NULL) < 0) - { - log_err(errno,id,"Failed when trying to open tcp connection - bindresvport() failed"); - } - */ + if ((stream = socket_get_tcp_priv()) < 0) { /* FAILED */ - log_err(errno,__func__,(char *)"Failed when trying to get privileged port - socket_get_tcp_priv() failed"); + log_err(errno,__func__,"Failed when trying to get privileged port - socket_get_tcp_priv() failed"); } else if ((rc = socket_connect_addr(&stream, sa, sa_size, 1, &err_msg)) != PBSE_NONE) { diff --git a/src/lib/Libutils/u_mu.c b/src/lib/Libutils/u_mu.c index acccfeaf18..71c698d5be 100644 --- a/src/lib/Libutils/u_mu.c +++ b/src/lib/Libutils/u_mu.c @@ -80,7 +80,7 @@ int MUSNPrintF( char **BPtr, /* I */ int *BSpace, /* I */ - char *Format, /* I */ + const char *Format, /* I */ ...) /* I */ { @@ -128,7 +128,7 @@ int MUSNPrintF( char *threadsafe_tokenizer( char **str, /* M */ - char *delims) /* I */ + const char *delims) /* I */ { char *current_char; @@ -178,7 +178,7 @@ char *threadsafe_tokenizer( int safe_strncat( char *str, - char *to_append, + const char *to_append, size_t space_remaining) { @@ -205,7 +205,7 @@ int MUStrNCat( char **BPtr, /* I (modified) */ int *BSpace, /* I (modified) */ - char *Src) /* I */ + const char *Src) /* I */ { int index; @@ -353,7 +353,7 @@ int write_buffer( } else { - log_err(errno,__func__,(char *)"Unable to write to file or socket"); + log_err(errno,__func__,"Unable to write to file or socket"); return(-1); } diff --git a/src/lib/Libutils/u_resizable_array.c b/src/lib/Libutils/u_resizable_array.c index 74e365764b..eab3918779 100644 --- a/src/lib/Libutils/u_resizable_array.c +++ b/src/lib/Libutils/u_resizable_array.c @@ -147,7 +147,7 @@ int check_and_resize( if ((tmp = (slot *)realloc(ra->slots,size)) == NULL) { - log_err(ENOMEM,__func__,(char *)"No memory left to resize the array"); + log_err(ENOMEM,__func__,"No memory left to resize the array"); return(ENOMEM); } diff --git a/src/lib/Libutils/u_threadpool.c b/src/lib/Libutils/u_threadpool.c index 4b23d14232..f909cb8dc3 100644 --- a/src/lib/Libutils/u_threadpool.c +++ b/src/lib/Libutils/u_threadpool.c @@ -114,7 +114,7 @@ int create_work_thread(void) if ((rc = pthread_attr_init(&attr)) != 0) { perror("pthread_attr_init failed. Could not start worker thread."); - log_err(-1, __func__, (char *)"pthread_attr_init failed. Could not start worker thread."); + log_err(-1, __func__, "pthread_attr_init failed. Could not start worker thread."); return rc; } @@ -227,7 +227,7 @@ static void *work_thread( if (request_pool == NULL) { - log_err(-1,__func__,(char *) "Pool doesn't exist, and thread is active??\nTerminating"); + log_err(-1,__func__, "Pool doesn't exist, and thread is active??\nTerminating"); return(NULL); } @@ -368,7 +368,7 @@ int initialize_threadpool( if ((rc = pthread_attr_init(&(*pool)->tp_attr)) != 0) { perror("pthread_attr_init failed. Could not init thread pool."); - log_err(-1, __func__, (char *)"pthread_attr_init failed. Could not init thread pool."); + log_err(-1, __func__, "pthread_attr_init failed. Could not init thread pool."); return rc; } diff --git a/src/lib/Libutils/u_xml.c b/src/lib/Libutils/u_xml.c index e86cc2723c..2cef9948fa 100644 --- a/src/lib/Libutils/u_xml.c +++ b/src/lib/Libutils/u_xml.c @@ -114,7 +114,7 @@ int get_parent_and_child( if (ptr == NULL) { - log_err(-1, __func__ ,(char *)"No parent tag found\n"); + log_err(-1, __func__ ,"No parent tag found\n"); return(-1); } @@ -158,7 +158,7 @@ int get_parent_and_child( if (child_end == NULL) { - log_err(-1, __func__, (char *)"Cannot find closing tag\n"); + log_err(-1, __func__, "Cannot find closing tag\n"); return(-1); } diff --git a/src/lib/test/scaffolding_lib.c b/src/lib/test/scaffolding_lib.c index 67b4eb9968..bc72aabde5 100644 --- a/src/lib/test/scaffolding_lib.c +++ b/src/lib/test/scaffolding_lib.c @@ -5,27 +5,13 @@ char log_buffer[LOG_BUF_SIZE]; -void log_err(int errnum, const char *routine, char *text) - { - fprintf(stderr, "The call to log_err needs to be mocked!!\n"); - exit(1); - } - -void log_event(int eventtype, int objclass, const char *objname, char *text) - { - fprintf(stderr, "The call to log_event needs to be mocked!!\n"); - exit(1); - } - -void log_ext(int errnum, const char *routine, char *text, int severity) - { - fprintf(stderr, "The call to log_ext needs to be mocked!!\n"); - exit(1); - } - -void log_record(int eventtype, int objclass, const char *objname, char *text) - { - fprintf(stderr, "The call to log_record needs to be mocked!!\n"); - exit(1); - } +void log_err(int errnum, const char *routine, const char *text) {} + +void log_event(int eventtype, int objclass, const char *objname, const char *text) {} + +void log_ext(int errnum, const char *routine, const char *text, int severity) { } + +void log_record(int eventtype, int objclass, const char *objname, const char *text) { } + + diff --git a/src/resmom/alps_reservations.c b/src/resmom/alps_reservations.c index 43ff934a79..00f2eab9fd 100644 --- a/src/resmom/alps_reservations.c +++ b/src/resmom/alps_reservations.c @@ -102,7 +102,7 @@ host_req *get_host_req( char *hostname) { - host_req *hr = calloc(1, sizeof(host_req)); + host_req *hr = (host_req *)calloc(1, sizeof(host_req)); hr->hostname = strdup(hostname); hr->ppn = 1; @@ -133,7 +133,7 @@ resizable_array *parse_exec_hosts( char *host_tok; char *exec_hosts = strdup(exec_hosts_param); char *str_ptr = exec_hosts; - char *delims = "+"; + const char *delims = "+"; char *prev_host_tok = NULL; host_req *hr; resizable_array *host_req_list = initialize_resizable_array(100); diff --git a/src/resmom/catch_child.c b/src/resmom/catch_child.c index e5e823c8c7..b7276626a2 100644 --- a/src/resmom/catch_child.c +++ b/src/resmom/catch_child.c @@ -77,10 +77,10 @@ extern char *PMOMCommand[]; /* external prototypes */ -u_long resc_used(job *, char *, u_long(*f) (resource *)); +u_long resc_used(job *, const char *, u_long(*f) (resource *)); void *preobit_reply (void *); void *obit_reply (void *); -extern u_long addclient (char *); +extern u_long addclient (const char *); extern void encode_used (job *, int, tlist_head *); extern void encode_flagged_attrs (job *, int, tlist_head *); extern void job_nodes (job *); @@ -827,7 +827,7 @@ int run_epilogues( { if (run_pelog(PE_EPILOGUSERJOB, path_epiloguserjob, pjob, io_type) != 0) { - log_err(-1, __func__, (char *)"user local epilog failed"); + log_err(-1, __func__, "user local epilog failed"); } free(path_epiloguserjob); @@ -836,7 +836,7 @@ int run_epilogues( } if (run_pelog(PE_EPILOGUSER, path_epiloguser, pjob, io_type) != 0) - log_err(-1, __func__, (char *)"user epilog failed - interactive job"); + log_err(-1, __func__, "user epilog failed - interactive job"); if ((rc = run_pelog(PE_EPILOG, path_epilog, pjob, io_type)) != 0) { @@ -848,11 +848,11 @@ int run_epilogues( else { if (run_pelog(PE_EPILOGUSER, path_epiloguserp, pjob, io_type) != 0) - log_err(-1, __func__, (char *)"user epilog failed - interactive job"); + log_err(-1, __func__, "user epilog failed - interactive job"); if (run_pelog(PE_EPILOG, path_epilogp, pjob, PE_IO_TYPE_STD) != 0) { - log_err(-1, __func__, (char *)"parallel epilog failed"); + log_err(-1, __func__, "parallel epilog failed"); } } @@ -1136,7 +1136,7 @@ void *preobit_reply( else { log_record( PBSEVENT_DEBUG, PBS_EVENTCLASS_SERVER, __func__, - "DIS_reply_read/decode_DIS_replySvr worked, top of while loop"); + "DIS_reply_read/decode_DIS_replySvr worked, top of while loop"); } /* find the job that triggered this req */ @@ -1295,7 +1295,7 @@ void *preobit_reply( /* parent - mark that job epilog subtask has been launched */ /* NOTE: pjob->ji_mompost will be executed in scan_for_terminated() */ - eji = calloc(1, sizeof(exiting_job_info)); + eji = (exiting_job_info *)calloc(1, sizeof(exiting_job_info)); strcpy(eji->jobid, pjob->ji_qs.ji_jobid); eji->obit_sent = time(NULL); insert_thing(exiting_job_list, eji); @@ -1653,7 +1653,7 @@ void init_abort_jobs( struct dirent *pdirent; job *pj; - char *job_suffix = JOB_FILE_SUFFIX; + const char *job_suffix = JOB_FILE_SUFFIX; int job_suf_len = strlen(job_suffix); char *psuffix; unsigned int momport = 0; @@ -2136,8 +2136,8 @@ int send_job_obit_to_ms( /* If I cannot contact mother superior, kill this job */ if (rc != PBSE_NONE) { - resend_momcomm *mc = calloc(1, sizeof(resend_momcomm)); - killjob_reply_info *kj = calloc(1, sizeof(killjob_reply_info)); + resend_momcomm *mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm)); + killjob_reply_info *kj = (killjob_reply_info *)calloc(1, sizeof(killjob_reply_info)); if (mc == NULL) { diff --git a/src/resmom/checkpoint.c b/src/resmom/checkpoint.c index 240b42d812..54e43c88bf 100644 --- a/src/resmom/checkpoint.c +++ b/src/resmom/checkpoint.c @@ -116,10 +116,10 @@ char restart_script_name[MAXPATHLEN + 1]; char checkpoint_run_exe_name[MAXPATHLEN + 1]; int default_checkpoint_interval = 10; /* minutes */ -extern char *mk_dirs(char *); -extern void set_attr(struct attrl **, char *, char *); +extern char *mk_dirs(const char *); +extern void set_attr(struct attrl **, const char *, const char *); extern int write_nodes_to_file(job *); -extern int write_attr_to_file(job *, int, char *); +extern int write_attr_to_file(job *, int, const char *); int create_missing_files(job *pjob); @@ -128,7 +128,7 @@ int create_missing_files(job *pjob); * for each arg so that the script gets a consistent * command line. */ -#define SET_ARG(x) (((x) == NULL) || (*(x) == 0))?"-":(x) +#define SET_ARG(x) (((x) == NULL) || (*(x) == 0))?(char *)"-":(x) /** @@ -192,7 +192,7 @@ int mom_checkpoint_execute_job( note, this func is called from a child process that exits after the executable is launched, so we don't have to worry about freeing this calloc later */ - arg[1] = calloc(1, strlen(shell) + 1); + arg[1] = (char *)calloc(1, strlen(shell) + 1); if (arg[1] == NULL) { @@ -286,7 +286,7 @@ int mom_checkpoint_init(void) void mom_checkpoint_set_directory_path( - char *str) + const char *str) { char *cp; @@ -303,7 +303,7 @@ void mom_checkpoint_set_directory_path( unsigned long -mom_checkpoint_set_checkpoint_interval(char *value) /* I */ +mom_checkpoint_set_checkpoint_interval(const char *value) /* I */ { log_record( @@ -323,7 +323,7 @@ mom_checkpoint_set_checkpoint_interval(char *value) /* I */ unsigned long mom_checkpoint_set_checkpoint_script( - char *value) /* I */ + const char *value) /* I */ { struct stat sbuf; @@ -352,7 +352,7 @@ unsigned long mom_checkpoint_set_checkpoint_script( unsigned long mom_checkpoint_set_restart_script( - char *value) /* I */ + const char *value) /* I */ { struct stat sbuf; @@ -381,7 +381,7 @@ unsigned long mom_checkpoint_set_restart_script( unsigned long mom_checkpoint_set_checkpoint_run_exe_name( - char *value) /* I */ + const char *value) /* I */ { struct stat sbuf; @@ -812,7 +812,7 @@ void mom_checkpoint_check_periodic_timer( { resource *prwall; - extern int start_checkpoint(); + extern int start_checkpoint(job *pjob, int abort, struct batch_request *preq); int rc; static resource_def *rdwall; @@ -967,8 +967,8 @@ int blcr_checkpoint_job( arg[4] = SET_ARG(pjob->ji_wattr[JOB_ATR_egroup].at_val.at_str); arg[5] = SET_ARG(namebuf); arg[6] = SET_ARG(pjob->ji_wattr[JOB_ATR_checkpoint_name].at_val.at_str); - arg[7] = (abort) ? "15" /*abort*/ : "0" /*run/continue*/; - arg[8] = SET_ARG(csv_find_value(pjob->ji_wattr[JOB_ATR_checkpoint].at_val.at_str, "depth")); + arg[7] = (abort) ? (char *)"15" /*abort*/ : (char *)"0" /*run/continue*/; + arg[8] = SET_ARG(csv_find_value(pjob->ji_wattr[JOB_ATR_checkpoint].at_val.at_str, (char *)"depth")); arg[9] = NULL; /* XXX this should be fixed to make sure there is no chance of a buffer overrun */ @@ -1097,7 +1097,7 @@ int blcr_checkpoint_job( * so it shouldn't have any holds set so we will send "uos" * to clear all holds */ - pbs_rlsjob_err(conn, pjob->ji_qs.ji_jobid, "uos", NULL, &local_errno); + pbs_rlsjob_err(conn, pjob->ji_qs.ji_jobid, (char *)"uos", NULL, &local_errno); } /* END if (abort != 0) */ @@ -1150,7 +1150,7 @@ int blcr_checkpoint_job( err = pbs_alterjob_err(conn, pjob->ji_qs.ji_jobid, attrib, - (request_type == PBS_BATCH_HoldJob) ? CHECKPOINTHOLD : CHECKPOINTCONT, + (request_type == PBS_BATCH_HoldJob) ? (char *)CHECKPOINTHOLD : (char *)CHECKPOINTCONT, &local_errno); if (err != 0) @@ -1561,7 +1561,7 @@ int start_checkpoint( /* Set the address of a function to execute in scan_for_terminated */ - pjob->ji_mompost = (int (*)())post_checkpoint; + pjob->ji_mompost = (int (*)(job *,int))post_checkpoint; if (preq) free_br(preq); /* child will send reply */ @@ -2325,7 +2325,7 @@ int create_missing_files( if (should_have_stdout) { bufsize = strlen(pjob->ji_qs.ji_fileprefix) + strlen(path_spool) + strlen(JOB_STDOUT_SUFFIX) + 1; - namebuf = calloc(bufsize, sizeof(char)); + namebuf = (char *)calloc(bufsize, sizeof(char)); if (namebuf == NULL) { @@ -2361,7 +2361,7 @@ int create_missing_files( if (should_have_stderr) { bufsize = strlen(pjob->ji_qs.ji_fileprefix) + strlen(path_spool) + strlen(JOB_STDOUT_SUFFIX) + 1; - namebuf = calloc(bufsize, sizeof(char)); + namebuf = (char *)calloc(bufsize, sizeof(char)); if (namebuf == NULL) { diff --git a/src/resmom/checkpoint.h b/src/resmom/checkpoint.h index b286714769..56690566b0 100644 --- a/src/resmom/checkpoint.h +++ b/src/resmom/checkpoint.h @@ -12,15 +12,15 @@ int mom_checkpoint_execute_job(job *pjob, char *shell, char *arg[], struct var_t int mom_checkpoint_init(void); -void mom_checkpoint_set_directory_path(char *str); +void mom_checkpoint_set_directory_path(const char *str); -unsigned long mom_checkpoint_set_checkpoint_interval(char *value); +unsigned long mom_checkpoint_set_checkpoint_interval(const char *value); -unsigned long mom_checkpoint_set_checkpoint_script(char *value); +unsigned long mom_checkpoint_set_checkpoint_script(const char *value); -unsigned long mom_checkpoint_set_restart_script(char *value); +unsigned long mom_checkpoint_set_restart_script(const char *value); -unsigned long mom_checkpoint_set_checkpoint_run_exe_name(char *value); +unsigned long mom_checkpoint_set_checkpoint_run_exe_name(const char *value); void get_jobs_default_checkpoint_dir(char *prefix, char *defaultpath); diff --git a/src/resmom/linux/mom_mach.c b/src/resmom/linux/mom_mach.c index 409c74f9c0..19f0fed4e3 100644 --- a/src/resmom/linux/mom_mach.c +++ b/src/resmom/linux/mom_mach.c @@ -141,16 +141,16 @@ extern char path_meminfo[MAX_LINE]; /* ** local functions and data */ -static char *resi (struct rm_attribute *); -static char *totmem (struct rm_attribute *); -static char *availmem (struct rm_attribute *); -static char *physmem (struct rm_attribute *); -static char *ncpus (struct rm_attribute *); -static char *walltime (struct rm_attribute *); -static char *quota (struct rm_attribute *); -static char *netload (struct rm_attribute *); +static const char *resi (struct rm_attribute *); +static const char *totmem (struct rm_attribute *); +static const char *availmem (struct rm_attribute *); +static const char *physmem (struct rm_attribute *); +static const char *ncpus (struct rm_attribute *); +static const char *walltime (struct rm_attribute *); +static const char *quota (struct rm_attribute *); +static const char *netload (struct rm_attribute *); #ifdef NUMA_SUPPORT -static char *cpuact (struct rm_attribute *); +static const char *cpuact (struct rm_attribute *); #endif #ifdef USELIBMEMACCT long long get_memacct_resi(pid_t pid); @@ -163,8 +163,8 @@ extern long get_weighted_memory_size(pid_t); mbool_t ProcIsChild(char *,pid_t,char *); -extern char *loadave(struct rm_attribute *); -extern char *nullproc(struct rm_attribute *); +extern const char *loadave(struct rm_attribute *); +extern const char *nullproc(struct rm_attribute *); time_t wait_time = 10; @@ -301,7 +301,7 @@ proc_stat_t *get_proc_stat( /* FAILURE */ if (!Hertz_errored) - log_err(errno, "get_proc_stat", (char *)"sysconf(_SC_CLK_TCK) failed, unable to monitor processes"); + log_err(errno, "get_proc_stat", "sysconf(_SC_CLK_TCK) failed, unable to monitor processes"); Hertz_errored = 1; @@ -687,13 +687,13 @@ proc_mem_t *get_proc_mem(void) void dep_initialize(void) { - char *id = "dep_initialize"; + const char *id = "dep_initialize"; pagesize = getpagesize(); if ((pdir = opendir(procfs)) == NULL) { - log_err(errno, id, (char *)"opendir"); + log_err(errno, id, "opendir"); return; } @@ -867,7 +867,7 @@ static unsigned long cput_sum( job *pjob) /* I */ { - char *id = "cput_sum"; + const char *id = "cput_sum"; ulong cputime; int nps = 0; int i; @@ -939,7 +939,7 @@ static int overcpu_proc( unsigned long limit) /* I */ { - char *id = "overcpu_proc"; + const char *id = "overcpu_proc"; ulong cputime; pid_t pid; @@ -1029,7 +1029,7 @@ static unsigned long long mem_sum( job *pjob) { - char *id = "mem_sum"; + const char *id = "mem_sum"; int i; unsigned long long segadd; proc_stat_t *ps; @@ -1083,7 +1083,7 @@ static unsigned long long resi_sum( job *pjob) { - char *id = "resi_sum"; + const char *id = "resi_sum"; int i; unsigned long long resisize; proc_stat_t *ps; @@ -1165,7 +1165,7 @@ static int overmem_proc( unsigned long long limit) /* I */ { - char *id = "overmem_proc"; + const char *id = "overmem_proc"; int i; proc_stat_t *ps; @@ -1204,7 +1204,7 @@ extern char *msg_momsetlim; int error( - char *string, + const char *string, int value) { @@ -1257,9 +1257,9 @@ int mom_set_limits( int set_mode) /* SET_LIMIT_SET or SET_LIMIT_ALTER */ { - char *id = "mom_set_limits"; + const char *id = "mom_set_limits"; - char *pname = NULL; + const char *pname = NULL; int retval; unsigned long value; /* place in which to build resource value */ resource *pres; @@ -1708,7 +1708,7 @@ int mom_do_poll( job *pjob) /* I */ { - char *pname; + const char *pname; resource *pres; assert(pjob != NULL); @@ -1766,7 +1766,7 @@ int mom_do_poll( int mom_open_poll(void) { - char *id = "mom_open_poll"; + const char *id = "mom_open_poll"; if (LOGLEVEL >= 6) { @@ -1779,7 +1779,7 @@ int mom_open_poll(void) if (proc_array == NULL) { - log_err(errno, id, (char *)"calloc"); + log_err(errno, id, "calloc"); return(PBSE_SYSTEM); } @@ -1821,7 +1821,7 @@ int mom_open_poll(void) int mom_get_sample(void) { - char *id = "mom_get_sample"; + const char *id = "mom_get_sample"; proc_stat_t *pi; proc_stat_t *ps; @@ -1899,7 +1899,7 @@ int mom_get_sample(void) if (hold == NULL) { - log_err(errno, id, (char *)"unable to realloc space for proc_array sample"); + log_err(errno, id, "unable to realloc space for proc_array sample"); return(PBSE_SYSTEM); } @@ -1948,7 +1948,7 @@ int mom_over_limit( #ifdef PENABLE_LINUX26_CPUSETS static char *id = "mom_over_limit"; #endif - char *pname; + const char *pname; int retval; unsigned long value; unsigned long num; @@ -2317,7 +2317,7 @@ int kill_task( int pg) /* I (1=signal process group, 0=signal master process only) */ { - char *id = "kill_task"; + const char *id = "kill_task"; int ct = 0; /* num of processes killed */ int NumProcessesFound = 0; /* number of processes found with session ID */ @@ -2664,7 +2664,7 @@ int kill_task( int mom_close_poll(void) { - char *id = "mom_close_poll"; + const char *id = "mom_close_poll"; if (LOGLEVEL >= 6) { @@ -2679,7 +2679,7 @@ int mom_close_poll(void) { if (closedir(pdir) != 0) { - log_err(errno, id, (char *)"closedir"); + log_err(errno, id, "closedir"); return(PBSE_SYSTEM); } @@ -2755,7 +2755,7 @@ char *cput_job( pid_t jobid) { - char *id = "cput_job"; + const char *id = "cput_job"; int found = 0; int i; @@ -2820,7 +2820,7 @@ char *cput_proc( pid_t pid) { - char *id = "cput_proc"; + const char *id = "cput_proc"; double cputime; proc_stat_t *ps; @@ -2853,12 +2853,12 @@ char *cput_proc( -char *cput( +const char *cput( struct rm_attribute *attrib) { - char *id = "cput"; + const char *id = "cput"; int value; if (attrib == NULL) @@ -2964,7 +2964,7 @@ char *mem_proc( pid_t pid) { - char *id = "mem_proc"; + const char *id = "mem_proc"; proc_stat_t *ps; if ((ps = get_proc_stat(pid)) == NULL) @@ -2993,12 +2993,12 @@ char *mem_proc( -char *mem( +const char *mem( struct rm_attribute *attrib) { - char *id = "mem"; + const char *id = "mem"; int value; if (attrib == NULL) @@ -3057,7 +3057,7 @@ static char *resi_job( pid_t jobid) { - char *id = "resi_job"; + const char *id = "resi_job"; int i; int found = 0; unsigned long long resisize; @@ -3129,7 +3129,7 @@ static char *resi_proc( pid_t pid) { - char *id = "resi_proc"; + const char *id = "resi_proc"; proc_stat_t *ps; #ifdef USELIBMEMACCT @@ -3172,12 +3172,12 @@ static char *resi_proc( -static char *resi( +static const char *resi( struct rm_attribute *attrib) { - char *id = "resi"; + const char *id = "resi"; int value; if (attrib == NULL) @@ -3227,12 +3227,12 @@ static char *resi( -char *sessions( +const char *sessions( struct rm_attribute *attrib) /* I */ { - char *id = "sessions"; + const char *id = "sessions"; int nsids = 0; pid_t sid; char *s; @@ -3344,7 +3344,7 @@ char *sessions( /* not found */ if ((sp = (struct pidl *)calloc(1, sizeof(struct pidl))) == NULL) { - log_err(errno, id, (char *)"no memory"); + log_err(errno, id, "no memory"); rm_errno = RM_ERR_SYSTEM; if (sids) free_pidlist(sids); @@ -3403,12 +3403,13 @@ char *sessions( -char *nsessions( +const char *nsessions( struct rm_attribute *attrib) { - char *result, *ch; + const char *result; + const char *ch; int num; if ((result = sessions(attrib)) == NULL) @@ -3436,12 +3437,12 @@ char *nsessions( -char *pids( +const char *pids( struct rm_attribute *attrib) /* I */ { - char *id = "pids"; + const char *id = "pids"; pid_t jobid; proc_stat_t *ps; char *fmt; @@ -3527,12 +3528,12 @@ char *pids( -char *nusers( +const char *nusers( struct rm_attribute *attrib) { - char *id = "nusers"; + const char *id = "nusers"; int j; int nuids = 0; uid_t *uids, *hold; @@ -3640,7 +3641,7 @@ char *nusers( if (hold == NULL) { - log_err(errno, id, (char *)"realloc"); + log_err(errno, id, "realloc"); rm_errno = RM_ERR_SYSTEM; @@ -3684,12 +3685,12 @@ char *nusers( -static char *totmem( +const char *totmem( struct rm_attribute *attrib) { - char *id = "totmem"; + const char *id = "totmem"; proc_mem_t *mm; if (attrib) @@ -3703,7 +3704,7 @@ static char *totmem( if ((mm = get_proc_mem()) == NULL) { - log_err(errno, id, (char *)"get_proc_mem"); + log_err(errno, id, "get_proc_mem"); rm_errno = RM_ERR_SYSTEM; @@ -3730,12 +3731,12 @@ static char *totmem( -static char *availmem( +const char *availmem( struct rm_attribute *attrib) { - char *id = "availmem"; + const char *id = "availmem"; proc_mem_t *mm; if (attrib != NULL) @@ -3749,7 +3750,7 @@ static char *availmem( if ((mm = get_proc_mem()) == NULL) { - log_err(errno, id, (char *)"get_proc_mem"); + log_err(errno, id, "get_proc_mem"); rm_errno = RM_ERR_SYSTEM; @@ -3775,7 +3776,7 @@ static char *availmem( -static char *ncpus( +const char *ncpus( struct rm_attribute *attrib) @@ -3784,7 +3785,7 @@ static char *ncpus( /* report the configured ncpus for this numa node */ sprintf(ret_string,"%d",node_boards[numa_index].num_cpus); #else - char *id = "ncpus"; + const char *id = "ncpus"; char label[128]; FILE *fp; int procs; @@ -3905,12 +3906,12 @@ int find_file( -static char *physmem( +static const char *physmem( struct rm_attribute *attrib) { - char *id = "physmem"; + const char *id = "physmem"; char tmpBuf[PMEMBUF_SIZE]; char *BPtr; @@ -4022,7 +4023,7 @@ char *size_fs( char *param) { - char *id = "size_fs"; + const char *id = "size_fs"; struct statfs fsbuf; @@ -4041,7 +4042,7 @@ char *size_fs( if (statfs(param, &fsbuf) == -1) { - log_err(errno, id, (char *)"statfs"); + log_err(errno, id, "statfs"); rm_errno = RM_ERR_BADPARAM; @@ -4069,7 +4070,7 @@ char *size_file( char *param) { - char *id = "size_file"; + const char *id = "size_file"; struct stat sbuf; @@ -4087,7 +4088,7 @@ char *size_file( if (stat(param, &sbuf) == -1) { - log_err(errno, id, (char *)"stat"); + log_err(errno, id, "stat"); rm_errno = RM_ERR_BADPARAM; @@ -4104,12 +4105,12 @@ char *size_file( -char *size( +const char *size( struct rm_attribute *attrib) { - char *id = "size"; + const char *id = "size"; char *param; if (attrib == NULL) @@ -4158,22 +4159,23 @@ char *size( void scan_non_child_tasks(void) { - char *id = "scan_non_child_tasks"; + const char *id = "scan_non_child_tasks"; - job *job; + job *pJob; static int first_time = TRUE; DIR *pdir; /* use local pdir to prevent race conditions associated w/global pdir (VPAC) */ pdir = opendir("/proc"); - for (job = GET_NEXT(svr_alljobs);job != NULL;job = GET_NEXT(job->ji_alljobs)) + for (pJob = (job *)(GET_NEXT(svr_alljobs)); + pJob != (job *)NULL;pJob = (job *)(GET_NEXT(pJob->ji_alljobs))) { - task *task; + task *pTask; - for (task = GET_NEXT(job->ji_tasks); - task != NULL; - task = GET_NEXT(task->ti_jobtask)) + for (pTask = (task *)(GET_NEXT(pJob->ji_tasks)); + pTask != NULL; + pTask = (task *)(GET_NEXT(pTask->ti_jobtask))) { #ifdef PENABLE_LINUX26_CPUSETS struct pidl *pids = NULL; @@ -4189,25 +4191,25 @@ void scan_non_child_tasks(void) * Check for tasks that were exiting when mom went down, set back to * running so we can reprocess them and send the obit */ - if ((first_time) && (task->ti_qs.ti_sid != 0) && - ((task->ti_qs.ti_status == TI_STATE_EXITED) || - (task->ti_qs.ti_status == TI_STATE_DEAD))) + if ((first_time) && (pTask->ti_qs.ti_sid != 0) && + ((pTask->ti_qs.ti_status == TI_STATE_EXITED) || + (pTask->ti_qs.ti_status == TI_STATE_DEAD))) { if (LOGLEVEL >= 7) { sprintf(log_buffer, "marking task %d as TI_STATE_RUNNING was %d", - task->ti_qs.ti_task, - task->ti_qs.ti_status); + pTask->ti_qs.ti_task, + pTask->ti_qs.ti_status); - log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, job->ji_qs.ji_jobid, log_buffer); + log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, pJob->ji_qs.ji_jobid, log_buffer); } - task->ti_qs.ti_status = TI_STATE_RUNNING; + pTask->ti_qs.ti_status = TI_STATE_RUNNING; } /* only check on tasks that we think should still be around */ - if (task->ti_qs.ti_status != TI_STATE_RUNNING) + if (pTask->ti_qs.ti_status != TI_STATE_RUNNING) continue; /* look for processes with this session id */ @@ -4216,7 +4218,7 @@ void scan_non_child_tasks(void) /* NOTE: on linux systems, the session master should have pid == sessionid */ - if (kill(task->ti_qs.ti_sid, 0) != -1) + if (kill(pTask->ti_qs.ti_sid, 0) != -1) { found = 1; } @@ -4224,7 +4226,7 @@ void scan_non_child_tasks(void) { /* session master cannot be found, look for other pid in session */ #ifdef PENABLE_LINUX26_CPUSETS - pids = get_cpuset_pidlist(job->ji_qs.ji_jobid, pids); + pids = get_cpuset_pidlist(pJob->ji_qs.ji_jobid, pids); pp = pids; while (pp != NULL) { @@ -4245,7 +4247,7 @@ void scan_non_child_tasks(void) if ((ps = get_proc_stat(pid)) == NULL) continue; - if (ps->session == task->ti_qs.ti_sid) + if (ps->session == pTask->ti_qs.ti_sid) { found = 1; @@ -4264,28 +4266,28 @@ void scan_non_child_tasks(void) extern int exiting_tasks; sprintf(buf, "found exited session %d for task %d in job %s", - task->ti_qs.ti_sid, - task->ti_qs.ti_task, - job->ji_qs.ji_jobid); + pTask->ti_qs.ti_sid, + pTask->ti_qs.ti_task, + pJob->ji_qs.ji_jobid); log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, id, buf); - task->ti_qs.ti_exitstat = 0; /* actually unknown */ - task->ti_qs.ti_status = TI_STATE_EXITED; + pTask->ti_qs.ti_exitstat = 0; /* actually unknown */ + pTask->ti_qs.ti_status = TI_STATE_EXITED; - task_save(task); + task_save(pTask); #ifdef USESAVEDRESOURCES if (first_time) { - job->ji_flags |= MOM_JOB_RECOVERY; + pJob->ji_flags |= MOM_JOB_RECOVERY; if (LOGLEVEL >= 7) { sprintf(buf, "marking job as MOM_JOB_RECOVERY for task %d", - task->ti_qs.ti_task); + pTask->ti_qs.ti_task); - log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, job->ji_qs.ji_jobid, buf); + log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, pJob->ji_qs.ji_jobid, buf); } } #endif /* USESAVEDRESOURCES */ @@ -4311,7 +4313,7 @@ time_t maxtm; void setmax( - char *dev) + const char *dev) { @@ -4331,12 +4333,12 @@ void setmax( -char *idletime( +const char *idletime( struct rm_attribute *attrib) { - char *id = "idletime"; + const char *id = "idletime"; DIR *dp; struct dirent *de; @@ -4354,7 +4356,7 @@ char *idletime( if ((dp = opendir("/dev")) == NULL) { - log_err(errno, id, (char *)"opendir /dev"); + log_err(errno, id, "opendir /dev"); rm_errno = RM_ERR_SYSTEM; @@ -4392,12 +4394,12 @@ char *idletime( -static char *walltime( +static const char *walltime( struct rm_attribute *attrib) { - char *id = "walltime"; + const char *id = "walltime"; int value, job, found = 0; time_t now, start; proc_stat_t *ps; @@ -4451,7 +4453,7 @@ static char *walltime( if ((now = time(NULL)) <= 0) { - log_err(errno, id, (char *)"time"); + log_err(errno, id, "time"); rm_errno = RM_ERR_SYSTEM; @@ -4503,7 +4505,7 @@ int get_la( { FILE *fp; - char *id = "get_la"; + const char *id = "get_la"; float load; if ((fp = fopen("/proc/loadavg", "r")) == NULL) @@ -4516,7 +4518,7 @@ int get_la( if (fscanf(fp, "%f", &load) != 1) { - log_err(errno, id, (char *)"fscanf of load in /proc/loadavg"); + log_err(errno, id, "fscanf of load in /proc/loadavg"); fclose(fp); @@ -4593,7 +4595,7 @@ void collect_cpuact(void) { if ((cpu_array = (proc_cpu_t *)calloc(system_ncpus, sizeof(proc_cpu_t))) == NULL) { - log_err(errno, id, (char *)"failed to allocate memory"); + log_err(errno, id, "failed to allocate memory"); return; } } @@ -4716,12 +4718,12 @@ u_long gracetime( -static char *quota( +static const char *quota( struct rm_attribute *attrib) { - char *id = "quota"; + const char *id = "quota"; int type; dev_t dirdev; uid_t uid; @@ -4735,16 +4737,16 @@ static char *quota( struct passwd *pw; - static char *type_array[] = + static const char *type_array[] = { - "harddata", - "softdata", - "currdata", - "hardfile", - "softfile", - "currfile", - "timedata", - "timefile", + "harddata", + "softdata", + "currdata", + "hardfile", + "softfile", + "currfile", + "timedata", + "timefile", NULL }; @@ -4848,7 +4850,7 @@ static char *quota( if ((m = setmntent(MOUNTED, "r")) == NULL) { - log_err(errno, id, (char *)"setmntent"); + log_err(errno, id, "setmntent"); rm_errno = RM_ERR_SYSTEM; return NULL; } @@ -4932,7 +4934,7 @@ static char *quota( uid, (caddr_t)&qi) == -1) { - log_err(errno, id, (char *)"quotactl"); + log_err(errno, id, "quotactl"); rm_errno = RM_ERR_SYSTEM; @@ -5019,7 +5021,7 @@ static char *quota( #define HEADER_STR "%*[^\n]\n%*[^\n]\n" #define INTERFACE_STR "%[^:]:%lu %*d %*d %*d %*d %*d %*d %*d %lu %*d %*d %*d %*d %*d %*d %*d\n" -static char *netload( +static const char *netload( struct rm_attribute *attrib) @@ -5037,7 +5039,7 @@ static char *netload( int interface = 0; /* int ethNum = 0; */ - char *id = "netload"; + const char *id = "netload"; if ((fp = fopen("/proc/net/dev", "r")) == NULL) { @@ -5050,7 +5052,7 @@ static char *netload( if (rc < 0) { - log_err(errno, id, (char *)"fscanf of header lines in /proc/net/dev"); + log_err(errno, id, "fscanf of header lines in /proc/net/dev"); fclose(fp); diff --git a/src/resmom/linux/mom_start.c b/src/resmom/linux/mom_start.c index 6993afd703..aa74fbf292 100644 --- a/src/resmom/linux/mom_start.c +++ b/src/resmom/linux/mom_start.c @@ -503,7 +503,7 @@ int open_master( if (status < 0) { - log_err(errno, "open_master", (char *)"failed in openpty()"); + log_err(errno, "open_master", "failed in openpty()"); return(-1); } @@ -609,5 +609,5 @@ struct sig_tbl sig_tbl[] = { "WINCH", SIGWINCH }, { "USR1", SIGUSR1 }, { "USR2", SIGUSR2 }, - {(char *)0, -1 } + { NULL, -1 } }; diff --git a/src/resmom/linux/test/mom_mach/scaffolding.c b/src/resmom/linux/test/mom_mach/scaffolding.c index f0d5849a63..09bcbbe10a 100644 --- a/src/resmom/linux/test/mom_mach/scaffolding.c +++ b/src/resmom/linux/test/mom_mach/scaffolding.c @@ -27,7 +27,7 @@ resource_def *svr_resc_def; int ignvmem = 0; char *msg_momsetlim = "Job start failed. Can't set \"%s\" limit: %s.\n"; tlist_head svr_alljobs; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int ignwalltime = 0; int rm_errno; @@ -46,7 +46,7 @@ void checkret(char **spot, long len) exit(1); } -char *nullproc(struct rm_attribute *attrib) +const char *nullproc(struct rm_attribute *attrib) { fprintf(stderr, "The call to nullproc needs to be mocked!!\n"); exit(1); @@ -70,7 +70,7 @@ void free_pidlist(struct pidl *pl) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def needs to be mocked!!\n"); exit(1); @@ -100,7 +100,7 @@ resource *find_resc_entry(pbs_attribute *pattr, resource_def *rscdf) exit(1); } -char *loadave(struct rm_attribute *attrib) +const char *loadave(struct rm_attribute *attrib) { fprintf(stderr, "The call to loadave needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/linux/test/mom_start/scaffolding.c b/src/resmom/linux/test/mom_start/scaffolding.c index 70c0f8ca07..9670c7ae27 100644 --- a/src/resmom/linux/test/mom_start/scaffolding.c +++ b/src/resmom/linux/test/mom_start/scaffolding.c @@ -18,7 +18,7 @@ char mom_host[PBS_MAXHOSTNAME + 1]; unsigned int pbs_rm_port = 0; tlist_head svr_alljobs; char noglobid[] = "none"; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *AllocParCmd = NULL; diff --git a/src/resmom/mom_comm.c b/src/resmom/mom_comm.c index 1a5eb76085..5abd9eeef7 100644 --- a/src/resmom/mom_comm.c +++ b/src/resmom/mom_comm.c @@ -161,8 +161,8 @@ unsigned long ssa_size; resizable_array *received_statuses; /* holds information on node's whose statuses we've received */ hash_table_t *received_table; int updates_waiting_to_send = 0; -time_t LastServerUpdateTime; -int ServerStatUpdateInterval; +extern time_t LastServerUpdateTime; +extern int ServerStatUpdateInterval; extern struct connection svr_conn[]; const char *PMOMCommand[] = @@ -295,7 +295,7 @@ int task_save( if (fds < 0) { - log_err(errno, __func__, (char *)"error on open"); + log_err(errno, __func__, "error on open"); return(-1); } @@ -315,7 +315,7 @@ int task_save( if (lseek(fds, (off_t)(TaskID*sizeof(ptask->ti_qs)), SEEK_SET) < 0) #endif { - log_err(errno, __func__, (char *)"lseek"); + log_err(errno, __func__, "lseek"); close(fds); @@ -328,10 +328,7 @@ int task_save( /* just write the "critical" base structure to the file */ - while ((i = write( - fds, - (char *) & ptask->ti_qs, - sizeof(ptask->ti_qs))) != sizeof(ptask->ti_qs)) + while ((i = write(fds,&ptask->ti_qs,sizeof(ptask->ti_qs)) ) != sizeof(ptask->ti_qs)) { if ((i < 0) && (errno == EINTR)) { @@ -343,7 +340,7 @@ int task_save( if (lseek(fds, (off_t)(TaskID*sizeof(ptask->ti_qs)), SEEK_SET) < 0) #endif { - log_err(errno, __func__, (char *)"lseek"); + log_err(errno, __func__, "lseek"); close(fds); @@ -353,7 +350,7 @@ int task_save( continue; } - log_err(errno, __func__, (char *)"quickwrite"); + log_err(errno, __func__, "quickwrite"); close(fds); @@ -442,7 +439,7 @@ task *pbs_task_create( { sprintf(log_buffer, "Ran into reserved task IDs on job %s", pjob->ji_qs.ji_jobid); - log_err(-1, __func__, (char *)log_buffer); + log_err(-1, __func__, log_buffer); return(NULL); } @@ -458,7 +455,7 @@ task *pbs_task_create( * be in production code, so I figure this is better than that --dbeer */ if (rd == NULL) { - log_err(-1, __func__, (char *)"No tasks per node resource definition? TORQUE is very broken!"); + log_err(-1, __func__, "No tasks per node resource definition? TORQUE is very broken!"); return(NULL); } @@ -476,7 +473,7 @@ task *pbs_task_create( if (ptask == NULL) { - log_err(ENOMEM, __func__, (char *)"No memory to allocate task! IMMINENT FAILURE"); + log_err(ENOMEM, __func__, "No memory to allocate task! IMMINENT FAILURE"); return(NULL); } @@ -601,7 +598,7 @@ int task_recov( char namebuf[MAXPATHLEN]; char portname[MAXPATHLEN]; - struct taskfix task_save; + taskfix task_save; tm_task_id tid; strcpy(namebuf, path_jobs); /* job directory path */ @@ -623,7 +620,7 @@ int task_recov( if (fds < 0) { - log_err(errno, __func__, (char *)"open of task file"); + log_err(errno, __func__, "open of task file"); unlink(namebuf); @@ -650,7 +647,7 @@ int task_recov( if ((pt = pbs_task_create(pjob, tid)) == NULL) { - log_err(errno, __func__, (char *)"cannot create task"); + log_err(errno, __func__, "cannot create task"); close(fds); @@ -913,7 +910,7 @@ int send_sisters( if (IS_VALID_STREAM(local_socket) == FALSE) { - if ((mc = calloc(1, sizeof(resend_momcomm))) != NULL) + if ((mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm))) != NULL) { mc->mc_type = COMPOSE_REPLY; mc->mc_struct = create_compose_reply_info(pjob->ji_qs.ji_jobid, cookie, np, com, TM_NULL_EVENT, TM_NULL_TASK); @@ -951,7 +948,7 @@ int send_sisters( if (ret != DIS_SUCCESS) { - if ((mc = calloc(1, sizeof(resend_momcomm))) != NULL) + if ((mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm))) != NULL) { mc->mc_type = COMPOSE_REPLY; mc->mc_struct = create_compose_reply_info(pjob->ji_qs.ji_jobid, cookie, np, com, TM_NULL_EVENT, TM_NULL_TASK); @@ -1007,7 +1004,7 @@ hnodent *find_node( if (getpeername(stream,&connecting_stack_addr,&len) != 0) { - log_err(errno, __func__, (char *)"Couldn't find connecting information for this stream"); + log_err(errno, __func__, "Couldn't find connecting information for this stream"); return(NULL); } @@ -1466,7 +1463,7 @@ int check_ms( if (pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) { - log_err(-1, __func__, (char *)"Mother Superior talking to herself"); + log_err(-1, __func__, "Mother Superior talking to herself"); return(TRUE); } @@ -1481,7 +1478,7 @@ int check_ms( u_long resc_used( job *pjob, - char *name, + const char *name, u_long(*func)(resource *)) { @@ -1602,8 +1599,9 @@ char *resc_string( svrattrl *pal; tlist_head lhead; int len, used, tot; - char *res_str, *ch; - char *getuname(); + char *res_str; + const char *ch; + const char *getuname(); int resc_access_perm = ATR_DFLAG_USRD; char *tmpResStr; @@ -1664,7 +1662,7 @@ char *resc_string( { tot *= 2; - tmpResStr = calloc(1, tot); + tmpResStr = (char *)calloc(1, tot); if (tmpResStr == NULL) { @@ -1899,7 +1897,7 @@ void send_im_error( { resend_momcomm *mc; - if ((mc = calloc(1, sizeof(resend_momcomm))) != NULL) + if ((mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm))) != NULL) { mc->mc_type = COMPOSE_REPLY; mc->mc_struct = create_compose_reply_info(pjob->ji_qs.ji_jobid, @@ -1988,7 +1986,7 @@ int reply_to_join_job_as_sister( if (ret != DIS_SUCCESS) { - resend_momcomm *mc = calloc(1, sizeof(resend_momcomm)); + resend_momcomm *mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm)); im_compose_info *ici; if (mc != NULL) @@ -2382,7 +2380,7 @@ int im_join_job_as_sister( sprintf(log_buffer, "Could not create cpuset for job %s.\n", pjob->ji_qs.ji_jobid); - log_err(-1, __func__, (char *)log_buffer); + log_err(-1, __func__, log_buffer); } } @@ -2411,7 +2409,7 @@ int im_join_job_as_sister( { send_im_error(PBSE_SYSTEM,1,pjob,cookie,event,fromtask); - log_err(-1, __func__, (char *)"cannot load sp switch table"); + log_err(-1, __func__, "cannot load sp switch table"); mom_job_purge(pjob); @@ -2762,7 +2760,7 @@ int im_spawn_task( if (i == num - 1) { - char **tmp = calloc(num * 2, sizeof(char **)); + char **tmp = (char **)calloc(num * 2, sizeof(char **)); if (tmp == NULL) { @@ -2888,10 +2886,10 @@ int im_spawn_task( resend_momcomm *mc; spawn_task_info *st; - if ((mc = calloc(1, sizeof(resend_momcomm))) != NULL) + if ((mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm))) != NULL) { mc->mc_type = COMPOSE_REPLY; - st = calloc(1, sizeof(spawn_task_info)); + st = (spawn_task_info *)calloc(1, sizeof(spawn_task_info)); if (st != NULL) { @@ -3065,7 +3063,7 @@ int im_signal_task( if (ret != DIS_SUCCESS) { - resend_momcomm *mc = calloc(1, sizeof(resend_momcomm)); + resend_momcomm *mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm)); if (mc != NULL) { @@ -3173,12 +3171,12 @@ int im_obit_task( if (ret != DIS_SUCCESS) { - resend_momcomm *mc = calloc(1, sizeof(resend_momcomm)); + resend_momcomm *mc = (resend_momcomm *)calloc(1, sizeof(resend_momcomm)); obit_task_info *ot; if (mc != NULL) { - if ((ot = calloc(1, sizeof(obit_task_info))) == NULL) + if ((ot = (obit_task_info *)calloc(1, sizeof(obit_task_info))) == NULL) { free(mc); } @@ -3211,7 +3209,7 @@ int im_obit_task( if (op == NULL) { - log_err(ENOMEM, __func__, (char *)"Cannot allocate memory for the obit entry"); + log_err(ENOMEM, __func__, "Cannot allocate memory for the obit entry"); } else { @@ -3328,7 +3326,7 @@ int im_get_info( else if ((ret = im_compose(local_chan,jobid,cookie,IM_ALL_OKAY,event,fromtask)) != DIS_SUCCESS) { } - else if ((ret = diswcs(local_chan, ip->ie_info, ip->ie_len)) != DIS_SUCCESS) + else if ((ret = diswcs(local_chan, (const char *)ip->ie_info, ip->ie_len)) != DIS_SUCCESS) { } else @@ -3630,7 +3628,7 @@ int im_get_tid( if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0) { - log_err(-1, __func__, (char *)"got GET_TID and I'm not MS"); + log_err(-1, __func__, "got GET_TID and I'm not MS"); return(IM_FAILURE); } @@ -3649,7 +3647,7 @@ int im_get_tid( if (IS_ADOPTED_TASK(pjob->ji_taskid)) { - log_err(-1, __func__, (char *)"Ran into reserved task ids"); + log_err(-1, __func__, "Ran into reserved task ids"); return(IM_FAILURE); } @@ -3703,7 +3701,7 @@ int handle_im_join_job_response( if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0) { - log_err(-1, __func__, (char *)"got JOIN_JOB OKAY and I'm not MS"); + log_err(-1, __func__, "got JOIN_JOB OKAY and I'm not MS"); return(IM_FAILURE); } @@ -3801,7 +3799,7 @@ int handle_im_kill_job_response( if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0) { - log_err(-1, __func__, (char *)"got KILL_JOB OKAY and I'm not MS"); + log_err(-1, __func__, "got KILL_JOB OKAY and I'm not MS"); return(IM_FAILURE); } @@ -4239,7 +4237,7 @@ int handle_im_poll_job_response( if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0) { - log_err(-1, __func__, (char *)"got POLL_JOB and I'm not MS"); + log_err(-1, __func__, "got POLL_JOB and I'm not MS"); return(IM_FAILURE); } @@ -4632,7 +4630,7 @@ void im_request( { long max_len = 1024; long final_len = 0; - char *tmp_line = calloc(1, max_len + 1); + char *tmp_line = (char *)calloc(1, max_len + 1); close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; @@ -4922,7 +4920,7 @@ void im_request( if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"im_spawn_task error"); + log_err(-1, __func__, "im_spawn_task error"); goto err; } @@ -4935,7 +4933,7 @@ void im_request( if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"im_signal_task error"); + log_err(-1, __func__, "im_signal_task error"); goto err; } @@ -4948,7 +4946,7 @@ void im_request( if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"im_obit_task error"); + log_err(-1, __func__, "im_obit_task error"); goto err; } @@ -4961,7 +4959,7 @@ void im_request( if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"im_get_info error"); + log_err(-1, __func__, "im_get_info error"); goto err; } @@ -4974,7 +4972,7 @@ void im_request( if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"im_get_resc_as_sister error"); + log_err(-1, __func__, "im_get_resc_as_sister error"); goto err; } @@ -4989,7 +4987,7 @@ void im_request( close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; - log_err(-1, __func__, (char *)"check_ms error IM_POLL_JOB"); + log_err(-1, __func__, "check_ms error IM_POLL_JOB"); goto err; } @@ -5010,7 +5008,7 @@ void im_request( close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; - log_err(-1, __func__, (char *)"check_ms error IM_ABORT_JOB"); + log_err(-1, __func__, "check_ms error IM_ABORT_JOB"); goto err; } @@ -5026,7 +5024,7 @@ void im_request( close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; - log_err(-1, __func__, (char *)"im_get_tid error"); + log_err(-1, __func__, "im_get_tid error"); goto err; } @@ -5047,7 +5045,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_join_job_response error"); + log_err(-1, __func__, "handle_im_join_job_response error"); goto err; } @@ -5060,7 +5058,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_kill_job_response error"); + log_err(-1, __func__, "handle_im_kill_job_response error"); goto err; } @@ -5072,7 +5070,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_spawn_task_response error"); + log_err(-1, __func__, "handle_im_spawn_task_response error"); goto err; } @@ -5084,7 +5082,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_get_tasks_response error"); + log_err(-1, __func__, "handle_im_get_tasks_response error"); goto err; } @@ -5096,7 +5094,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_signal_task_response error"); + log_err(-1, __func__, "handle_im_signal_task_response error"); goto err; } @@ -5108,7 +5106,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_obit_task_response error"); + log_err(-1, __func__, "handle_im_obit_task_response error"); goto err; } @@ -5120,7 +5118,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_get_info_response error"); + log_err(-1, __func__, "handle_im_get_info_response error"); goto err; } @@ -5132,7 +5130,7 @@ void im_request( chan->sock = -1; if (ret == IM_FAILURE) { - log_err(-1, __func__, (char *)"handle_im_get_resc_response error"); + log_err(-1, __func__, "handle_im_get_resc_response error"); goto err; } @@ -5144,7 +5142,7 @@ void im_request( { close_conn(chan->sock, FALSE); chan->sock = -1; - log_err(-1, __func__, (char *)"handle_im_poll_job_response error"); + log_err(-1, __func__, "handle_im_poll_job_response error"); goto err; } close_conn(chan->sock, FALSE); @@ -5171,7 +5169,7 @@ void im_request( case IM_FAILURE: { - log_err(-1, __func__, (char *)"IM_FAILURE in IM_GET_TID handle response"); + log_err(-1, __func__, "IM_FAILURE in IM_GET_TID handle response"); goto err; } } @@ -5222,7 +5220,7 @@ void im_request( if (((pjob->ji_qs.ji_svrflags & JOB_SVFLG_INTERMEDIATE_MOM) == 0) && ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0)) { - log_err(-1, __func__, (char *)"got JOIN_JOB OKAY and I'm not an intermediate MOM or Mother Superior"); + log_err(-1, __func__, "got JOIN_JOB OKAY and I'm not an intermediate MOM or Mother Superior"); goto err; } @@ -5422,7 +5420,7 @@ void im_request( close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; - log_err(-1, __func__, (char *)"Count not read cput||mem||vmem||nodeid"); + log_err(-1, __func__, "Count not read cput||mem||vmem||nodeid"); goto err; } @@ -5505,7 +5503,7 @@ void im_request( close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; - log_err(-1, __func__, (char *)"Count not read cput||mem||vmem||nodeid"); + log_err(-1, __func__, "Count not read cput||mem||vmem||nodeid"); goto err; } @@ -5571,7 +5569,7 @@ void im_request( close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; - log_err(-1, __func__, (char *)"KILL_JOB_RADIX OK received on a leaf node"); + log_err(-1, __func__, "KILL_JOB_RADIX OK received on a leaf node"); goto err; } @@ -5617,7 +5615,7 @@ void im_request( svr_conn[chan->sock].cn_stay_open = FALSE; chan->sock = -1; - log_err(-1, __func__, (char *)"Could not read error code"); + log_err(-1, __func__, "Could not read error code"); goto err; } @@ -5630,7 +5628,7 @@ void im_request( close_conn(chan->sock, FALSE); svr_conn[chan->sock].cn_stay_open = FALSE; - log_err(-1, __func__, (char *)"IM_GET_TID close_conn"); + log_err(-1, __func__, "IM_GET_TID close_conn"); goto err; } @@ -5651,7 +5649,7 @@ void im_request( */ if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0) { - log_err(-1, __func__, (char *)"JOIN_JOB ERROR and I'm not MS"); + log_err(-1, __func__, "JOIN_JOB ERROR and I'm not MS"); goto err; } @@ -5670,7 +5668,7 @@ void im_request( if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0) { - log_err(-1, __func__, (char *)"KILL_JOB ERROR and I'm not MS"); + log_err(-1, __func__, "KILL_JOB ERROR and I'm not MS"); goto err; } @@ -5778,7 +5776,7 @@ void im_request( if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0) { - log_err(-1, __func__, (char *)"POLL_JOB ERROR and I'm not MS"); + log_err(-1, __func__, "POLL_JOB ERROR and I'm not MS"); goto err; } @@ -6129,7 +6127,7 @@ int tm_spawn_request( if (argv == NULL) { - log_err(ENOMEM, __func__, (char *)"No memory available, cannot calloc!"); + log_err(ENOMEM, __func__, "No memory available, cannot calloc!"); return(TM_ERROR); } @@ -6154,7 +6152,7 @@ int tm_spawn_request( if (envp == NULL) { - log_err(ENOMEM, __func__, (char *)"No memory available, cannot calloc!"); + log_err(ENOMEM, __func__, "No memory available, cannot calloc!"); return(TM_ERROR); } @@ -6207,7 +6205,7 @@ int tm_spawn_request( /* tack on PBS_VNODENUM */ - envp[i] = calloc(MAXLINE, sizeof(char)); + envp[i] = (char *)calloc(MAXLINE, sizeof(char)); if (envp[i] == NULL) { @@ -6785,7 +6783,7 @@ int tm_obit_request( if (op == NULL) { - log_err(ENOMEM, __func__, (char *)"No memory! Cannot calloc!"); + log_err(ENOMEM, __func__, "No memory! Cannot calloc!"); return(TM_ERROR); } @@ -6921,7 +6919,7 @@ int tm_getinfo_request( *ret = tm_reply(chan, TM_OKAY, event); if (*ret == DIS_SUCCESS) - *ret = diswcs(chan, ip->ie_info, ip->ie_len); + *ret = diswcs(chan, (const char *)ip->ie_info, ip->ie_len); free(name); @@ -7797,7 +7795,7 @@ char *cat_dirs( len += strlen(base); - pn = calloc(1, len+2); + pn = (char *)calloc(1, len+2); if (!pn) { return(NULL); @@ -7917,7 +7915,7 @@ int get_job_struct( if ((new_job = job_alloc()) == NULL) { /* out of memory */ - log_err(-1, __func__, (char *)"insufficient memory to create job"); + log_err(-1, __func__, "insufficient memory to create job"); ret = PBSE_SYSTEM; @@ -8135,7 +8133,7 @@ void fork_demux( /* create pipe so that child can tell us when the demux is opened */ if (pipe(pipes) == -1) { - log_err(errno, __func__, (char *)"Couldn't create the pipe!"); + log_err(errno, __func__, "Couldn't create the pipe!"); pipe_failed = TRUE; } @@ -8432,11 +8430,11 @@ received_node *get_received_node_entry( if (index == -1) { - rn = calloc(1, sizeof(received_node)); + rn = (received_node *)calloc(1, sizeof(received_node)); if (rn == NULL) { - log_err(ENOMEM, __func__, (char *)"No memory to allocate for status information\n"); + log_err(ENOMEM, __func__, "No memory to allocate for status information\n"); return(NULL); } @@ -8446,7 +8444,7 @@ received_node *get_received_node_entry( if (rn->statuses == NULL) { - log_err(ENOMEM, __func__, (char *)"No memory to allocate for status information\n"); + log_err(ENOMEM, __func__, "No memory to allocate for status information\n"); free(rn); return(NULL); } @@ -8466,7 +8464,7 @@ received_node *get_received_node_entry( index = insert_thing(received_statuses, rn); if (index == -1) - log_err(ENOMEM, __func__, (char *)"No memory to resize the received_statuses array...SYSTEM FAILURE\n"); + log_err(ENOMEM, __func__, "No memory to resize the received_statuses array...SYSTEM FAILURE\n"); else { add_hash(received_table, index, rn->hostname); diff --git a/src/resmom/mom_comm.h b/src/resmom/mom_comm.h index 1bccd43465..2ea5ae2999 100644 --- a/src/resmom/mom_comm.h +++ b/src/resmom/mom_comm.h @@ -40,7 +40,7 @@ void im_eof(int stream, int ret); int check_ms(struct tcp_chan *chan, job *pjob); -u_long resc_used(job *pjob, char *name, u_long(*func)(resource *)); +u_long resc_used(job *pjob, const char *name, u_long(*func)(resource *)); infoent *task_findinfo(task *ptask, char *name); diff --git a/src/resmom/mom_inter.c b/src/resmom/mom_inter.c index f51bc3f7aa..f92bf6f463 100644 --- a/src/resmom/mom_inter.c +++ b/src/resmom/mom_inter.c @@ -115,7 +115,7 @@ extern int mom_reader_go; static int IPv4or6 = AF_UNSPEC; #endif -extern int conn_qsub(char *, int, char *); +extern int conn_qsub(char *, long, char *); extern char xauth_path[]; extern int DEBUGMODE; @@ -541,7 +541,7 @@ int x11_create_display( *display = '\0'; - if ((socks = calloc(sizeof(struct pfwdsock), NUM_SOCKS)) == NULL) + if ((socks = (struct pfwdsock *)calloc(sizeof(struct pfwdsock), NUM_SOCKS)) == NULL) { /* FAILURE - cannot alloc memory */ @@ -550,7 +550,7 @@ int x11_create_display( return(-1); } - if ((homeenv = calloc(1, strlen("HOME=") + strlen(homedir) + 2)) == NULL) + if ((homeenv = (char *)calloc(1, strlen("HOME=") + strlen(homedir) + 2)) == NULL) { /* FAILURE - cannot alloc memory */ free(socks); diff --git a/src/resmom/mom_job_func.c b/src/resmom/mom_job_func.c index 5620ba0614..9e28263fc7 100644 --- a/src/resmom/mom_job_func.c +++ b/src/resmom/mom_job_func.c @@ -814,7 +814,7 @@ void mom_job_purge( { job_file_delete_info *jfdi; - jfdi = calloc(1, sizeof(job_file_delete_info)); + jfdi = (job_file_delete_info *)calloc(1, sizeof(job_file_delete_info)); if (jfdi == NULL) { diff --git a/src/resmom/mom_main.c b/src/resmom/mom_main.c index 897edd26f2..81fd78c157 100644 --- a/src/resmom/mom_main.c +++ b/src/resmom/mom_main.c @@ -93,8 +93,13 @@ #include #endif /* _POSIX_MEMLOCK */ +#ifdef HAVE_SYS_STATVFS_H +#include +#endif + #define MAX_UPDATES_BEFORE_SENDING 20 #define PMOMTCPTIMEOUT 60 /* duration in seconds mom TCP requests will block */ +#define TCP_READ_PROTO_TIMEOUT 2 /* Global Data Items */ @@ -165,7 +170,7 @@ char *path_mom_hierarchy; char *path_spool; char *path_undeliv; char *path_aux; -char *path_home = PBS_SERVER_HOME; +char *path_home = (char *)PBS_SERVER_HOME; char *mom_home; extern dynamic_string *mom_status; @@ -275,12 +280,12 @@ extern void mom_server_all_init(void); extern void mom_server_all_update_stat(void); extern void mom_server_all_update_gpustat(void); extern int mark_for_resend(job *); -extern int mom_server_add(char *name); +extern int mom_server_add(const char *name); extern int mom_server_count; extern int post_epilogue(job *, int); extern int mom_checkpoint_init(void); extern void mom_checkpoint_check_periodic_timer(job *pjob); -extern void mom_checkpoint_set_directory_path(char *str); +extern void mom_checkpoint_set_directory_path(const char *str); #ifdef NVIDIA_GPUS #ifdef NVML_API @@ -331,80 +336,80 @@ struct config_list /* NOTE: must adjust RM_NPARM in resmom.h to be larger than number of parameters specified below */ -static unsigned long setxauthpath(char *); -static unsigned long setrcpcmd(char *); -static unsigned long setpbsclient(char *); -static unsigned long configversion(char *); -static unsigned long cputmult(char *); -static unsigned long setallocparcmd(char *); -static unsigned long setidealload(char *); -static unsigned long setignwalltime(char *); -static unsigned long setignmem(char *); -static unsigned long setigncput(char *); -static unsigned long setignvmem(char *); -static unsigned long setlogevent(char *); -static unsigned long setloglevel(char *); -static unsigned long setumask(char *); -static unsigned long setpreexec(char *); -static unsigned long setmaxload(char *); -static unsigned long setenablemomrestart(char *); -static unsigned long prologalarm(char *); -static unsigned long restricted(char *); -static unsigned long jobstartblocktime(char *); -static unsigned long usecp(char *); -static unsigned long wallmult(char *); -static unsigned long setpbsserver(char *); -static unsigned long setnodecheckscript(char *); -unsigned long setnodecheckinterval(char *); -static unsigned long settimeout(char *); -extern unsigned long mom_checkpoint_set_checkpoint_interval(char *); -extern unsigned long mom_checkpoint_set_checkpoint_script(char *); -extern unsigned long mom_checkpoint_set_restart_script(char *); -extern unsigned long mom_checkpoint_set_checkpoint_run_exe_name(char *); -static unsigned long setdownonerror(char *); -static unsigned long setstatusupdatetime(char *); -static unsigned long setcheckpolltime(char *); -static unsigned long settmpdir(char *); -static unsigned long setlogfilemaxsize(char *); -static unsigned long setlogfilerolldepth(char *); -static unsigned long setlogfilesuffix(char *); -static unsigned long setlogdirectory(char *); -static unsigned long setlogkeepdays(char *); -static unsigned long setvarattr(char *); -static unsigned long setautoidealload(char *); -static unsigned long setautomaxload(char *); -static unsigned long setnodefilesuffix(char *); -static unsigned long setnospooldirlist(char *); -static unsigned long setmomhost(char *); -static unsigned long setrreconfig(char *); -static unsigned long setsourceloginbatch(char *); -static unsigned long setsourcelogininteractive(char *); -static unsigned long setspoolasfinalname(char *); -static unsigned long setattempttomakedir(char *); -static unsigned long setremchkptdirlist(char *); -static unsigned long setmaxconnecttimeout(char *); -unsigned long aliasservername(char *); -unsigned long jobstarter(char *value); +static unsigned long setxauthpath(const char *); +static unsigned long setrcpcmd(const char *); +static unsigned long setpbsclient(const char *); +static unsigned long configversion(const char *); +static unsigned long cputmult(const char *); +static unsigned long setallocparcmd(const char *); +static unsigned long setidealload(const char *); +static unsigned long setignwalltime(const char *); +static unsigned long setignmem(const char *); +static unsigned long setigncput(const char *); +static unsigned long setignvmem(const char *); +static unsigned long setlogevent(const char *); +static unsigned long setloglevel(const char *); +static unsigned long setumask(const char *); +static unsigned long setpreexec(const char *); +static unsigned long setmaxload(const char *); +static unsigned long setenablemomrestart(const char *); +static unsigned long prologalarm(const char *); +static unsigned long restricted(const char *); +static unsigned long jobstartblocktime(const char *); +static unsigned long usecp(const char *); +static unsigned long wallmult(const char *); +static unsigned long setpbsserver(const char *); +static unsigned long setnodecheckscript(const char *); +unsigned long setnodecheckinterval(const char *); +static unsigned long settimeout(const char *); +extern unsigned long mom_checkpoint_set_checkpoint_interval(const char *); +extern unsigned long mom_checkpoint_set_checkpoint_script(const char *); +extern unsigned long mom_checkpoint_set_restart_script(const char *); +extern unsigned long mom_checkpoint_set_checkpoint_run_exe_name(const char *); +static unsigned long setdownonerror(const char *); +static unsigned long setstatusupdatetime(const char *); +static unsigned long setcheckpolltime(const char *); +static unsigned long settmpdir(const char *); +static unsigned long setlogfilemaxsize(const char *); +static unsigned long setlogfilerolldepth(const char *); +static unsigned long setlogfilesuffix(const char *); +static unsigned long setlogdirectory(const char *); +static unsigned long setlogkeepdays(const char *); +static unsigned long setvarattr(const char *); +static unsigned long setautoidealload(const char *); +static unsigned long setautomaxload(const char *); +static unsigned long setnodefilesuffix(const char *); +static unsigned long setnospooldirlist(const char *); +static unsigned long setmomhost(const char *); +static unsigned long setrreconfig(const char *); +static unsigned long setsourceloginbatch(const char *); +static unsigned long setsourcelogininteractive(const char *); +static unsigned long setspoolasfinalname(const char *); +static unsigned long setattempttomakedir(const char *); +static unsigned long setremchkptdirlist(const char *); +static unsigned long setmaxconnecttimeout(const char *); +unsigned long aliasservername(const char *); +unsigned long jobstarter(const char *value); #ifdef PENABLE_LINUX26_CPUSETS -static unsigned long setusesmt(char *); -static unsigned long setmempressthr(char *); -static unsigned long setmempressdur(char *); +static unsigned long setusesmt(const char *); +static unsigned long setmempressthr(const char *); +static unsigned long setmempressdur(const char *); #endif -static unsigned long setreduceprologchecks(char *); -static unsigned long setextpwdretry(char *); -static unsigned long setexecwithexec(char *); -static unsigned long setmaxupdatesbeforesending(char *); -static unsigned long setthreadunlinkcalls(char *); -static unsigned long setapbasilpath(char *); -static unsigned long setapbasilprotocol(char *); -static unsigned long setreportermom(char *); -static unsigned long setloginnode(char *); -static unsigned long setrejectjobsubmission(char *); +static unsigned long setreduceprologchecks(const char *); +static unsigned long setextpwdretry(const char *); +static unsigned long setexecwithexec(const char *); +static unsigned long setmaxupdatesbeforesending(const char *); +static unsigned long setthreadunlinkcalls(const char *); +static unsigned long setapbasilpath(const char *); +static unsigned long setapbasilprotocol(const char *); +static unsigned long setreportermom(const char *); +static unsigned long setloginnode(const char *); +static unsigned long setrejectjobsubmission(const char *); static struct specials { - char *name; - u_long(*handler)(); + const char *name; + u_long(*handler)(const char *); } special[] = { { "alloc_par_cmd", setallocparcmd }, { "auto_ideal_load", setautoidealload }, @@ -481,16 +486,16 @@ static struct specials }; -static char *arch(struct rm_attribute *); -static char *opsys(struct rm_attribute *); -static char *requname(struct rm_attribute *); -static char *validuser(struct rm_attribute *); -static char *reqmsg(struct rm_attribute *); -char *reqgres(struct rm_attribute *); -static char *reqstate(struct rm_attribute *); -static char *getjoblist(struct rm_attribute *); -static char *reqvarattr(struct rm_attribute *); -/* static char *nullproc(struct rm_attribute *); */ +static const char *arch(struct rm_attribute *); +static const char *opsys(struct rm_attribute *); +static const char *requname(struct rm_attribute *); +static const char *validuser(struct rm_attribute *); +static const char *reqmsg(struct rm_attribute *); +const char *reqgres(struct rm_attribute *); +static const char *reqstate(struct rm_attribute *); +static const char *getjoblist(struct rm_attribute *); +static const char *reqvarattr(struct rm_attribute *); +/* static const char *nullproc(struct rm_attribute *); */ struct config common_config[] = @@ -682,12 +687,12 @@ void check_log(void); -char *nullproc( +const char *nullproc( struct rm_attribute *attrib) { - log_err(-1, __func__, (char *)"should not be called"); + log_err(-1, __func__, "should not be called"); return(NULL); } /* END nullproc() */ @@ -695,7 +700,7 @@ char *nullproc( -static char *arch( +static const char *arch( struct rm_attribute *attrib) /* I */ @@ -735,7 +740,7 @@ static char *arch( -static char *opsys( +static const char *opsys( struct rm_attribute *attrib) /* I */ @@ -776,7 +781,7 @@ static char *opsys( -char * +const char * getuname(void) { @@ -808,7 +813,7 @@ getuname(void) -static char *reqmsg( +static const char *reqmsg( struct rm_attribute *attrib) @@ -828,7 +833,7 @@ static char *reqmsg( -static char *getjoblist( +static const char *getjoblist( struct rm_attribute *attrib) /* I */ @@ -845,7 +850,7 @@ static char *getjoblist( if (list == NULL) { - if ((list = calloc(BUFSIZ + 50, sizeof(char)))==NULL) + if ((list = (char *)calloc(BUFSIZ + 50, sizeof(char)))==NULL) { /* FAILURE - cannot alloc memory */ @@ -895,7 +900,7 @@ static char *getjoblist( int new_list_len = listlen + BUFSIZ; char *tmpList; - tmpList = realloc(list, new_list_len); + tmpList = (char *)realloc(list, new_list_len); if (tmpList == NULL) { @@ -932,7 +937,7 @@ static char *getjoblist( #define TMAX_VARBUF 65536 -static char *reqvarattr( +static const char *reqvarattr( struct rm_attribute *attrib) /* I */ @@ -953,15 +958,15 @@ static char *reqvarattr( if (list == NULL) { - list = calloc(BUFSIZ + 1024, sizeof(char)); + list = (char *)calloc(BUFSIZ + 1024, sizeof(char)); if (list == NULL) { /* FAILURE - cannot alloc memory */ - log_err(errno, __func__, (char *)"cannot alloc memory"); + log_err(errno, __func__, "cannot alloc memory"); - return(" "); + return((char *)" "); } listlen = BUFSIZ; @@ -971,7 +976,7 @@ static char *reqvarattr( if ((pva = (struct varattr *)GET_NEXT(mom_varattrs)) == NULL) { - return(" "); + return((char *)" "); } for (;pva != NULL;pva = (struct varattr *)GET_NEXT(pva->va_link)) @@ -994,13 +999,13 @@ static char *reqvarattr( { listlen += BUFSIZ; - list = realloc(list, listlen); + list = (char *)realloc(list, listlen); if (list == NULL) { - log_err(errno, __func__, (char *)"cannot alloc memory"); + log_err(errno, __func__, "cannot alloc memory"); - return(" "); + return((char *)" "); } } @@ -1012,7 +1017,7 @@ static char *reqvarattr( pva->va_lasttime = time_now; if (pva->va_value == NULL) - pva->va_value = calloc(TMAX_VARBUF, sizeof(char)); + pva->va_value = (char *)calloc(TMAX_VARBUF, sizeof(char)); /* execute script and get a new value */ @@ -1047,7 +1052,7 @@ static char *reqvarattr( if (len == -1) { /* FAILURE - cannot read var script output */ - log_err(errno, __func__, (char *)"pipe read"); + log_err(errno, __func__, "pipe read"); sprintf(pva->va_value, "? %d", RM_ERR_SYSTEM); @@ -1103,13 +1108,13 @@ static char *reqvarattr( if ((int)strlen(list) >= listlen) { listlen += BUFSIZ; - list = realloc(list, listlen); + list = (char *)realloc(list, listlen); if (list == NULL) { - log_err(errno, __func__, (char *)"cannot alloc memory"); + log_err(errno, __func__, "cannot alloc memory"); - return(" "); + return((char *)" "); } } } /* END for (pva) */ @@ -1124,7 +1129,7 @@ static char *reqvarattr( -char *reqgres( +const char *reqgres( struct rm_attribute *attrib) /* I (ignored) */ @@ -1222,7 +1227,7 @@ char *reqgres( -static char *reqstate( +static const char *reqstate( struct rm_attribute *attrib) /* I (ignored) */ @@ -1242,12 +1247,12 @@ static char *reqstate( -static char *requname( +static const char *requname( struct rm_attribute *attrib) { - char *cp; + const char *cp; if (attrib != NULL) { @@ -1267,7 +1272,7 @@ static char *requname( -static char *validuser( +static const char *validuser( struct rm_attribute *attrib) @@ -1293,7 +1298,7 @@ static char *validuser( } /* END validuser() */ -char *loadave( +const char *loadave( struct rm_attribute *attrib) @@ -1338,7 +1343,7 @@ char *loadave( struct config *rm_search( struct config *where, /* I */ - char *what) /* I */ + const char *what) /* I */ { @@ -1368,9 +1373,9 @@ struct config *rm_search( ** Search the various resource lists. */ -char *dependent( +const char *dependent( - char *res, /* I */ + const char *res, /* I */ struct rm_attribute *attr) /* I */ { @@ -1480,7 +1485,7 @@ void die( void memcheck( - char *buf) + const char *buf) { if (buf != NULL) @@ -1488,7 +1493,7 @@ void memcheck( return; } - log_err(-1, "memcheck", (char *)"memory allocation failed"); + log_err(-1, "memcheck", "memory allocation failed"); die(0); @@ -1527,7 +1532,7 @@ void checkret( log_record(PBSEVENT_SYSTEM, 0, __func__, log_buffer); - hold = realloc(ret_string, ret_size); /* new buf */ + hold = (char *)realloc(ret_string, ret_size); /* new buf */ memcheck(hold); @@ -1607,7 +1612,7 @@ void rmnl( static int setbool( - char *value) /* I */ + const char *value) /* I */ { int enable = -1; @@ -1653,7 +1658,7 @@ static int setbool( u_long addclient( - char *name) /* I */ + const char *name) /* I */ { struct addrinfo *addr_info; @@ -1688,7 +1693,7 @@ u_long addclient( static u_long setpbsclient( - char *value) /* I */ + const char *value) /* I */ { u_long rc; @@ -1719,7 +1724,7 @@ static u_long setpbsclient( static u_long setpbsserver( - char *value) /* I */ + const char *value) /* I */ { if ((value == NULL) || (*value == '\0')) @@ -1738,14 +1743,14 @@ static u_long setpbsserver( static u_long settmpdir( - char *Value) + const char *Value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, Value); if (*Value != '/') { - log_err(-1, __func__, (char *)"tmpdir must be a full path"); + log_err(-1, __func__, "tmpdir must be a full path"); return(0); } @@ -1760,10 +1765,10 @@ static u_long settmpdir( static u_long setexecwithexec( - char *value) + const char *value) { - static char *id = "setexecwithexec"; + static const char *id = "setexecwithexec"; log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, value); @@ -1780,14 +1785,14 @@ static u_long setexecwithexec( static u_long setxauthpath( - char *Value) + const char *Value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, Value); if (*Value != '/') { - log_err(-1, __func__, (char *)"xauthpath must be a full path"); + log_err(-1, __func__, "xauthpath must be a full path"); return(0); } @@ -1802,7 +1807,7 @@ static u_long setxauthpath( static u_long setrcpcmd( - char *Value) /* I */ + const char *Value) /* I */ { static char *ptr; @@ -1811,7 +1816,7 @@ static u_long setrcpcmd( if (*Value != '/') { - log_err(-1, __func__, (char *)"rcpcmd must be a full path"); + log_err(-1, __func__, "rcpcmd must be a full path"); /* FAILURE */ @@ -1843,7 +1848,7 @@ static u_long setrcpcmd( static u_long setlogevent( - char *value) + const char *value) { char *bad; @@ -1866,7 +1871,7 @@ static u_long setlogevent( static u_long restricted( - char *name) + const char *name) { char **tmpMaskClient; @@ -1879,7 +1884,7 @@ static u_long restricted( { /* FAILURE - cannot alloc memory */ - log_err(errno, __func__, (char *)"cannot alloc memory"); + log_err(errno, __func__, "cannot alloc memory"); return(-1); } @@ -1893,7 +1898,7 @@ static u_long restricted( { /* FAILURE - cannot alloc memory */ - log_err(errno, __func__, (char *)"cannot alloc memory"); + log_err(errno, __func__, "cannot alloc memory"); return(-1); } @@ -1912,7 +1917,7 @@ static u_long restricted( { /* FAILURE - cannot alloc memory */ - log_err(errno, __func__, (char *)"cannot alloc memory"); + log_err(errno, __func__, "cannot alloc memory"); return(-1); } @@ -1931,7 +1936,7 @@ static u_long restricted( static u_long configversion( - char *Value) /* I */ + const char *Value) /* I */ { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, Value); @@ -1956,7 +1961,7 @@ static u_long configversion( static u_long setdownonerror( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -1973,7 +1978,7 @@ static u_long setdownonerror( static u_long setenablemomrestart( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -1991,7 +1996,7 @@ static u_long setenablemomrestart( static u_long cputmult( - char *value) /* I */ + const char *value) /* I */ { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, value); @@ -2010,7 +2015,7 @@ static u_long cputmult( static u_long wallmult( - char *value) + const char *value) { double tmpD; @@ -2045,7 +2050,7 @@ static u_long wallmult( static u_long usecp( - char *value) /* I */ + const char *value) /* I */ { char *pnxt; @@ -2063,7 +2068,7 @@ static u_long usecp( if (cphosts_max == 0) { - pcphosts = calloc(2, sizeof(struct cphosts)); + pcphosts = (struct cphosts *)calloc(2, sizeof(struct cphosts)); if (pcphosts == NULL) { @@ -2079,7 +2084,7 @@ static u_long usecp( } else if (cphosts_max == cphosts_num) { - newp = realloc( + newp = (struct cphosts *)realloc( pcphosts, (cphosts_max + 2) * sizeof(struct cphosts)); @@ -2100,7 +2105,7 @@ static u_long usecp( cphosts_max += 2; } - pnxt = strchr(value, (int)':'); + pnxt = strchr((char *)value, (int)':'); if (pnxt == NULL) { @@ -2192,7 +2197,7 @@ static u_long usecp( static unsigned long prologalarm( - char *value) /* I */ + const char *value) /* I */ { int i; @@ -2221,7 +2226,7 @@ static unsigned long prologalarm( static unsigned long setloglevel( - char *value) /* I */ + const char *value) /* I */ { int i; @@ -2245,7 +2250,7 @@ static unsigned long setloglevel( static unsigned long setmaxupdatesbeforesending( - char *value) + const char *value) { int i; @@ -2269,7 +2274,7 @@ static unsigned long setmaxupdatesbeforesending( static unsigned long setumask( - char *value) /* I */ + const char *value) /* I */ { log_record( @@ -2288,7 +2293,7 @@ static unsigned long setumask( static unsigned long setpreexec( - char *value) /* I */ + const char *value) /* I */ { log_record( @@ -2300,7 +2305,7 @@ static unsigned long setpreexec( snprintf(PRE_EXEC, sizeof(PRE_EXEC), "%s", value); #if SHELL_USE_ARGV == 0 - log_err(0, __func__, (char *)"pbs_mom not configured with enable-shell-user-argv option"); + log_err(0, __func__, "pbs_mom not configured with enable-shell-user-argv option"); #endif return(1); @@ -2309,7 +2314,7 @@ static unsigned long setpreexec( static unsigned long setsourceloginbatch( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -2325,7 +2330,7 @@ static unsigned long setsourceloginbatch( static unsigned long setsourcelogininteractive( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -2342,7 +2347,7 @@ static unsigned long setsourcelogininteractive( static unsigned long jobstartblocktime( - char *value) /* I */ + const char *value) /* I */ { int i; @@ -2371,7 +2376,7 @@ static unsigned long jobstartblocktime( static unsigned long setstatusupdatetime( - char *value) /* I */ + const char *value) /* I */ { int i; @@ -2400,7 +2405,7 @@ static unsigned long setstatusupdatetime( static unsigned long setcheckpolltime( - char *value) /* I */ + const char *value) /* I */ { int i; @@ -2502,7 +2507,7 @@ static void add_static( static unsigned long setidealload( - char *value) + const char *value) { char newstr[50] = "ideal_load "; @@ -2536,7 +2541,7 @@ static unsigned long setidealload( static unsigned long setignwalltime( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -2553,7 +2558,7 @@ static unsigned long setignwalltime( static unsigned long setignmem( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -2570,7 +2575,7 @@ static unsigned long setignmem( static unsigned long setigncput( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -2586,7 +2591,7 @@ static unsigned long setigncput( static unsigned long setignvmem( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -2602,7 +2607,7 @@ static unsigned long setignvmem( static unsigned long setautoidealload( - char *value) + const char *value) { log_record( @@ -2628,7 +2633,7 @@ static unsigned long setautoidealload( static unsigned long setallocparcmd( - char *value) /* I */ + const char *value) /* I */ { log_record( @@ -2648,7 +2653,7 @@ static unsigned long setallocparcmd( static unsigned long setautomaxload( - char *value) + const char *value) { log_record( @@ -2674,7 +2679,7 @@ static unsigned long setautomaxload( static unsigned long setmaxconnecttimeout( - char *value) /* I */ + const char *value) /* I */ { MaxConnectTimeout = strtol(value, NULL, 10); @@ -2693,7 +2698,7 @@ static unsigned long setmaxconnecttimeout( static unsigned long setreduceprologchecks( - char *value) + const char *value) { log_record( @@ -2714,7 +2719,7 @@ static unsigned long setreduceprologchecks( static unsigned long setnodecheckscript( - char *value) + const char *value) { char newstr[1024] = "node_check_script "; @@ -2751,7 +2756,7 @@ static unsigned long setnodecheckscript( unsigned long setnodecheckinterval( - char *value) + const char *value) { char newstr[1024] = "node_check_interval "; @@ -2779,7 +2784,7 @@ unsigned long setnodecheckinterval( static unsigned long settimeout( - char *value) + const char *value) { char newstr[1024]; @@ -2805,7 +2810,7 @@ static unsigned long settimeout( static unsigned long setmaxload( - char *value) /* I */ + const char *value) /* I */ { char newstr[50] = "max_load "; @@ -2836,7 +2841,7 @@ static unsigned long setmaxload( static unsigned long setlogfilemaxsize( - char *value) /* I */ + const char *value) /* I */ { log_file_max_size = strtol(value, NULL, 10); @@ -2856,7 +2861,7 @@ static unsigned long setlogfilemaxsize( static unsigned long setlogfilerolldepth( - char *value) /* I */ + const char *value) /* I */ { log_file_roll_depth = strtol(value, NULL, 10); @@ -2875,7 +2880,7 @@ static unsigned long setlogfilerolldepth( static unsigned long setlogdirectory( - char *value) /* I */ + const char *value) /* I */ { path_log = strdup(value); @@ -2888,7 +2893,7 @@ static unsigned long setlogdirectory( static unsigned long setlogfilesuffix( - char *value) /* I */ + const char *value) /* I */ { log_init(value, NULL); @@ -2900,7 +2905,7 @@ static unsigned long setlogfilesuffix( static unsigned long setlogkeepdays( - char *value) /* I */ + const char *value) /* I */ { int i; @@ -2920,7 +2925,7 @@ static unsigned long setlogkeepdays( static unsigned long setextpwdretry( - char *value) /* I */ + const char *value) /* I */ { int i; @@ -2941,19 +2946,19 @@ static unsigned long setextpwdretry( static u_long setvarattr( - char *value) /* I */ + const char *value) /* I */ { struct varattr *pva; - char *ptr; + const char *ptr; - pva = calloc(1, sizeof(struct varattr)); + pva = (struct varattr *)calloc(1, sizeof(struct varattr)); if (pva == NULL) { /* FAILURE */ - log_err(errno, __func__, (char *)"no memory"); + log_err(errno, __func__, "no memory"); return(0); } @@ -3007,7 +3012,7 @@ static u_long setvarattr( static unsigned long setthreadunlinkcalls( - char *value) /* I */ + const char *value) /* I */ { log_record( @@ -3030,12 +3035,12 @@ static unsigned long setthreadunlinkcalls( static unsigned long setnodefilesuffix( - char *value) /* I */ + const char *value) /* I */ { char *ptr; - ptr = strtok(value, ","); + ptr = strtok((char *)value, ","); nodefile_suffix = strdup(ptr); @@ -3054,7 +3059,7 @@ static unsigned long setnodefilesuffix( static unsigned long setmomhost( - char *value) /* I */ + const char *value) /* I */ { hostname_specified = 1; @@ -3069,7 +3074,7 @@ static unsigned long setmomhost( static u_long setrreconfig( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -3085,7 +3090,7 @@ static u_long setrreconfig( static unsigned long setnospooldirlist( - char *value) /* I */ + const char *value) /* I */ { char *TokPtr; @@ -3095,7 +3100,7 @@ static unsigned long setnospooldirlist( char tmpLine[1024]; - ptr = strtok_r(value, " \t\n:,", &TokPtr); + ptr = strtok_r((char *)value, " \t\n:,", &TokPtr); while (ptr != NULL) { @@ -3125,7 +3130,7 @@ static unsigned long setnospooldirlist( } /* END setnospooldirlist() */ -unsigned long aliasservername( char *value) +unsigned long aliasservername(const char *value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, value); @@ -3146,7 +3151,7 @@ unsigned long aliasservername( char *value) static unsigned long setspoolasfinalname( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -3163,7 +3168,7 @@ static unsigned long setspoolasfinalname( static unsigned long setapbasilpath( - char *value) + const char *value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "apbasil_path", value); @@ -3187,7 +3192,7 @@ static unsigned long setapbasilpath( static unsigned long setapbasilprotocol( - char *value) + const char *value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "apbasil_protocol", value); @@ -3219,7 +3224,7 @@ static unsigned long setapbasilprotocol( static unsigned long setreportermom( - char *value) + const char *value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, value); @@ -3243,7 +3248,7 @@ static unsigned long setreportermom( static unsigned long setloginnode( - char *value) + const char *value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, value); @@ -3267,7 +3272,7 @@ static unsigned long setloginnode( static unsigned long setrejectjobsubmission( - char *value) + const char *value) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, value); @@ -3287,7 +3292,7 @@ static unsigned long setrejectjobsubmission( static unsigned long setattempttomakedir( - char *value) + const char *value) { log_record( @@ -3312,7 +3317,7 @@ static unsigned long setattempttomakedir( * Return: 1 success * 0 file named by value does not exist. fail *******************************************************/ -unsigned long jobstarter(char *value) /* I */ +unsigned long jobstarter(const char *value) /* I */ { struct stat sbuf; @@ -3341,7 +3346,7 @@ unsigned long jobstarter(char *value) /* I */ static unsigned long setremchkptdirlist( - char *value) /* I */ + const char *value) /* I */ { char *TokPtr; @@ -3358,7 +3363,7 @@ static unsigned long setremchkptdirlist( if (index >= TMAX_RCDCOUNT) return (1); - ptr = strtok_r(value, " \t\n:,", &TokPtr); + ptr = strtok_r((char *)value, " \t\n:,", &TokPtr); while (ptr != NULL) { @@ -3422,7 +3427,7 @@ void check_log(void) if (log_remove_old(path_log,(LOGKEEPDAYS * SECS_PER_DAY)) != 0) { - log_err(-1,"check_log", (char *)"failure occurred when checking for old pbs_mom logs"); + log_err(-1,"check_log", "failure occurred when checking for old pbs_mom logs"); } } @@ -3692,8 +3697,8 @@ int read_config( { for (ap = config_array;ap->c_name != NULL;ap++) { - free(ap->c_name); - free(ap->c_u.c_value); + free((void *)ap->c_name); + free((void *)ap->c_u.c_value); } free(config_array); @@ -3701,7 +3706,7 @@ int read_config( config_array = (struct config *)calloc(nconfig + 1, sizeof(struct config)); - memcheck((char *)config_array); + memcheck((const char *)config_array); /* ** Copy in the new information saved from the file. @@ -3750,7 +3755,7 @@ int read_config( #ifdef PENABLE_LINUX26_CPUSETS static u_long setusesmt( - char *value) /* I */ + const char *value) /* I */ { int enable; @@ -3766,7 +3771,7 @@ static u_long setusesmt( static u_long setmempressthr( - char *value) + const char *value) { long long val; @@ -3786,7 +3791,7 @@ static u_long setmempressthr( static u_long setmempressdur( - char *value) + const char *value) { int val; @@ -3940,7 +3945,7 @@ char *conf_res( if (resline == NULL) { - return(""); + return((char *)""); } if (resline[0] != '!') @@ -3991,7 +3996,7 @@ char *conf_res( if (attr != NULL) { /* too many params */ - log_err(-1, __func__, (char *)"too many params"); + log_err(-1, __func__, "too many params"); sprintf(ret_string, "? %d", RM_ERR_BADPARAM); @@ -4049,7 +4054,7 @@ char *conf_res( if (!used[i]) { /* parameter sent but not used */ - log_err(-1, __func__, (char *)"unused parameters"); + log_err(-1, __func__, "unused parameters"); sprintf(ret_string, "? %d", RM_ERR_BADPARAM); @@ -4064,7 +4069,7 @@ char *conf_res( if ((child = popen(ret_string, "r")) == NULL) { - log_err(errno, __func__, (char *)"popen"); + log_err(errno, __func__, "popen"); sprintf(ret_string, "? %d", RM_ERR_SYSTEM); @@ -4110,7 +4115,7 @@ char *conf_res( goto retryread; } - log_err(errno, __func__, (char *)"pipe read"); + log_err(errno, __func__, "pipe read"); sprintf(ret_string, "? %d", RM_ERR_SYSTEM); @@ -4491,7 +4496,7 @@ int rm_request( int ret; int restrictrm = 0; char *curr; - char *value; + const char *value; char *cp; char *body; int sindex; @@ -4858,12 +4863,11 @@ int rm_request( MUStrNCat(&BPtr, &BSpace, tmpLine); #ifdef HAVE_SYS_STATVFS_H - { -#include + { struct statvfs VFSStat; - if (statvfs(path_spool, &VFSStat) < 0) + if (statvfs((const char *)path_spool, &VFSStat) < 0) { MUSNPrintF(&BPtr, &BSpace, "ALERT: cannot stat stdout/stderr spool directory '%s' (errno=%d) %s\n", path_spool, @@ -5063,7 +5067,7 @@ int rm_request( long max_len = 1024; long final_len = 0; - char *tmp_line = calloc(1, max_len + 1); + char *tmp_line = (char *)calloc(1, max_len + 1); if (tmp_line != NULL) { ret = AVL_list(okclients, &tmp_line, &final_len, &max_len); @@ -5100,7 +5104,7 @@ int rm_request( { int numvnodes = 0; resource *pres; - char *resname; + const char *resname; unsigned long resvalue; char SIDList[1024]; task *ptask; @@ -5323,7 +5327,7 @@ int rm_request( if (DIS_tcp_wflush(chan) == -1) { - log_err(errno, __func__, (char *)"flush"); + log_err(errno, __func__, "flush"); goto bad; } @@ -5340,14 +5344,14 @@ int rm_request( if (MOMConfigRReconfig == FALSE) { log_err(-1, __func__, - (char *)"remote reconfiguration disabled, ignoring request"); + "remote reconfiguration disabled, ignoring request"); goto bad; } if (restrictrm) { - log_err(-1, __func__, (char *)"restricted configure attempt"); + log_err(-1, __func__, "restricted configure attempt"); goto bad; } @@ -5424,7 +5428,7 @@ int rm_request( if (DIS_tcp_wflush(chan) == -1) { - log_err(errno, __func__, (char *)"flush"); + log_err(errno, __func__, "flush"); goto bad; } @@ -5437,7 +5441,7 @@ int rm_request( if (restrictrm) { - log_err(-1, __func__, (char *)"restricted shutdown attempt"); + log_err(-1, __func__, "restricted shutdown attempt"); goto bad; } @@ -5553,6 +5557,8 @@ int tcp_read_proto_version( tmpT = pbs_tcp_timeout; + pbs_tcp_timeout = TCP_READ_PROTO_TIMEOUT; + *proto = disrsi(chan, &rc); if (tmpT > 0) @@ -5805,7 +5811,7 @@ void *tcp_request( -char *find_signal_name( +const char *find_signal_name( int sig) @@ -5844,7 +5850,7 @@ int kill_job( job *pjob, /* I */ int sig, /* I */ const char *killer_id_name, /* I - process name of calling routine */ - char *why_killed_reason) /* I - reason for killing */ + const char *why_killed_reason) /* I - reason for killing */ { task *ptask; @@ -5883,7 +5889,7 @@ int kill_job( { if (run_pelog(PE_EPILOGUSER, path_epilogpdel, pjob, PE_IO_TYPE_NULL) != 0) { - log_err(-1, __func__, (char *)"precancel epilog failed"); + log_err(-1, __func__, "precancel epilog failed"); sprintf(PBSNodeMsgBuf, "ERROR: precancel epilog failed"); } @@ -6180,7 +6186,7 @@ int job_over_limit( return(0); } - units = index == 0 ? "secs" : "kb"; + units = index == 0 ? (char *)"secs" : (char *)"kb"; sprintf(log_buffer, "%s job total %lu %s exceeded limit %lu %s", rd->rs_name, @@ -6253,7 +6259,7 @@ char *MOMFindMyExe( char *path; - link = calloc(MAXPATHLEN + 1, sizeof(char)); + link = (char *)calloc(MAXPATHLEN + 1, sizeof(char)); if (link == NULL) { @@ -6430,6 +6436,9 @@ void MOMCheckRestart(void) { time_t newmtime; + /* make sure we're not making a mess in the aux dir */ + cleanup_aux(); + if ((MOMConfigRestart <= 0) || (MOMExeTime <= 0)) { return; @@ -6457,9 +6466,6 @@ void MOMCheckRestart(void) DBPRT(("%s\n", log_buffer)); } - - /* make sure we're not making a mess in the aux dir */ - cleanup_aux(); } /* END MOMCheckRestart() */ @@ -6531,9 +6537,9 @@ void initialize_globals(void) if (pbs_mom_port <= 0) { pbs_mom_port = get_svrport( - PBS_MOM_SERVICE_NAME, - "tcp", - PBS_MOM_SERVICE_PORT); + PBS_MOM_SERVICE_NAME, + "tcp", + PBS_MOM_SERVICE_PORT); } ptr = getenv("PBS_BATCH_SERVICE_PORT"); @@ -6546,9 +6552,9 @@ void initialize_globals(void) if (default_server_port <= 0) { default_server_port = get_svrport( - PBS_BATCH_SERVICE_NAME, - "tcp", - PBS_BATCH_SERVICE_PORT); + PBS_BATCH_SERVICE_NAME, + "tcp", + PBS_BATCH_SERVICE_PORT); } ptr = getenv("PBS_MANAGER_SERVICE_PORT"); @@ -6561,9 +6567,9 @@ void initialize_globals(void) if (pbs_rm_port <= 0) { pbs_rm_port = get_svrport( - PBS_MANAGER_SERVICE_NAME, - "tcp", - PBS_MANAGER_SERVICE_PORT); + PBS_MANAGER_SERVICE_NAME, + "tcp", + PBS_MANAGER_SERVICE_PORT); } /* set timeout values for MOM */ @@ -6658,13 +6664,13 @@ static void PBSAdjustLogLevel( char *mk_dirs( - char *base) /* I */ + const char *base) /* I */ { char *pn; int ltop = strlen(path_home); - pn = calloc(1, ltop + strlen(base) + 2); + pn = (char *)calloc(1, ltop + strlen(base) + 2); if (pn == NULL) { @@ -6730,7 +6736,7 @@ void parse_command_line( else if (!strcmp(optarg, "version")) { printf("Version: %s\nRevision: %s\n", - PACKAGE_VERSION, SVN_VERSION); + PACKAGE_VERSION, GIT_HASH); exit(0); } @@ -7257,19 +7263,19 @@ int setup_program_environment(void) /* load system topology */ if ((hwloc_topology_init(&topology) == -1)) { - log_err(-1, msg_daemonname, (char *)"Unable to init machine topology"); + log_err(-1, msg_daemonname, "Unable to init machine topology"); return(-1); } if ((hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM) != 0)) { - log_err(-1, msg_daemonname, (char *)"Unable to configure machine topology"); + log_err(-1, msg_daemonname, "Unable to configure machine topology"); return(-1); } if ((hwloc_topology_load(topology) == -1)) { - log_err(-1, msg_daemonname, (char *)"Unable to load machine topology"); + log_err(-1, msg_daemonname, "Unable to load machine topology"); return(-1); } @@ -7310,7 +7316,7 @@ int setup_program_environment(void) if (setsid() == -1) { - log_err(errno, msg_daemonname, (char *)"setsid failed"); + log_err(errno, msg_daemonname, "setsid failed"); return(2); } @@ -7362,7 +7368,7 @@ int setup_program_environment(void) if (ftruncate(lockfds, (off_t)0) != 0) { - log_err(errno, msg_daemonname, (char *)"failed to truncate lockfile"); + log_err(errno, msg_daemonname, "failed to truncate lockfile"); return(2); } @@ -7372,7 +7378,7 @@ int setup_program_environment(void) if (write(lockfds, log_buffer, strlen(log_buffer) + 1) != (ssize_t)(strlen(log_buffer) + 1)) { - log_err(errno, msg_daemonname, (char *)"failed to write to lockfile"); + log_err(errno, msg_daemonname, "failed to write to lockfile"); return(2); } @@ -7384,7 +7390,7 @@ int setup_program_environment(void) if (plock(PROCLOCK) == -1) { - log_err(errno, msg_daemonname, (char *)"failed to lock mom into memory with plock"); + log_err(errno, msg_daemonname, "failed to lock mom into memory with plock"); } else { @@ -7564,7 +7570,7 @@ int setup_program_environment(void) if (c == -1) { - log_err(-1, msg_daemonname, (char *)"Unable to get my host name"); + log_err(-1, msg_daemonname, "Unable to get my host name"); return(-1); } @@ -7573,7 +7579,7 @@ int setup_program_environment(void) ret_size = RETURN_STRING_SIZE; - if ((ret_string = calloc(1, ret_size)) == NULL) + if ((ret_string = (char *)calloc(1, ret_size)) == NULL) { perror("calloc"); @@ -7611,14 +7617,14 @@ int setup_program_environment(void) /* initialize machine-dependent polling routines */ if ((c = mom_open_poll()) != PBSE_NONE) { - log_err(c, msg_daemonname, (char *)"pre_poll failed"); + log_err(c, msg_daemonname, "pre_poll failed"); return(3); } if (mom_get_sample() != PBSE_NONE) { - log_err(c, msg_daemonname, (char *)"mom_get_sample failed after mom_open_poll"); + log_err(c, msg_daemonname, "mom_get_sample failed after mom_open_poll"); return(3); } @@ -7701,7 +7707,7 @@ int setup_program_environment(void) if ((received_statuses == NULL) || (received_table == NULL)) { - log_err(ENOMEM, __func__, (char *)"No memory!!!"); + log_err(ENOMEM, __func__, "No memory!!!"); return(-1); } @@ -7968,7 +7974,7 @@ void examine_all_polled_jobs(void) { char *kill_msg; - kill_msg = calloc(1, 80 + strlen(log_buffer)); + kill_msg = (char *)calloc(1, 80 + strlen(log_buffer)); if (kill_msg != NULL) { @@ -8263,14 +8269,14 @@ int mark_for_resend( void prepare_child_tasks_for_delete() { - job *job; + job *pJob; - for (job = GET_NEXT(svr_alljobs);job != NULL;job = GET_NEXT(job->ji_alljobs)) + for (pJob = (job *)GET_NEXT(svr_alljobs);pJob != NULL;pJob = (job *)GET_NEXT(pJob->ji_alljobs)) { - task *task; + task *pTask; - for (task = GET_NEXT(job->ji_tasks);task != NULL;task = GET_NEXT(task->ti_jobtask)) + for (pTask = (task *)GET_NEXT(pJob->ji_tasks);pTask != NULL;pTask = (task *)GET_NEXT(pTask->ti_jobtask)) { char buf[128]; @@ -8278,16 +8284,16 @@ void prepare_child_tasks_for_delete() extern int exiting_tasks; sprintf(buf, "preparing exited session %d for task %d in job %s for deletion", - (int)task->ti_qs.ti_sid, - task->ti_qs.ti_task, - job->ji_qs.ji_jobid); + (int)pTask->ti_qs.ti_sid, + pTask->ti_qs.ti_task, + pJob->ji_qs.ji_jobid); log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, buf); - task->ti_qs.ti_exitstat = 0; /* actually unknown */ - task->ti_qs.ti_status = TI_STATE_EXITED; + pTask->ti_qs.ti_exitstat = 0; /* actually unknown */ + pTask->ti_qs.ti_status = TI_STATE_EXITED; - task_save(task); + task_save(pTask); exiting_tasks = 1; } @@ -8411,7 +8417,7 @@ void main_loop(void) /* unblock signals */ if (sigprocmask(SIG_UNBLOCK, &allsigs, NULL) == -1) - log_err(errno, __func__, (char *)"sigprocmask(UNBLOCK)"); + log_err(errno, __func__, "sigprocmask(UNBLOCK)"); time_now = time((time_t *)0); @@ -8438,13 +8444,13 @@ void main_loop(void) init_network(pbs_rm_port, tcp_request); } - log_err(-1, msg_daemonname, (char *)"wait_request failed"); + log_err(-1, msg_daemonname, "wait_request failed"); } /* block signals while we do things */ if (sigprocmask(SIG_BLOCK, &allsigs, NULL) == -1) - log_err(errno, __func__, (char *)"sigprocmask(BLOCK)"); + log_err(errno, __func__, "sigprocmask(BLOCK)"); if ((pjob = (job *)GET_NEXT(svr_alljobs)) == NULL) @@ -8472,7 +8478,7 @@ void restart_mom( { char *envstr; - envstr = calloc(1, (strlen("PATH") + strlen(orig_path) + 2) * sizeof(char)); + envstr = (char *)calloc(1, (strlen("PATH") + strlen(orig_path) + 2) * sizeof(char)); if (!envstr) { @@ -8569,7 +8575,7 @@ int read_layout_file() /* Allocate temp nodeset */ if ((nodeset = hwloc_bitmap_alloc()) == NULL) { - log_err(errno, __func__, (char *)"failed to allocate nodeset"); + log_err(errno, __func__, "failed to allocate nodeset"); return(-1); } @@ -8615,7 +8621,7 @@ int read_layout_file() /* Store nodeset of node_boards[i], may be empty */ if ((node_boards[i].nodeset = hwloc_bitmap_dup(nodeset)) == NULL) { - log_err(errno, __func__, (char *)"failed to duplicate nodeset"); + log_err(errno, __func__, "failed to duplicate nodeset"); return(-1); } @@ -8690,7 +8696,7 @@ int setup_nodeboards() /* Read mom.layout, init nodesets */ if ((rc = read_layout_file()) != PBSE_NONE) { - log_err(-1, __func__, (char *)"Could not read layout file!\n"); + log_err(-1, __func__, "Could not read layout file!\n"); exit(rc); } @@ -8705,7 +8711,7 @@ int setup_nodeboards() /* Allocate cpuset for this nodeboard */ if ((node_boards[i].cpuset = hwloc_bitmap_alloc()) == NULL) { - log_err(errno, __func__, (char *)"failed to allocate cpuset"); + log_err(errno, __func__, "failed to allocate cpuset"); exit(-1); } @@ -8752,7 +8758,7 @@ int setup_nodeboards() { if ((node_boards[i].path_meminfo = (char **)calloc(node_boards[i].num_nodes, sizeof(char *))) == NULL) { - log_err(errno, __func__, (char *)"failed to allocate memory"); + log_err(errno, __func__, "failed to allocate memory"); exit(-1); } @@ -8761,7 +8767,7 @@ int setup_nodeboards() { if ((node_boards[i].path_meminfo[k] = (char *)calloc(1, mempath_len)) == NULL) { - log_err(errno, __func__, (char *)"failed to allocate memory"); + log_err(errno, __func__, "failed to allocate memory"); exit(-1); } @@ -8910,7 +8916,7 @@ im_compose_info *create_compose_reply_info( tm_task_id taskid) { - im_compose_info *ici = calloc(1, sizeof(im_compose_info)); + im_compose_info *ici = (im_compose_info *)calloc(1, sizeof(im_compose_info)); if (ici != NULL) { @@ -8922,7 +8928,7 @@ im_compose_info *create_compose_reply_info( ici->taskid = taskid; } else - log_err(ENOMEM, __func__, (char *)"Cannot allocate memory!"); + log_err(ENOMEM, __func__, "Cannot allocate memory!"); return(ici); } /* END create_compose_reply_info() */ diff --git a/src/resmom/mom_main.h b/src/resmom/mom_main.h index 505e7a8885..dcca9e16bd 100644 --- a/src/resmom/mom_main.h +++ b/src/resmom/mom_main.h @@ -24,13 +24,13 @@ #define MAX_LINE 1024 #endif -char *nullproc(struct rm_attribute *attrib); +const char *nullproc(struct rm_attribute *attrib); /* static char *arch(struct rm_attribute *attrib); */ /* static char *opsys(struct rm_attribute *attrib); */ -char * getuname(void); +const char * getuname(void); /* static char *reqmsg(struct rm_attribute *attrib); */ @@ -38,7 +38,7 @@ char * getuname(void); /* static char *reqvarattr(struct rm_attribute *attrib); */ -char *reqgres(struct rm_attribute *attrib); +const char *reqgres(struct rm_attribute *attrib); /* static char *reqstate(struct rm_attribute *attrib); */ @@ -46,11 +46,11 @@ char *reqgres(struct rm_attribute *attrib); /* static char *validuser(struct rm_attribute *attrib); */ -char *loadave(struct rm_attribute *attrib); +const char *loadave(struct rm_attribute *attrib); -struct config *rm_search(struct config *where, char *what); +struct config *rm_search(struct config *where, const char *what); -char *dependent(char *res, struct rm_attribute *attr); +const char *dependent(const char *res, struct rm_attribute *attr); void initialize(void); @@ -58,7 +58,7 @@ void cleanup(void); void die(int sig); -void memcheck(char *buf); +void memcheck(const char *buf); void checkret(char **spot, long len); @@ -70,7 +70,7 @@ void rmnl(char *str); /* static int setbool(char *value); */ -u_long addclient(char *name); +u_long addclient(const char *name); /* static u_long setpbsclient(char *value); */ @@ -168,11 +168,11 @@ u_long addclient(char *name); /* static unsigned long setnospooldirlist(char *value); */ -unsigned long aliasservername(char *value); +unsigned long aliasservername(const char *value); /* static unsigned long setspoolasfinalname(char *value); */ -unsigned long jobstarter(char *value); +unsigned long jobstarter(const char *value); /* static unsigned long setremchkptdirlist(char *value); */ @@ -210,9 +210,9 @@ int do_tcp(int socket); void *tcp_request(void *sock_num); -char *find_signal_name(int sig); +const char *find_signal_name(int sig); -int kill_job(job *pjob, int sig, const char *killer_id_name, char *why_killed_reason); +int kill_job(job *pjob, int sig, const char *killer_id_name, const char *why_killed_reason); unsigned long getsize(resource *pres); @@ -234,7 +234,7 @@ void initialize_globals(void); /* static void PBSAdjustLogLevel(int sig); */ -char *mk_dirs(char *base); +char *mk_dirs(const char *base); void parse_command_line(int argc, char *argv[]); diff --git a/src/resmom/mom_process_request.c b/src/resmom/mom_process_request.c index 049f63f72c..592f1dbb85 100644 --- a/src/resmom/mom_process_request.c +++ b/src/resmom/mom_process_request.c @@ -491,13 +491,13 @@ static void mom_close_client( struct batch_request *alloc_br( - int type) + int type) { struct batch_request *req = NULL; - req = calloc(1, sizeof(struct batch_request)); + req = (struct batch_request *)calloc(1, sizeof(struct batch_request)); if (req == NULL) { @@ -543,7 +543,7 @@ static void close_quejob( while (pjob != NULL) { - npjob = GET_NEXT(pjob->ji_alljobs); + npjob = (job *)GET_NEXT(pjob->ji_alljobs); if (pjob->ji_qs.ji_un.ji_newt.ji_fromsock == sfds) { diff --git a/src/resmom/mom_req_quejob.c b/src/resmom/mom_req_quejob.c index c5a25df2a7..d7e33211f1 100644 --- a/src/resmom/mom_req_quejob.c +++ b/src/resmom/mom_req_quejob.c @@ -159,7 +159,7 @@ extern int reject_job_submit; extern char *msg_daemonname; -extern int decode_arst_merge(struct pbs_attribute *,char *,char *,char *); +extern int decode_arst_merge(struct pbs_attribute *,const char *,char *,char *); /* Private Functions in this file */ diff --git a/src/resmom/mom_server.c b/src/resmom/mom_server.c index dc18565515..1c13f4602d 100644 --- a/src/resmom/mom_server.c +++ b/src/resmom/mom_server.c @@ -301,11 +301,11 @@ extern unsigned int ssa_index; extern resizable_array *received_statuses; dynamic_string *mom_status = NULL; -extern struct config *rm_search(struct config *where, char *what); +extern struct config *rm_search(struct config *where, const char *what); extern struct rm_attribute *momgetattr(char *str); extern char *conf_res(char *resline, struct rm_attribute *attr); -extern char *dependent(char *res, struct rm_attribute *attr); +extern char *dependent(const char *res, struct rm_attribute *attr); extern char *reqgres(struct rm_attribute *); extern void send_update_soon(); @@ -315,7 +315,7 @@ extern int use_nvidia_gpu; void check_state(int); void state_to_server(int, int); -void node_comm_error(node_comm_t *, char *); +void node_comm_error(node_comm_t *, const char *); /* clear servers */ @@ -370,7 +370,7 @@ void mom_server_all_init(void) mom_server *mom_server_find_by_name( - char *name) + const char *name) { mom_server *pms; @@ -475,7 +475,7 @@ mom_server *mom_server_find_empty_slot(void) int mom_server_add( - char *value) + const char *value) { mom_server *pms; @@ -584,7 +584,7 @@ void mom_server_stream_error( int stream, char *name, const char *id, - char *message) + const char *message) { sprintf(log_buffer, "error %s to server %s", message, name); @@ -615,7 +615,7 @@ int mom_server_flush_io( struct tcp_chan *chan, const char *id, - char *message) + const char *message) { if (DIS_tcp_wflush(chan) == -1) @@ -649,7 +649,7 @@ int is_compose( int command) { - static char *id = "is_compose"; + static const char *id = "is_compose"; int ret; if (chan->sock < 0) @@ -731,7 +731,7 @@ extern struct config *config_array; void gen_size( - char *name, + const char *name, char **BPtr, int *BSpace) @@ -772,7 +772,7 @@ void gen_size( void gen_arch( - char *name, + const char *name, char **BPtr, int *BSpace) @@ -800,7 +800,7 @@ void gen_arch( void gen_opsys( - char *name, + const char *name, char **BPtr, int *BSpace) @@ -828,7 +828,7 @@ void gen_opsys( void gen_jdata( - char *name, + const char *name, char **BPtr, int *BSpace) @@ -851,7 +851,7 @@ void gen_jdata( void gen_gres( - char *name, + const char *name, char **BPtr, int *BSpace) @@ -880,7 +880,7 @@ void gen_gres( void gen_gen( - char *name, + const char *name, char **BPtr, int *BSpace) @@ -937,11 +937,11 @@ void gen_gen( return; } /* END gen_gen() */ -typedef void (*gen_func_ptr)(char *, char **, int *); +typedef void (*gen_func_ptr)(const char *, char **, int *); typedef struct stat_record { - char *name; + const char *name; gen_func_ptr func; } stat_record; @@ -1339,11 +1339,11 @@ int mom_server_update_stat( void node_comm_error( node_comm_t *nc, - char *message) + const char *message) { snprintf(log_buffer,sizeof(log_buffer), "%s %s", message, nc->name); - log_err(-1, (char *)"Node communication process",log_buffer); + log_err(-1, "Node communication process",log_buffer); close(nc->stream); nc->stream = -1; @@ -1560,7 +1560,7 @@ void mom_server_all_update_stat(void) } if (rc == COULD_NOT_CONTACT_SERVER) - log_err(-1, __func__, (char *)"Could not contact any of the servers to send an update"); + log_err(-1, __func__, "Could not contact any of the servers to send an update"); } else close(nc->stream); @@ -1834,7 +1834,7 @@ void mom_server_update_receive_time( void mom_server_update_receive_time_by_ip( u_long ipaddr, - char *command_name) + const char *command_name) { mom_server *pms; @@ -1980,7 +1980,7 @@ int process_host_name( int *something_added) { - static char *id = "process_host_name"; + static const char *id = "process_host_name"; char *colon; unsigned short rm_port; unsigned long ipaddr; @@ -2070,7 +2070,7 @@ int process_level_string( int *something_added) { - char *delims = ","; + const char *delims = ","; char *host_tok; int rc = PBSE_NONE; int temp_rc; @@ -2234,7 +2234,7 @@ int read_cluster_addresses( /* log the hierrarchy */ list_size = MAXLINE * 2; - if ((okclients_list = calloc(1, list_size)) != NULL) + if ((okclients_list = (char *)calloc(1, list_size)) != NULL) { AVL_list(okclients, &okclients_list, &list_len, &list_size); snprintf(log_buffer, sizeof(log_buffer), @@ -2669,7 +2669,7 @@ void check_state( static char tmpPBSNodeMsgBuf[1024]; - char *id = "check_state"; + const char *id = "check_state"; if (Force) { @@ -2935,7 +2935,7 @@ void state_to_server( } else { - mom_server_stream_error(-1, pms->pbs_servername, __func__, "Coudln't open stream to server"); + mom_server_stream_error(-1, pms->pbs_servername, __func__, "Couldn't open stream to server"); } return; diff --git a/src/resmom/mom_server_lib.h b/src/resmom/mom_server_lib.h index b095b25c60..b19056f54b 100644 --- a/src/resmom/mom_server_lib.h +++ b/src/resmom/mom_server_lib.h @@ -15,31 +15,31 @@ void mom_server_init(mom_server *pms); void mom_server_all_init(void); -mom_server *mom_server_find_by_name(char *name); +mom_server *mom_server_find_by_name(const char *name); mom_server *mom_server_find_by_ip(u_long search_ipaddr); mom_server *mom_server_find_empty_slot(void); -int mom_server_add(char *value); +int mom_server_add(const char *value); -void mom_server_stream_error(int socket, char *name, const char *id, char *message); +void mom_server_stream_error(int socket, char *name, const char *id, const char *message); -int mom_server_flush_io(struct tcp_chan *chan, const char *id, char *message); +int mom_server_flush_io(struct tcp_chan *chan, const char *id, const char *message); int is_compose(struct tcp_chan *chan, char *server_name, int command); -void gen_size(char *name, char **BPtr, int *BSpace); +void gen_size(const char *name, char **BPtr, int *BSpace); -void gen_arch(char *name, char **BPtr, int *BSpace); +void gen_arch(const char *name, char **BPtr, int *BSpace); -void gen_opsys(char *name, char **BPtr, int *BSpace); +void gen_opsys(const char *name, char **BPtr, int *BSpace); -void gen_jdata(char *name, char **BPtr, int *BSpace); +void gen_jdata(const char *name, char **BPtr, int *BSpace); -void gen_gres(char *name, char **BPtr, int *BSpace); +void gen_gres(const char *name, char **BPtr, int *BSpace); -void gen_gen(char *name, char **BPtr, int *BSpace); +void gen_gen(const char *name, char **BPtr, int *BSpace); #if defined(NVIDIA_GPUS) && defined(NVML_API) void log_nvml_error(nvmlReturn_t rc, char* gpuid, const char* id); @@ -81,7 +81,7 @@ int write_my_server_status(struct tcp_chan *chan, const char *id, char *status_s int write_cached_statuses(struct tcp_chan *chan, const char *id, void *dest, int mode); -void node_comm_error(node_comm_t *nc, char *message); +void node_comm_error(node_comm_t *nc, const char *message); int write_status_strings(char *stat_str, node_comm_t *nc); @@ -99,7 +99,7 @@ void mom_server_all_diag(char **BPtr, int *BSpace); void mom_server_update_receive_time(int stream, char *command_name); -void mom_server_update_receive_time_by_ip(u_long ipaddr, char *command_name); +void mom_server_update_receive_time_by_ip(u_long ipaddr, const char *command_name); mom_server *mom_server_valid_message_source(struct tcp_chan *chan, char **err_msg); diff --git a/src/resmom/prolog.c b/src/resmom/prolog.c index 377679c12b..2967b3dd57 100644 --- a/src/resmom/prolog.c +++ b/src/resmom/prolog.c @@ -179,7 +179,7 @@ static char *resc_to_string( if (aindex == JOB_ATR_resource) { - if (encode_resc(pattr, &svlist, "x", NULL, ATR_ENCODE_CLIENT, ATR_DFLAG_ACCESS) <= 0) + if (encode_resc(pattr, &svlist, (char *)"x", NULL, ATR_ENCODE_CLIENT, ATR_DFLAG_ACCESS) <= 0) { return(buf); } @@ -406,7 +406,7 @@ int run_pelog( resource *r; - char *EmptyString = ""; + char *EmptyString = (char *)""; int LastArg; int aindex; @@ -417,20 +417,20 @@ int run_pelog( int moabenvcnt = 14; /* # of entries in moabenvs */ static char *moabenvs[] = { - "MOAB_NODELIST", - "MOAB_JOBID", - "MOAB_JOBNAME", - "MOAB_USER", - "MOAB_GROUP", - "MOAB_CLASS", - "MOAB_TASKMAP", - "MOAB_QOS", - "MOAB_PARTITION", - "MOAB_PROCCOUNT", - "MOAB_NODECOUNT", - "MOAB_MACHINE", - "MOAB_JOBARRAYINDEX", - "MOAB_JOBARRAYRANGE" + (char *)"MOAB_NODELIST", + (char *)"MOAB_JOBID", + (char *)"MOAB_JOBNAME", + (char *)"MOAB_USER", + (char *)"MOAB_GROUP", + (char *)"MOAB_CLASS", + (char *)"MOAB_TASKMAP", + (char *)"MOAB_QOS", + (char *)"MOAB_PARTITION", + (char *)"MOAB_PROCCOUNT", + (char *)"MOAB_NODECOUNT", + (char *)"MOAB_MACHINE", + (char *)"MOAB_JOBARRAYINDEX", + (char *)"MOAB_JOBARRAYRANGE" }; if ((pjob == NULL) || (specpelog == NULL) || (specpelog[0] == '\0')) @@ -469,7 +469,7 @@ int run_pelog( (which == PE_EPILOGUSERJOB)) { - real_gids = calloc(num_gids, sizeof(gid_t)); + real_gids = (gid_t *)calloc(num_gids, sizeof(gid_t)); if (real_gids == NULL) { @@ -607,7 +607,7 @@ int run_pelog( undo_set_euid_egid(which,real_uid,real_gid,num_gids,real_gids,__func__); free(real_gids); - return(pelog_err(pjob,pelog,errno,"cannot stat")); + return(pelog_err(pjob,pelog,errno,(char *)"cannot stat")); } if (LOGLEVEL >= 5) @@ -985,7 +985,7 @@ int run_pelog( r = find_resc_entry( &pjob->ji_wattr[JOB_ATR_resource], - find_resc_def(svr_resc_def, "nodes", svr_resc_size)); + find_resc_def(svr_resc_def, (char *)"nodes", svr_resc_size)); if (r != NULL) { @@ -994,7 +994,7 @@ int run_pelog( const char *envname = "PBS_RESOURCE_NODES="; char *envstr; - envstr = calloc((strlen(envname) + strlen(r->rs_value.at_val.at_str) + 1), sizeof(char)); + envstr = (char *)calloc((strlen(envname) + strlen(r->rs_value.at_val.at_str) + 1), sizeof(char)); if (envstr != NULL) { @@ -1010,7 +1010,7 @@ int run_pelog( r = find_resc_entry( &pjob->ji_wattr[JOB_ATR_resource], - find_resc_def(svr_resc_def, "gres", svr_resc_size)); + find_resc_def(svr_resc_def, (char *)"gres", svr_resc_size)); if (r != NULL) { @@ -1019,7 +1019,7 @@ int run_pelog( const char *envname = "PBS_RESOURCE_GRES="; char *envstr; - envstr = calloc((strlen(envname) + strlen(r->rs_value.at_val.at_str) + 1), sizeof(char)); + envstr = (char *)calloc((strlen(envname) + strlen(r->rs_value.at_val.at_str) + 1), sizeof(char)); if (envstr != NULL) { @@ -1038,7 +1038,7 @@ int run_pelog( const char *envname = "TMPDIR="; char *envstr; - envstr = calloc((strlen(envname) + strlen(buf) + 1), sizeof(char)); + envstr = (char *)calloc((strlen(envname) + strlen(buf) + 1), sizeof(char)); if (envstr != NULL) { @@ -1055,13 +1055,13 @@ int run_pelog( /* Set PBS_SCHED_HINT */ { - char *envname = "PBS_SCHED_HINT"; + char *envname = (char *)"PBS_SCHED_HINT"; char *envval; char *envstr; if ((envval = get_job_envvar(pjob, envname)) != NULL) { - envstr = calloc((strlen(envname) + strlen(envval) + 2), sizeof(char)); + envstr = (char *)calloc((strlen(envname) + strlen(envval) + 2), sizeof(char)); if (envstr != NULL) { @@ -1076,13 +1076,13 @@ int run_pelog( /* Set PBS_NODENUM */ { - char *envname = "PBS_NODENUM"; + char *envname = (char *)"PBS_NODENUM"; char *envstr; sprintf(buf, "%d", pjob->ji_nodeid); - envstr = calloc((strlen(envname) + strlen(buf) + 2), sizeof(char)); + envstr = (char *)calloc((strlen(envname) + strlen(buf) + 2), sizeof(char)); if (envstr != NULL) { @@ -1096,12 +1096,12 @@ int run_pelog( /* Set PBS_MSHOST */ { - char *envname = "PBS_MSHOST"; + char *envname = (char *)"PBS_MSHOST"; char *envstr; if ((pjob->ji_vnods[0].vn_host != NULL) && (pjob->ji_vnods[0].vn_host->hn_host != NULL)) { - envstr = calloc((strlen(envname) + strlen(pjob->ji_vnods[0].vn_host->hn_host) + 2), sizeof(char)); + envstr = (char *)calloc((strlen(envname) + strlen(pjob->ji_vnods[0].vn_host->hn_host) + 2), sizeof(char)); if (envstr != NULL) { @@ -1116,7 +1116,7 @@ int run_pelog( /* Set PBS_NODEFILE */ { - char *envname = "PBS_NODEFILE"; + char *envname = (char *)"PBS_NODEFILE"; char *envstr; if (pjob->ji_flags & MOM_HAS_NODEFILE) @@ -1125,7 +1125,7 @@ int run_pelog( path_aux, pjob->ji_qs.ji_jobid); - envstr = calloc((strlen(envname) + strlen(buf) + 2), sizeof(char)); + envstr = (char *)calloc((strlen(envname) + strlen(buf) + 2), sizeof(char)); if (envstr != NULL) { @@ -1140,14 +1140,14 @@ int run_pelog( /* Set PBS_O_Workdir */ { - char *envname = "PBS_O_WORKDIR"; + char *envname = (char *)"PBS_O_WORKDIR"; char *workdir_val; char *envstr; workdir_val = get_job_envvar(pjob,envname); if (workdir_val != NULL) { - envstr = calloc((strlen(workdir_val) + strlen(envname) + 2), sizeof(char)); + envstr = (char *)calloc((strlen(workdir_val) + strlen(envname) + 2), sizeof(char)); if (envstr != NULL) { @@ -1188,7 +1188,7 @@ int run_pelog( { char *envstr; - envstr = calloc((strlen(vstrs->as_string[j])), sizeof(char)); + envstr = (char *)calloc((strlen(vstrs->as_string[j])), sizeof(char)); if (envstr != NULL) { @@ -1211,7 +1211,7 @@ int run_pelog( tmp_val = get_job_envvar(pjob,moabenvs[aindex]); if (tmp_val != NULL) { - envstr = calloc((strlen(tmp_val) + strlen(moabenvs[aindex]) + 2), sizeof(char)); + envstr = (char *)calloc((strlen(tmp_val) + strlen(moabenvs[aindex]) + 2), sizeof(char)); if (envstr != NULL) { diff --git a/src/resmom/requests.c b/src/resmom/requests.c index 34b436cf6d..7133cba852 100644 --- a/src/resmom/requests.c +++ b/src/resmom/requests.c @@ -188,7 +188,7 @@ static gid_t usergid; static int ngroup; static int *groups; #if NO_SPOOL_OUTPUT == 0 -static char *output_retained = "Output retained on that host in: "; +static char *output_retained = (char *)"Output retained on that host in: "; #endif /* !NO_SPOOL_OUTPUT */ static char rcperr[MAXPATHLEN]; /* file to contain rcp error */ @@ -199,7 +199,7 @@ extern int LOGLEVEL; /* prototypes */ -char *get_job_envvar(job *, char *); +char *get_job_envvar(job *, const char *); int replace_checkpoint_path(char *); int in_remote_checkpoint_dir(char *); @@ -211,7 +211,7 @@ int in_remote_checkpoint_dir(char *); char *get_job_envvar( job *pjob, /* I */ - char *variable) /* I */ + const char *variable) /* I */ { char *pc; @@ -283,7 +283,7 @@ static pid_t fork_to_user( ngroup = pjob->ji_grpcache->gc_ngroup; groups = pjob->ji_grpcache->gc_groups; - if ((idir = get_job_envvar(pjob, "PBS_O_INITDIR")) != NULL) + if ((idir = get_job_envvar(pjob, (char *)"PBS_O_INITDIR")) != NULL) { hdir = idir; } @@ -343,7 +343,7 @@ static pid_t fork_to_user( /* determine user`s home directory */ - if ((pjob != NULL) && ((idir = get_job_envvar(pjob, "PBS_O_INITDIR")) != NULL)) + if ((pjob != NULL) && ((idir = get_job_envvar(pjob, (char *)"PBS_O_INITDIR")) != NULL)) { hdir = idir; } @@ -357,7 +357,7 @@ static pid_t fork_to_user( { /* FAILURE */ - log_err(PBSE_UNKRESC, __func__, "cannot determine home directory"); + log_err(PBSE_UNKRESC, __func__, (char *)"cannot determine home directory"); if (EMsg != NULL) snprintf(EMsg, 1024, "%s", "cannot determine home directory"); @@ -500,7 +500,7 @@ static pid_t fork_to_user( char *envstr; - envstr = calloc((strlen("HOME=") + strlen(hdir) + 1), sizeof(char)); + envstr = (char *)calloc((strlen("HOME=") + strlen(hdir) + 1), sizeof(char)); if (envstr == NULL) { @@ -522,7 +522,7 @@ static pid_t fork_to_user( putenv(envstr); - envstr = calloc((strlen("PBS_JOBID=") + strlen(preq->rq_ind.rq_cpyfile.rq_jobid) + 1), sizeof(char)); + envstr = (char *)calloc((strlen("PBS_JOBID=") + strlen(preq->rq_ind.rq_cpyfile.rq_jobid) + 1), sizeof(char)); if (envstr == NULL) { @@ -571,13 +571,13 @@ static void add_bad_list( { needed += strlen(*pbl) + strlen(newtext) + nl + 1; - pnew = realloc(*pbl, needed); + pnew = (char *)realloc(*pbl, needed); } else { needed += strlen(newtext) + nl + 1; - pnew = calloc(1, needed); + pnew = (char *)calloc(1, needed); if (pnew != NULL) *pnew = '\0'; @@ -1129,7 +1129,7 @@ void req_deletejob( PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, - "deleting job"); + (char *)"deleting job"); } /* @@ -1152,7 +1152,7 @@ void req_deletejob( } else { - req_reject(PBSE_UNKJOBID, 0, preq, mom_host, "cannot locate job to delete"); + req_reject(PBSE_UNKJOBID, 0, preq, mom_host, (char *)"cannot locate job to delete"); } return; @@ -1200,7 +1200,7 @@ void mom_req_holdjob( } if ((rc = start_checkpoint(pjob,1,preq)) != PBSE_NONE) - req_reject(rc,0,preq,mom_host,"cannot checkpoint job"); /* unable to start checkpoint */ + req_reject(rc,0,preq,mom_host,(char *)"cannot checkpoint job"); /* unable to start checkpoint */ } return; @@ -1230,12 +1230,12 @@ void req_checkpointjob( if (pjob == NULL) { rc = PBSE_UNKJOBID; - req_reject(rc, 0, preq, mom_host, "job does not exist on mom"); + req_reject(rc, 0, preq, mom_host, (char *)"job does not exist on mom"); } else { if ((rc = start_checkpoint(pjob, 0, preq)) != PBSE_NONE) - req_reject(rc, 0, preq, mom_host, "cannot checkpoint job"); /* unable to start checkpoint */ + req_reject(rc, 0, preq, mom_host, (char *)"cannot checkpoint job"); /* unable to start checkpoint */ } /* note, normally the reply to the server is in start_checkpoint() */ @@ -1300,7 +1300,7 @@ int message_job( if (text[len - 1] != '\n') { - if ((pstr = calloc(1, len + 2)) == NULL) + if ((pstr = (char *)calloc(1, len + 2)) == NULL) { close(fds); @@ -1378,7 +1378,7 @@ void req_messagejob( } else { - req_reject(ret, 0, preq, mom_host, "cannot add message to job output/error buffer"); + req_reject(ret, 0, preq, mom_host, (char *)"cannot add message to job output/error buffer"); } } /* END req_messagejob() */ @@ -1505,7 +1505,7 @@ void req_modifyjob( PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, - "modifying job"); + (char *)"modifying job"); } plist = (svrattrl *)GET_NEXT(preq->rq_ind.rq_modify.rq_attr); @@ -1550,7 +1550,7 @@ void req_modifyjob( /* cannot set attributes, return FAILURE */ - req_reject(rc, 0, preq, mom_host, "cannot set attributes"); + req_reject(rc, 0, preq, mom_host, (char *)"cannot set attributes"); return; } @@ -1597,7 +1597,7 @@ void req_modifyjob( tmpLine[0] = '\0'; tmpPtr = arst_string( - "", + (char *)"", &newattr[i]); if (tmpPtr != NULL) @@ -1660,7 +1660,7 @@ void req_modifyjob( if (rc != 0) { - req_reject(rc, bad, preq, mom_host, "cannot set limits"); + req_reject(rc, bad, preq, mom_host, (char *)"cannot set limits"); return; } @@ -2034,7 +2034,7 @@ static void resume_suspend( PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, - "job suspended - adjusted job state"); + (char *)"job suspended - adjusted job state"); } } else @@ -2062,7 +2062,7 @@ static void resume_suspend( PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, - "job resumed - adjusted job state"); + (char *)"job resumed - adjusted job state"); } } /* END else (susp != 0) */ @@ -2163,7 +2163,7 @@ void req_signaljob( PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, - "resume request on job that is not suspended"); + (char *)"resume request on job that is not suspended"); } #ifdef _CRAY @@ -2521,11 +2521,11 @@ static int del_files( wordexp_t pathexp; #endif - path = calloc((MAXPATHLEN + 1), sizeof(char)); + path = (char *)calloc((MAXPATHLEN + 1), sizeof(char)); if (path==NULL) { - add_bad_list(pbadfile,"calloc failed",1); + add_bad_list(pbadfile,(char *)"calloc failed",1); return(-1); } @@ -2844,7 +2844,7 @@ void req_rerunjob( if (LOGLEVEL >= 3) { - log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, "rerunning job"); + log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, (char *)"rerunning job"); } /* fork to send files back */ @@ -2894,7 +2894,7 @@ void req_rerunjob( PBSEVENT_ERROR, PBS_EVENTCLASS_REQUEST, __func__, - "cannot move output files to server"); + (char *)"cannot move output files to server"); req_reject(rc, 0, preq, NULL, NULL); @@ -2933,7 +2933,7 @@ void req_returnfiles( { if (retry_attempts++ >= 10) { - req_reject(PBSE_NOSERVER, 0, preq, NULL, "Unable to open socket to pbs_server"); + req_reject(PBSE_NOSERVER, 0, preq, NULL, (char *)"Unable to open socket to pbs_server"); break; } @@ -2965,7 +2965,7 @@ void req_returnfiles( } else { - req_reject(PBSE_UNKJOBID, 0, preq, mom_host, "cannot locate job"); + req_reject(PBSE_UNKJOBID, 0, preq, mom_host, (char *)"cannot locate job"); } return; @@ -3000,8 +3000,8 @@ static int sys_copy( { /* local copy */ - ag0 = "/bin/cp"; - ag1 = "-rp"; + ag0 = (char *)"/bin/cp"; + ag1 = (char *)"-rp"; } else { @@ -3308,7 +3308,7 @@ void req_cpyfile( } else { - wdir = get_job_envvar(pjob, "PBS_O_WORKDIR"); + wdir = get_job_envvar(pjob, (char *)"PBS_O_WORKDIR"); } if (wdir != NULL) @@ -3377,7 +3377,7 @@ void req_cpyfile( { char *envstr; - envstr = calloc((strlen("TMPDIR=") + strlen(faketmpdir) + 1), sizeof(char)); + envstr = (char *)calloc((strlen("TMPDIR=") + strlen(faketmpdir) + 1), sizeof(char)); if (envstr == NULL) { @@ -3415,8 +3415,8 @@ void req_cpyfile( /* build up cp/rcp command(s), one per file pair */ - arg2 = calloc((MAXPATHLEN + 1), sizeof(char)); - arg3 = calloc((MAXPATHLEN + 1), sizeof(char)); + arg2 = (char *)calloc((MAXPATHLEN + 1), sizeof(char)); + arg3 = (char *)calloc((MAXPATHLEN + 1), sizeof(char)); if ((arg2==NULL) || (arg3==NULL)) { @@ -3810,7 +3810,7 @@ void req_cpyfile( if ((fp = fopen(rcperr, "r")) != NULL) { - add_bad_list(&bad_list, "*** error from copy", 1); + add_bad_list(&bad_list, (char *)"*** error from copy", 1); while (fgets(log_buffer, LOG_BUF_SIZE, fp) != NULL) { @@ -3824,7 +3824,7 @@ void req_cpyfile( fclose(fp); - add_bad_list(&bad_list, "*** end error output", 1); + add_bad_list(&bad_list, (char *)"*** end error output", 1); } diff --git a/src/resmom/rm_dep.h b/src/resmom/rm_dep.h index cc2421d2d4..bf0d5d19fe 100644 --- a/src/resmom/rm_dep.h +++ b/src/resmom/rm_dep.h @@ -7,15 +7,15 @@ ** these resources. */ -char *cput(struct rm_attribute *attrib); -char *mem(struct rm_attribute *attrib); -char *sessions(struct rm_attribute *attrib); -char *pids(struct rm_attribute *attrib); -char *nsessions(struct rm_attribute *attrib); -char *nusers(struct rm_attribute *attrib); -char *size(struct rm_attribute *attrib); -char *idletime(struct rm_attribute *attrib); -char *nullproc(struct rm_attribute *attrib); +const char *cput(struct rm_attribute *attrib); +const char *mem(struct rm_attribute *attrib); +const char *sessions(struct rm_attribute *attrib); +const char *pids(struct rm_attribute *attrib); +const char *nsessions(struct rm_attribute *attrib); +const char *nusers(struct rm_attribute *attrib); +const char *size(struct rm_attribute *attrib); +const char *idletime(struct rm_attribute *attrib); +const char *nullproc(struct rm_attribute *attrib); struct config standard_config[] = { diff --git a/src/resmom/start_exec.c b/src/resmom/start_exec.c index 762440340a..b2577ec3b5 100644 --- a/src/resmom/start_exec.c +++ b/src/resmom/start_exec.c @@ -267,7 +267,7 @@ enum TVarElseEnum tveLAST }; -static char *variables_else[] = /* variables to add, value computed */ +static const char *variables_else[] = /* variables to add, value computed */ { "HOME", "LOGNAME", @@ -455,7 +455,7 @@ struct passwd *check_pwd( pjob->ji_qs.ji_un.ji_momt.ji_exuid = pwdp->pw_uid; - pjob->ji_grpcache = calloc(1, sizeof(struct grpcache) + strlen(pwdp->pw_dir) + 1); + pjob->ji_grpcache = (struct grpcache *)calloc(1, sizeof(struct grpcache) + strlen(pwdp->pw_dir) + 1); if (pjob->ji_grpcache == NULL) { @@ -825,7 +825,7 @@ static int open_pty( pjob->ji_qs.ji_un.ji_momt.ji_exgid) == -1) { close(pts); - log_err(errno, "open_pty", (char *)"cannot change slave's owner"); + log_err(errno, "open_pty", "cannot change slave's owner"); return -1; } @@ -971,7 +971,7 @@ static int open_std_out_err( } else { - log_err(errno, __func__, (char *)"unable to open standard output/error"); + log_err(errno, __func__, "unable to open standard output/error"); } return(-1); @@ -1042,7 +1042,7 @@ int mkdirtree( oldmask = umask(0000); - part = strtok(path, (char *)"/"); + part = strtok(path, "/"); if (part == NULL) { @@ -1299,7 +1299,7 @@ int InitUserEnv( vtable.v_bsize = ebsize + EXTRA_VARIABLE_SPACE + (vstrs != NULL ? (vstrs->as_next - vstrs->as_buf) : 0); - vtable.v_block = calloc(1, vtable.v_bsize); + vtable.v_block = (char *)calloc(1, vtable.v_bsize); if (vtable.v_block == NULL) { @@ -1315,7 +1315,7 @@ int InitUserEnv( vtable.v_used = 0; - vtable.v_envp = calloc(vtable.v_ensize, sizeof(char *)); + vtable.v_envp = (char **)calloc(vtable.v_ensize, sizeof(char *)); if (vtable.v_envp == NULL) { @@ -1478,7 +1478,7 @@ int InitUserEnv( if (presc != NULL) { - char *ppn_str = "ppn="; + const char *ppn_str = "ppn="; char *tmp; if (presc->rs_value.at_val.at_str != NULL) @@ -1573,11 +1573,11 @@ int mom_jobstarter_execute_job( note, this func is called from a child process that exits after the executable is launched, so we don't have to worry about freeing this calloc later */ - arg[1] = calloc(1, strlen(shell) + 1); + arg[1] = (char *)calloc(1, strlen(shell) + 1); if (arg[1] == NULL) { - log_err(errno,__func__, (char *)"cannot alloc env"); + log_err(errno,__func__, "cannot alloc env"); return(-1); } @@ -1794,25 +1794,25 @@ struct radix_buf **allocate_sister_list( int i; /* create sister lists to send out to intermediate moms */ - if ((sister_list = calloc((size_t)radix, sizeof(struct radix_buf *))) == NULL) + if ((sister_list = (struct radix_buf **)calloc((size_t)radix, sizeof(struct radix_buf *))) == NULL) { - log_err(ENOMEM,__func__, (char *)""); + log_err(ENOMEM,__func__, ""); return(NULL); } for (i = 0; i < radix; i++) { - if ((sister_list[i] = calloc(1, sizeof(struct radix_buf))) == NULL) + if ((sister_list[i] = (struct radix_buf *)calloc(1, sizeof(struct radix_buf))) == NULL) { free(sister_list); - log_err(ENOMEM,__func__, (char *)""); + log_err(ENOMEM,__func__, ""); return(NULL); } - if ((sister_list[i]->host_list = calloc(1, THE_LIST_SIZE)) == NULL) + if ((sister_list[i]->host_list = (char *)calloc(1, THE_LIST_SIZE)) == NULL) { free(sister_list); - log_err(ENOMEM,__func__, (char *)""); + log_err(ENOMEM,__func__, ""); return(NULL); } @@ -2032,7 +2032,7 @@ int TMomFinalizeJob1( { /* FAILURE */ - log_err(-1, __func__, (char *)"Restart failed"); + log_err(-1, __func__, "Restart failed"); /* retry for any kind of changable thing */ @@ -2113,7 +2113,7 @@ int TMomFinalizeJob1( if ((TJE->ptc = open_master(&TJE->ptc_name)) < 0) { - log_err(errno, __func__, (char *)"cannot open master pty"); + log_err(errno, __func__, "cannot open master pty"); *SC = JOB_EXEC_RETRY; @@ -2535,7 +2535,7 @@ int write_attr_to_file( job *pjob, int index, - char *suffix) + const char *suffix) { char filename[MAXPATHLEN]; @@ -2588,7 +2588,7 @@ int write_attr_to_file( { fclose(file); - log_err(ENOMEM,__func__, (char *)"Couldn't allocate a string to work with? EPIC FAIL"); + log_err(ENOMEM,__func__, "Couldn't allocate a string to work with? EPIC FAIL"); return(ENOMEM); } @@ -2748,7 +2748,7 @@ int write_nodes_to_file( else { /* this should never happen */ - log_err(-1, __func__, (char *)"Numa enabled but no dash in hostname?"); + log_err(-1, __func__, "Numa enabled but no dash in hostname?"); } #endif /* def NUMA_SUPPORT */ @@ -2936,7 +2936,7 @@ void handle_prologs( if ((rc = run_pelog(PE_PROLOG, path_prolog, pjob, PE_IO_TYPE_ASIS)) != PBSE_NONE) { - log_err(-1, __func__, (char *)"prolog failed"); + log_err(-1, __func__, "prolog failed"); if ((TJE->is_interactive == FALSE) && (rc != 1)) @@ -2955,7 +2955,7 @@ void handle_prologs( /* run user prolog */ if ((rc = run_pelog(PE_PROLOGUSER, path_prologuser, pjob, PE_IO_TYPE_ASIS)) != PBSE_NONE) { - log_err(-1, __func__, (char *)"user prolog failed"); + log_err(-1, __func__, "user prolog failed"); if ((TJE->is_interactive == FALSE) && (rc != 1)) @@ -2986,7 +2986,7 @@ void handle_prologs( { if ((rc = run_pelog(PE_PROLOGUSERJOB, path_prologuserjob, pjob, PE_IO_TYPE_ASIS)) != PBSE_NONE) { - log_err(-1, __func__, (char *)"batch job local user prolog failed"); + log_err(-1, __func__, "batch job local user prolog failed"); free(path_prologuserjob); if ((TJE->is_interactive == FALSE) && @@ -3068,7 +3068,7 @@ int start_interactive_session( if ((phost == NULL) || ((phost = strchr(phost, '=')) == NULL)) { - log_err(-1, __func__, (char *)"PBS_O_HOST not set"); + log_err(-1, __func__, "PBS_O_HOST not set"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL1, sjr); } @@ -3105,7 +3105,7 @@ int start_interactive_session( if ((*qsub_sock_ptr < 0)|| (write(*qsub_sock_ptr, pjob->ji_qs.ji_jobid, PBS_MAXSVRJOBID + 1) != PBS_MAXSVRJOBID + 1)) { - log_err(errno, __func__, (char *)"cannot write jobid"); + log_err(errno, __func__, "cannot write jobid"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL1, sjr); } @@ -3113,7 +3113,7 @@ int start_interactive_session( /* receive terminal type and window size */ if ((termtype = rcvttype(*qsub_sock_ptr)) == NULL) { - log_err(errno, __func__, (char *)"cannot get termtype"); + log_err(errno, __func__, "cannot get termtype"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL1, sjr); } @@ -3123,7 +3123,7 @@ int start_interactive_session( if (rcvwinsize(*qsub_sock_ptr) == -1) { - log_err(errno, __func__, (char *)"cannot get winsize"); + log_err(errno, __func__, "cannot get winsize"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL1, sjr); } @@ -3140,7 +3140,7 @@ int start_interactive_session( /* open the slave pty as the controlling tty */ if ((*pts_ptr = open_pty(pjob)) < 0) { - log_err(errno, __func__, (char *)"cannot open slave"); + log_err(errno, __func__, "cannot open slave"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL1, sjr); } @@ -3286,7 +3286,7 @@ void setup_interactive_job( shutdown(*qsub_sock_ptr, 2); /* change pty back to available after job is done */ - if (chmod((char *)TJE->ptc_name, 0666) != 0) + if (chmod(TJE->ptc_name, 0666) != 0) { log_err(errno, __func__, "can't chmod 0666 to change pty back to available"); } @@ -3302,7 +3302,7 @@ void setup_interactive_job( else { /* FAILURE - fork failed */ - log_err(errno, __func__, (char *)"cannot fork nanny"); + log_err(errno, __func__, "cannot fork nanny"); /* change pty back to available */ if (chmod(TJE->ptc_name, 0666) != 0) @@ -3374,7 +3374,7 @@ void set_job_script_as_stdin( if (script_in < 0) { - log_err(errno, __func__, (char *)"unable to open script"); + log_err(errno, __func__, "unable to open script"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL1, sjr); } @@ -3419,7 +3419,7 @@ void setup_batch_job( /* NOTE: set arg2 to 5 to enable file open timeout check */ if (open_std_out_err(pjob, 0) == -1) { - log_err(-1, __func__, (char *)"unable to open stdout/stderr descriptors"); + log_err(-1, __func__, "unable to open stdout/stderr descriptors"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_STDOUTFAIL, sjr); } @@ -3484,7 +3484,7 @@ void attempt_to_set_limits( } else { - log_err(errno, __func__, (char *)"mom_set_limits failed"); + log_err(errno, __func__, "mom_set_limits failed"); } starter_return(TJE->upfds, TJE->downfds, j, sjr); /* exits */ @@ -3617,11 +3617,11 @@ void setup_interactive_command_if_present( if ((pjob->ji_wattr[JOB_ATR_inter_cmd].at_flags & ATR_VFLAG_SET) != 0) { - arg[aindex] = calloc(1, strlen("-c") + 1); + arg[aindex] = (char *)calloc(1, strlen("-c") + 1); if (arg[aindex] == NULL) { - log_err(errno, __func__, (char *)"cannot alloc env"); + log_err(errno, __func__, "cannot alloc env"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL2, sjr); } @@ -3632,11 +3632,11 @@ void setup_interactive_command_if_present( aindex++; - arg[aindex] = calloc(1, strlen(pjob->ji_wattr[JOB_ATR_inter_cmd].at_val.at_str) + 1); + arg[aindex] = (char *)calloc(1, strlen(pjob->ji_wattr[JOB_ATR_inter_cmd].at_val.at_str) + 1); if (arg[aindex] == NULL) { - log_err(errno, __func__, (char *)"cannot alloc env"); + log_err(errno, __func__, "cannot alloc env"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL2, sjr); } @@ -3704,7 +3704,7 @@ void add_preexec_if_needed( if (arg[aindex] == NULL) { - log_err(errno, __func__, (char *)"cannot alloc env"); + log_err(errno, __func__, "cannot alloc env"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL2, sjr); } @@ -3729,7 +3729,7 @@ void launch_the_demux( { /* child does demux */ - char *demux = DEMUX; + const char *demux = DEMUX; char *shellname; char *arg[MAX_JOB_ARGS]; int aindex; @@ -3749,7 +3749,7 @@ void launch_the_demux( close(pjob->ji_stderr); /* construct argv array */ - shellname = strrchr(demux, '/'); + shellname = strrchr((char *)demux, '/'); if (shellname != NULL) ++shellname; /* go past last '/' */ @@ -3758,11 +3758,11 @@ void launch_the_demux( aindex = 0; - arg[aindex] = calloc(1, strlen(shellname) + 1); + arg[aindex] = (char *)calloc(1, strlen(shellname) + 1); if (arg[aindex] == NULL) { - log_err(errno, __func__, (char *)"cannot alloc env"); + log_err(errno, __func__, "cannot alloc env"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL2, sjr); } @@ -3778,7 +3778,7 @@ void launch_the_demux( execve(demux, arg, vtable.v_envp); /* reached only if execve fails */ - *shell_ptr = demux; /* for fprintf below */ + *shell_ptr = (char *)demux; /* for fprintf below */ } /* END launch_the_demux() */ @@ -3801,11 +3801,11 @@ void source_login_shells_or_not( if (((TJE->is_interactive == TRUE) && (src_login_interactive == FALSE)) || ((TJE->is_interactive != TRUE) && (src_login_batch == FALSE))) { - arg[aindex] = calloc(1, strlen(shellname) + 1); + arg[aindex] = (char *)calloc(1, strlen(shellname) + 1); if (arg[aindex] == NULL) { - log_err(errno, __func__, (char *)"cannot alloc env"); + log_err(errno, __func__, "cannot alloc env"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL2, sjr); } @@ -3822,11 +3822,11 @@ void source_login_shells_or_not( } else { - arg[aindex] = calloc(1, strlen(shellname) + 2); + arg[aindex] = (char *)calloc(1, strlen(shellname) + 2); if (arg[aindex] == NULL) { - log_err(errno, __func__, (char *)"cannot alloc env"); + log_err(errno, __func__, "cannot alloc env"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_FAIL2, sjr); } @@ -3880,7 +3880,7 @@ int TMomFinalizeChild( if (pwdp == NULL) { - log_err(PBSE_BADUSER, __func__, (char *)"Running job with no password entry?"); + log_err(PBSE_BADUSER, __func__, "Running job with no password entry?"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_RETRY, &sjr); @@ -3921,7 +3921,7 @@ int TMomFinalizeChild( /* Setup user env */ if (InitUserEnv(pjob, ptask, NULL, pwdp, shell) < 0) { - log_err(-1, __func__, (char *)"failed to setup user env"); + log_err(-1, __func__, "failed to setup user env"); starter_return(TJE->upfds, TJE->downfds, JOB_EXEC_RETRY, &sjr); } @@ -3950,7 +3950,7 @@ int TMomFinalizeChild( if ((j = CPACreatePartition(pjob, &vtable)) != 0) { - log_err(-1, __func__, (char *)"CPACreatePartition failed"); + log_err(-1, __func__, "CPACreatePartition failed"); starter_return(TJE->upfds, TJE->downfds, j, &sjr); /* exits */ @@ -3967,7 +3967,7 @@ int TMomFinalizeChild( if (j != 0) { - log_err(-1, __func__, (char *)"failed to set mach vars"); + log_err(-1, __func__, "failed to set mach vars"); starter_return(TJE->upfds, TJE->downfds, j, &sjr); /* exits */ @@ -4149,7 +4149,7 @@ int TMomFinalizeChild( if (arg[aindex] == NULL) { - log_err(errno, __func__, (char *)"cannot alloc env"); + log_err(errno, __func__, "cannot alloc env"); starter_return(TJE->upfds,TJE->downfds,JOB_EXEC_FAIL2,&sjr); @@ -4307,7 +4307,7 @@ int TMomFinalizeJob3( if (pjob == NULL) { - log_err(-1, __func__, (char *)"This function needs a valid job pointer"); + log_err(-1, __func__, "This function needs a valid job pointer"); return(FAILURE); } @@ -4836,7 +4836,7 @@ int start_process( if (InitUserEnv(pjob, ptask, envp, NULL, NULL) < 0) { - log_err(errno, __func__, (char *)"failed to setup user env"); + log_err(errno, __func__, "failed to setup user env"); starter_return(kid_write, kid_read, JOB_EXEC_RETRY, &sjr); @@ -4898,7 +4898,7 @@ int start_process( if ((fd0 = search_env_and_open("MPIEXEC_STDIN_PORT", ipaddr)) == -2) { - log_err(errno, __func__, (char *)"cannot locate MPIEXEC_STDIN_PORT"); + log_err(errno, __func__, "cannot locate MPIEXEC_STDIN_PORT"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -4909,7 +4909,7 @@ int start_process( if ((fd0 < 0) && ((fd0 = search_env_and_open("TM_STDIN_PORT", ipaddr)) == -2)) { - log_err(errno, __func__, (char *)"cannot locate TM_STDIN_PORT"); + log_err(errno, __func__, "cannot locate TM_STDIN_PORT"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -4922,7 +4922,7 @@ int start_process( if ((fd0 < 0) && (fd0 = open("/dev/null", O_RDONLY)) == -1) { - log_err(errno, __func__, (char *)"could not open dev/null"); + log_err(errno, __func__, "could not open dev/null"); close(0); } @@ -4938,7 +4938,7 @@ int start_process( if ((fd1 = search_env_and_open("MPIEXEC_STDOUT_PORT", ipaddr)) == -2) { - log_err(errno, __func__, (char *)"cannot locate MPIEXEC_STDOUT_PORT"); + log_err(errno, __func__, "cannot locate MPIEXEC_STDOUT_PORT"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -4951,7 +4951,7 @@ int start_process( { if ((fd1 = search_env_and_open("TM_STDOUT_PORT", ipaddr)) == -2) { - log_err(errno, __func__, (char *)"cannot locate TM_STDOUT_PORT"); + log_err(errno, __func__, "cannot locate TM_STDOUT_PORT"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -4963,7 +4963,7 @@ int start_process( if ((fd2 = search_env_and_open("MPIEXEC_STDERR_PORT", ipaddr)) == -2) { - log_err(errno, __func__, (char *)"cannot locate MPIEXEC_STDERR_PORT"); + log_err(errno, __func__, "cannot locate MPIEXEC_STDERR_PORT"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -4976,7 +4976,7 @@ int start_process( { if ((fd2 = search_env_and_open("TM_STDERR_PORT", ipaddr)) == -2) { - log_err(errno, __func__, (char *)"cannot locate TM_STDERR_PORT"); + log_err(errno, __func__, "cannot locate TM_STDERR_PORT"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -5025,7 +5025,7 @@ int start_process( if ((fd1 < 0) && ((fd1 = open_demux(ipaddr, pjob->ji_portout)) == -1)) { - log_err(errno, __func__, (char *)"cannot open mux stdout port"); + log_err(errno, __func__, "cannot open mux stdout port"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -5041,7 +5041,7 @@ int start_process( if ((fd2 < 0) && ((fd2 = open_demux(ipaddr, pjob->ji_porterr)) == -1)) { - log_err(errno, __func__, (char *)"cannot open mux stderr port"); + log_err(errno, __func__, "cannot open mux stderr port"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -5076,7 +5076,7 @@ int start_process( { if ((pts = open_pty(pjob)) < 0) { - log_err(errno, __func__, (char *)"cannot open slave pty"); + log_err(errno, __func__, "cannot open slave pty"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); @@ -5117,7 +5117,7 @@ int start_process( { if (open_std_out_err(pjob, -1) == -1) { - log_err(errno, __func__, (char *)"cannot open job stderr/stdout files"); + log_err(errno, __func__, "cannot open job stderr/stdout files"); starter_return(kid_write, kid_read, JOB_EXEC_FAIL1, &sjr); } @@ -5456,7 +5456,7 @@ void job_nodes( } else { - log_err(-1, __func__, (char *)"Cannot parse the nodes for a job without exec hosts being set"); + log_err(-1, __func__, "Cannot parse the nodes for a job without exec hosts being set"); return; } @@ -5466,7 +5466,7 @@ void job_nodes( if ((pjob->ji_hosts == NULL) || (pjob->ji_vnods == NULL)) { - log_err(-1,__func__,"(char *)Out of memory, system failure!\n"); + log_err(-1,__func__,"Out of memory, system failure!\n"); return; } @@ -5942,9 +5942,9 @@ int generate_cookie( if (!(pjob->ji_wattr[JOB_ATR_Cookie].at_flags & ATR_VFLAG_SET)) { - if ((tt = calloc(1, JOB_COOKIE_SIZE)) == NULL) + if ((tt = (char *)calloc(1, JOB_COOKIE_SIZE)) == NULL) { - log_err(ENOMEM, __func__, (char *)"cannot alloc memory"); + log_err(ENOMEM, __func__, "cannot alloc memory"); exec_bail(pjob, JOB_EXEC_FAIL1); @@ -6388,7 +6388,7 @@ pid_t fork_me( } else if (pid < 0) { - log_err(errno, "fork_me", (char *)"fork failed"); + log_err(errno, "fork_me", "fork failed"); } return(pid); @@ -6534,7 +6534,7 @@ char *std_file_name( char key; int len; char *pd; - char *suffix; + const char *suffix; char *jobpath = NULL; #ifdef QSUB_KEEP_NO_OVERRIDE char *pt; @@ -6903,7 +6903,7 @@ int open_std_file( if ((path = std_file_name(pjob, which, &keeping)) == NULL) { - log_err(-1, __func__, (char *)"cannot determine filename"); + log_err(-1, __func__, "cannot determine filename"); /* FAILURE - cannot determine filename */ @@ -6987,7 +6987,7 @@ int open_std_file( if (S_ISLNK(statbuf.st_mode)) { - log_err(-1, __func__, (char *)"std file is symlink, someone is doing something fishy"); + log_err(-1, __func__, "std file is symlink, someone is doing something fishy"); goto reset_ids_fail; } @@ -7022,12 +7022,12 @@ int open_std_file( pjob->ji_qs.ji_un.ji_momt.ji_exuid, pjob->ji_qs.ji_un.ji_momt.ji_exgid) == -1) { - log_err(errno, __func__, (char *)"std file exists with the wrong group, someone is doing something fishy, cannot change file group"); + log_err(errno, __func__, "std file exists with the wrong group, someone is doing something fishy, cannot change file group"); goto reset_ids_fail; } #else - log_err(-1, __func__, (char *)"std file exists with the wrong group, someone is doing something fishy"); + log_err(-1, __func__, "std file exists with the wrong group, someone is doing something fishy"); goto reset_ids_fail; #endif @@ -7261,8 +7261,8 @@ static int find_env_slot( void bld_env_variables( struct var_table *vtable, /* I (modified) */ - char *name, /* I (required) */ - char *value) /* I (optional) */ + const char *name, /* I (required) */ + const char *value) /* I (optional) */ { int amt; @@ -7281,7 +7281,7 @@ void bld_env_variables( if (LOGLEVEL >= 7) { - log_err(-1, "bld_env_variables", (char *)"invalid name passed"); + log_err(-1, "bld_env_variables", "invalid name passed"); } } @@ -7385,7 +7385,7 @@ int init_groups( if (nsaved < 0) { - log_err(errno, __func__, (char *)"getgroups"); + log_err(errno, __func__, "getgroups"); return(-1); } @@ -7418,7 +7418,7 @@ int init_groups( if (pwe == NULL) { - log_err(errno, __func__, (char *)"no such user"); + log_err(errno, __func__, "no such user"); return(-1); } @@ -7436,7 +7436,7 @@ int init_groups( if (sigprocmask(SIG_BLOCK, &allsigs, &savedset) == -1) { - log_err(errno, __func__, (char *)"sigprocmask(BLOCK)"); + log_err(errno, __func__, "sigprocmask(BLOCK)"); return(-1); } @@ -7445,7 +7445,7 @@ int init_groups( if (initgroups(pwname, pwgrp) < 0) { - log_err(errno, __func__, (char *)"initgroups"); + log_err(errno, __func__, "initgroups"); n = -1; } @@ -7462,10 +7462,10 @@ int init_groups( /* restore state */ if (setgroups(nsaved, savedgroups) < 0) - log_err(errno, __func__, (char *)"setgroups"); + log_err(errno, __func__, "setgroups"); if (sigprocmask(SIG_SETMASK, &savedset, NULL) == -1) - log_err(errno, __func__, (char *)"sigprocmask(SIG_SETMASK)"); + log_err(errno, __func__, "sigprocmask(SIG_SETMASK)"); return(n); } /* END init_groups() */ @@ -8437,7 +8437,7 @@ int allocate_demux_sockets( /* command sisters to abort job and continue */ - log_err(errno, __func__, (char *)"stdout/err socket"); + log_err(errno, __func__, "stdout/err socket"); exec_bail(pjob, JOB_EXEC_FAIL1); diff --git a/src/resmom/start_exec.h b/src/resmom/start_exec.h index 728ae29b93..aed7f258fa 100644 --- a/src/resmom/start_exec.h +++ b/src/resmom/start_exec.h @@ -86,7 +86,7 @@ int open_std_file(job *pjob, enum job_file which, int mode, gid_t exgid); /* static int find_env_slot(struct var_table *ptbl, char *pstr); */ -void bld_env_variables(struct var_table *vtable, char *name, char *value); +void bld_env_variables(struct var_table *vtable, const char *name, const char *value); #ifndef __TOLDGROUP int init_groups(char *pwname, int pwgrp, int groupsize, int *groups); diff --git a/src/resmom/test/alps_reservations/scaffolding.c b/src/resmom/test/alps_reservations/scaffolding.c index ae300ff199..bf36b5cf07 100644 --- a/src/resmom/test/alps_reservations/scaffolding.c +++ b/src/resmom/test/alps_reservations/scaffolding.c @@ -426,7 +426,7 @@ int append_char_to_dynamic_string( char *threadsafe_tokenizer( char **str, /* M */ - char *delims) /* I */ + const char *delims) /* I */ { char *current_char; @@ -468,7 +468,7 @@ char *threadsafe_tokenizer( } /* END threadsafe_tokenizer() */ -void log_err(int errnum, const char *routine, char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} diff --git a/src/resmom/test/catch_child/scaffolding.c b/src/resmom/test/catch_child/scaffolding.c index 107de54b8d..592cea9c94 100644 --- a/src/resmom/test/catch_child/scaffolding.c +++ b/src/resmom/test/catch_child/scaffolding.c @@ -41,7 +41,7 @@ const char *PMOMCommand[] = NULL }; int termin_child = 0; /* mom_main.c */ -int LOGLEVEL = 0; /* mom_main.c/pbsd_main.c */ +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ /* mom_main.c/pbsd_main.c */ tlist_head svr_alljobs; /* mom_main.c */ char log_buffer[LOG_BUF_SIZE]; /* pbs_log.c */ int multi_mom = 1; /* mom_main.c */ /* 1 to trigger conditions */ @@ -75,7 +75,7 @@ void exit_test(int num) exit_called = num; } -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { } @@ -617,7 +617,7 @@ void checkpoint_partial(job *pjob) { } -void log_event(int eventtype, int objclass, const char *objname, char *text) +void log_event(int eventtype, int objclass, const char *objname, const char *text) { } @@ -777,7 +777,7 @@ const char *PJobSubState[] = NULL }; -int kill_job(job *pjob, int sig, const char *killer_id_name, char *why_killed_reason) +int kill_job(job *pjob, int sig, const char *killer_id_name, const char *why_killed_reason) { if (func_num == INIT_ABORT_JOBS) { @@ -1067,7 +1067,7 @@ int DIS_reply_read(struct tcp_chan *chan, struct batch_reply *preply) return rc; } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { } @@ -1112,7 +1112,7 @@ resource *find_resc_entry(pbs_attribute *pattr, resource_def *rscdf) return presc; } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { return NULL; } @@ -1129,7 +1129,7 @@ int run_pelog(int which, char *specpelog, job *pjog, int pe_io_type) return 1; } -void log_ext(int errnum, const char *routine, char *text, int severity) +void log_ext(int errnum, const char *routine, const char *text, int severity) { } @@ -1230,7 +1230,7 @@ void mom_checkpoint_recover(job *pjob) } } -u_long addclient(char *name) +u_long addclient(const char *name) { return 0; } diff --git a/src/resmom/test/catch_child/test_mom_deljob.c b/src/resmom/test/catch_child/test_mom_deljob.c index 6fee87dcb8..c4220a6b2f 100644 --- a/src/resmom/test/catch_child/test_mom_deljob.c +++ b/src/resmom/test/catch_child/test_mom_deljob.c @@ -4,8 +4,8 @@ START_TEST(test_mom_deljob_1) { - job *pjob = NULL; - mom_deljob(pjob); + /*job *pjob = NULL; + mom_deljob(pjob);*/ } END_TEST diff --git a/src/resmom/test/checkpoint/scaffolding.c b/src/resmom/test/checkpoint/scaffolding.c index 2c961bb2be..baf052fb47 100644 --- a/src/resmom/test/checkpoint/scaffolding.c +++ b/src/resmom/test/checkpoint/scaffolding.c @@ -22,7 +22,7 @@ int exiting_tasks; /* mom_main.c */ resource_def *svr_resc_def; /* resc_def_all.c */ char *path_spool; /* mom_main.c */ int pbs_rm_port; /* mom_main.c */ -int LOGLEVEL = 0; /* mom_main.c/pbsd_main.c */ +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ /* mom_main.c/pbsd_main.c */ int job_save(job *pjob, int updatetype, int mom_port) @@ -73,7 +73,7 @@ int mach_checkpoint(struct task *tsk, char *path, int abt) exit(1); } -char *mk_dirs(char *base) +char *mk_dirs(const char *base) { fprintf(stderr, "The call to mk_dirs needs to be mocked!!\n"); exit(1); @@ -97,7 +97,7 @@ int mom_does_checkpoint() exit(1); } -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_str needs to be mocked!!\n"); exit(1); @@ -145,7 +145,7 @@ void net_close(int but) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); @@ -175,7 +175,7 @@ long mach_restart(struct task *tsk, char *path) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def needs to be mocked!!\n"); exit(1); @@ -229,7 +229,7 @@ resource *find_resc_entry(pbs_attribute *pattr, resource_def *rscdf) exit(1); } -int kill_job(job *pjob, int sig, const char *killer_id_name, char *why_killed_reason) +int kill_job(job *pjob, int sig, const char *killer_id_name, const char *why_killed_reason) { fprintf(stderr, "The call to kill_job needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/generate_alps_status/scaffolding.c b/src/resmom/test/generate_alps_status/scaffolding.c index c28cc9dd98..93343c37b1 100644 --- a/src/resmom/test/generate_alps_status/scaffolding.c +++ b/src/resmom/test/generate_alps_status/scaffolding.c @@ -16,7 +16,7 @@ char log_buffer[16384]; -void log_err(int errnum, const char *routine, char *msg) {} +void log_err(int errnum, const char *routine, const char *msg) {} diff --git a/src/resmom/test/mom_comm/scaffolding.c b/src/resmom/test/mom_comm/scaffolding.c index 2a8bb4bab4..5f258156e1 100644 --- a/src/resmom/test/mom_comm/scaffolding.c +++ b/src/resmom/test/mom_comm/scaffolding.c @@ -34,8 +34,10 @@ AvlTree okclients; /* mom_main.c */ tlist_head mom_polljobs; /* mom_main.c */ char *path_prologp; /* mom_main.c */ tlist_head svr_alljobs; /* mom_main.c */ -int LOGLEVEL = 0; /* mom_main.c/pbsd_main.c */ +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ /* mom_main.c/pbsd_main.c */ int maxupdatesbeforesending = 0; +int ServerStatUpdateInterval = DEFAULT_SERVER_STAT_UPDATES; +time_t LastServerUpdateTime = 0; /* NOTE: all servers updated together */ int insert_thing(resizable_array *ra, void *thing) { @@ -140,7 +142,7 @@ int add_hash(hash_table_t *ht, int value, void *key) exit(1); } -char *get_job_envvar(job *pjob, char *variable) +char *get_job_envvar(job *pjob, const char *variable) { fprintf(stderr, "The call to get_job_envvar needs to be mocked!!\n"); exit(1); @@ -183,7 +185,7 @@ unsigned long disrul(int stream, int *retval) exit(1); } -char * getuname(void ) +const char * getuname(void ) { fprintf(stderr, "The call to getuname needs to be mocked!!\n"); exit(1); @@ -310,7 +312,7 @@ void attrl_fixlink(tlist_head *phead) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def needs to be mocked!!\n"); exit(1); @@ -425,7 +427,7 @@ int allocate_demux_sockets(job *pjob, int flag) exit(1); } -int kill_job(job *pjob, int sig, const char *killer_id_name, char *why_killed_reason) +int kill_job(job *pjob, int sig, const char *killer_id_name, const char *why_killed_reason) { fprintf(stderr, "The call to kill_job needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/mom_inter/scaffolding.c b/src/resmom/test/mom_inter/scaffolding.c index da5b1857d0..9825ae8a1d 100644 --- a/src/resmom/test/mom_inter/scaffolding.c +++ b/src/resmom/test/mom_inter/scaffolding.c @@ -19,7 +19,7 @@ ssize_t read_blocking_socket(int fd, void *buf, ssize_t count) exit(1); } -void port_forwarder( struct pfwdsock *socks, int (*connfunc)(char *, int, char *), char *phost, int pport, char *EMsg) +void port_forwarder( struct pfwdsock *socks, int (*connfunc)(char *, long, char *), char *phost, int pport, char *EMsg) { fprintf(stderr, "The call to port_forwarder needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/mom_job_func/scaffolding.c b/src/resmom/test/mom_job_func/scaffolding.c index fca06d9173..42dd9c7931 100644 --- a/src/resmom/test/mom_job_func/scaffolding.c +++ b/src/resmom/test/mom_job_func/scaffolding.c @@ -25,7 +25,7 @@ char tmpdir_basename[MAXPATHLEN]; /* mom_main.c */ char *msg_err_purgejob; /* pbs_messages.c */ int pbs_rm_port; /* mom_main.c */ tlist_head svr_alljobs; /* mom_main.c */ -int LOGLEVEL = 0; /* mom_main.c/pbsd_main.c */ +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ /* mom_main.c/pbsd_main.c */ char log_buffer[LOG_BUF_SIZE]; /* pbs_log.c */ @@ -47,7 +47,7 @@ void delete_link(struct list_link *old) exit(1); } -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_record needs to be mocked!!\n"); exit(1); @@ -59,7 +59,7 @@ int enqueue_threadpool_request(void *(*func)(void *),void *arg) exit(1); } -void log_ext(int errnum, const char *routine, char *text, int severity) +void log_ext(int errnum, const char *routine, const char *text, int severity) { fprintf(stderr, "The call to log_ext needs to be mocked!!\n"); exit(1); @@ -95,7 +95,7 @@ void mom_checkpoint_delete_files(job_file_delete_info *jfdi) exit(1); } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/mom_main/scaffolding.c b/src/resmom/test/mom_main/scaffolding.c index 60feddd08f..a19f5871e8 100644 --- a/src/resmom/test/mom_main/scaffolding.c +++ b/src/resmom/test/mom_main/scaffolding.c @@ -88,7 +88,7 @@ void scan_non_child_tasks(void) exit(1); } -unsigned int get_svrport(char *service_name, char *ptype, unsigned int pdefault) +unsigned int get_svrport(const char *service_name, const char *ptype, unsigned int pdefault) { fprintf(stderr, "The call to get_svrport needs to be mocked!!\n"); exit(1); @@ -172,7 +172,7 @@ int add_network_entry(mom_hierarchy_t *nt, char *name, struct addrinfo *ai, unsi exit(1); } -int log_init(char *suffix, char *hostname) +int log_init(const char *suffix, const char *hostname) { fprintf(stderr, "The call to log_init needs to be mocked!!\n"); exit(1); @@ -184,7 +184,7 @@ int post_epilogue(job *pjob, int ev) exit(1); } -char *get_job_envvar(job *pjob, char *variable) +char *get_job_envvar(job *pjob, const char *variable) { fprintf(stderr, "The call to get_job_envvar needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/mom_process_request/scaffolding.c b/src/resmom/test/mom_process_request/scaffolding.c index bfb95c5c2a..8ed2ba7bf0 100644 --- a/src/resmom/test/mom_process_request/scaffolding.c +++ b/src/resmom/test/mom_process_request/scaffolding.c @@ -104,7 +104,7 @@ int AVL_is_in_tree_no_port_compare(u_long key, uint16_t port, AvlTree tree) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/mom_req_quejob/scaffolding.c b/src/resmom/test/mom_req_quejob/scaffolding.c index e932a19fad..bc43f9a734 100644 --- a/src/resmom/test/mom_req_quejob/scaffolding.c +++ b/src/resmom/test/mom_req_quejob/scaffolding.c @@ -27,7 +27,7 @@ char mom_host[PBS_MAXHOSTNAME + 1]; unsigned int pbs_rm_port = 0; int internal_state = 0; tlist_head svr_alljobs; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int PBSNodeCheckProlog = 0; char log_buffer[LOG_BUF_SIZE]; int reject_job_submit = 0; @@ -76,13 +76,13 @@ void delete_link(struct list_link *old) exit(1); } -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_record needs to be mocked!!\n"); exit(1); } -int decode_arst_merge(struct pbs_attribute *patr, char *name, char *rescn, char *val) +int decode_arst_merge(struct pbs_attribute *patr, const char *name, char *rescn, char *val) { fprintf(stderr, "The call to decode_arst_merge needs to be mocked!!\n"); exit(1); @@ -100,7 +100,7 @@ int find_attr(struct attribute_def *attr_def, char *name, int limit) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); @@ -136,7 +136,7 @@ int open_std_file(job *pjob, enum job_file which, int mode, gid_t exgid) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def needs to be mocked!!\n"); exit(1); @@ -166,7 +166,7 @@ int reply_jobid(struct batch_request *preq, char *jobid, int which) exit(1); } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/mom_server/scaffolding.c b/src/resmom/test/mom_server/scaffolding.c index e6820436b9..f0f715654c 100644 --- a/src/resmom/test/mom_server/scaffolding.c +++ b/src/resmom/test/mom_server/scaffolding.c @@ -47,7 +47,7 @@ char PBSNodeMsgBuf[1024]; int alarm_time; tlist_head svr_alljobs; char mom_alias[PBS_MAXHOSTNAME + 1]; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int rm_errno; int needs_cluster_addrs; time_t LastServerUpdateTime; @@ -68,7 +68,7 @@ node_comm_t *update_current_path(mom_hierarchy_t *nt) exit(1); } -char *dependent(char *res, struct rm_attribute *attr) +const char *dependent(const char *res, struct rm_attribute *attr) { fprintf(stderr, "The call to dependent needs to be mocked!!\n"); exit(1); @@ -86,7 +86,7 @@ int MUStrNCat(char **BPtr, int *BSpace, char *Src) exit(1); } -char *reqgres(struct rm_attribute *attrib) +const char *reqgres(struct rm_attribute *attrib) { fprintf(stderr, "The call to reqgres needs to be mocked!!\n"); exit(1); @@ -230,7 +230,7 @@ AvlTree AVL_insert(u_long key, uint16_t port, struct pbsnode *node, AvlTree tree exit(1); } -struct config *rm_search(struct config *where, char *what) +struct config *rm_search(struct config *where, const char *what) { fprintf(stderr, "The call to rm_search needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/prolog/scaffolding.c b/src/resmom/test/prolog/scaffolding.c index 97b88de376..c2c409d7ad 100644 --- a/src/resmom/test/prolog/scaffolding.c +++ b/src/resmom/test/prolog/scaffolding.c @@ -17,13 +17,13 @@ int reduceprologchecks; resource_def *svr_resc_def; char PBSNodeMsgBuf[1024]; int MOMPrologFailureCount; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char log_buffer[LOG_BUF_SIZE]; int MOMPrologTimeoutCount; uid_t pbsuser; gid_t pbsgroup; -int encode_resc(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int ac_perm) +int encode_resc(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int ac_perm) { fprintf(stderr, "The call to encode_resc needs to be mocked!!\n"); exit(1); @@ -35,7 +35,7 @@ char *get_job_envvar(job *pjob, char *variable) exit(1); } -void log_record(int eventtype, int objclass, const char *objname, char *text) +void log_record(int eventtype, int objclass, const char *objname, const char *text) { fprintf(stderr, "The call to log_record needs to be mocked!!\n"); exit(1); @@ -65,7 +65,7 @@ void net_close(int but) exit(1); } -void log_ext(int errnum, const char *routine, char *text, int severity) +void log_ext(int errnum, const char *routine, const char *text, int severity) { fprintf(stderr, "The call to log_ext needs to be mocked!!\n"); exit(1); @@ -95,7 +95,7 @@ int open_std_file(job *pjob, enum job_file which, int mode, gid_t exgid) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def needs to be mocked!!\n"); exit(1); @@ -113,7 +113,7 @@ int is_joined(job *pjob) exit(1); } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/release_reservation/scaffolding.c b/src/resmom/test/release_reservation/scaffolding.c index 3e4cc6999d..186400be94 100644 --- a/src/resmom/test/release_reservation/scaffolding.c +++ b/src/resmom/test/release_reservation/scaffolding.c @@ -7,7 +7,7 @@ char log_buffer[LOG_BUF_SIZE]; -void log_err(int errnum, const char *routine, char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} int find_error_type( diff --git a/src/resmom/test/requests/scaffolding.c b/src/resmom/test/requests/scaffolding.c index 6083b735f0..3a33463aba 100644 --- a/src/resmom/test/requests/scaffolding.c +++ b/src/resmom/test/requests/scaffolding.c @@ -38,7 +38,7 @@ unsigned int pbs_rm_port = 0; unsigned int alarm_time = 10; char *TNoSpoolDirList[TMAX_NSDCOUNT]; tlist_head svr_alljobs; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *msg_manager = "%s at request of %s@%s"; int multi_mom = 1; char MOMUNameMissing[64]; @@ -50,7 +50,7 @@ struct batch_request *alloc_br(int type) exit(1); } -char *arst_string(char *str, pbs_attribute *pattr) +char *arst_string(const char *str, pbs_attribute *pattr) { fprintf(stderr, "The call to arst_string needs to be mocked!!\n"); exit(1); @@ -164,7 +164,7 @@ int mom_open_socket_to_jobs_server(job *pjob, const char *caller_id, void *(*mes exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); @@ -326,7 +326,7 @@ job *job_alloc(void) exit(1); } -int kill_job(job *pjob, int sig, const char *killer_id_name, char *why_killed_reason) +int kill_job(job *pjob, int sig, const char *killer_id_name, const char *why_killed_reason) { fprintf(stderr, "The call to kill_job needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/start_exec/scaffolding.c b/src/resmom/test/start_exec/scaffolding.c index e12da1000d..44fdaf4408 100644 --- a/src/resmom/test/start_exec/scaffolding.c +++ b/src/resmom/test/start_exec/scaffolding.c @@ -52,7 +52,7 @@ char DEFAULT_UMASK[1024]; tlist_head mom_polljobs; long TJobStartBlockTime = 5; char *TNoSpoolDirList[TMAX_NSDCOUNT]; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *submithost_suffix = NULL; int num_var_env; char jobstarter_exe_name[MAXPATHLEN + 1]; @@ -83,7 +83,7 @@ int mom_checkpoint_start_restart(job *pjob) exit(1); } -char *arst_string(char *str, pbs_attribute *pattr) +char *arst_string(const char *str, pbs_attribute *pattr) { fprintf(stderr, "The call to arst_string needs to be mocked!!\n"); exit(1); @@ -161,7 +161,7 @@ void delete_link(struct list_link *old) exit(1); } -char *get_job_envvar(job *pjob, char *variable) +char *get_job_envvar(job *pjob, const char *variable) { fprintf(stderr, "The call to get_job_envvar needs to be mocked!!\n"); exit(1); @@ -323,7 +323,7 @@ int site_mom_chkuser(job *pjob) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/test/tmsock_recov/scaffolding.c b/src/resmom/test/tmsock_recov/scaffolding.c index 1ecc314dd7..283b83e5f4 100644 --- a/src/resmom/test/tmsock_recov/scaffolding.c +++ b/src/resmom/test/tmsock_recov/scaffolding.c @@ -9,7 +9,7 @@ ssize_t read_nonblocking_socket(int fd, void *buf, ssize_t count) exit(1); } -void log_err(int errnum, const char *routine, char *text) +void log_err(int errnum, const char *routine, const char *text) { fprintf(stderr, "The call to log_err needs to be mocked!!\n"); exit(1); diff --git a/src/resmom/tmsock_recov.c b/src/resmom/tmsock_recov.c index c8f6d066f9..f39635dec7 100644 --- a/src/resmom/tmsock_recov.c +++ b/src/resmom/tmsock_recov.c @@ -77,7 +77,7 @@ int recov_tmsock( job *pjob) /* I */ /* pathname to job save file */ { - char *id = "recov_tmsock"; + const char *id = "recov_tmsock"; static int sizeofint = sizeof(int); diff --git a/src/server/display_alps_status.c b/src/server/display_alps_status.c index 816edb0f15..6af33c4a9b 100644 --- a/src/server/display_alps_status.c +++ b/src/server/display_alps_status.c @@ -24,7 +24,7 @@ int get_alps_statuses( while ((alps_node = next_host(&(parent->alps_subnodes), &iter, NULL)) != NULL) { rc = status_node(alps_node, preq, bad, pstathd); - unlock_node(alps_node, __func__, NULL, 0); + unlock_node(alps_node, __func__, (char *)NULL, 0); if (rc != PBSE_NONE) break; diff --git a/src/server/ji_mutex.h b/src/server/ji_mutex.h index 526e4ba931..b2bc96e984 100644 --- a/src/server/ji_mutex.h +++ b/src/server/ji_mutex.h @@ -4,11 +4,11 @@ #include "pbs_job.h" #include "array.h" -int lock_ji_mutex(job *, const char *, char *, int); -int unlock_ji_mutex(job *, const char *, char *, int); +int lock_ji_mutex(job *, const char *, const char *, int); +int unlock_ji_mutex(job *, const char *, const char *, int); -int lock_ai_mutex(job_array *, const char *, char *, int); -int unlock_ai_mutex(job_array *, const char *, char *, int); +int lock_ai_mutex(job_array *, const char *, const char *, int); +int unlock_ai_mutex(job_array *, const char *, const char *, int); #endif diff --git a/src/server/job_attr_def.c b/src/server/job_attr_def.c index 3861ecf983..b33a3d0191 100644 --- a/src/server/job_attr_def.c +++ b/src/server/job_attr_def.c @@ -103,8 +103,8 @@ int encode_exec_host( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist */ - char *atname, /* name of pbs_attribute */ - char *rsname, /* resource name or null */ + const char *atname, /* name of pbs_attribute */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/server/job_func.c b/src/server/job_func.c index 81a9f615d4..a5b32a7a1a 100644 --- a/src/server/job_func.c +++ b/src/server/job_func.c @@ -148,6 +148,7 @@ #include "issue_request.h" /* release_req */ #include "ji_mutex.h" #include "user_info.h" +#include "svr_task.h" #ifndef TRUE @@ -166,7 +167,7 @@ int conn_qsub(char *, long, char *); extern void cleanup_restart_file(job *); extern struct batch_request *setup_cpyfiles(struct batch_request *,job *,char*,char *,int,int); extern int job_log_open(char *, char *); -extern int log_job_record(char *buf); +extern int log_job_record(const char *buf); extern void check_job_log(struct work_task *ptask); int issue_signal(job **, char *, void(*)(batch_request *), void *); @@ -1696,7 +1697,7 @@ int svr_job_purge( /* Start a task to monitor job log roll over if it is not already started */ if (check_job_log_started == 0) { - set_task(WORK_Timed, time_now + 10, check_job_log, (char *)NULL, FALSE); + set_task(WORK_Timed, time_now + 10, check_job_log, NULL, FALSE); check_job_log_started = 1; } @@ -1758,12 +1759,10 @@ int svr_job_purge( { int need_deque = !pjob->ji_cold_restart; - unlock_ji_mutex(pjob, __func__, (char *)"1", LOGLEVEL); - /* jobs that are being deleted after a cold restart * haven't been queued */ if (need_deque == TRUE) - rc = svr_dequejob(job_id, FALSE); + rc = svr_dequejob(pjob, FALSE); if (rc != PBSE_JOBNOTFOUND) { diff --git a/src/server/job_recov.c b/src/server/job_recov.c index 232d7f2714..0119b345d7 100644 --- a/src/server/job_recov.c +++ b/src/server/job_recov.c @@ -185,7 +185,7 @@ int job_save( char namebuf1[MAXPATHLEN]; char namebuf2[MAXPATHLEN]; char save_buf[SAVEJOB_BUF_SIZE]; - char *tmp_ptr = NULL; + const char *tmp_ptr = NULL; size_t buf_remaining = sizeof(save_buf); int openflags; diff --git a/src/server/job_route.c b/src/server/job_route.c index d311dc33b6..b9b872efd8 100644 --- a/src/server/job_route.c +++ b/src/server/job_route.c @@ -119,13 +119,12 @@ #define ROUTE_RETRY_TIME 10 /* External functions called */ -int svr_movejob(job *, char *, int *, struct batch_request *, int); +int svr_movejob(job *, char *, int *, struct batch_request *); long count_proc(char *spec); /* Local Functions */ int job_route(job *); -void *queue_route(void *); /* Global Data */ extern char *msg_routexceed; @@ -136,8 +135,6 @@ extern pthread_mutex_t *reroute_job_mutex; /* * Add an entry to the list of bad destinations for a job. - * - * Return: pointer to the new entry if it is added, NULL if not. */ void add_dest( @@ -146,24 +143,24 @@ void add_dest( { badplace *bp; - char *baddest = jobp->ji_qs.ji_destin; + char *baddest; + if (jobp == NULL) + { + log_err(-1, __func__, "add_dest called with null jobp"); + return; + } + baddest = jobp->ji_qs.ji_destin; bp = (badplace *)calloc(1, sizeof(badplace)); - if (bp == NULL) { log_err(errno, __func__, msg_err_malloc); - return; } CLEAR_LINK(bp->bp_link); - strcpy(bp->bp_dest, baddest); - append_link(&jobp->ji_rejectdest, &bp->bp_link, bp); - - return; } /* END add_dest() */ @@ -184,7 +181,6 @@ badplace *is_bad_dest( /* ji_rejectdest is set in add_dest if approved in ??? */ badplace *bp; - bp = (badplace *)GET_NEXT(jobp->ji_rejectdest); while (bp != NULL) @@ -276,7 +272,7 @@ int default_router( if (is_bad_dest(jobp, destination)) continue; - switch (svr_movejob(jobp, destination, &local_errno, NULL, TRUE)) + switch (svr_movejob(jobp, destination, &local_errno, NULL)) { case ROUTE_PERM_FAILURE: /* permanent failure */ @@ -561,10 +557,8 @@ void *queue_route( (pjob->ji_qs.ji_un.ji_routet.ji_rteretry != 0)) { reroute_job(pjob, pque); - unlock_ji_mutex(pjob, __func__, (char *)"1", LOGLEVEL); } - else - unlock_ji_mutex(pjob, __func__, (char *)"1", LOGLEVEL); + unlock_ji_mutex(pjob, __func__, (char *)"1", LOGLEVEL); } free(queue_name); diff --git a/src/server/login_nodes.c b/src/server/login_nodes.c index 4c16b2658b..206ce1ccbc 100644 --- a/src/server/login_nodes.c +++ b/src/server/login_nodes.c @@ -132,7 +132,7 @@ struct pbsnode *check_node( { struct pbsnode *pnode = ln->pnode; - lock_node(pnode, __func__, NULL, 20); + lock_node(pnode, __func__, (char *)NULL, 20); if ((hasprop(pnode, needed) == TRUE) && (pnode->nd_nsn - pnode->nd_np_to_be_used >= 1) && @@ -141,7 +141,7 @@ struct pbsnode *check_node( return(pnode); else { - unlock_node(pnode, __func__, NULL, 20); + unlock_node(pnode, __func__, (char *)NULL, 20); return(NULL); } } /* END check_node() */ @@ -252,7 +252,7 @@ struct pbsnode *get_next_login_node( if (ln != NULL) { pnode = ln->pnode; - lock_node(pnode, __func__, NULL, 0); + lock_node(pnode, __func__, (char *)NULL, 0); if (needed != NULL) { @@ -272,7 +272,7 @@ struct pbsnode *get_next_login_node( if (node_fits == FALSE) { - unlock_node(pnode, __func__, NULL, 0); + unlock_node(pnode, __func__, (char *)NULL, 0); pnode = find_fitting_node(needed); } else diff --git a/src/server/node_func.c b/src/server/node_func.c index 41917b77a3..3c9f805574 100644 --- a/src/server/node_func.c +++ b/src/server/node_func.c @@ -54,11 +54,13 @@ #include "work_task.h" #include "net_cache.h" #include "ji_mutex.h" +#include "svr_task.h" /* set_task */ #if !defined(H_ERRNO_DECLARED) && !defined(_AIX) -extern int h_errno; +/*extern int h_errno;*/ #endif +#define NULLSTR static_cast (0); /* Global Data */ extern hello_container failures; @@ -129,7 +131,7 @@ struct pbsnode *PGetNodeFromAddr( } } /* END for (aindex) */ - unlock_node(pnode, __func__, NULL, LOGLEVEL); + unlock_node(pnode, __func__, 0, LOGLEVEL); } /* END for each node */ return(NULL); @@ -174,7 +176,7 @@ void bad_node_warning( /* only release the mutex if we obtained it in this function */ if (node_possessed == NULL) - unlock_node(pnode, "bad_node_warning", "attained in function", LOGLEVEL); + unlock_node(pnode, __func__, (char *)"attained in function", LOGLEVEL); } } /* END bad_node_warning() */ @@ -246,7 +248,7 @@ int addr_ok( } if (release_mutex == TRUE) - unlock_node(pnode, __func__, "release_mutex = TRUE", LOGLEVEL); + unlock_node(pnode, __func__, (char *)"release_mutex = TRUE", LOGLEVEL); return(status); } /* END addr_ok() */ @@ -272,7 +274,7 @@ struct pbsnode *find_node_in_allnodes( pnode = (struct pbsnode *)an->ra->slots[index].item; if (pnode != NULL) - lock_node(pnode, __func__, NULL, 0); + lock_node(pnode, __func__, 0, 0); } pthread_mutex_unlock(an->allnodes_mutex); @@ -527,7 +529,7 @@ int login_encode_jobs( } } - if ((pal = attrlist_create(ATTR_NODE_jobs, NULL, strlen(job_str->str) + 1)) == NULL) + if ((pal = attrlist_create((char *)ATTR_NODE_jobs, (char *)NULL, strlen(job_str->str) + 1)) == NULL) { log_err(ENOMEM, __func__, (char *)""); return(ENOMEM); @@ -1147,7 +1149,7 @@ int update_nodes_file( PBSEVENT_ADMIN, PBS_EVENTCLASS_SERVER, "nodes", - "Node description file update failed"); + (char *)"Node description file update failed"); return(-1); } @@ -1158,7 +1160,7 @@ int update_nodes_file( PBSEVENT_ADMIN, PBS_EVENTCLASS_SERVER, "nodes", - "Server has empty nodes list"); + (char *)"Server has empty nodes list"); fclose(nin); @@ -1228,18 +1230,18 @@ int update_nodes_file( PBSEVENT_ADMIN, PBS_EVENTCLASS_SERVER, "nodes", - "Node description file update failed"); + (char *)"Node description file update failed"); fclose(nin); if (held != np) - unlock_node(np, __func__, "error", LOGLEVEL); + unlock_node(np, __func__, (char *)"error", LOGLEVEL); return(-1); } if (held != np) - unlock_node(np, __func__, "loop", LOGLEVEL); + unlock_node(np, __func__, (char *)"loop", LOGLEVEL); } /* for each node */ fclose(nin); @@ -1250,7 +1252,7 @@ int update_nodes_file( PBSEVENT_ADMIN, PBS_EVENTCLASS_SERVER, "nodes", - "replacing old nodes file failed"); + (char *)"replacing old nodes file failed"); return(-1); } @@ -1376,7 +1378,7 @@ int create_a_gpusubnode( { int rc = PBSE_NONE; - struct gpusubn *tmp = calloc((1 + pnode->nd_ngpus), sizeof(struct gpusubn)); + struct gpusubn *tmp = (struct gpusubn *)calloc((1 + pnode->nd_ngpus), sizeof(struct gpusubn)); if (tmp == NULL) { @@ -1674,7 +1676,7 @@ void recheck_for_node( int rc; int bad; - if ((host_info = ptask->wt_parm1) == NULL) + if ((host_info = (node_info *)ptask->wt_parm1) == NULL) { free(ptask->wt_mutex); free(ptask); @@ -1766,10 +1768,10 @@ int create_pbs_node( pattrl->al_flags = SET; append_link(&host_info->atrlist, &pattrl->al_link, pattrl); - pal = GET_NEXT(pal->al_link); + pal = (svrattrl *)GET_NEXT(pal->al_link); } - pattrl = GET_NEXT(host_info->atrlist); + pattrl = (svrattrl *)GET_NEXT(host_info->atrlist); host_info->plist = pattrl; if (objname != NULL) @@ -2148,7 +2150,7 @@ int setup_nodes(void) /* if any properties, create property attr and add to list */ if (propstr[0] != '\0') { - pal = attrlist_create(ATTR_NODE_properties, 0, strlen(propstr) + 1); + pal = (svrattrl *)attrlist_create((char *)ATTR_NODE_properties, 0, strlen(propstr) + 1); if (pal == NULL) { @@ -2168,7 +2170,7 @@ int setup_nodes(void) } /* now create node and subnodes */ - pal = GET_NEXT(atrlist); + pal = (svrattrl *)GET_NEXT(atrlist); if ((open_bracket = strchr(nodename,'[')) != NULL) { @@ -2328,12 +2330,12 @@ int setup_nodes(void) /* exclusive bits are calculated later in set_old_nodes() */ np->nd_state &= ~INUSE_JOB; - unlock_node(np, __func__, "match", LOGLEVEL); + unlock_node(np, __func__, (char *)"match", LOGLEVEL); break; } - unlock_node(np, __func__, "no match", LOGLEVEL); + unlock_node(np, __func__, (char *)"no match", LOGLEVEL); } } @@ -2361,7 +2363,7 @@ int setup_nodes(void) log_record(PBSEVENT_SCHED, PBS_EVENTCLASS_REQUEST, __func__, log_buf); } - unlock_node(np, __func__, "init - no note", LOGLEVEL); + unlock_node(np, __func__, (char *)"init - no note", LOGLEVEL); } } @@ -2626,12 +2628,12 @@ int node_gpus_action( if (new_gp < old_gp) { - delete_a_gpusubnode(pnode); + delete_a_gpusubnode((struct pbsnode *)pnode); old_gp--; } else { - create_a_gpusubnode(pnode); + create_a_gpusubnode((struct pbsnode *)pnode); old_gp++; } } @@ -2685,7 +2687,7 @@ int node_mics_action( if (new_mics > np->nd_nmics_alloced) { - struct jobinfo *tmp = calloc(new_mics, sizeof(struct jobinfo)); + struct jobinfo *tmp = (struct jobinfo *)calloc(new_mics, sizeof(struct jobinfo)); if (tmp == NULL) return(ENOMEM); @@ -2879,7 +2881,7 @@ int create_partial_pbs_node( } ntype = NTYPE_CLUSTER; - pul = calloc(2, sizeof(u_long)); + pul = (u_long *)calloc(2, sizeof(u_long)); if (!pul) { free(pnode); @@ -2993,9 +2995,9 @@ struct pbsnode *get_my_next_node_board( iter->numa_index++; numa = AVL_find(iter->numa_index, pnode->nd_mom_port, pnode->node_boards); - unlock_node(pnode, __func__, "pnode", LOGLEVEL); + unlock_node(pnode, __func__, (char *)"pnode", LOGLEVEL); if (numa != NULL) - lock_node(numa, __func__, "numa", LOGLEVEL); + lock_node(numa, __func__, (char *)"numa", LOGLEVEL); return(numa); } /* END get_my_next_node_board() */ @@ -3011,7 +3013,7 @@ struct pbsnode *get_my_next_alps_node( { struct pbsnode *alps_node = next_host(&(pnode->alps_subnodes), &(iter->alps_index), NULL); - unlock_node(pnode, __func__, NULL, 0); + unlock_node(pnode, __func__, (char *)NULL, 0); return(alps_node); } /* END get_my_next_alps_node() */ @@ -3037,7 +3039,7 @@ struct pbsnode *next_node( pthread_mutex_lock(an->allnodes_mutex); /* the first call to next_node */ - next = next_thing(an->ra, &iter->node_index); + next = (struct pbsnode *)next_thing(an->ra, &iter->node_index); if (next != NULL) lock_node(next, __func__, "next != NULL", LOGLEVEL); @@ -3082,7 +3084,7 @@ struct pbsnode *next_node( iter->alps_index = -1; pthread_mutex_lock(an->allnodes_mutex); - next = next_thing(an->ra, &iter->node_index); + next = (struct pbsnode *)next_thing(an->ra, &iter->node_index); pthread_mutex_unlock(an->allnodes_mutex); if (next != NULL) @@ -3100,7 +3102,7 @@ struct pbsnode *next_node( iter->alps_index = -1; pthread_mutex_lock(an->allnodes_mutex); - next = next_thing(an->ra, &iter->node_index); + next = (struct pbsnode *)next_thing(an->ra, &iter->node_index); pthread_mutex_unlock(an->allnodes_mutex); if (next != NULL) @@ -3121,7 +3123,7 @@ struct pbsnode *next_node( unlock_node(current, __func__, "next == NULL && numa_index+1", LOGLEVEL); pthread_mutex_lock(an->allnodes_mutex); - next = next_thing(an->ra, &iter->node_index); + next = (struct pbsnode *)next_thing(an->ra, &iter->node_index); pthread_mutex_unlock(an->allnodes_mutex); @@ -3155,7 +3157,7 @@ void initialize_all_nodes_array( an->ra = initialize_resizable_array(INITIAL_NODE_SIZE); an->ht = create_hash(INITIAL_HASH_SIZE); - an->allnodes_mutex = calloc(1, sizeof(pthread_mutex_t)); + an->allnodes_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(an->allnodes_mutex,NULL); } /* END initialize_all_nodes_array() */ @@ -3251,7 +3253,7 @@ struct pbsnode *next_host( pthread_mutex_lock(an->allnodes_mutex); } - pnode = next_thing(an->ra,iter); + pnode = (struct pbsnode *)next_thing(an->ra,iter); if ((pnode != NULL) && ((pnode != held) && (name == NULL))) @@ -3417,7 +3419,7 @@ void initialize_hello_container( { hc->ra = initialize_resizable_array(INITIAL_NODE_SIZE); - hc->hello_mutex = calloc(1, sizeof(pthread_mutex_t)); + hc->hello_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(hc->hello_mutex, NULL); } /* END initialize_hello_container() */ @@ -3449,7 +3451,7 @@ int add_hello( { int rc; - hello_info *hi = calloc(1, sizeof(hello_info)); + hello_info *hi = (hello_info *)calloc(1, sizeof(hello_info)); hi->name = node_name; pthread_mutex_lock(hc->hello_mutex); @@ -3476,7 +3478,7 @@ int add_hello_after( int index) { - hello_info *hi = calloc(1, sizeof(hello_info)); + hello_info *hi = (hello_info *)calloc(1, sizeof(hello_info)); int rc; hi->name = node_name; diff --git a/src/server/node_manager.c b/src/server/node_manager.c index a0b6eceaee..2368b4b3b3 100644 --- a/src/server/node_manager.c +++ b/src/server/node_manager.c @@ -128,6 +128,7 @@ #include "net_cache.h" #include "ji_mutex.h" #include "alps_constants.h" +#include "svr_task.h" #define IS_VALID_STR(STR) (((STR) != NULL) && ((STR)[0] != '\0')) @@ -135,7 +136,7 @@ extern int LOGLEVEL; #if !defined(H_ERRNO_DECLARED) && !defined(_AIX) -extern int h_errno; +/*extern int h_errno;*/ #endif @@ -1259,7 +1260,7 @@ void *write_node_state_work( { struct pbsnode *np; - static char *fmt = "%s %d\n"; + static char *fmt = (char *)"%s %d\n"; static FILE *nstatef = NULL; int iter = -1; diff --git a/src/server/pbsd_init.c b/src/server/pbsd_init.c index 66e2448abd..dc288597d4 100644 --- a/src/server/pbsd_init.c +++ b/src/server/pbsd_init.c @@ -243,7 +243,7 @@ void on_job_exit_task(struct work_task *); /* Private functions in this file */ void init_abt_job(job *); -char *build_path(char *, char *, char *); +char *build_path(char *, const char *, const char *); void catch_abort(int); void change_logs(); void change_logs_handler(int); @@ -348,7 +348,7 @@ int DArrayAppend( memcpy(tmp, Array->Data, sizeof(Array->Data[0]) * Array->Length); free(Array->Data); - Array->Data = tmp; + Array->Data = &tmp; Array->Length = newLength; } @@ -614,7 +614,7 @@ int handle_level( { char log_buf[LOCAL_LOG_BUF_SIZE]; - char *delims = ","; + const char *delims = ","; char *host_tok; dynamic_string *level_buf; @@ -799,7 +799,7 @@ dynamic_string *parse_mom_hierarchy( log_err( -1, __func__, log_buf); } - unlock_node(pnode, __func__, NULL, LOGLEVEL); + unlock_node(pnode, __func__, (char *)NULL, LOGLEVEL); } if (first_missing_node == FALSE) @@ -901,7 +901,7 @@ void add_all_nodes_to_hello_container() add_hello_after(&hellos, node_name_dup, level_indices[pnode->nd_hierarchy_level]); } - unlock_node(pnode, __func__, NULL, LOGLEVEL); + unlock_node(pnode, __func__, (char *)NULL, LOGLEVEL); } return; @@ -1112,8 +1112,8 @@ int initialize_paths() { int rc = PBSE_NONE; - char *suffix_slash = "/"; - char *new_tag = ".new"; + const char *suffix_slash = "/"; + const char *new_tag = ".new"; struct stat statbuf; char log_buf[LOCAL_LOG_BUF_SIZE]; #if !defined(DEBUG) && !defined(NO_SECURITY_CHECK) @@ -1212,7 +1212,7 @@ int initialize_paths() rc |= chk_file_sec(path_spool, 1, 1, S_IWOTH, 0, EMsg); rc |= chk_file_sec(path_acct, 1, 0, S_IWGRP | S_IWOTH, 0, EMsg); rc |= chk_file_sec(path_credentials, 1, 0, S_IWGRP | S_IWOTH, 0, EMsg); - rc |= chk_file_sec(PBS_ENVIRON, 0, 0, S_IWGRP | S_IWOTH, 1, EMsg); + rc |= chk_file_sec((char *)PBS_ENVIRON, 0, 0, S_IWGRP | S_IWOTH, 1, EMsg); if (rc != PBSE_NONE) { @@ -1230,22 +1230,22 @@ int initialize_data_structures_and_mutexes() { long cray_enabled = FALSE; - svr_do_schedule_mutex = calloc(1, sizeof(pthread_mutex_t)); + svr_do_schedule_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(svr_do_schedule_mutex, NULL); - check_tasks_mutex = calloc(1, sizeof(pthread_mutex_t)); + check_tasks_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(check_tasks_mutex, NULL); - listener_command_mutex = calloc(1, sizeof(pthread_mutex_t)); + listener_command_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(listener_command_mutex, NULL); - node_state_mutex = calloc(1, sizeof(pthread_mutex_t)); + node_state_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(node_state_mutex, NULL); - scheduler_sock_jobct_mutex = calloc(1, sizeof(pthread_mutex_t)); + scheduler_sock_jobct_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(scheduler_sock_jobct_mutex, NULL); - reroute_job_mutex = calloc(1, sizeof(pthread_mutex_t)); + reroute_job_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(reroute_job_mutex, NULL); pthread_mutex_lock(scheduler_sock_jobct_mutex); @@ -1288,7 +1288,7 @@ int initialize_data_structures_and_mutexes() initialize_alps_reservations(); } - acctfile_mutex = calloc(1, sizeof(pthread_mutex_t)); + acctfile_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(acctfile_mutex, NULL); return(PBSE_NONE); @@ -1620,7 +1620,7 @@ int handle_job_recovery( int baselen = 0; char *psuffix; int job_count = 0; /* Count of recovered jobs */ - char *job_suffix = JOB_FILE_SUFFIX; + const char *job_suffix = JOB_FILE_SUFFIX; int job_suf_len = strlen(job_suffix); char basen[MAXPATHLEN+1]; int Index; @@ -1992,7 +1992,7 @@ int handle_tracking_records() if (server.sv_tracksize < PBS_TRACK_MINSIZE) server.sv_tracksize = PBS_TRACK_MINSIZE; - if ((server.sv_track = calloc(server.sv_tracksize, sizeof(struct tracking))) == NULL) + if ((server.sv_track = (struct tracking *)calloc(server.sv_tracksize, sizeof(struct tracking))) == NULL) { /* FAILURE - cannot alloc memory */ log_err(errno, "pbs_init", (char *)"calloc failure"); @@ -2154,8 +2154,8 @@ int pbsd_init( char *build_path( char *parent, /* parent directory name (dirname) */ - char *name, /* sub directory name */ - char *suffix) /* suffix string to append */ + const char *name, /* sub directory name */ + const char *suffix) /* suffix string to append */ { int prefixslash; @@ -2176,7 +2176,7 @@ char *build_path( if (suffix != NULL) len += strlen(suffix); - ppath = calloc(1, PATH_MAX); + ppath = (char *)calloc(1, PATH_MAX); if (ppath != NULL) { @@ -2786,7 +2786,7 @@ void resume_net_move( struct work_task *ptask) { - char *jobid = ptask->wt_parm1; + char *jobid = (char *)ptask->wt_parm1; job *pjob; if (jobid != NULL) @@ -2827,15 +2827,15 @@ void rm_files( /* list of directories in which files are removed */ - static char *byebye[] = + static const char *byebye[] = { - "acl_groups", - "acl_hosts", - "acl_svr", - "acl_users", - "hostlist", - "queues", - NULL + "acl_groups", + "acl_hosts", + "acl_svr", + "acl_users", + "hostlist", + "queues", + NULL }; /* keep as last entry */ dir = opendir(dirname); @@ -2912,7 +2912,7 @@ int recov_svr_attr( { int rc; - char *suffix_slash = "/"; + const char *suffix_slash = "/"; if (type != RECOV_CREATE) { diff --git a/src/server/pbsd_main.c b/src/server/pbsd_main.c index c41cf02dbb..6a190d10f8 100644 --- a/src/server/pbsd_main.c +++ b/src/server/pbsd_main.c @@ -139,6 +139,7 @@ #include "ji_mutex.h" #include "job_route.h" /* queue_route */ #include "exiting_jobs.h" +#include "svr_task.h" #define TASK_CHECK_INTERVAL 10 #define HELLO_WAIT_TIME 600 @@ -219,7 +220,7 @@ int high_availability_mode = FALSE; char *acct_file = NULL; char *log_file = NULL; char *job_log_file = NULL; -char *path_home = PBS_SERVER_HOME; +char *path_home = (char *)PBS_SERVER_HOME; char *path_acct; char path_log[MAXPATHLEN + 1]; char *path_priv = NULL; @@ -243,7 +244,7 @@ char *path_jobinfo_log; char *ArgV[MAX_CMD_ARGS]; extern char *msg_daemonname; extern char *msg_info_server; /* Server information message */ -char *pbs_o_host = "PBS_O_HOST"; +const char *pbs_o_host = "PBS_O_HOST"; pbs_net_t pbs_mom_addr; unsigned int pbs_mom_port = 0; unsigned int pbs_rm_port; @@ -590,7 +591,7 @@ int add_listener( int PBSShowUsage( - char *EMsg) /* I (optional) */ + const char *EMsg) /* I (optional) */ { fprintf(stderr, "Usage: %s\n", @@ -652,7 +653,7 @@ void parse_command_line( static struct { - char *it_name; + const char *it_name; int it_type; } init_name_type[] = @@ -683,7 +684,7 @@ void parse_command_line( if (!strcmp(optarg, "version")) { fprintf(stderr, "Version: %s\nRevision: %s \n", - PACKAGE_VERSION, SVN_VERSION); + PACKAGE_VERSION, GIT_HASH); exit(0); } @@ -701,6 +702,7 @@ void parse_command_line( printf("installdir: %s\n", PBS_INSTALL_DIR); printf("serverhome: %s\n", PBS_SERVER_HOME); printf("version: %s\n", PACKAGE_VERSION); + printf("Revision: %s\n", GIT_HASH); exit(0); } @@ -1192,7 +1194,7 @@ void *handle_scheduler_contact( -void *start_accept_listener() +void *start_accept_listener(void *vp) { char server_name_trimmed[PBS_MAXSERVERNAME + 1]; diff --git a/src/server/pbsd_main.h b/src/server/pbsd_main.h index 902a1fae9c..122d0e5f82 100644 --- a/src/server/pbsd_main.h +++ b/src/server/pbsd_main.h @@ -16,7 +16,7 @@ void clear_listeners(void); int add_listener(pbs_net_t l_addr, unsigned int l_port); -int PBSShowUsage(char *EMsg); +int PBSShowUsage(const char *EMsg); void parse_command_line(int argc, char *argv[]); diff --git a/src/server/process_mom_update.c b/src/server/process_mom_update.c index aab315e7ea..1146fec321 100644 --- a/src/server/process_mom_update.c +++ b/src/server/process_mom_update.c @@ -90,6 +90,7 @@ #include "dis.h" #include "utils.h" #include "ji_mutex.h" +#include "../lib/Libutils/u_lock_ctl.h" @@ -242,7 +243,7 @@ struct pbsnode *get_numa_from_str( np->nd_name); log_err(-1, __func__, log_buf); - unlock_node(np, __func__, "np numa update", LOGLEVEL); + unlock_node(np, __func__, (char *)"np numa update", LOGLEVEL); return(NULL); } @@ -261,14 +262,14 @@ struct pbsnode *get_numa_from_str( np->nd_name); log_err(-1, __func__, log_buf); - unlock_node(np, __func__, "np numa update", LOGLEVEL); + unlock_node(np, __func__, (char *)"np numa update", LOGLEVEL); return(NULL); } /* SUCCESS */ - unlock_node(np, __func__, "np numa update", LOGLEVEL); - lock_node(numa, __func__, "numa numa update", LOGLEVEL); + unlock_node(np, __func__, (char *)"np numa update", LOGLEVEL); + lock_node(numa, __func__, (char *)"numa numa update", LOGLEVEL); numa->nd_lastupdate = time(NULL); @@ -296,7 +297,7 @@ struct pbsnode *get_node_from_str( /* don't do anything if the name is the same as this node's name */ if (strcmp(node_id, np->nd_name)) { - unlock_node(np, __func__, "np not numa update", LOGLEVEL); + unlock_node(np, __func__, (char *)"np not numa update", LOGLEVEL); next = find_nodebyname(node_id); @@ -776,7 +777,7 @@ int process_status_info( if (current != NULL) { save_node_status(current, &temp); - unlock_node(current, __func__, NULL, 0); + unlock_node(current, __func__, (char *)NULL, 0); } if ((rc == PBSE_NONE) && diff --git a/src/server/queue_func.c b/src/server/queue_func.c index cdafbd7fbd..761f1f6de8 100644 --- a/src/server/queue_func.c +++ b/src/server/queue_func.c @@ -137,7 +137,7 @@ int lock_queue( int logging) { - int rc = PBSE_NONE; + int rc = PBSE_NONE; char *err_msg = NULL; if (logging >= 10) @@ -148,15 +148,15 @@ int lock_queue( } if (pthread_mutex_lock(the_queue->qu_mutex) != 0) - { - if (logging >= 10) + { + if (logging >= 10) { snprintf(err_msg, MSG_LEN_LONG, "ALERT: cannot lock queue %s mutex in method %s", the_queue->qu_qs.qu_name, id); log_record(PBSEVENT_DEBUG, PBS_EVENTCLASS_NODE, __func__, err_msg); } rc = PBSE_MUTEX; - } + } if (err_msg != NULL) free(err_msg); @@ -234,7 +234,7 @@ pbs_queue *que_alloc( pq->qu_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); pq->qu_jobs = (struct all_jobs *)calloc(1, sizeof(struct all_jobs)); - pq->qu_jobs_array_sum = calloc(1, sizeof(struct all_jobs)); + pq->qu_jobs_array_sum = (struct all_jobs *)calloc(1, sizeof(struct all_jobs)); if ((pq->qu_mutex == NULL) || (pq->qu_jobs == NULL) || @@ -566,102 +566,6 @@ pbs_queue *next_queue( -/* - * gets the locks on both queues without releasing the all_queues mutex lock. - * Doing this another way can cause deadlock. - * - * @return PBSE_NONE on success - */ - -int get_parent_dest_queues( - - char *queue_parent_name, - char *queue_dest_name, - pbs_queue **parent, - pbs_queue **dest, - job **pjob_ptr) - - { - pbs_queue *pque_parent; - pbs_queue *pque_dest; - char jobid[PBS_MAXSVRJOBID + 1]; - char log_buf[LOCAL_LOG_BUF_SIZE + 1]; - job *pjob = *pjob_ptr; - int index_parent; - int index_dest; - int rc = PBSE_NONE; - - strcpy(jobid, pjob->ji_qs.ji_jobid); - - if ((queue_parent_name != NULL) && (queue_dest_name != NULL)) - { - if (!strcmp(queue_parent_name, queue_dest_name)) - { - /* parent and destination are the same. - Job is already in destnation queue. return */ - snprintf(log_buf, sizeof(log_buf), "parent and destination queues are the same: parent %s - dest %s. jobid: %s", - queue_parent_name, - queue_dest_name, - jobid); - log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf); - return(-1); - } - } - else - return(-1); - - unlock_ji_mutex(pjob, __func__, (char *)"1", LOGLEVEL); - - unlock_queue(*parent, __func__, (char *)NULL, 0); - - *parent = NULL; - *dest = NULL; - - pthread_mutex_lock(svr_queues.allques_mutex); - - index_parent = get_value_hash(svr_queues.ht, queue_parent_name); - index_dest = get_value_hash(svr_queues.ht, queue_dest_name); - - if ((index_parent < 0) || - (index_dest < 0)) - { - rc = -1; - } - else - { - /* good path */ - pque_parent = svr_queues.ra->slots[index_parent].item; - pque_dest = svr_queues.ra->slots[index_dest].item; - - if ((pque_parent == NULL) || - (pque_dest == NULL)) - { - rc = -1; - } - else - { - /* SUCCESS! */ - lock_queue(pque_parent, __func__, (char *)NULL, 0); - lock_queue(pque_dest, __func__, (char *)NULL, 0); - *parent = pque_parent; - *dest = pque_dest; - - rc = PBSE_NONE; - } - } - - pthread_mutex_unlock(svr_queues.allques_mutex); - - if ((*pjob_ptr = svr_find_job(jobid, TRUE)) == NULL) - rc = -1; - - return(rc); - } /* END get_parent_dest_queues() */ - - - - - pbs_queue *lock_queue_with_job_held( pbs_queue *pque, diff --git a/src/server/queue_func.h b/src/server/queue_func.h index 6b2bd55bb6..8e9c0a1dfa 100644 --- a/src/server/queue_func.h +++ b/src/server/queue_func.h @@ -29,6 +29,4 @@ int remove_queue(all_queues *aq, pbs_queue *pque); pbs_queue *next_queue(all_queues *aq, int *iter); -int get_parent_dest_queues(char *queue_parent_name, char *queue_dest_name, pbs_queue **parent, pbs_queue **dest, job **pjob_ptr); - #endif /* _QUEUE_FUNC_H */ diff --git a/src/server/receive_mom_communication.c b/src/server/receive_mom_communication.c index 80e9028a3f..7c41d28e3e 100644 --- a/src/server/receive_mom_communication.c +++ b/src/server/receive_mom_communication.c @@ -93,6 +93,7 @@ #include "net_cache.h" #include "threadpool.h" #include "../lib/Libnet/lib_net.h" +#include "../lib/Libutils/u_lock_ctl.h" diff --git a/src/server/reply_send.c b/src/server/reply_send.c index baca023693..a4e5e00b99 100644 --- a/src/server/reply_send.c +++ b/src/server/reply_send.c @@ -329,8 +329,8 @@ void req_reject( int code, /* I */ int aux, /* I */ struct batch_request *preq, /* I */ - char *HostName, /* I (optional) */ - char *Msg) /* I (optional) */ + const char *HostName, /* I (optional) */ + const char *Msg) /* I (optional) */ { char msgbuf[ERR_MSG_SIZE + 256 + 1]; diff --git a/src/server/reply_send.h b/src/server/reply_send.h index 4dd72e1b81..64fcf8b5bc 100644 --- a/src/server/reply_send.h +++ b/src/server/reply_send.h @@ -18,7 +18,7 @@ void reply_ack(struct batch_request *preq); void reply_free(struct batch_reply *prep); -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg); +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg); void reply_badattr(int code, int aux, svrattrl *pal, struct batch_request *preq); diff --git a/src/server/req_delete.c b/src/server/req_delete.c index 94e98669f3..2e935b7c88 100644 --- a/src/server/req_delete.c +++ b/src/server/req_delete.c @@ -113,8 +113,10 @@ #include "utils.h" #include "svr_func.h" /* get_svr_attr_* */ #include "job_func.h" /* svr_job_purge */ +#include "svr_task.h" #include "ji_mutex.h" #include "threadpool.h" +#include "svr_task.h" #define PURGE_SUCCESS 1 #define MOM_DELETE 2 diff --git a/src/server/req_deletearray.c b/src/server/req_deletearray.c index 5638146f2e..35247b5ac1 100644 --- a/src/server/req_deletearray.c +++ b/src/server/req_deletearray.c @@ -15,6 +15,7 @@ #include "pbs_job.h" #include "queue.h" #include "pbs_error.h" +#include "svr_task.h" #include "acct.h" #include "log.h" #include "../lib/Liblog/pbs_log.h" @@ -26,6 +27,8 @@ #include "ji_mutex.h" +#include "svr_task.h" + extern int LOGLEVEL; extern int svr_authorize_req(struct batch_request *preq, char *owner, char *submit_host); diff --git a/src/server/req_gpuctrl.c b/src/server/req_gpuctrl.c index c02d82ae69..c8601fc248 100644 --- a/src/server/req_gpuctrl.c +++ b/src/server/req_gpuctrl.c @@ -192,7 +192,7 @@ int req_gpuctrl_svr( rc = PBSE_UNKREQ; sprintf(log_buf,"Node %s is not available",pnode->nd_name); req_reject(rc, 0, preq, NULL, log_buf); - unlock_node(pnode, "req_gpuctrl", NULL, LOGLEVEL); + unlock_node(pnode, "req_gpuctrl", (char *)NULL, LOGLEVEL); return rc; } @@ -202,7 +202,7 @@ int req_gpuctrl_svr( { rc = PBSE_UNKREQ; req_reject(rc, 0, preq, NULL, "Not allowed for virtual gpus"); - unlock_node(pnode, "req_gpuctrl", NULL, LOGLEVEL); + unlock_node(pnode, "req_gpuctrl", (char *)NULL, LOGLEVEL); return rc; } @@ -212,7 +212,7 @@ int req_gpuctrl_svr( { rc = PBSE_UNKREQ; req_reject(rc, 0, preq, NULL, "GPU ID does not exist on node"); - unlock_node(pnode, "req_gpuctrl", NULL, LOGLEVEL); + unlock_node(pnode, "req_gpuctrl", (char *)NULL, LOGLEVEL); return rc; } @@ -222,7 +222,7 @@ int req_gpuctrl_svr( { rc = PBSE_UNKREQ; req_reject(rc, 0, preq, NULL, "No action specified"); - unlock_node(pnode, "req_gpuctrl", NULL, LOGLEVEL); + unlock_node(pnode, "req_gpuctrl", (char *)NULL, LOGLEVEL); return rc; } @@ -232,7 +232,7 @@ int req_gpuctrl_svr( { rc = PBSE_UNKREQ; req_reject(rc, 0, preq, NULL, "GPU driver version does not support mode 3"); - unlock_node(pnode, "req_gpuctrl", NULL, LOGLEVEL); + unlock_node(pnode, "req_gpuctrl", (char *)NULL, LOGLEVEL); return rc; } @@ -241,7 +241,7 @@ int req_gpuctrl_svr( preq->rq_orgconn = preq->rq_conn; /* restore client socket */ - unlock_node(pnode, "req_gpuctrl", NULL, LOGLEVEL); + unlock_node(pnode, "req_gpuctrl", (char *)NULL, LOGLEVEL); conn = svr_connect( pnode->nd_addrs[0], pbs_mom_port, diff --git a/src/server/req_jobobit.c b/src/server/req_jobobit.c index b86c35acd1..8b870965a7 100644 --- a/src/server/req_jobobit.c +++ b/src/server/req_jobobit.c @@ -114,43 +114,45 @@ #include "issue_request.h" /* issue_request */ #include "utils.h" #include "svr_func.h" /* get_svr_attr_* */ +#include "svr_task.h" #include "req_jobobit.h" /* req_jobobit */ #include "svr_connect.h" /* svr_connect */ #include "job_func.h" /* svr_job_purge */ #include "ji_mutex.h" #include "../lib/Libutils/u_lock_ctl.h" #include "exiting_jobs.h" +#include "svr_task.h" /* set_task */ #define RESC_USED_BUF 2048 #define JOBMUSTREPORTDEFAULTKEEP 30 /* External Global Data Items */ -extern struct all_jobs alljobs; -extern unsigned int pbs_mom_port; -extern unsigned int pbs_rm_port; -extern char *path_spool; -extern int server_init_type; -extern pbs_net_t pbs_server_addr; -extern char *msg_init_abt; -extern char *msg_job_end; -extern char *msg_job_end_sig; -extern char *msg_job_end_stat; -extern char *msg_momnoexec1; -extern char *msg_momnoexec2; -extern char *msg_momjoboverlimit; -extern char *msg_obitnojob; -extern char *msg_obitnocpy; -extern char *msg_obitnodel; -extern char server_host[]; -extern int svr_do_schedule; +extern struct all_jobs alljobs; +extern unsigned int pbs_mom_port; +extern unsigned int pbs_rm_port; +extern char *path_spool; +extern int server_init_type; +extern pbs_net_t pbs_server_addr; +extern char *msg_init_abt; +extern char *msg_job_end; +extern char *msg_job_end_sig; +extern char *msg_job_end_stat; +extern char *msg_momnoexec1; +extern char *msg_momnoexec2; +extern char *msg_momjoboverlimit; +extern char *msg_obitnojob; +extern char *msg_obitnocpy; +extern char *msg_obitnodel; +extern char server_host[]; +extern int svr_do_schedule; extern pthread_mutex_t *svr_do_schedule_mutex; extern pthread_mutex_t *listener_command_mutex; -extern int listener_command; +extern int listener_command; -extern int LOGLEVEL; +extern int LOGLEVEL; -extern const char *PJobState[]; +extern const char *PJobState[]; /* External Functions called */ @@ -167,7 +169,7 @@ void *on_job_exit_task(void *vp); * output, error, or checkpoint */ -static char *setup_from( +char *setup_from( job *pjob, /* I */ char *suffix) /* I */ @@ -300,7 +302,7 @@ struct batch_request *setup_cpyfiles( -static int is_joined( +int is_joined( job *pjob, /* I */ enum job_atr ati) /* I */ @@ -325,11 +327,13 @@ static int is_joined( { pd = pattr->at_val.at_str; - if ((pd != NULL) && (*pd != '\0') && (*pd != 'n')) + if ((pd != NULL) && + (*pd != '\0') && + (*pd != 'n')) { /* if not the first letter, and in list - is joined */ - - if ((*pd != key) && (strchr(pd + 1, (int)key))) + if ((*pd != key) && + (strchr(pd + 1, (int)key))) { return(1); /* being joined */ } @@ -340,14 +344,13 @@ static int is_joined( } -static struct batch_request *return_stdfile( +struct batch_request *return_stdfile( struct batch_request *preq, job *pjob, enum job_atr ati) { - if ((pjob->ji_wattr[JOB_ATR_interactive].at_flags) && (pjob->ji_wattr[JOB_ATR_interactive].at_val.at_long)) { @@ -359,7 +362,6 @@ static struct batch_request *return_stdfile( return(NULL); } - /* if this file is joined to another then it doesn't have to get copied back */ if (is_joined(pjob, ati)) { @@ -383,7 +385,9 @@ static struct batch_request *return_stdfile( } return(preq); - } + } /* END return_stdfile() */ + + /* @@ -2451,7 +2455,7 @@ void on_job_rerun( * child that sent the job to MOM. */ -static void wait_for_send( +void wait_for_send( struct work_task *ptask) @@ -2467,7 +2471,7 @@ static void wait_for_send( -static int setrerun( +int setrerun( job *pjob) @@ -2480,7 +2484,7 @@ static int setrerun( /* SUCCESS */ - return(0); + return(PBSE_NONE); } /* FAILURE */ @@ -2712,7 +2716,7 @@ int handle_subjob_exit_status( log_event(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, other_jobid, log_buf); kill_job_on_mom(other_jobid, pnode); - unlock_node(pnode, __func__, NULL, 0); + unlock_node(pnode, __func__, (char *)NULL, 0); } } else diff --git a/src/server/req_manager.c b/src/server/req_manager.c index 8bc98612e8..f3b641daa3 100644 --- a/src/server/req_manager.c +++ b/src/server/req_manager.c @@ -136,6 +136,7 @@ #include "../lib/Libutils/u_lock_ctl.h" /* unlock_node */ #include "queue_func.h" /* find_queuebyname, que_alloc, que_free */ #include "queue_recov.h" /* que_save */ +#include "svr_task.h" #define PERM_MANAGER (ATR_DFLAG_MGWR | ATR_DFLAG_MGRD) @@ -173,14 +174,14 @@ static char *all_quename = "_All_"; static char *all_nodes_str = "_All_"; /* - * check_que_attr - check if attributes in request are consistant with + * check_que_attr - check if attributes in request are consistent with * the current queue type. This is called when creating or setting * the attributes of a queue. * * Returns: NULL if all ok or name of bad pbs_attribute if not ok */ -static char *check_que_attr( +static const char *check_que_attr( pbs_queue *pque) @@ -957,7 +958,7 @@ void mgr_queue_create( { int bad; - char *badattr; + const char *badattr; svrattrl *plist; pbs_queue *pque; int rc; @@ -1411,7 +1412,7 @@ void mgr_queue_set( { int allques; int bad = 0; - char *badattr; + const char *badattr; svrattrl *plist; pbs_queue *pque; char *qname; @@ -1783,7 +1784,7 @@ void mgr_node_set( break; } - unlock_node(pnode, "mgr_node_set", "error", LOGLEVEL); + unlock_node(pnode, "mgr_node_set", (char *)"error", LOGLEVEL); return; } /* END if (rc != 0) */ @@ -1795,7 +1796,7 @@ void mgr_node_set( mgr_log_attr(msg_man_set, plist, PBS_EVENTCLASS_NODE, pnode->nd_name); } - unlock_node(pnode, "mgr_node_set", "single_node", LOGLEVEL); + unlock_node(pnode, "mgr_node_set", (char *)"single_node", LOGLEVEL); } /* END single node case */ if (need_todo & WRITENODE_STATE) diff --git a/src/server/req_modify.c b/src/server/req_modify.c index 90a2d6d314..967463fefe 100644 --- a/src/server/req_modify.c +++ b/src/server/req_modify.c @@ -111,6 +111,7 @@ #include "svr_func.h" /* get_svr_attr_* */ #include "ji_mutex.h" #include "threadpool.h" +#include "svr_task.h" #define CHK_HOLD 1 #define CHK_CONT 2 diff --git a/src/server/req_movejob.c b/src/server/req_movejob.c index b6855094cc..5775d5b608 100644 --- a/src/server/req_movejob.c +++ b/src/server/req_movejob.c @@ -110,7 +110,7 @@ extern char *msg_manager; extern char *msg_movejob; extern char *pbs_o_host; -int svr_movejob(job *, char *, int *, struct batch_request *, int); +int svr_movejob(job *, char *, int *, struct batch_request *); int svr_chkque(job *, pbs_queue *, char *, int, char *); job *chk_job_request(char *, struct batch_request *); @@ -177,7 +177,7 @@ int req_movejob( return(PBSE_NONE); } - switch (svr_movejob(jobp, req->rq_ind.rq_move.rq_destin, &local_errno, req, FALSE)) + switch (svr_movejob(jobp, req->rq_ind.rq_move.rq_destin, &local_errno, req)) { case 0: @@ -242,8 +242,6 @@ int req_orderjob( char tmpqn[PBS_MAXQUEUENAME+1]; struct batch_request *req = (struct batch_request *)vp; char log_buf[LOCAL_LOG_BUF_SIZE]; - char job_id1[PBS_MAXSVRJOBID+1]; - char job_id2[PBS_MAXSVRJOBID+1]; pbs_queue *pque1; pbs_queue *pque2; @@ -342,13 +340,9 @@ int req_orderjob( strcpy(tmpqn, pjob1->ji_qs.ji_queue); strcpy(pjob1->ji_qs.ji_queue, pjob2->ji_qs.ji_queue); strcpy(pjob2->ji_qs.ji_queue, tmpqn); - strcpy(job_id1, pjob1->ji_qs.ji_jobid); - strcpy(job_id2, pjob2->ji_qs.ji_jobid); - unlock_ji_mutex(pjob1, __func__, (char *)"5", LOGLEVEL); - unlock_ji_mutex(pjob2, __func__, (char *)"6", LOGLEVEL); - svr_dequejob(job_id1, FALSE); - svr_dequejob(job_id2, FALSE); + svr_dequejob(pjob1, FALSE); + svr_dequejob(pjob2, FALSE); if (svr_enquejob(pjob1, FALSE, -1) == PBSE_JOB_RECYCLED) pjob1 = NULL; diff --git a/src/server/req_quejob.c b/src/server/req_quejob.c index 685dd92a26..4c687d1735 100644 --- a/src/server/req_quejob.c +++ b/src/server/req_quejob.c @@ -210,7 +210,7 @@ int set_nodes_attr( resource *pres; int nodect_set = 0; int rc = 0; - char *pname; + const char *pname; if (pjob->ji_wattr[JOB_ATR_resource].at_flags & ATR_VFLAG_SET) { @@ -428,7 +428,7 @@ int set_node_attr( resource *pres; int nodect_set = 0; int rc = 0; - char *pname; + const char *pname; if (pjob->ji_wattr[JOB_ATR_resource].at_flags & ATR_VFLAG_SET) { diff --git a/src/server/req_register.c b/src/server/req_register.c index 4bdf0f619f..a7d5c0e09f 100644 --- a/src/server/req_register.c +++ b/src/server/req_register.c @@ -2478,9 +2478,9 @@ struct dependnames int decode_depend( pbs_attribute *patr, - char *name, /* attribute name */ - char *rescn, /* resource name, unused here */ - char *val, /* attribute value */ + const char *name, /* attribute name */ + char *rescn, /* resource name, unused here */ + char *val, /* attribute value */ int perm) /* only used for resources */ { @@ -2687,8 +2687,8 @@ int encode_depend( pbs_attribute *attr, /* ptr to attribute to encode */ tlist_head *phead, /* ptr to head of attrlist list */ - char *atname, /* attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/server/req_register.h b/src/server/req_register.h index 574a43432e..0092b34b32 100644 --- a/src/server/req_register.h +++ b/src/server/req_register.h @@ -16,62 +16,18 @@ int register_array_depend(job_array *pa, struct batch_request *preq, int type, i void set_array_depend_holds(job_array *pa); -/* static void post_doq(struct work_task *pwt); */ - -/* static void alter_unreg(job *pjob, pbs_attribute *old, pbs_attribute *new); */ - int depend_on_que(pbs_attribute *pattr, void *pjob, int mode); -/* static void post_doe(struct work_task *pwt); */ - int depend_on_exec(job *pjob); int depend_on_term(char *job_id); -/* static void release_cheapest(job *pjob, struct depend *pdep); */ - -/* static void set_depend_hold(job *pjob, pbs_attribute *pattr); */ - void depend_clrrdy(job *pjob); -/* static struct depend *find_depend(int type, pbs_attribute *pattr); */ - -/* static struct depend *make_depend(int type, pbs_attribute *pattr); */ - -/* static int register_sync(struct depend *pdep, char *child, char *host, long cost); */ - -/* static int register_dep(pbs_attribute *pattr, struct batch_request *preq, int type, int *made); */ - -/* static int unregister_dep(pbs_attribute *pattr, struct batch_request *preq); */ - -/* static int unregister_sync(pbs_attribute *pattr, struct batch_request *preq); */ - -/* static struct depend_job *find_dependjob(struct depend *pdep, char *name); */ - -/* static struct depend_job *make_dependjob(struct depend *pdep, char *jobid, char *host); */ - -int decode_depend(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); - -/* static void cat_jobsvr(char **Dest, char *Src); */ - -/* static void fast_strcat(char **Dest, char *Src); */ - -/* static int dup_depend(pbs_attribute *pattr, struct depend *pd); */ - -int encode_depend(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); - int set_depend(struct pbs_attribute *attr, struct pbs_attribute *new, enum batch_op op); int comp_depend(struct pbs_attribute *attr, struct pbs_attribute *with); void free_depend(struct pbs_attribute *attr); -/* static int build_depend(pbs_attribute *pattr, char *value); */ - -/* static void clear_depend(struct depend *pd, int type, int exist); */ - -/* static void del_depend(struct depend *pd); */ - -/* static void del_depend_job(struct depend_job *pdj); */ - #endif /* _REQ_REGISTER_H */ diff --git a/src/server/req_runjob.c b/src/server/req_runjob.c index 43a18d61d2..b4d79f7b00 100644 --- a/src/server/req_runjob.c +++ b/src/server/req_runjob.c @@ -117,6 +117,7 @@ #include "svr_func.h" /* get_svr_attr_* */ #include "req_stat.h" /* stat_mom_job */ #include "ji_mutex.h" +#include "svr_task.h" #ifdef HAVE_NETINET_IN_H #include @@ -1863,7 +1864,7 @@ int set_job_exec_info( memcpy(&hostaddr, &pnode->nd_sock_addr.sin_addr, sizeof(hostaddr)); pjob->ji_qs.ji_un.ji_exect.ji_momaddr = ntohl(hostaddr.s_addr); - unlock_node(pnode, __func__, NULL, LOGLEVEL); + unlock_node(pnode, __func__, (char *)NULL, LOGLEVEL); return(PBSE_NONE); } diff --git a/src/server/req_stat.c b/src/server/req_stat.c index 3f2bcbf6b5..603d61b9b7 100644 --- a/src/server/req_stat.c +++ b/src/server/req_stat.c @@ -122,6 +122,7 @@ #include "node_manager.h" /* tfind_addr */ #include "ji_mutex.h" #include "unistd.h" +#include "svr_task.h" /* Global Data Items: */ @@ -936,14 +937,14 @@ int stat_to_mom( log_event(PBSEVENT_SYSTEM,PBS_EVENTCLASS_JOB,job_id,log_buf); } - unlock_node(node, __func__, "no rely mom", LOGLEVEL); + unlock_node(node, __func__, (char *)"no rely mom", LOGLEVEL); free_br(newrq); return PBSE_NORELYMOM; } /* get connection to MOM */ - unlock_node(node, __func__, "before svr_connect", LOGLEVEL); + unlock_node(node, __func__, (char *)"before svr_connect", LOGLEVEL); handle = svr_connect(job_momaddr, job_momport, &rc, NULL, NULL, ToServerDIS); /* Unlock job here */ @@ -986,6 +987,7 @@ void stat_update( int oldsid; int bad = 0; time_t time_now = time(NULL); + char log_buf[LOCAL_LOG_BUF_SIZE]; preply = &preq->rq_reply; @@ -1051,10 +1053,15 @@ void stat_update( } } + else + { + snprintf(log_buf, sizeof(log_buf), + "Poll job request failed for job %s", preq->rq_ind.rq_status.rq_id); + log_err(preply->brp_code, __func__, log_buf); + } } cntl->sc_conn = -1; - /* MUTSU - Unlock job here? */ if (cntl->sc_post) cntl->sc_post(cntl); /* continue where we left off */ @@ -1126,7 +1133,7 @@ void poll_job_task( job *pjob; time_t time_now = time(NULL); long poll_jobs = 0; - int job_state = -1; + int job_state = -1; if (job_id != NULL) { @@ -1379,9 +1386,9 @@ int get_numa_statuses( if (pn == NULL) continue; - lock_node(pn, __func__, NULL, LOGLEVEL); + lock_node(pn, __func__, (char *)NULL, LOGLEVEL); rc = status_node(pn, preq, bad, pstathd); - unlock_node(pn, __func__, NULL, LOGLEVEL); + unlock_node(pn, __func__, (char *)NULL, LOGLEVEL); if (rc != PBSE_NONE) { @@ -1482,7 +1489,7 @@ int req_stat_node( else rc = get_numa_statuses(pnode, preq, &bad, &preply->brp_un.brp_status); - unlock_node(pnode, __func__, "type == 0", LOGLEVEL); + unlock_node(pnode, __func__, (char *)"type == 0", LOGLEVEL); } else { @@ -1494,7 +1501,7 @@ int req_stat_node( if ((type == 2) && (!hasprop(pnode, &props))) { - unlock_node(pnode, __func__, "type != 0, next_host", LOGLEVEL); + unlock_node(pnode, __func__, (char *)"type != 0, next_host", LOGLEVEL); continue; } @@ -1506,11 +1513,11 @@ int req_stat_node( if (rc != PBSE_NONE) { - unlock_node(pnode, __func__, "type != 0, rc != 0, get_numa_statuses", LOGLEVEL); + unlock_node(pnode, __func__, (char *)"type != 0, rc != 0, get_numa_statuses", LOGLEVEL); break; } - unlock_node(pnode, __func__, "type != 0, rc == 0, get_numa_statuses", LOGLEVEL); + unlock_node(pnode, __func__, (char *)"type != 0, rc == 0, get_numa_statuses", LOGLEVEL); } } diff --git a/src/server/req_track.c b/src/server/req_track.c index b0c147e45a..c74bbd85d2 100644 --- a/src/server/req_track.c +++ b/src/server/req_track.c @@ -98,11 +98,13 @@ #include "pbs_job.h" #include "pbs_error.h" #include "work_task.h" +#include "svr_task.h" #include "tracking.h" #include "svrfunc.h" #include "log.h" #include "../lib/Liblog/pbs_log.h" #include "../lib/Liblog/log_event.h" +#include "svr_task.h" /* External functions */ diff --git a/src/server/resc_def_all.c b/src/server/resc_def_all.c index d3969fe358..fc1e058689 100644 --- a/src/server/resc_def_all.c +++ b/src/server/resc_def_all.c @@ -115,12 +115,12 @@ extern struct server server; /* sync w/job_attr_def.c */ -int decode_nodes(struct pbs_attribute *, char *, char *, char *, int); +int decode_nodes(struct pbs_attribute *, const char *, char *, char *, int); int set_node_ct(resource *, pbs_attribute *, int actmode); int set_proc_ct(resource *, pbs_attribute *, int actmode); int set_tokens_nodect(struct pbs_attribute *attr, struct pbs_attribute *new_attr, enum batch_op actmode); int set_mppnodect(resource *, pbs_attribute *, int actmode); -int encode_procct(pbs_attribute *, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_procct(pbs_attribute *, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); resource_def *svr_resc_def; @@ -829,7 +829,7 @@ int init_resc_defs(void) #endif - svr_resc_def = calloc(svr_resc_size + dindex, sizeof(resource_def)); + svr_resc_def = (resource_def *)calloc(svr_resc_size + dindex, sizeof(resource_def)); if (svr_resc_def == NULL) { @@ -884,7 +884,7 @@ int init_resc_defs(void) int decode_nodes( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name - unused here */ char *val, /* pbs_attribute value */ int perm) /* replaces resc_access_perm */ @@ -1352,8 +1352,8 @@ int encode_procct( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/server/stat_job.c b/src/server/stat_job.c index 45bb234ce2..e2d86eb2b9 100644 --- a/src/server/stat_job.c +++ b/src/server/stat_job.c @@ -199,7 +199,7 @@ int add_walltime_remaining( { int len = 0; char buf[MAXPATHLEN+1]; - char *pname; + const char *pname; svrattrl *pal; resource *pres; diff --git a/src/server/svr_attr_def.c b/src/server/svr_attr_def.c index 52b04b9a68..e438d2a185 100644 --- a/src/server/svr_attr_def.c +++ b/src/server/svr_attr_def.c @@ -100,11 +100,11 @@ extern int set_nextjobnum (pbs_attribute * attr, pbs_attribute * new_attr, extern int poke_scheduler (pbs_attribute * pattr, void *pobject, int actmode); extern int encode_svrstate (pbs_attribute * pattr, tlist_head * phead, - char *aname, char *rsname, int mode, int perm); + const char *aname, const char *rsname, int mode, int perm); -extern int decode_rcost (pbs_attribute * patr, char *name, char *rn, char *val, int perm); -extern int encode_rcost (pbs_attribute * attr, tlist_head * phead, char *atname, - char *rsname, int mode, int perm); +extern int decode_rcost (pbs_attribute * patr, const char *name, char *rn, char *val, int perm); +extern int encode_rcost (pbs_attribute * attr, tlist_head * phead, const char *atname, + const char *rsname, int mode, int perm); extern int set_rcost (pbs_attribute * attr, pbs_attribute * new_attr, enum batch_op); extern void free_rcost (pbs_attribute * attr); extern int set_null (pbs_attribute * patr, pbs_attribute * new_attr, enum batch_op op); diff --git a/src/server/svr_func.c b/src/server/svr_func.c index 0dd22509c7..eaf3e56db0 100644 --- a/src/server/svr_func.c +++ b/src/server/svr_func.c @@ -139,8 +139,8 @@ int encode_svrstate( pbs_attribute *pattr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* null */ int mode, /* encode mode */ int perm) /* only used for resources */ @@ -422,7 +422,7 @@ int ck_checkpoint( * and queue ) attributes. It just returns 0. */ -int decode_null(pbs_attribute *patr, char *name, char *rn, char *val, int perm) +int decode_null(pbs_attribute *patr, const char *name, char *rn, char *val, int perm) { return 0; } diff --git a/src/server/svr_func.h b/src/server/svr_func.h index 17836d4ed9..7b86e7ea26 100644 --- a/src/server/svr_func.h +++ b/src/server/svr_func.h @@ -6,13 +6,13 @@ #include "list_link.h" /* tlist_head */ #include "pbs_job.h" /* job */ -int encode_svrstate(pbs_attribute *pattr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_svrstate(pbs_attribute *pattr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); void set_resc_assigned(job *pjob, enum batch_op op); int ck_checkpoint(pbs_attribute *pattr, void *pobject, int mode); -int decode_null(pbs_attribute *patr, char *name, char *rn, char *val, int perm); +int decode_null(pbs_attribute *patr, const char *name, char *rn, char *val, int perm); int set_null(pbs_attribute *pattr, pbs_attribute *new_attr, enum batch_op op); diff --git a/src/server/svr_jobfunc.c b/src/server/svr_jobfunc.c index ba9ce0d186..8425402536 100644 --- a/src/server/svr_jobfunc.c +++ b/src/server/svr_jobfunc.c @@ -125,6 +125,7 @@ #include "queue.h" #include "pbs_job.h" #include "work_task.h" +#include "svr_task.h" #include "pbs_error.h" #include "log.h" #include "../lib/Liblog/pbs_log.h" @@ -140,6 +141,7 @@ #include "ji_mutex.h" #include "user_info.h" #include "svr_jobfunc.h" +#include "svr_task.h" #define MSG_LEN_LONG 160 @@ -624,25 +626,20 @@ int svr_enquejob( int svr_dequejob( - char *job_id, /* I, M */ - int parent_queue_mutex_held) /* I */ + job *pjob, /* I, M */ + int parent_queue_mutex_held) /* I */ { int bad_ct = 0; int rc = PBSE_NONE; - job *pjob = NULL; pbs_attribute *pattr; pbs_queue *pque; resource *presc; char log_buf[LOCAL_LOG_BUF_SIZE]; /* remove job from server's all job list and reduce server counts */ - - if ((pjob = svr_find_job(job_id, FALSE)) == NULL) - return(PBSE_JOBNOTFOUND); - - if (LOGLEVEL >= 10) - LOG_EVENT(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, pjob->ji_qs.ji_jobid); + if (LOGLEVEL >= 7) + log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, pjob->ji_qs.ji_jobid); if (parent_queue_mutex_held == FALSE) { @@ -708,11 +705,14 @@ int svr_dequejob( pque ? pque->qu_qs.qu_name : "unknown queue", PJobState[pjob->ji_qs.ji_state]); - log_event(PBSEVENT_DEBUG2,PBS_EVENTCLASS_JOB,job_id,log_buf); + log_event(PBSEVENT_DEBUG2, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buf); if (bad_ct) /* state counts are all messed up */ { char queue_name[PBS_MAXQUEUENAME]; + char job_id[PBS_MAXSVRJOBID+1]; + + strcpy(job_id, pjob->ji_qs.ji_jobid); /* this function will lock queues and jobs */ unlock_ji_mutex(pjob, __func__, (char *)NULL, 0); @@ -1116,7 +1116,7 @@ int chk_svr_resc_limit( resource *cmpwith; int LimitIsFromQueue = FALSE; - char *LimitName; + const char *LimitName; /* NOTE: support Cray-specific evaluation */ @@ -2845,7 +2845,7 @@ int lock_ji_mutex( job *pjob, const char *id, - char *msg, + const char *msg, int logging) { @@ -2885,7 +2885,7 @@ int unlock_ji_mutex( job *pjob, const char *id, - char *msg, + const char *msg, int logging) { int rc = PBSE_NONE; @@ -2923,7 +2923,7 @@ int lock_ai_mutex( job_array *pa, const char *id, - char *msg, + const char *msg, int logging) { @@ -2962,7 +2962,7 @@ int unlock_ai_mutex( job_array *pa, const char *id, - char *msg, + const char *msg, int logging) { diff --git a/src/server/svr_jobfunc.h b/src/server/svr_jobfunc.h index 1ea43309d5..690eaabd57 100644 --- a/src/server/svr_jobfunc.h +++ b/src/server/svr_jobfunc.h @@ -10,8 +10,6 @@ int svr_enquejob(job *pjob, int has_sv_qs_mutex, int); -int svr_dequejob(char *job_id, int); - int svr_setjobstate(job *pjob, int newstate, int newsubstate, int); void svr_evaljobstate(job *pjob, int *newstate, int *newsub, int forceeval); diff --git a/src/server/svr_movejob.c b/src/server/svr_movejob.c index ba9ea4a90e..1bd9de7a85 100644 --- a/src/server/svr_movejob.c +++ b/src/server/svr_movejob.c @@ -133,6 +133,7 @@ extern int job_route(job *); extern int svr_job_purge(job *); int PBSD_commit_get_sid(int ,long *,char *); int get_job_file_path(job *,enum job_file, char *, int); +void add_dest(job *jobp); extern struct pbsnode *PGetNodeFromAddr(pbs_net_t); @@ -140,7 +141,7 @@ extern struct pbsnode *PGetNodeFromAddr(pbs_net_t); /* Private Functions local to this file */ -int local_move(job *, int *, struct batch_request *, int); +int local_move(job *, int *, struct batch_request *); int should_retry_route(int err); /* Global Data */ @@ -186,8 +187,7 @@ int svr_movejob( job *jobp, char *destination, int *my_err, - struct batch_request *req, - int parent_queue_mutex_held) + struct batch_request *req) { pbs_net_t destaddr; @@ -208,7 +208,7 @@ int svr_movejob( destination, PBS_MAXROUTEDEST); - log_err(-1, "svr_movejob", log_buf); + log_err(-1, __func__, log_buf); *my_err = PBSE_QUENBIG; @@ -238,7 +238,7 @@ int svr_movejob( if (local != 0) { - return(local_move(jobp, my_err, req, parent_queue_mutex_held)); + return(local_move(jobp, my_err, req)); } return(net_move(jobp, req)); @@ -262,13 +262,10 @@ int local_move( job *pjob, int *my_err, - struct batch_request *req, - int parent_queue_mutex_held) + struct batch_request *req) { - pbs_queue *routing_que; - pbs_queue *dest_que; - pbs_queue *tmp_que; + pbs_queue *dest_que = NULL; char *destination = pjob->ji_qs.ji_destin; int mtype; char log_buf[LOCAL_LOG_BUF_SIZE]; @@ -279,56 +276,12 @@ int local_move( * by making sure that the destionation queue and the current queue are different. * If they are the same then consider it done correctly */ if (!strcmp(pjob->ji_qs.ji_queue, pjob->ji_qs.ji_destin)) - { return(PBSE_NONE); - } if (LOGLEVEL >= 7) { sprintf(log_buf, "%s", pjob->ji_qs.ji_jobid); - LOG_EVENT(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf); - } - - /* search for destination queue */ - /* CAUTION!!! This code is very complex - be very careful editing */ - if (parent_queue_mutex_held == TRUE) - routing_que = pjob->ji_qhdr; - else - { - routing_que = get_jobs_queue(&pjob); - - if (pjob == NULL) - { - log_err(PBSE_JOBNOTFOUND, __func__, (char *)"Job lost while acquiring queue 14"); - return(PBSE_JOBNOTFOUND); - } - } - - if (routing_que == NULL) - { - sprintf(log_buf, "queue %s does not exist\n", pjob->ji_qs.ji_queue); - - log_err(-1, __func__, log_buf); - - *my_err = PBSE_UNKQUE; - - return(-1); - } - - - if (get_parent_dest_queues(pjob->ji_qs.ji_queue, destination, &routing_que, &dest_que, &pjob) != PBSE_NONE) - { - if (dest_que != NULL) - unlock_queue(dest_que, __func__, (char *)NULL, 0); - - if ((parent_queue_mutex_held == FALSE) && - (routing_que != NULL)) - unlock_queue(routing_que, __func__, (char *)NULL, 0); - - if (pjob == NULL) - return(-10); - else - return(-1); + log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf); } /* @@ -336,7 +289,6 @@ int local_move( * checks on queue availability, etc. are skipped; * otherwise all checks are enforced. */ - if (req == 0) { mtype = MOVE_TYPE_Route; /* route */ @@ -350,29 +302,44 @@ int local_move( mtype = MOVE_TYPE_Move; /* non-privileged move */ } + strcpy(job_id, pjob->ji_qs.ji_jobid); + unlock_ji_mutex(pjob, __func__, NULL, LOGLEVEL); + + dest_que = find_queuebyname(destination); + + if ((pjob = svr_find_job(job_id, TRUE)) == NULL) + { + /* job disappeared while locking queue */ + if (dest_que != NULL) + unlock_queue(dest_que, __func__, NULL, LOGLEVEL); + + return(PBSE_JOB_RECYCLED); + } + + if (dest_que == NULL) + { + /* this should never happen */ + sprintf(log_buf, "queue %s does not exist\n", pjob->ji_qs.ji_queue); + log_err(-1, __func__, log_buf); + + *my_err = PBSE_UNKQUE; + return(-1); + } + /* check the destination */ - if ((*my_err = svr_chkque( - pjob, - dest_que, - get_variable(pjob, pbs_o_host), mtype, NULL))) + if ((*my_err = svr_chkque(pjob, dest_que, get_variable(pjob, pbs_o_host), mtype, NULL))) { unlock_queue(dest_que, __func__, (char *)NULL, 0); /* should this queue be retried? */ - if (parent_queue_mutex_held == FALSE) - unlock_queue(routing_que, __func__, (char *)"retry", LOGLEVEL); - return(should_retry_route(*my_err)); } + unlock_queue(dest_que, __func__, (char *)NULL, 0); + /* dequeue job from present queue, update destination and */ /* queue_rank for new queue and enqueue into destination */ - - strcpy(job_id, pjob->ji_qs.ji_jobid); - unlock_ji_mutex(pjob, __func__,(char *)"1", LOGLEVEL); - - /* if we come out of svr_dequejob successfully pjob->ji_mutex will be locked */ - rc = svr_dequejob(job_id, TRUE); + rc = svr_dequejob(pjob, FALSE); if (rc) return(rc); @@ -380,21 +347,9 @@ int local_move( pjob->ji_wattr[JOB_ATR_qrank].at_val.at_long = ++queue_rank; - unlock_queue(dest_que, __func__, (char *)NULL, 0); - unlock_queue(routing_que, __func__, (char *)"success", LOGLEVEL); - if ((*my_err = svr_enquejob(pjob, FALSE, -1)) == PBSE_JOB_RECYCLED) return(-1); - if (parent_queue_mutex_held == TRUE) - { - /* re-lock the routing queue */ - if ((tmp_que = lock_queue_with_job_held(routing_que, &pjob)) == NULL) - lock_queue(routing_que, __func__, (char *)NULL, 0); - else - routing_que = tmp_que; - } - if (*my_err != PBSE_NONE) { return(-1); /* should never ever get here */ @@ -749,8 +704,7 @@ int send_job_work( encode_type = ATR_ENCODE_SVR; /* clear default resource settings */ - unlock_ji_mutex(pjob, __func__, (char *)"1", LOGLEVEL); - ret = svr_dequejob(job_id, FALSE); + ret = svr_dequejob(pjob, FALSE); if (ret) return(ret); } diff --git a/src/server/svr_movejob.h b/src/server/svr_movejob.h index 490f7dff5c..d5669a0a37 100644 --- a/src/server/svr_movejob.h +++ b/src/server/svr_movejob.h @@ -5,9 +5,7 @@ #include "pbs_job.h" /* job */ #include "batch_request.h" /* batch_request */ -int svr_movejob(job *jobp, char *destination, int *, struct batch_request *req, int); - -/* static int local_move(job *jobp, struct batch_request *req, int); */ +int svr_movejob(job *jobp, char *destination, int *, struct batch_request *req); void finish_routing_processing(job *pjob, int status); diff --git a/src/server/svr_recov.c b/src/server/svr_recov.c index 9161585338..fbe3ec28dd 100644 --- a/src/server/svr_recov.c +++ b/src/server/svr_recov.c @@ -147,7 +147,7 @@ int svr_recov( int sdb; char log_buf[LOCAL_LOG_BUF_SIZE]; - void recov_acl(pbs_attribute *, attribute_def *, char *, char *); + void recov_acl(pbs_attribute *, attribute_def *, const char *, const char *); sdb = open(svrfile, O_RDONLY, 0); @@ -1004,8 +1004,8 @@ int save_acl( pbs_attribute *attr, /* acl pbs_attribute */ attribute_def *pdef, /* pbs_attribute def structure */ - char *subdir, /* sub-directory path */ - char *name) /* parent object name = file name */ + const char *subdir, /* sub-directory path */ + const char *name) /* parent object name = file name */ { static char *this_function_name = "save_acl"; @@ -1123,8 +1123,8 @@ void recov_acl( pbs_attribute *pattr, /* acl pbs_attribute */ attribute_def *pdef, /* pbs_attribute def structure */ - char *subdir, /* directory path */ - char *name) /* parent object name = file name */ + const char *subdir, /* directory path */ + const char *name) /* parent object name = file name */ { static char *this_function_name = "recov_acl"; diff --git a/src/server/svr_recov.h b/src/server/svr_recov.h index af51b9d919..4f84fcd78e 100644 --- a/src/server/svr_recov.h +++ b/src/server/svr_recov.h @@ -19,8 +19,8 @@ int svr_save_xml(struct server *ps, int mode); int svr_save(struct server *ps, int mode); -int save_acl(pbs_attribute *attr, attribute_def *pdef, char *subdir, char *name); +int save_acl(pbs_attribute *attr, attribute_def *pdef, const char *subdir, const char *name); -void recov_acl(pbs_attribute *pattr, attribute_def *pdef, char *subdir, char *name); +void recov_acl(pbs_attribute *pattr, attribute_def *pdef, const char *subdir, const char *name); #endif /* _SVR_RECOV_H */ diff --git a/src/server/svr_resccost.c b/src/server/svr_resccost.c index 284dcc1827..19f1825772 100644 --- a/src/server/svr_resccost.c +++ b/src/server/svr_resccost.c @@ -170,7 +170,7 @@ static struct resource_cost *add_cost_entry( int decode_rcost( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* used only with resources */ @@ -245,8 +245,8 @@ int encode_rcost( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* used only with resources */ diff --git a/src/server/svr_resccost.h b/src/server/svr_resccost.h index 0162cee6b6..9f6074c99b 100644 --- a/src/server/svr_resccost.h +++ b/src/server/svr_resccost.h @@ -9,9 +9,9 @@ /* static struct resource_cost *add_cost_entry(pbs_attribute *patr, resource_def *prdef); */ -int decode_rcost(pbs_attribute *patr, char *name, char *rescn, char *val, int perm); +int decode_rcost(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm); -int encode_rcost(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_rcost(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_rcost(pbs_attribute *attr_old, pbs_attribute *attr_new, enum batch_op op); diff --git a/src/server/test/array_func/scaffolding.c b/src/server/test/array_func/scaffolding.c index 8771f1b439..52054797c3 100644 --- a/src/server/test/array_func/scaffolding.c +++ b/src/server/test/array_func/scaffolding.c @@ -16,7 +16,7 @@ char *path_arrays; char *pbs_o_host = "PBS_O_HOST"; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int array_259_upgrade = 0; int insert_thing(resizable_array *ra, void *thing) @@ -175,7 +175,7 @@ void *get_next(list_link pl, char *file, int line) exit(1); } -char *threadsafe_tokenizer(char **str, char *delims) +char *threadsafe_tokenizer(char **str, const char *delims) { char *current_char; char *start; diff --git a/src/server/test/batch_request/scaffolding.c b/src/server/test/batch_request/scaffolding.c index a1080a45e6..3612ebd36d 100644 --- a/src/server/test/batch_request/scaffolding.c +++ b/src/server/test/batch_request/scaffolding.c @@ -60,7 +60,7 @@ hash_table_t *create_hash( return(NULL); } -void log_err(int errnum, const char *routine, char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} int remove_hash( diff --git a/src/server/test/dis_read/scaffolding.c b/src/server/test/dis_read/scaffolding.c index ff05ae0bdf..05d41bdb01 100644 --- a/src/server/test/dis_read/scaffolding.c +++ b/src/server/test/dis_read/scaffolding.c @@ -5,7 +5,7 @@ #include "batch_request.h" /* batch_request */ #include "libpbs.h" /* batch_reply */ const char *dis_emsg[10]; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int decode_DIS_JobId(struct tcp_chan *chan, char *jobid) diff --git a/src/server/test/exiting_jobs/scaffolding.c b/src/server/test/exiting_jobs/scaffolding.c index 3e9c95901d..2b20d7e5cc 100644 --- a/src/server/test/exiting_jobs/scaffolding.c +++ b/src/server/test/exiting_jobs/scaffolding.c @@ -86,4 +86,4 @@ void on_job_exit(batch_request *preq, char *jobid) {} void force_purge_work(job *pjob) {} -void log_event(int eventtype, int objclass, const char *objname, char *text) {} +void log_event(int eventtype, int objclass, const char *objname, const char *text) {} diff --git a/src/server/test/issue_request/scaffolding.c b/src/server/test/issue_request/scaffolding.c index e605828de2..3e12d5749c 100644 --- a/src/server/test/issue_request/scaffolding.c +++ b/src/server/test/issue_request/scaffolding.c @@ -16,7 +16,7 @@ struct connect_handle connection[10]; struct connection svr_conn[PBS_NET_MAX_CONNECTIONS]; char *msg_norelytomom = "Server could not connect to MOM"; unsigned int pbs_server_port_dis; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ all_tasks task_list_event; char *msg_issuebad = "attempt to issue invalid request of type %d"; diff --git a/src/server/test/job_container/scaffolding.c b/src/server/test/job_container/scaffolding.c index 5fb6cf6810..c109de960f 100644 --- a/src/server/test/job_container/scaffolding.c +++ b/src/server/test/job_container/scaffolding.c @@ -10,7 +10,7 @@ char server_name[PBS_MAXSERVERNAME + 1]; /* host_name[:service struct all_jobs alljobs; int LOGLEVEL; -void log_err(int errno, const char *ident, char *msg) {} +void log_err(int errno, const char *ident, const char *msg) {} void log_event(int type, int class, const char *ident, char *msg) {} diff --git a/src/server/test/job_func/scaffolding.c b/src/server/test/job_func/scaffolding.c index bb90e43b8d..8bc14aaefc 100644 --- a/src/server/test/job_func/scaffolding.c +++ b/src/server/test/job_func/scaffolding.c @@ -37,7 +37,7 @@ char *msg_err_purgejob = "Unlink of job file failed"; struct server server; struct all_jobs array_summary; char *path_jobinfo_log; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ pthread_mutex_t *job_log_mutex; user_info_holder users; @@ -60,7 +60,7 @@ void account_record(int acctype, job *pjob, char *text) exit(1); } -char *arst_string(char *str, pbs_attribute *pattr) +char *arst_string(const char *str, pbs_attribute *pattr) { fprintf(stderr, "The call to arst_string needs to be mocked!!\n"); exit(1); @@ -155,7 +155,7 @@ struct work_task *set_task(enum work_type type, long event_id, void (*func)(), v exit(1); } -int svr_dequejob(char *job_id, int val) +int svr_dequejob(job *pjob, int val) { fprintf(stderr, "The call to svr_dequejob needs to be mocked!!\n"); exit(1); @@ -515,7 +515,7 @@ struct pbs_queue *lock_queue_with_job_held( int decode_ll( pbs_attribute *patr, - char *name, /* pbs_attribute name */ + const char *name, /* pbs_attribute name */ char *rescn, /* resource name, unused here */ char *val, /* pbs_attribute value */ int perm) /* only used for resources */ @@ -538,8 +538,8 @@ int encode_ll( pbs_attribute *attr, /* ptr to pbs_attribute */ tlist_head *phead, /* head of attrlist list */ - char *atname, /* pbs_attribute name */ - char *rsname, /* resource name or null */ + const char *atname, /* pbs_attribute name */ + const char *rsname, /* resource name or null */ int mode, /* encode mode, unused here */ int perm) /* only used for resources */ diff --git a/src/server/test/job_route/scaffolding.c b/src/server/test/job_route/scaffolding.c index d419d419a8..28e0eb5865 100644 --- a/src/server/test/job_route/scaffolding.c +++ b/src/server/test/job_route/scaffolding.c @@ -12,7 +12,7 @@ char *msg_err_noqueue = "Unable to requeue job, queue is not defined"; char *msg_err_malloc = "malloc failed"; char *msg_routexceed = "Route queue lifetime exceeded"; int svr_resc_size = 0; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ resource_def *svr_resc_def; pthread_mutex_t *reroute_job_mutex; @@ -34,11 +34,30 @@ job *next_job(struct all_jobs *aj, int *iter) exit(1); } -void *get_next(list_link pl, char *file, int line) +#ifndef NDEBUG + +void *get_next( + + list_link pl, /* I */ + char *file, /* I */ + int line) /* I */ + { - fprintf(stderr, "The call to get_next needs to be mocked!!\n"); - exit(1); - } + if ((pl.ll_next == NULL) || + ((pl.ll_next == &pl) && (pl.ll_struct != NULL))) + { + fprintf(stderr, "Assertion failed, bad pointer in link: file \"%s\", line %d\n", + file, + line); + + return NULL; + } + + return(pl.ll_next->ll_struct); + } /* END get_next() */ + +#else +#endif int site_alt_router(job *jobp, pbs_queue *qp, long retry_time) { @@ -54,8 +73,60 @@ int site_alt_router(job *jobp, pbs_queue *qp, long retry_time) void append_link(tlist_head *head, list_link *new_link, void *pobj) { - fprintf(stderr, "The call to append_link needs to be mocked!!\n"); - exit(1); +#ifndef NDEBUG + /* first make sure unlinked entries are pointing to themselves */ + + if ((pobj == NULL) || + (head->ll_prior == NULL) || + (head->ll_next == NULL) || + (new_link->ll_prior != (list_link *)new_link) || + (new_link->ll_next != (list_link *)new_link)) + { + if (pobj == NULL) + fprintf(stderr, "ERROR: bad pobj pointer in append_link\n"); + + if (head->ll_prior == NULL) + fprintf(stderr, "ERROR: bad head->ll_prior pointer in append_link\n"); + + if (head->ll_next == NULL) + fprintf(stderr, "ERROR: bad head->ll_next pointer in append_link\n"); + + if (new_link->ll_prior == NULL) + fprintf(stderr, "ERROR: bad new->ll_prior pointer in append_link\n"); + + if (new_link->ll_next == NULL) + fprintf(stderr, "ERROR: bad new->ll_next pointer in append_link\n"); + + abort(); + } /* END if ((pobj == NULL) || ...) */ + + +#endif /* NDEBUG */ + + /* + * its big trouble if ll_struct is null, it would make this + * entry appear to be the head, so we never let that happen + */ + + if (pobj != NULL) + { + new_link->ll_struct = pobj; + } + else + { + /* WARNING: This mixes list_link pointers and ll_struct + pointers, and may break if the list_link we are operating + on is not the first embeded list_link in the surrounding + structure, e.g. work_task.wt_link_obj */ + + new_link->ll_struct = (void *)new_link; + } + + new_link->ll_prior = head->ll_prior; + + new_link->ll_next = head; + head->ll_prior = new_link; + new_link->ll_prior->ll_next = new_link; /* now visible to forward iteration */ } resource *add_resource_entry(pbs_attribute *pattr, resource_def *prdef) @@ -69,7 +140,7 @@ long count_proc(char *param_spec) return(0); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { return(NULL); } @@ -113,3 +184,8 @@ pbs_queue *find_queuebyname(char *quename) { return(NULL); } + +void log_err(int errnum, const char *routine, const char *text) + { + } + diff --git a/src/server/test/job_route/test_job_route.c b/src/server/test/job_route/test_job_route.c index 4dd7bffb4c..4f49394c74 100644 --- a/src/server/test/job_route/test_job_route.c +++ b/src/server/test/job_route/test_job_route.c @@ -8,39 +8,49 @@ START_TEST(test_add_dest_null) { - // This used to cause a seg fault. If it executes without - // crashing, the test passes. - add_dest(NULL); + /* This used to cause a seg fault. If it executes without + crashing, the test passes. */ + add_dest(NULL); } END_TEST - - -START_TEST(test_one) +START_TEST(test_add_dest) { - - + struct job j; + CLEAR_HEAD(j.ji_rejectdest); + strcpy(j.ji_qs.ji_destin, "test"); + add_dest(&j); } END_TEST -START_TEST(test_two) +START_TEST(test_queue_route_null) { + fail_unless(NULL == queue_route(NULL), "expected queue_route(NULL) to return NULL"); + } +END_TEST - +START_TEST(test_is_bad_dest) + { + struct job j; + CLEAR_HEAD(j.ji_rejectdest); + strcpy(j.ji_qs.ji_destin, "test"); + add_dest(&j); + fail_unless(NULL == is_bad_dest(&j, "random")); + fail_unless(NULL != is_bad_dest(&j, "test")); } END_TEST Suite *job_route_suite(void) { Suite *s = suite_create("job_route_suite methods"); - TCase *tc_core = tcase_create("test_one"); - tcase_add_test(tc_core, test_one); - suite_add_tcase(s, tc_core); - - tc_core = tcase_create("test_two"); - tcase_add_test(tc_core, test_two); - suite_add_tcase(s, tc_core); + TCase * tc = tcase_create("job_route"); + tcase_add_test(tc, test_add_dest_null); + tcase_add_test(tc, test_add_dest); + tcase_add_test(tc, test_queue_route_null); + tcase_add_test(tc, test_is_bad_dest); + + suite_add_tcase(s, tc); return s; } diff --git a/src/server/test/node_func/scaffolding.c b/src/server/test/node_func/scaffolding.c index a7e164c9b4..aa66493335 100644 --- a/src/server/test/node_func/scaffolding.c +++ b/src/server/test/node_func/scaffolding.c @@ -31,7 +31,7 @@ attribute_def node_attr_def[2]; int svr_clnodes = 0; struct server server; AvlTree ipaddrs = NULL; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int svr_totnodes = 0; const char *dis_emsg[] = {"No error", "Input value too large to convert to this type", @@ -56,7 +56,7 @@ int insert_thing(resizable_array *ra, void *thing) exit(1); } -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/node_manager/scaffolding.c b/src/server/test/node_manager/scaffolding.c index a5d17536a1..3403b063f2 100644 --- a/src/server/test/node_manager/scaffolding.c +++ b/src/server/test/node_manager/scaffolding.c @@ -29,7 +29,7 @@ resource_def *svr_resc_def; attribute_def node_attr_def[2]; char *path_nodenote_new; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ hello_container hellos; struct pbsnode reporter; struct pbsnode *alps_reporter = &reporter; @@ -195,13 +195,13 @@ node_iterator *get_node_iterator() exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def needs to be mocked!!\n"); exit(1); } -int decode_arst(struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_arst(struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_arst needs to be mocked!!\n"); exit(1); @@ -351,7 +351,7 @@ void free_dynamic_string(dynamic_string *ds) -char *threadsafe_tokenizer(char **str, char *delims) +char *threadsafe_tokenizer(char **str, const char *delims) { fprintf(stderr, "The call to threadsafe_tokenizer needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/pbsd_init/scaffolding.c b/src/server/test/pbsd_init/scaffolding.c index 8a19f4a219..632163726f 100644 --- a/src/server/test/pbsd_init/scaffolding.c +++ b/src/server/test/pbsd_init/scaffolding.c @@ -82,7 +82,7 @@ attribute_def svr_attr_def[10]; int a_opt_init = -1; all_tasks task_list_timed; char *path_jobinfo_log; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ pthread_mutex_t *svr_requests_mutex = NULL; all_tasks task_list_event; char *path_svrdb_new; @@ -468,7 +468,7 @@ int unlock_queue(struct pbs_queue *the_queue, const char *method_name, char *msg } -char *threadsafe_tokenizer(char **str, char *delims) +char *threadsafe_tokenizer(char **str, const char *delims) { fprintf(stderr, "The call to threadsafe_tokenizer needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/pbsd_main/scaffolding.c b/src/server/test/pbsd_main/scaffolding.c index 880f6604ed..0cc617dfdc 100644 --- a/src/server/test/pbsd_main/scaffolding.c +++ b/src/server/test/pbsd_main/scaffolding.c @@ -63,7 +63,7 @@ int job_save(job *pjob, int updatetype, int mom_port) exit(1); } -unsigned int get_svrport(char *service_name, char *ptype, unsigned int pdefault) +unsigned int get_svrport(const char *service_name, const char *ptype, unsigned int pdefault) { fprintf(stderr, "The call to get_svrport needs to be mocked!!\n"); exit(1); @@ -75,7 +75,7 @@ char * netaddr(struct sockaddr_in *ap) exit(1); } -int decode_b(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_b(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_b needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/process_alps_status/scaffolding.c b/src/server/test/process_alps_status/scaffolding.c index db2e5dc536..c1af1d243e 100644 --- a/src/server/test/process_alps_status/scaffolding.c +++ b/src/server/test/process_alps_status/scaffolding.c @@ -33,7 +33,7 @@ c ^= b; c -= rot(b,24); \ } -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ all_nodes allnodes; struct node_state { @@ -51,9 +51,9 @@ struct node_state {0, NULL} }; -void log_record(int eventtype, int objclass, const char *objname, char *msg) {} -void log_event(int eventtype, int objclass, const char *objname, char *text) {} -void log_err(int errnum, const char *routine, char *text) {} +void log_record(int eventtype, int objclass, const char *objname, const char *msg) {} +void log_event(int eventtype, int objclass, const char *objname, const char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} int lock_node(struct pbsnode *pnode, const char *method, char *msg, int log_level) {return(0);} int unlock_node(struct pbsnode *pnode, const char *method, char *msg, int log_level) {return(0);} @@ -517,7 +517,7 @@ int mgr_set_node_attr( /* nothing needed for this function */ -int decode_arst(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_arst(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { return(0); } /* END decode_arst() */ @@ -684,8 +684,8 @@ void clear_attr( int str_nc_cmp( - char *s1, /* I */ - char *s2) + const char *s1, /* I */ + const char *s2) { return(0); @@ -1646,22 +1646,22 @@ int comp_null(struct pbs_attribute *attr, struct pbs_attribute *with) return(0); } -int decode_ntype(pbs_attribute *pattr, char *name, char *rescn, char *val, int perm) +int decode_ntype(pbs_attribute *pattr, const char *name, char *rescn, char *val, int perm) { return(0); } -int encode_l(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_l(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { return(0); } -int encode_str(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_str(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { return(0); } -int decode_null(pbs_attribute *patr, char *name, char *rn, char *val, int perm) +int decode_null(pbs_attribute *patr, const char *name, char *rn, char *val, int perm) { return(0); } @@ -2006,7 +2006,7 @@ char *parse_comma_string( return(rv); } /* END parse_comma_string() */ -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { return(0); } @@ -2031,12 +2031,12 @@ int set_note_str(struct pbs_attribute *attr, struct pbs_attribute *new_attr, enu return(0); } -int decode_state(pbs_attribute *pattr, char *name, char *rescn, char *val, int perm) +int decode_state(pbs_attribute *pattr, const char *name, char *rescn, char *val, int perm) { return(0); } -int encode_jobs(pbs_attribute *pattr, tlist_head *ph, char *aname, char *rname, int mode, int perm) +int encode_jobs(pbs_attribute *pattr, tlist_head *ph, const char *aname, const char *rname, int mode, int perm) { return(0); } @@ -2068,7 +2068,7 @@ int numa_str_action(pbs_attribute *new_attr, void *pnode, int actmode) void free_str(struct pbs_attribute *attr) {} -int encode_ntype(pbs_attribute *pattr, tlist_head *ph, char *aname, char *rname, int mode, int perm) +int encode_ntype(pbs_attribute *pattr, tlist_head *ph, const char *aname, const char *rname, int mode, int perm) { return(0); } @@ -2103,12 +2103,12 @@ int node_numa_action(pbs_attribute *new_attr, void *pnode, int actmode) return(0); } -int decode_l( pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_l( pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { return(0); } -int encode_state(pbs_attribute *pattr, tlist_head *ph, char *aname, char *rname, int mode, int perm) +int encode_state(pbs_attribute *pattr, tlist_head *ph, const char *aname, const char *rname, int mode, int perm) { return(0); } @@ -2128,7 +2128,7 @@ int node_gpus_action(pbs_attribute *new_attr, void *pnode, int actmode) return(0); } -int encode_arst( pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_arst( pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { return(0); } diff --git a/src/server/test/process_mom_update/scaffolding.c b/src/server/test/process_mom_update/scaffolding.c index e870b6c686..3b126e143c 100644 --- a/src/server/test/process_mom_update/scaffolding.c +++ b/src/server/test/process_mom_update/scaffolding.c @@ -33,16 +33,16 @@ attribute_def node_attr_def[1]; -void log_record(int eventtype, int objclass, const char *objname, char *text) {} -void log_event(int eventtype, int objclass, const char *objname, char *text) {} -void log_err(int errnum, const char *routine, char *text) {} +void log_record(int eventtype, int objclass, const char *objname, const char *text) {} +void log_event(int eventtype, int objclass, const char *objname, const char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} void close_conn(int sd, int has_mutex) {} hello_container hellos; char *threadsafe_tokenizer( char **str, /* M */ - char *delims) /* I */ + const char *delims) /* I */ { return(NULL); @@ -198,7 +198,7 @@ struct pbsnode *AVL_find( int decode_arst( pbs_attribute *patr, /* O (modified) */ - char *name, /* I pbs_attribute name (notused) */ + const char *name, /* I pbs_attribute name (notused) */ char *rescn, /* I resource name (notused) */ char *val, /* I pbs_attribute value */ int perm) /* only used for resources */ diff --git a/src/server/test/process_request/scaffolding.c b/src/server/test/process_request/scaffolding.c index 4d69a58086..f9903426f9 100644 --- a/src/server/test/process_request/scaffolding.c +++ b/src/server/test/process_request/scaffolding.c @@ -21,7 +21,7 @@ struct connection svr_conn[PBS_NET_MAX_CONNECTIONS]; char *msg_request = "Type %s request received from %s@%s, sock=%d"; struct server server; char *server_host; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ @@ -169,7 +169,7 @@ void req_rdytocommit(struct batch_request *preq) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/queue_func/scaffolding.c b/src/server/test/queue_func/scaffolding.c index 8a425efbfb..d7502c1f2e 100644 --- a/src/server/test/queue_func/scaffolding.c +++ b/src/server/test/queue_func/scaffolding.c @@ -14,7 +14,7 @@ char *msg_err_unlink = "Unlink of %s file %s failed"; all_queues svr_queues; attribute_def que_attr_def[10]; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *path_queues; int insert_thing(resizable_array *ra, void *thing) @@ -35,7 +35,7 @@ void clear_attr(pbs_attribute *pattr, attribute_def *pdef) exit(1); } -int save_acl(pbs_attribute *attr, attribute_def *pdef, char *subdir, char *name) +int save_acl(pbs_attribute *attr, attribute_def *pdef, const char *subdir, const char *name) { fprintf(stderr, "The call to save_acl needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/queue_recov/scaffolding.c b/src/server/test/queue_recov/scaffolding.c index df081db5da..8ad6b0eda4 100644 --- a/src/server/test/queue_recov/scaffolding.c +++ b/src/server/test/queue_recov/scaffolding.c @@ -11,7 +11,7 @@ pthread_mutex_t *setup_save_mutex = NULL; char *path_queues; attribute_def que_attr_def[10]; -void recov_acl(pbs_attribute *pattr, attribute_def *pdef, char *subdir, char *name) +void recov_acl(pbs_attribute *pattr, attribute_def *pdef, const char *subdir, const char *name) { fprintf(stderr, "The call to recov_acl needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/receive_mom_communication/scaffolding.c b/src/server/test/receive_mom_communication/scaffolding.c index f46dd76c42..8af4eb969b 100644 --- a/src/server/test/receive_mom_communication/scaffolding.c +++ b/src/server/test/receive_mom_communication/scaffolding.c @@ -55,7 +55,7 @@ void log_record( int eventtype, /* I */ int objclass, /* I */ const char *objname, /* I */ - char *text) /* I */ {} + const char *text) /* I */ {} int insert_addr_name_info( @@ -191,8 +191,8 @@ long disrsl( return(0); } -void log_event(int eventtype, int objclass, const char *objname, char *text) {} -void log_err(int errnum, const char *routine, char *text) {} +void log_event(int eventtype, int objclass, const char *objname, const char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} void close_conn(int sd, int has_mutex) {} int copy_to_end_of_dynamic_string(dynamic_string *ds, const char *to_copy) diff --git a/src/server/test/reply_send/scaffolding.c b/src/server/test/reply_send/scaffolding.c index b08b0db8b4..90194f9323 100644 --- a/src/server/test/reply_send/scaffolding.c +++ b/src/server/test/reply_send/scaffolding.c @@ -8,7 +8,7 @@ #include "list_link.h" /* list_link */ char *msg_daemonname = "unset"; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ all_tasks task_list_event; diff --git a/src/server/test/req_delete/scaffolding.c b/src/server/test/req_delete/scaffolding.c index 38902cc67e..c966262ecc 100644 --- a/src/server/test/req_delete/scaffolding.c +++ b/src/server/test/req_delete/scaffolding.c @@ -16,7 +16,7 @@ char *msg_deletejob = "Job deleted"; struct all_jobs alljobs; char *msg_delrunjobsig = "Job sent signal %s on delete"; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *msg_manager = "%s at request of %s@%s"; @@ -104,7 +104,7 @@ struct work_task *set_task(enum work_type type, long event_id, void (*func)(), v exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); @@ -201,7 +201,7 @@ int insert_task(all_tasks *at, work_task *wt) } -char *threadsafe_tokenizer(char **str, char *delims) +char *threadsafe_tokenizer(char **str, const char *delims) { fprintf(stderr, "The call to threadsafe_tokenizer needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_deletearray/scaffolding.c b/src/server/test/req_deletearray/scaffolding.c index c7bab1966b..e223ed0b64 100644 --- a/src/server/test/req_deletearray/scaffolding.c +++ b/src/server/test/req_deletearray/scaffolding.c @@ -12,7 +12,7 @@ char *msg_permlog = "Unauthorized Request, request type: %d, Object: %s, Name: %s, request from: %s@%s"; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int svr_authorize_req(struct batch_request *preq, char *owner, char *submit_host) { @@ -80,7 +80,7 @@ job_array *get_array(char *id) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_getcred/scaffolding.c b/src/server/test/req_getcred/scaffolding.c index 558398fe0c..a24c42406a 100644 --- a/src/server/test/req_getcred/scaffolding.c +++ b/src/server/test/req_getcred/scaffolding.c @@ -28,7 +28,7 @@ ssize_t write_nonblocking_socket( int fd, const void *buf, ssize_t count) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_gpuctrl/scaffolding.c b/src/server/test/req_gpuctrl/scaffolding.c index 9528421c23..25b556d5c4 100644 --- a/src/server/test/req_gpuctrl/scaffolding.c +++ b/src/server/test/req_gpuctrl/scaffolding.c @@ -4,9 +4,9 @@ #include "batch_request.h" /* batch_request */ -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to log_ext to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_holdarray/scaffolding.c b/src/server/test/req_holdarray/scaffolding.c index ce50381914..cd1331acb7 100644 --- a/src/server/test/req_holdarray/scaffolding.c +++ b/src/server/test/req_holdarray/scaffolding.c @@ -41,7 +41,7 @@ job_array *get_array(char *id) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_holdjob/scaffolding.c b/src/server/test/req_holdjob/scaffolding.c index ba2a4bd027..b5f3b61a09 100644 --- a/src/server/test/req_holdjob/scaffolding.c +++ b/src/server/test/req_holdjob/scaffolding.c @@ -9,7 +9,7 @@ #include "list_link.h" /* list_link */ #include "work_task.h" /* work_task */ -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ attribute_def job_attr_def[10]; char *msg_jobholdrel = "Holds %s released at request of %s@%s"; char *msg_mombadhold = "MOM rejected hold request: %d"; @@ -106,7 +106,7 @@ int first_job_index(job_array *pa) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_jobobit/scaffolding.c b/src/server/test/req_jobobit/scaffolding.c index d86723676d..8388bbd957 100644 --- a/src/server/test/req_jobobit/scaffolding.c +++ b/src/server/test/req_jobobit/scaffolding.c @@ -20,9 +20,11 @@ #include "pbs_nodes.h" /* pbsnode */ #include "queue.h" /* pbs_queue */ + + char *msg_momnoexec2 = "Job cannot be executed\nSee job standard error file"; char *msg_job_end_sig = "Terminated on signal %d"; - char *msg_obitnojob = "Job Obit notice received from %s has error %d"; +char *msg_obitnojob = "Job Obit notice received from %s has error %d"; attribute_def job_attr_def[10]; char *msg_obitnocpy = "Post job file processing error; job %s on host %s"; int server_init_type = RECOV_WARM; @@ -33,7 +35,7 @@ const char *PJobState[] = {"hi", "hello"}; struct server server; int svr_do_schedule = SCH_SCHEDULE_NULL; int listener_command = SCH_SCHEDULE_NULL; -int LOGLEVEL = 0; +int LOGLEVEL = 10; char *msg_obitnodel = "Unable to delete files for job %s, on host %s"; char *msg_momnoexec1 = "Job cannot be executed\nSee Administrator for help"; char *msg_job_end_stat = "Exit_status=%d"; @@ -46,8 +48,9 @@ pthread_mutex_t *listener_command_mutex; struct batch_request *alloc_br(int type) { - fprintf(stderr, "The call to alloc_br to be mocked!!\n"); - exit(1); + batch_request *preq = calloc(1, sizeof(batch_request)); + preq->rq_type = type; + return(preq); } job_array *get_jobs_array(job **pjob) @@ -74,11 +77,7 @@ int svr_job_purge(job *pjob) exit(1); } -void svr_mailowner(job *pjob, int mailpoint, int force, char *text) - { - fprintf(stderr, "The call to svr_mailowner to be mocked!!\n"); - exit(1); - } +void svr_mailowner(job *pjob, int mailpoint, int force, char *text) {} int modify_job_attr(job *pjob, svrattrl *plist, int perm, int *bad) { @@ -122,11 +121,7 @@ void release_req(struct work_task *pwt) exit(1); } -void free_nodes(node_info **ninfo_arr) - { - fprintf(stderr, "The call to free_nodes to be mocked!!\n"); - exit(1); - } +void free_nodes(node_info **ninfo_arr) {} void free_br(struct batch_request *preq) { @@ -158,7 +153,7 @@ void svr_disconnect(int handle) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); @@ -166,8 +161,7 @@ void req_reject(int code, int aux, struct batch_request *preq, char *HostName, c int depend_on_term(char *job_id) { - fprintf(stderr, "The call to depend_on_term to be mocked!!\n"); - exit(1); + return(0); } void *get_next(list_link pl, char *file, int line) @@ -182,11 +176,7 @@ int issue_Drequest(int conn, struct batch_request *request, void (*func)(struct exit(1); } -void set_resc_assigned(job *pjob, enum batch_op op) - { - fprintf(stderr, "The call to set_resc_assigned to be mocked!!\n"); - exit(1); - } +void set_resc_assigned(job *pjob, enum batch_op op) {} void update_array_values(job_array *pa, int old_state, enum ArrayEventsEnum event, char *job_id, long job_atr_hold, int job_exit_status) { @@ -214,14 +204,14 @@ void issue_track(job *pjob) int svr_setjobstate(job *pjob, int newstate, int newsubstate, int has_queue_mute) { - fprintf(stderr, "The call to svr_setjobstate to be mocked!!\n"); - exit(1); + pjob->ji_qs.ji_state = newstate; + pjob->ji_qs.ji_substate = newsubstate; + return(0); } job *svr_find_job(char *jobid, int get_subjob) { - fprintf(stderr, "The call to find_job to be mocked!!\n"); - exit(1); + return(NULL); } int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) @@ -255,7 +245,7 @@ void get_jobowner(char *from, char *to) } -char *threadsafe_tokenizer(char **str, char *delims) +char *threadsafe_tokenizer(char **str, const char *delims) { fprintf(stderr, "The call to threadsafe_tokenizer needs to be mocked!!\n"); exit(1); @@ -345,3 +335,8 @@ int remove_job_from_exiting_list(job *pjob) { return(0); } + +void log_event(int eventtype, int objclass, const char *objname, const char *text) + { + } + diff --git a/src/server/test/req_jobobit/test_req_jobobit.c b/src/server/test/req_jobobit/test_req_jobobit.c index f3c1aa9912..895de5049d 100644 --- a/src/server/test/req_jobobit/test_req_jobobit.c +++ b/src/server/test/req_jobobit/test_req_jobobit.c @@ -1,35 +1,179 @@ #include "license_pbs.h" /* See here for the software license */ -#include "req_jobobit.h" -#include "test_req_jobobit.h" #include #include + +#include "pbs_job.h" +#include "req_jobobit.h" +#include "test_req_jobobit.h" #include "pbs_error.h" -START_TEST(test_one) +#include "batch_request.h" +#include "sched_cmds.h" + + +char *setup_from(job *pjob, char *suffix); +int is_joined(job *pjob, enum job_atr ati); +batch_request *return_stdfile(batch_request *preq, job *pjob, enum job_atr ati); +void rel_resc(job *pjob); +int handle_exiting_or_abort_substate(job *pjob); +int setrerun(job *pjob); + +extern pthread_mutex_t *svr_do_schedule_mutex; +extern pthread_mutex_t *listener_command_mutex; +extern int svr_do_schedule; +extern int listener_command; + + + +START_TEST(setup_from_test) { + job pjob; + char *str; + + memset(&pjob, 0, sizeof(pjob)); + strcpy(pjob.ji_qs.ji_fileprefix, "bob"); + str = setup_from(&pjob, "by"); + fail_unless(!strcmp(str, "bobby")); + } +END_TEST + + +START_TEST(is_joined_test) + { + job pjob; + + memset(&pjob, 0, sizeof(pjob)); + pjob.ji_wattr[JOB_ATR_join].at_flags |= ATR_VFLAG_SET; + + pjob.ji_wattr[JOB_ATR_join].at_val.at_str = strdup("oe"); + fail_unless(is_joined(&pjob, JOB_ATR_exec_host) == 0); + fail_unless(is_joined(&pjob, JOB_ATR_outpath) == 0); + fail_unless(is_joined(&pjob, JOB_ATR_errpath) == 1); + + pjob.ji_wattr[JOB_ATR_join].at_val.at_str = strdup("e"); + fail_unless(is_joined(&pjob, JOB_ATR_outpath) == 0); + + pjob.ji_wattr[JOB_ATR_join].at_val.at_str = strdup("o"); + fail_unless(is_joined(&pjob, JOB_ATR_errpath) == 0); } END_TEST -START_TEST(test_two) + + + +START_TEST(return_stdfile_test) { + job pjob; + batch_request preq; + batch_request *p1 = &preq; + batch_request *p2; + + memset(&pjob, 0, sizeof(pjob)); + memset(&preq, 0, sizeof(preq)); + pjob.ji_wattr[JOB_ATR_checkpoint_name].at_flags = ATR_VFLAG_SET; + fail_unless(return_stdfile(&preq, &pjob, JOB_ATR_outpath) != NULL); + fail_unless(return_stdfile(&preq, &pjob, JOB_ATR_errpath) != NULL); + pjob.ji_wattr[JOB_ATR_join].at_flags |= ATR_VFLAG_SET; + pjob.ji_wattr[JOB_ATR_join].at_val.at_str = strdup("oe"); + + fail_unless((p2 = return_stdfile(&preq, &pjob, JOB_ATR_errpath)) == p1); + fail_unless((p2 = return_stdfile(NULL, &pjob, JOB_ATR_outpath)) != NULL); + fail_unless(p2->rq_type == PBS_BATCH_ReturnFiles); + + pjob.ji_wattr[JOB_ATR_checkpoint_name].at_flags = 0; + fail_unless(return_stdfile(&preq, &pjob, JOB_ATR_outpath) == NULL); + + pjob.ji_wattr[JOB_ATR_interactive].at_flags |= ATR_VFLAG_SET; + pjob.ji_wattr[JOB_ATR_interactive].at_val.at_long = 1; + fail_unless(return_stdfile(&preq, &pjob, JOB_ATR_outpath) == NULL); } END_TEST + + + +START_TEST(rel_resc_test) + { + job pjob; + svr_do_schedule_mutex = calloc(1, sizeof(pthread_mutex_t)); + listener_command_mutex = calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(svr_do_schedule_mutex, NULL); + pthread_mutex_init(listener_command_mutex, NULL); + + rel_resc(&pjob); + fail_unless(svr_do_schedule == SCH_SCHEDULE_TERM); + fail_unless(listener_command == SCH_SCHEDULE_TERM); + } +END_TEST + + + + +START_TEST(handle_exiting_or_abort_substate_test) + { + job pjob; + + memset(&pjob, 0, sizeof(pjob)); + + fail_unless(handle_exiting_or_abort_substate(&pjob) == PBSE_NONE); + fail_unless(pjob.ji_qs.ji_state == JOB_STATE_EXITING); + fail_unless(pjob.ji_qs.ji_substate == JOB_SUBSTATE_RETURNSTD); + + pjob.ji_wattr[JOB_ATR_depend].at_flags |= ATR_VFLAG_SET; + fail_unless(handle_exiting_or_abort_substate(&pjob) == PBSE_NONE); + } +END_TEST + + + + +START_TEST(setrerun_test) + { + job pjob; + + memset(&pjob, 0, sizeof(pjob)); + + fail_unless(setrerun(&pjob) != PBSE_NONE); + pjob.ji_wattr[JOB_ATR_rerunable].at_val.at_long = 1; + fail_unless(setrerun(&pjob) == PBSE_NONE); + fail_unless(pjob.ji_qs.ji_substate == JOB_SUBSTATE_RERUN); + } +END_TEST + + + + Suite *req_jobobit_suite(void) { Suite *s = suite_create("req_jobobit_suite methods"); - TCase *tc_core = tcase_create("test_one"); - tcase_add_test(tc_core, test_one); + TCase *tc_core = tcase_create("setup_from_test"); + tcase_add_test(tc_core, setup_from_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("is_joined_test"); + tcase_add_test(tc_core, is_joined_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("return_stdfile_test"); + tcase_add_test(tc_core, return_stdfile_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("rel_resc_test"); + tcase_add_test(tc_core, rel_resc_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("handle_exiting_or_abort_substate_test"); + tcase_add_test(tc_core, handle_exiting_or_abort_substate_test); suite_add_tcase(s, tc_core); - tc_core = tcase_create("test_two"); - tcase_add_test(tc_core, test_two); + tc_core = tcase_create("setrerun_test"); + tcase_add_test(tc_core, setrerun_test); suite_add_tcase(s, tc_core); - return s; + return(s); } void rundebug() diff --git a/src/server/test/req_locate/scaffolding.c b/src/server/test/req_locate/scaffolding.c index 8f9f35c37b..4719eefd1b 100644 --- a/src/server/test/req_locate/scaffolding.c +++ b/src/server/test/req_locate/scaffolding.c @@ -8,7 +8,7 @@ char server_name[PBS_MAXSERVERNAME + 1]; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int reply_send_svr(struct batch_request *request) { @@ -16,7 +16,7 @@ int reply_send_svr(struct batch_request *request) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_manager/scaffolding.c b/src/server/test/req_manager/scaffolding.c index 717ca6e683..c713fed2e8 100644 --- a/src/server/test/req_manager/scaffolding.c +++ b/src/server/test/req_manager/scaffolding.c @@ -30,7 +30,7 @@ attribute_def node_attr_def[2]; struct server server; char *array_disallowed_types[] = {"hi", "hello"}; attribute_def svr_attr_def[10]; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int svr_chngNodesfile = 0; int svr_totnodes = 0; @@ -137,7 +137,7 @@ struct pbsnode *next_host(all_nodes *an, int *iter, struct pbsnode *held) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); @@ -179,7 +179,7 @@ void que_free(pbs_queue *pq, int sv_qs_mutex_held) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_message/scaffolding.c b/src/server/test/req_message/scaffolding.c index 19f5512718..2ccd4f2c4e 100644 --- a/src/server/test/req_message/scaffolding.c +++ b/src/server/test/req_message/scaffolding.c @@ -7,7 +7,7 @@ #include "work_task.h" /* work_task */ char *msg_messagejob = "Message request to job status %d"; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ void reply_ack(struct batch_request *preq) { @@ -21,7 +21,7 @@ void svr_disconnect(int handle) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_modify/scaffolding.c b/src/server/test/req_modify/scaffolding.c index 9fa5d8deb9..28a0f1e0a7 100644 --- a/src/server/test/req_modify/scaffolding.c +++ b/src/server/test/req_modify/scaffolding.c @@ -22,7 +22,7 @@ attribute_def job_attr_def[10]; resource_def *svr_resc_def; const char *PJobState[] = {"hi", "hello"}; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ struct batch_request *alloc_br(int type) { @@ -90,7 +90,7 @@ void svr_disconnect(int handle) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); @@ -132,7 +132,7 @@ int comp_resc2(struct pbs_attribute *attr, struct pbs_attribute *with, int IsQue exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_movejob/scaffolding.c b/src/server/test/req_movejob/scaffolding.c index 58590b307a..903406ba76 100644 --- a/src/server/test/req_movejob/scaffolding.c +++ b/src/server/test/req_movejob/scaffolding.c @@ -9,7 +9,7 @@ char *pbs_o_host = "PBS_O_HOST"; char *msg_movejob = "Job moved to "; char *msg_manager = "%s at request of %s@%s"; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int job_save(job *pjob, int updatetype, int mom_port) { @@ -41,13 +41,13 @@ char *get_variable(job *pjob, char *variable) exit(1); } -int svr_dequejob(char *job_id, int val) +int svr_dequejob(job *pjob, int val) { fprintf(stderr, "The call to svr_dequejob to be mocked!!\n"); exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_quejob/scaffolding.c b/src/server/test/req_quejob/scaffolding.c index a05ba46735..22ba13a296 100644 --- a/src/server/test/req_quejob/scaffolding.c +++ b/src/server/test/req_quejob/scaffolding.c @@ -28,7 +28,7 @@ resource_def *svr_resc_def; int queue_rank = 0; char *path_spool; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *msg_daemonname = "unset"; user_info_holder users; @@ -129,13 +129,13 @@ int find_attr(struct attribute_def *attr_def, char *name, int limit) exit(1); } -int decode_resc(struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_resc(struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_resc to be mocked!!\n"); exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); @@ -171,7 +171,7 @@ int svr_enquejob(job *pjob, int has_sv_qs_mutex, int prev_index) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_register/scaffolding.c b/src/server/test/req_register/scaffolding.c index c2f081ef9d..30f01abe15 100644 --- a/src/server/test/req_register/scaffolding.c +++ b/src/server/test/req_register/scaffolding.c @@ -42,7 +42,7 @@ void svr_mailowner(job *pjob, int mailpoint, int force, char *text) exit(1); } -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { svrattrl *pal; size_t asz; @@ -110,7 +110,7 @@ job_array *get_array(char *id) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) {} +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) {} int svr_chk_owner(struct batch_request *preq, job *pjob) { @@ -312,5 +312,5 @@ int unlock_ai_mutex(job_array *pa, const char *id, char *msg, int logging) return(0); } -void log_event(int eventtype, int objclass, const char *objname, char *text) {} -void log_err(int errnum, const char *routine, char *text) {} +void log_event(int eventtype, int objclass, const char *objname, const char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} diff --git a/src/server/test/req_register/test_req_register.c b/src/server/test/req_register/test_req_register.c index a88d816fb9..64c34683fb 100644 --- a/src/server/test/req_register/test_req_register.c +++ b/src/server/test/req_register/test_req_register.c @@ -26,8 +26,8 @@ int build_depend(pbs_attribute *pattr, char *value); void fast_strcat(char **Dest, char *Src); int dup_depend(pbs_attribute *pattr, struct depend *pd); void cat_jobsvr(char **Dest, char *Src); -int decode_depend(pbs_attribute *pattr, char *name, char *rescn, char *val, int perm); -int encode_depend(pbs_attribute *pattr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int decode_depend(pbs_attribute *pattr, const char *name, char *rescn, char *val, int perm); +int encode_depend(pbs_attribute *pattr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); int set_depend(pbs_attribute *attr, pbs_attribute *new_attr, enum batch_op op); int unregister_sync(pbs_attribute *attr, batch_request *preq); int register_before_dep(batch_request *preq, job *pjob, int type); diff --git a/src/server/test/req_rerun/scaffolding.c b/src/server/test/req_rerun/scaffolding.c index 0eaabef174..bea9f34a1a 100644 --- a/src/server/test/req_rerun/scaffolding.c +++ b/src/server/test/req_rerun/scaffolding.c @@ -10,7 +10,7 @@ char *msg_jobrerun = "Job Rerun"; attribute_def job_attr_def[10]; char *msg_manager = "%s at request of %s@%s"; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ void account_record(int acctype, job *pjob, char *text) @@ -43,7 +43,7 @@ void reply_ack(struct batch_request *preq) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_rescq/scaffolding.c b/src/server/test/req_rescq/scaffolding.c index 3f6eb9a695..70f07e2d27 100644 --- a/src/server/test/req_rescq/scaffolding.c +++ b/src/server/test/req_rescq/scaffolding.c @@ -23,7 +23,7 @@ void reply_ack(struct batch_request *preq) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_runjob/scaffolding.c b/src/server/test/req_runjob/scaffolding.c index c18d919001..6616fac0ce 100644 --- a/src/server/test/req_runjob/scaffolding.c +++ b/src/server/test/req_runjob/scaffolding.c @@ -30,7 +30,7 @@ int scheduler_jobct = 0; struct server server; int scheduler_sock = -1; pbs_net_t pbs_mom_addr; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *msg_manager = "%s at request of %s@%s"; int svr_totnodes = 0; @@ -136,7 +136,7 @@ int unlock_node(struct pbsnode *the_node, const char *id, char *msg, int logging exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); @@ -178,7 +178,7 @@ int job_set_wait(pbs_attribute *pattr, void *pjob, int mode) exit(1); } - resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) + resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); @@ -264,7 +264,7 @@ int insert_task(all_tasks *at, work_task *wt) exit(1); } -char *threadsafe_tokenizer(char **str, char *delims) +char *threadsafe_tokenizer(char **str, const char *delims) { fprintf(stderr, "The call to threadsafe_tokenizer needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_select/scaffolding.c b/src/server/test/req_select/scaffolding.c index a9d6ed1130..e0078da975 100644 --- a/src/server/test/req_select/scaffolding.c +++ b/src/server/test/req_select/scaffolding.c @@ -16,7 +16,7 @@ int svr_resc_size = 0; attribute_def job_attr_def[10]; struct all_jobs alljobs; resource_def *svr_resc_def; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ struct server server; struct all_jobs array_summary; @@ -39,7 +39,7 @@ int reply_send_svr(struct batch_request *request) exit(1); } -int encode_str(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_str(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_str to be mocked!!\n"); exit(1); @@ -51,7 +51,7 @@ int svr_authorize_jobreq(struct batch_request *preq, job *pjob) exit(1); } -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_str to be mocked!!\n"); exit(1); @@ -69,7 +69,7 @@ int set_str(struct pbs_attribute *attr, struct pbs_attribute *new_attr, enum bat exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); @@ -99,7 +99,7 @@ void *get_next(list_link pl, char *file, int line) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_shutdown/scaffolding.c b/src/server/test/req_shutdown/scaffolding.c index a960010137..b63e5283cf 100644 --- a/src/server/test/req_shutdown/scaffolding.c +++ b/src/server/test/req_shutdown/scaffolding.c @@ -21,7 +21,7 @@ char *msg_job_abort = "Aborted by PBS Server "; attribute_def job_attr_def[10]; struct all_jobs alljobs; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ struct batch_request *alloc_br(int type) @@ -42,7 +42,7 @@ void reply_ack(struct batch_request *preq) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_signal/scaffolding.c b/src/server/test/req_signal/scaffolding.c index f0419529a2..e57ed11eaa 100644 --- a/src/server/test/req_signal/scaffolding.c +++ b/src/server/test/req_signal/scaffolding.c @@ -6,7 +6,7 @@ #include "pbs_job.h" /* job */ #include "node_func.h" /* node_info */ -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ struct batch_request *alloc_br(int type) @@ -51,7 +51,7 @@ void svr_disconnect(int handle) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_stat/scaffolding.c b/src/server/test/req_stat/scaffolding.c index 72b714ccdb..936febc075 100644 --- a/src/server/test/req_stat/scaffolding.c +++ b/src/server/test/req_stat/scaffolding.c @@ -26,7 +26,7 @@ struct server server; struct all_jobs array_summary; attribute_def svr_attr_def[10]; int svr_totnodes = 0; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ struct batch_request *alloc_br(int type) { @@ -52,7 +52,7 @@ void svr_mailowner(job *pjob, int mailpoint, int force, char *text) exit(1); } -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create to be mocked!!\n"); exit(1); @@ -130,7 +130,7 @@ struct pbsnode *next_host(all_nodes *an, int *iter, struct pbsnode *held) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/req_track/scaffolding.c b/src/server/test/req_track/scaffolding.c index 6d42a6c052..77c825b887 100644 --- a/src/server/test/req_track/scaffolding.c +++ b/src/server/test/req_track/scaffolding.c @@ -10,7 +10,7 @@ char *path_track; char server_name[PBS_MAXSERVERNAME + 1]; struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ struct batch_request *alloc_br(int type) @@ -37,7 +37,7 @@ ssize_t write_nonblocking_socket( int fd, const void *buf, ssize_t count) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/resc_def_all/scaffolding.c b/src/server/test/resc_def_all/scaffolding.c index c24ae479e1..d5d06df6bb 100644 --- a/src/server/test/resc_def_all/scaffolding.c +++ b/src/server/test/resc_def_all/scaffolding.c @@ -21,13 +21,13 @@ resource *find_resc_entry(pbs_attribute *pattr, resource_def *rscdf) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); } -int encode_unkn(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_unkn(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_unkn to be mocked!!\n"); exit(1); @@ -45,7 +45,7 @@ int set_unkn(struct pbs_attribute *old, struct pbs_attribute *new_attr, enum bat exit(1); } -int decode_unkn(pbs_attribute *patr, char *name, char *rescn, char *value, int perm) +int decode_unkn(pbs_attribute *patr, const char *name, char *rescn, char *value, int perm) { fprintf(stderr, "The call to decode_unkn to be mocked!!\n"); exit(1); @@ -69,19 +69,19 @@ int comp_b(struct pbs_attribute *attr, struct pbs_attribute *with) exit(1); } -int encode_b(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_b(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_b to be mocked!!\n"); exit(1); } -int decode_b(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_b(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_b to be mocked!!\n"); exit(1); } -int encode_l(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_l(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_l to be mocked!!\n"); exit(1); @@ -99,19 +99,19 @@ int comp_l(struct pbs_attribute *attr, struct pbs_attribute *with) exit(1); } -int decode_l(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_l(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_l to be mocked!!\n"); exit(1); } -int encode_str(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_str(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_str to be mocked!!\n"); exit(1); } -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_str to be mocked!!\n"); exit(1); @@ -147,37 +147,37 @@ int set_ll(struct pbs_attribute *attr, struct pbs_attribute *new_attr, enum batc exit(1); } -int encode_ll(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_ll(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_ll to be mocked!!\n"); exit(1); } -int decode_ll(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_ll(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_ll to be mocked!!\n"); exit(1); } -int encode_time(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_time(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_time to be mocked!!\n"); exit(1); } -int decode_time(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_time(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_time to be mocked!!\n"); exit(1); } -int encode_size(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_size(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_size to be mocked!!\n"); exit(1); } -int decode_size(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_size(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_size to be mocked!!\n"); exit(1); @@ -201,7 +201,7 @@ void free_null(struct pbs_attribute *attr) exit(1); } -int decode_tokens(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_tokens(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_tokens to be mocked!!\n"); exit(1); @@ -212,7 +212,7 @@ int get_svr_attr_arst(int index, struct array_strings **arst) return(0); } -char *threadsafe_tokenizer(char **str, char *delims) +char *threadsafe_tokenizer(char **str, const char *delims) { fprintf(stderr, "The call to threadsafe_tokenizer needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/scaffolding_job_attr_def.c b/src/server/test/scaffolding_job_attr_def.c index ebca6e8fc0..2be6ab4655 100644 --- a/src/server/test/scaffolding_job_attr_def.c +++ b/src/server/test/scaffolding_job_attr_def.c @@ -24,13 +24,13 @@ void free_arst(struct pbs_attribute *attr) exit(1); } -int encode_arst(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_arst(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_arst needs to be mocked!!\n"); exit(1); } -int decode_arst(struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_arst(struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_arst needs to be mocked!!\n"); exit(1); @@ -54,13 +54,13 @@ void free_str(struct pbs_attribute *attr) exit(1); } -int encode_str(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_str(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_str needs to be mocked!!\n"); exit(1); } -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_str needs to be mocked!!\n"); exit(1); @@ -84,13 +84,13 @@ void free_resc(pbs_attribute *pattr) exit(1); } -int encode_resc(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int ac_perm) +int encode_resc(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int ac_perm) { fprintf(stderr, "The call to encode_resc needs to be mocked!!\n"); exit(1); } -int decode_resc(struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_resc(struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_resc needs to be mocked!!\n"); exit(1); @@ -120,13 +120,13 @@ void free_unkn(pbs_attribute *pattr) exit(1); } -int encode_unkn(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_unkn(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_unkn needs to be mocked!!\n"); exit(1); } -int decode_unkn(pbs_attribute *patr, char *name, char *rescn, char *value, int perm) +int decode_unkn(pbs_attribute *patr, const char *name, char *rescn, char *value, int perm) { fprintf(stderr, "The call to decode_unkn needs to be mocked!!\n"); exit(1); @@ -150,13 +150,13 @@ void free_depend(struct pbs_attribute *attr) exit(1); } -int encode_depend(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_depend(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_depend needs to be mocked!!\n"); exit(1); } -int decode_depend(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_depend(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_depend needs to be mocked!!\n"); exit(1); @@ -168,13 +168,13 @@ int comp_hold(struct pbs_attribute *attr, struct pbs_attribute *with) exit(1); } -int encode_hold(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_hold(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_hold needs to be mocked!!\n"); exit(1); } -int decode_hold(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_hold(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_hold needs to be mocked!!\n"); exit(1); @@ -192,13 +192,13 @@ int comp_l(struct pbs_attribute *attr, struct pbs_attribute *with) exit(1); } -int encode_l(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_l(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_l needs to be mocked!!\n"); exit(1); } -int decode_l(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_l(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_l needs to be mocked!!\n"); exit(1); @@ -216,13 +216,13 @@ int comp_b(struct pbs_attribute *attr, struct pbs_attribute *with) exit(1); } -int encode_b(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_b(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_b needs to be mocked!!\n"); exit(1); } -int decode_b(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_b(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_b needs to be mocked!!\n"); exit(1); @@ -240,13 +240,13 @@ int comp_c(struct pbs_attribute *attr, struct pbs_attribute *with) exit(1); } -int encode_c(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_c(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_c needs to be mocked!!\n"); exit(1); } -int decode_c(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_c(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_c needs to be mocked!!\n"); exit(1); @@ -264,19 +264,19 @@ int comp_tv(struct pbs_attribute *attr, struct pbs_attribute *with) exit(1); } -int encode_tv(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_tv(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_tv needs to be mocked!!\n"); exit(1); } -int decode_tv(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_tv(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_tv needs to be mocked!!\n"); exit(1); } -int encode_inter(pbs_attribute *attr, tlist_head *phead, char *atname, char *rsname, int mode, int perm) +int encode_inter(pbs_attribute *attr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm) { fprintf(stderr, "The call to encode_inter needs to be mocked!!\n"); exit(1); diff --git a/src/server/test/stat_job/scaffolding.c b/src/server/test/stat_job/scaffolding.c index b5550aa313..f42b96afa3 100644 --- a/src/server/test/stat_job/scaffolding.c +++ b/src/server/test/stat_job/scaffolding.c @@ -12,7 +12,7 @@ struct server server; -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create to be mocked!!\n"); exit(1); diff --git a/src/server/test/svr_chk_owner/scaffolding.c b/src/server/test/svr_chk_owner/scaffolding.c index 2809e9834e..5963c5f5dc 100644 --- a/src/server/test/svr_chk_owner/scaffolding.c +++ b/src/server/test/svr_chk_owner/scaffolding.c @@ -28,7 +28,7 @@ char *get_variable(job *pjob, char *variable) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/svr_connect/scaffolding.c b/src/server/test/svr_connect/scaffolding.c index 2ec68c8cbf..4eba1c3e17 100644 --- a/src/server/test/svr_connect/scaffolding.c +++ b/src/server/test/svr_connect/scaffolding.c @@ -14,7 +14,7 @@ char pbs_current_user[PBS_MAXUSER]; struct connection svr_conn[PBS_NET_MAX_CONNECTIONS]; pbs_net_t pbs_server_addr; unsigned int pbs_server_port_dis; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ diff --git a/src/server/test/svr_func/scaffolding.c b/src/server/test/svr_func/scaffolding.c index 83f157279f..7bd63a379d 100644 --- a/src/server/test/svr_func/scaffolding.c +++ b/src/server/test/svr_func/scaffolding.c @@ -15,12 +15,12 @@ struct server server; int scheduler_sock = -1; int svr_do_schedule = SCH_SCHEDULE_NULL; int listener_command = SCH_SCHEDULE_NULL; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ pthread_mutex_t *svr_do_schedule_mutex; pthread_mutex_t *scheduler_sock_jobct_mutex; pthread_mutex_t *listener_command_mutex; -int encode_svrstate(pbs_attribute *pattr, tlist_head *phead, char *atname, char *rsname, int mode, int perm); +int encode_svrstate(pbs_attribute *pattr, tlist_head *phead, const char *atname, const char *rsname, int mode, int perm); attribute_def svr_attr_def[] = { @@ -44,7 +44,7 @@ resource *add_resource_entry(pbs_attribute *pattr, resource_def *prdef) exit(1); } -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create to be mocked!!\n"); exit(1); diff --git a/src/server/test/svr_jobfunc/scaffolding.c b/src/server/test/svr_jobfunc/scaffolding.c index b3dc107d38..2762c1f9ec 100644 --- a/src/server/test/svr_jobfunc/scaffolding.c +++ b/src/server/test/svr_jobfunc/scaffolding.c @@ -28,7 +28,7 @@ struct server server; struct all_jobs array_summary; int svr_do_schedule = SCH_SCHEDULE_NULL; int listener_command = SCH_SCHEDULE_NULL; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ pthread_mutex_t *svr_do_schedule_mutex; pthread_mutex_t *listener_command_mutex; @@ -51,7 +51,7 @@ void account_record(int acctype, job *pjob, char *text) exit(1); } -char *arst_string(char *str, pbs_attribute *pattr) +char *arst_string(const char *str, pbs_attribute *pattr) { fprintf(stderr, "The call to arst_string to be mocked!!\n"); exit(1); @@ -81,7 +81,7 @@ int procs_available(int proc_ct) exit(1); } -int decode_str(pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_str(pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_str to be mocked!!\n"); exit(1); @@ -147,7 +147,7 @@ int comp_resc2(struct pbs_attribute *attr, struct pbs_attribute *with, int IsQue exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); diff --git a/src/server/test/svr_mail/scaffolding.c b/src/server/test/svr_mail/scaffolding.c index 2509e9593a..597b800371 100644 --- a/src/server/test/svr_mail/scaffolding.c +++ b/src/server/test/svr_mail/scaffolding.c @@ -5,7 +5,7 @@ #include "server.h" /* server mail_info*/ struct server server; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ int enqueue_threadpool_request(void *(*func)(void *),void *arg) { diff --git a/src/server/test/svr_movejob/scaffolding.c b/src/server/test/svr_movejob/scaffolding.c index 115a92cea6..09edba89d8 100644 --- a/src/server/test/svr_movejob/scaffolding.c +++ b/src/server/test/svr_movejob/scaffolding.c @@ -22,7 +22,7 @@ char *path_spool; char *msg_movejob = "Job moved to "; pbs_net_t pbs_server_addr; unsigned int pbs_server_port_dis; -int LOGLEVEL = 0; +int LOGLEVEL = 7; /* force logging code to be exercised as tests run */ char *msg_manager = "%s at request of %s@%s"; @@ -117,7 +117,7 @@ void remove_checkpoint(job *pjob) exit(1); } -int svr_dequejob(char *job_id, int val) +int svr_dequejob(job *pjob, int val) { fprintf(stderr, "The call to svr_dequejob to be mocked!!\n"); exit(1); @@ -135,7 +135,7 @@ void svr_disconnect(int handle) exit(1); } -void req_reject(int code, int aux, struct batch_request *preq, char *HostName, char *Msg) +void req_reject(int code, int aux, struct batch_request *preq, const char *HostName, const char *Msg) { fprintf(stderr, "The call to req_reject to be mocked!!\n"); exit(1); diff --git a/src/server/test/svr_recov/scaffolding.c b/src/server/test/svr_recov/scaffolding.c index dc4b0c5b9a..8e5b556436 100644 --- a/src/server/test/svr_recov/scaffolding.c +++ b/src/server/test/svr_recov/scaffolding.c @@ -51,7 +51,7 @@ int find_attr(struct attribute_def *attr_def, char *name, int limit) exit(1); } -int decode_resc(struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_resc(struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_resc to be mocked!!\n"); exit(1); @@ -75,7 +75,7 @@ void *get_next(list_link pl, char *file, int line) exit(1); } -int decode_arst(struct pbs_attribute *patr, char *name, char *rescn, char *val, int perm) +int decode_arst(struct pbs_attribute *patr, const char *name, char *rescn, char *val, int perm) { fprintf(stderr, "The call to decode_arst to be mocked!!\n"); exit(1); diff --git a/src/server/test/svr_resccost/scaffolding.c b/src/server/test/svr_resccost/scaffolding.c index 6cd573135d..8a5dd9fd21 100644 --- a/src/server/test/svr_resccost/scaffolding.c +++ b/src/server/test/svr_resccost/scaffolding.c @@ -12,7 +12,7 @@ resource_def *svr_resc_def; struct server server; -svrattrl *attrlist_create(char *aname, char *rname, int vsize) +svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { fprintf(stderr, "The call to attrlist_create to be mocked!!\n"); exit(1); @@ -30,7 +30,7 @@ void *get_next(list_link pl, char *file, int line) exit(1); } -resource_def *find_resc_def(resource_def *rscdf, char *name, int limit) +resource_def *find_resc_def(resource_def *rscdf, const char *name, int limit) { fprintf(stderr, "The call to find_resc_def to be mocked!!\n"); exit(1); diff --git a/src/server/test/track_alps_reservations/scaffolding.c b/src/server/test/track_alps_reservations/scaffolding.c index e92332698d..8335984239 100644 --- a/src/server/test/track_alps_reservations/scaffolding.c +++ b/src/server/test/track_alps_reservations/scaffolding.c @@ -14,7 +14,7 @@ int unlock_node(struct pbsnode *the_node, const char *method_name, char *msg, in return(0); } -void log_err(int errnum, const char *routine, char *text) {} +void log_err(int errnum, const char *routine, const char *text) {} void free_resizable_array( @@ -362,7 +362,7 @@ hash_table_t *create_hash( char *threadsafe_tokenizer( char **str, /* M */ - char *delims) /* I */ + const char *delims) /* I */ { char *current_char; diff --git a/src/server/test/user_info/scaffolding.c b/src/server/test/user_info/scaffolding.c index 22404bcd2d..1398270c63 100644 --- a/src/server/test/user_info/scaffolding.c +++ b/src/server/test/user_info/scaffolding.c @@ -59,7 +59,7 @@ hash_table_t *create_hash(int size) return((hash_table_t *)1); } -void log_err(int error, const char *func_id, char *msg) {} +void log_err(int error, const char *func_id, const char *msg) {} void free_hash(hash_table_t *ht) {}