diff options
author | Toomas Soome <tsoome@me.com> | 2019-01-26 14:25:35 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2019-07-26 08:29:41 +0300 |
commit | e9610e3e86cbfb5fd6797a438c65b493250b4219 (patch) | |
tree | ad836f965bb27491aad07f45a2a1509b44ac8fbf | |
parent | 3f77e798e029df017fe2a6df5b524cf0808b7faa (diff) | |
download | illumos-gate-e9610e3e86cbfb5fd6797a438c65b493250b4219.tar.gz |
11406 picl: NULL pointer errors
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Approved by: Dan McDonald <danmcd@joyent.com>
6 files changed, 60 insertions, 65 deletions
diff --git a/usr/src/cmd/picl/picld/picld.c b/usr/src/cmd/picl/picld/picld.c index ae67fd7581..8c978949ef 100644 --- a/usr/src/cmd/picl/picld/picld.c +++ b/usr/src/cmd/picl/picld/picld.c @@ -101,7 +101,7 @@ static int doreinit = 0; static int door_id = -1; static pthread_mutex_t door_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t door_cv = PTHREAD_COND_INITIALIZER; -static int service_requests = 0; +static int service_requests = 0; static hrtime_t orig_time; static hrtime_t sliding_interval_ms; static uint32_t dos_req_limit; @@ -1174,7 +1174,7 @@ main(int argc, char **argv) /* * Initialize the PICL Tree */ - if (xptree_initialize(NULL) != PICL_SUCCESS) { + if (xptree_initialize(0) != PICL_SUCCESS) { syslog(LOG_CRIT, INIT_FAILED); exit(1); } diff --git a/usr/src/cmd/picl/plugins/common/devtree/picldevtree.c b/usr/src/cmd/picl/plugins/common/devtree/picldevtree.c index 2f648d5336..798a2c89c0 100644 --- a/usr/src/cmd/picl/plugins/common/devtree/picldevtree.c +++ b/usr/src/cmd/picl/plugins/common/devtree/picldevtree.c @@ -102,7 +102,7 @@ static picld_plugin_reg_t my_reg_info = { #define SUNW_PICLDEVTREE_PLUGIN_DEBUG "SUNW_PICLDEVTREE_PLUGIN_DEBUG" static int picldevtree_debug = 0; -static conf_entries_t *conf_name_class_map = NULL; +static conf_entries_t *conf_name_class_map = NULL; static builtin_map_t sun4u_map[] = { /* MAX_NAMEVAL_SIZE */ { "SUNW,bpp", PICL_CLASS_PARALLEL}, @@ -285,11 +285,11 @@ mc_completion_handler(char *ename, void *earg, size_t size) nvlist_t *unpack_nvl; if (strcmp(ename, PICLEVENT_MC_REMOVED) == 0 && - nvlist_unpack(earg, size, &unpack_nvl, NULL) == 0) { - mch = NULL; + nvlist_unpack(earg, size, &unpack_nvl, 0) == 0) { + mch = 0; (void) nvlist_lookup_uint64(unpack_nvl, PICLEVENTARG_NODEHANDLE, &mch); - if (mch != NULL) { + if (mch != 0) { if (picldevtree_debug) syslog(LOG_INFO, "picldevtree: destroying_node:%llx\n", @@ -318,14 +318,14 @@ post_mc_event(char *ename, picl_nodehdl_t mch) if (ev_name == NULL) return (-1); - if (nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, NULL)) { + if (nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, 0)) { free(ev_name); return (-1); } pack_buf = NULL; if (nvlist_add_uint64(nvl, PICLEVENTARG_NODEHANDLE, mch) || - nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) { + nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, 0)) { free(ev_name); nvlist_free(nvl); return (-1); @@ -1200,11 +1200,11 @@ add_di_path_prop(picl_nodehdl_t nodeh, di_path_prop_t di_path_prop) static void construct_mpath_node(picl_nodehdl_t parh, di_node_t di_node) { - di_path_t pi = DI_PATH_NIL; + di_path_t pi = DI_PATH_NIL; while ((pi = di_path_next_phci(di_node, pi)) != DI_PATH_NIL) { - di_node_t phci_node = di_path_phci_node(pi); - di_path_prop_t di_path_prop; + di_node_t phci_node = di_path_phci_node(pi); + di_path_prop_t di_path_prop; picl_nodehdl_t nodeh; ptree_propinfo_t propinfo; int err; @@ -1974,7 +1974,7 @@ get_fputypes(ptree_rarg_t *rarg, void *vbuf) static int get_pi_state_begin(ptree_rarg_t *rarg, void *vbuf) { - int err; + int err; int cpu_id; static kstat_ctl_t *kc = NULL; static pthread_mutex_t kc_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -2023,7 +2023,7 @@ get_pi_state_begin(ptree_rarg_t *rarg, void *vbuf) static int add_processor_info(picl_nodehdl_t cpuh, void *args) { - int err; + int err; int cpu_id; ptree_propinfo_t propinfo; ptree_propinfo_t pinfo; @@ -2084,7 +2084,7 @@ add_processor_info(picl_nodehdl_t cpuh, void *args) static int setup_cpus(picl_nodehdl_t plafh) { - int err; + int err; err = ptree_walk_tree_by_class(plafh, PICL_CLASS_CPU, NULL, add_processor_info); @@ -2128,11 +2128,11 @@ fmt_manf_id(manuf_t manufid, int bufsz, char *outbuf) static int open_ffb_device(picl_nodehdl_t ffbh, int *fd) { - DIR *dirp; - char devfs_path[PATH_MAX]; - char dev_path[PATH_MAX]; - char *devp; - struct dirent *direntp; + DIR *dirp; + char devfs_path[PATH_MAX]; + char dev_path[PATH_MAX]; + char *devp; + struct dirent *direntp; int err; int tmpfd; @@ -2196,9 +2196,9 @@ add_ffb_config_info(picl_nodehdl_t rooth) { picl_nodehdl_t nodeh; int err; - char piclclass[PICL_CLASSNAMELEN_MAX]; - char manfidbuf[FFB_MANUF_BUFSIZE]; - int fd; + char piclclass[PICL_CLASSNAMELEN_MAX]; + char manfidbuf[FFB_MANUF_BUFSIZE]; + int fd; int board_rev; ffb_sys_info_t fsi; ptree_propinfo_t pinfo; @@ -2948,11 +2948,11 @@ get_first_reg_word(picl_nodehdl_t nodeh, uint32_t *regval) { int err; uint32_t *regbuf; - picl_prophdl_t regh; + picl_prophdl_t regh; ptree_propinfo_t pinfo; err = ptree_get_prop_by_name(nodeh, OBP_REG, ®h); - if (err != PICL_SUCCESS) /* no reg property */ + if (err != PICL_SUCCESS) /* no reg property */ return (err); err = ptree_get_propinfo(regh, &pinfo); if (err != PICL_SUCCESS) @@ -3635,7 +3635,7 @@ picldevtree_evhandler(const char *ename, const void *earg, size_t size, } nvlp = NULL; - if (nvlist_unpack((char *)earg, size, &nvlp, NULL) || + if (nvlist_unpack((char *)earg, size, &nvlp, 0) || nvlist_lookup_string(nvlp, PICLEVENTARG_DEVFS_PATH, &devfs_path) || strlen(devfs_path) > (PATH_MAX - sizeof (PLATFORM_PATH))) { syslog(LOG_INFO, PICL_EVENT_DROPPED, ename); diff --git a/usr/src/cmd/picl/plugins/common/memcfg/piclmemcfg_comm.c b/usr/src/cmd/picl/plugins/common/memcfg/piclmemcfg_comm.c index df5b34d8d3..4af768727d 100644 --- a/usr/src/cmd/picl/plugins/common/memcfg/piclmemcfg_comm.c +++ b/usr/src/cmd/picl/plugins/common/memcfg/piclmemcfg_comm.c @@ -217,7 +217,7 @@ undo_phymem_tree(void) /* * Delete nodes and properties of memory-module-group(s) */ - if (mmghdl->mmgh == NULL) + if (mmghdl->mmgh == 0) continue; (void) ptree_delete_node(mmghdl->mmgh); @@ -227,7 +227,7 @@ undo_phymem_tree(void) * Clear out the saved node handle of memory module group * so that logic memory tree won't link to it. */ - mmghdl->mch = mmghdl->mmgh = NULL; + mmghdl->mch = mmghdl->mmgh = 0; mmghdl = mmghdl->next; } } @@ -560,8 +560,8 @@ create_physical_tree(picl_nodehdl_t mch, void *args) mmodgrp_info_t *mmghdl; picl_nodehdl_t mmodgrph; ptree_propinfo_t propinfo; - struct mc_control *mccontrol; - struct mc_devgrp mcdevgrp; + struct mc_control *mccontrol; + struct mc_devgrp mcdevgrp; int fd; fd = (int)args; @@ -705,7 +705,7 @@ init_mc(void) DIR *dirp; struct dirent *retp; char path[PATH_MAX]; - int found = 0; + int found = 0; int valid_entry = 0; /* open the directory */ @@ -899,8 +899,8 @@ piclmemcfg_evhandler(const char *ename, const void *earg, size_t size, int old_nsegs; nvlist_t *nvlp; - memh = NULL; - if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) + memh = 0; + if (nvlist_unpack((char *)earg, size, &nvlp, 0)) return; if (nvlist_lookup_uint64(nvlp, PICLEVENTARG_NODEHANDLE, &nodeh)) { diff --git a/usr/src/cmd/picl/plugins/common/piclevent/picl_slm.c b/usr/src/cmd/picl/plugins/common/piclevent/picl_slm.c index 71cb732d3f..1c42d1e622 100644 --- a/usr/src/cmd/picl/plugins/common/piclevent/picl_slm.c +++ b/usr/src/cmd/picl/plugins/common/piclevent/picl_slm.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <unistd.h> #include <stdlib.h> #include <errno.h> @@ -255,7 +253,7 @@ piclslm_add_ec_dr_req_args(nvlist_t *nvl, sysevent_t *ev) } if (nvlist_lookup_string(nvlist, DR_AP_ID, &ap_id) != 0 || - ap_id == NULL) { + ap_id == NULL) { nvlist_free(nvlist); return (EINVAL); } @@ -269,15 +267,14 @@ piclslm_add_ec_dr_req_args(nvlist_t *nvl, sysevent_t *ev) if (nvlist_lookup_string(nvlist, DR_REQ_TYPE, &dr_req) != 0) dr_req = ""; - if (nvlist_add_string(nvl, PICLEVENTARG_DR_REQ_TYPE, - dr_req)) { + if (nvlist_add_string(nvl, PICLEVENTARG_DR_REQ_TYPE, dr_req)) { nvlist_free(nvlist); return (EAGAIN); } if (piclslm_debug) syslog(LOG_DEBUG, "piclevent: dr_req_type = %s on %s\n", - (dr_req ? dr_req : "Investigate"), ap_id); + (dr_req ? dr_req : "Investigate"), ap_id); nvlist_free(nvlist); return (0); @@ -344,7 +341,7 @@ piclslm_deliver_event(sysevent_t *ev, int flag) return (EAGAIN); } - if (nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, NULL)) { + if (nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, 0)) { free(ename); sysevent_free(dupev); return (EAGAIN); @@ -371,7 +368,7 @@ piclslm_deliver_event(sysevent_t *ev, int flag) if (nvlist_add_string(nvl, PICLEVENTARG_EVENT_NAME, ename) || nvlist_add_string(nvl, PICLEVENTARG_DATA_TYPE, PICLEVENTARG_PICLEVENT_DATA) || - nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) { + nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, 0)) { free(ename); nvlist_free(nvl); sysevent_free(dupev); @@ -402,7 +399,7 @@ slm_init(void) (void) mutex_init(&nvq_lock, USYNC_THREAD, NULL); (void) cond_init(&nvq_cv, USYNC_THREAD, NULL); - if (thr_create(NULL, NULL, piclslm_deliver_thr, + if (thr_create(NULL, 0, piclslm_deliver_thr, NULL, THR_BOUND, &piclslm_deliver_thr_id) != 0) { (void) mutex_destroy(&nvq_lock); (void) cond_destroy(&nvq_cv); diff --git a/usr/src/cmd/picl/plugins/common/piclevent/piclevent.c b/usr/src/cmd/picl/plugins/common/piclevent/piclevent.c index 8d1804e340..1185248e6d 100644 --- a/usr/src/cmd/picl/plugins/common/piclevent/piclevent.c +++ b/usr/src/cmd/picl/plugins/common/piclevent/piclevent.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * PICL plug-in that listens to sysevent and posts picl events */ @@ -111,7 +109,7 @@ parse_piclevent(nvlist_t *nvlp) return; packed_nvl = NULL; - if (nvlist_pack(nvlp, &packed_nvl, &nvl_size, NV_ENCODE_NATIVE, NULL)) + if (nvlist_pack(nvlp, &packed_nvl, &nvl_size, NV_ENCODE_NATIVE, 0)) return; ename = strdup(enval); @@ -158,7 +156,7 @@ event_handler(void *cookie, char *argp, size_t asize, (cred.dc_euid != 0)) (void) door_return(argp, 0, NULL, 0); - if (nvlist_unpack(argp, asize, &nvlp, NULL)) + if (nvlist_unpack(argp, asize, &nvlp, 0)) (void) door_return(argp, 0, NULL, 0); if (nvlist_lookup_string(nvlp, PICLEVENTARG_DATA_TYPE, &dtype)) { diff --git a/usr/src/cmd/picl/plugins/lib/picld_pluginutil/picld_pluginutil.c b/usr/src/cmd/picl/plugins/lib/picld_pluginutil/picld_pluginutil.c index 9c71ebf720..8a41a4d7f3 100644 --- a/usr/src/cmd/picl/plugins/lib/picld_pluginutil/picld_pluginutil.c +++ b/usr/src/cmd/picl/plugins/lib/picld_pluginutil/picld_pluginutil.c @@ -132,38 +132,38 @@ verbose_log(int pri, const char *fmt, ...) static void undo_commands(cmdbuf_t *cmds, int last_cmd_index) { - int i; + int i; command_t *com = cmds->commands; for (i = last_cmd_index; i >= 0; i--) { switch (com[i].type) { case TOK_NODE: - if (com[i].nodecmd_nodeh == NULL) + if (com[i].nodecmd_nodeh == 0) break; (void) ptree_delete_node(com[i].nodecmd_nodeh); (void) ptree_destroy_node(com[i].nodecmd_nodeh); break; case TOK_REFNODE: - if (com[i].refnodecmd_nodeh == NULL) + if (com[i].refnodecmd_nodeh == 0) break; (void) ptree_delete_node(com[i].refnodecmd_nodeh); (void) ptree_destroy_node(com[i].refnodecmd_nodeh); break; case TOK_PROP: - if (com[i].propcmd_proph == NULL) + if (com[i].propcmd_proph == 0) break; (void) ptree_delete_prop(com[i].propcmd_proph); (void) ptree_destroy_prop(com[i].propcmd_proph); break; case TOK_REFPROP: - if (com[i].refpropcmd_proph == NULL) + if (com[i].refpropcmd_proph == 0) break; (void) ptree_delete_prop(com[i].refpropcmd_proph); (void) ptree_destroy_prop(com[i].refpropcmd_proph); break; case TOK_TABLE: - if ((com[i].tablecmd_tblh == NULL) || + if ((com[i].tablecmd_tblh == 0) || (com[i].tablecmd_newtbl == 0)) break; (void) ptree_delete_prop(com[i].tablecmd_tblh); @@ -335,7 +335,7 @@ parse_node(char *line, command_t *command) command->nodecmd_nodename = strdup(nametok); command->nodecmd_classname = strdup(classtok); - command->nodecmd_nodeh = NULL; + command->nodecmd_nodeh = 0; if ((command->nodecmd_nodename == NULL) || (command->nodecmd_classname == NULL)) return (EC_FAILURE); @@ -402,11 +402,11 @@ getpiclmode(char *mode) static int validate_size_and_cvt_val(void *outbuf, size_t size, int type, char *val) { - int64_t llval; + int64_t llval; int32_t intval; int16_t sval; int8_t cval; - uint64_t ullval; + uint64_t ullval; uint32_t uintval; uint16_t usval; uint8_t ucval; @@ -637,7 +637,7 @@ parse_prop(char *line, command_t *command) command->propcmd_type = typetok; command->propcmd_accessmode = modetok; command->propcmd_size = 0; - command->propcmd_proph = NULL; + command->propcmd_proph = 0; return (EC_SYNTAX_OK); } @@ -683,7 +683,7 @@ parse_prop(char *line, command_t *command) command->propcmd_type = typetok; command->propcmd_accessmode = modetok; command->propcmd_size = sizetok; - command->propcmd_proph = NULL; + command->propcmd_proph = 0; return (EC_SYNTAX_OK); } @@ -803,7 +803,7 @@ parse_refnode(char *line, command_t *command) command->refnodecmd_name = strdup(nodenm); command->refnodecmd_class = strdup(classnm); command->refnodecmd_dstnode = strdup(dsttok); - command->refnodecmd_nodeh = NULL; + command->refnodecmd_nodeh = 0; if ((command->refnodecmd_name == NULL) || (command->refnodecmd_class == NULL) || (command->refnodecmd_dstnode == NULL)) @@ -879,7 +879,7 @@ parse_refprop(char *line, command_t *command) command->refpropcmd_pname = strdup(pnametok); command->refpropcmd_dstnode = strdup(dsttok); - command->refpropcmd_proph = NULL; + command->refpropcmd_proph = 0; if ((command->refpropcmd_pname == NULL) || (command->refpropcmd_dstnode == NULL)) return (EC_FAILURE); @@ -894,8 +894,8 @@ static int process_refprop(cmdbuf_t *cmds, command_t *command, picl_nodehdl_t nodeh) { int err; - picl_nodehdl_t dsth; - picl_prophdl_t proph; + picl_nodehdl_t dsth; + picl_prophdl_t proph; ptree_propinfo_t propinfo; /* refprop in discarded row */ @@ -972,7 +972,7 @@ parse_table(char *line, command_t *command) return (EC_FAILURE); command->tablecmd_newtbl = 0; - command->tablecmd_tblh = NULL; + command->tablecmd_tblh = 0; return (EC_SYNTAX_OK); } @@ -985,8 +985,8 @@ static int process_table(command_t *command, picl_nodehdl_t nodeh) { int err; - picl_prophdl_t tblh; - picl_prophdl_t proph; + picl_prophdl_t tblh; + picl_prophdl_t proph; ptree_propinfo_t propinfo; /* find if table already exists */ @@ -1387,7 +1387,7 @@ check_conffile_syntax(cmdbuf_t *cmds, FILE *fp) if (err == EC_SYNTAX_OK) (void) strlcpy(lbuf, buf, RECORD_SIZE_MAX); else if (strlcat(lbuf, buf, RECORD_SIZE_MAX) >= - RECORD_SIZE_MAX) { /* buffer overflow */ + RECORD_SIZE_MAX) { /* buffer overflow */ err = EC_FAILURE; break; } @@ -1458,7 +1458,7 @@ check_conffile_syntax(cmdbuf_t *cmds, FILE *fp) */ static void skip_to_next_valid_path(cmdbuf_t *cmds, int starting_index, - picl_nodehdl_t *parent, int *last_processed_index) + picl_nodehdl_t *parent, int *last_processed_index) { int err; int index; |