diff options
author | Toomas Soome <tsoome@me.com> | 2019-01-22 10:20:29 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2019-06-24 23:11:08 +0300 |
commit | f00128d8e2d39a5be61357047531dc79fde48623 (patch) | |
tree | caea1557d04dd515088e277035b66b3ecd6eb388 | |
parent | 4a014300cea3d870431d7e52aff6781d3c63e5d1 (diff) | |
download | illumos-joyent-f00128d8e2d39a5be61357047531dc79fde48623.tar.gz |
11134 libdevinfo: NULL pointer errors
Reviewed by: Jason Lippert <jason@glasspelican.ca>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/lib/libdevinfo/devfsinfo.c | 10 | ||||
-rw-r--r-- | usr/src/lib/libdevinfo/devinfo.c | 60 | ||||
-rw-r--r-- | usr/src/lib/libdevinfo/devinfo_devperm.c | 17 |
3 files changed, 42 insertions, 45 deletions
diff --git a/usr/src/lib/libdevinfo/devfsinfo.c b/usr/src/lib/libdevinfo/devfsinfo.c index d6f8407ebb..4aee4285ae 100644 --- a/usr/src/lib/libdevinfo/devfsinfo.c +++ b/usr/src/lib/libdevinfo/devfsinfo.c @@ -491,7 +491,7 @@ devfs_bootdev_set_list(const char *dev_name, const uint_t options) i++; } ptr--; - *ptr = NULL; + *ptr = 0; prom_list_free(prom_list); } @@ -835,7 +835,7 @@ find_x86_boot_device(struct openpromio *opp) */ int devfs_bootdev_get_list(const char *default_root, - struct boot_dev ***bootdev_list) + struct boot_dev ***bootdev_list) { Oppbuf oppbuf; struct openpromio *opp = &(oppbuf.opp); @@ -877,7 +877,7 @@ devfs_bootdev_get_list(const char *default_root, */ static int process_bootdev(const char *bootdevice, const char *default_root, - struct boot_dev ***list) + struct boot_dev ***list) { int i; char *entry, *ptr; @@ -1202,7 +1202,7 @@ devfs_phys_to_logical(struct boot_dev **bootdev_array, const int array_size, /* ARGSUSED */ static int check_logical_dev(const char *node, const struct stat *node_stat, int flags, - struct FTW *ftw_info) + struct FTW *ftw_info) { char link_buf[MAXPATHLEN]; int link_buf_len; @@ -1352,7 +1352,7 @@ devfs_dev_to_prom_names(char *dev_path, char *prom_path, size_t len) i = len - opp->oprom_size; if (i < 0) { bcopy(opp->oprom_array, prom_path, len); - prom_path[len - 1] = NULL; + prom_path[len - 1] = '\0'; return (len); } else { bcopy(opp->oprom_array, prom_path, len); diff --git a/usr/src/lib/libdevinfo/devinfo.c b/usr/src/lib/libdevinfo/devinfo.c index 678f891c90..476c9a2e43 100644 --- a/usr/src/lib/libdevinfo/devinfo.c +++ b/usr/src/lib/libdevinfo/devinfo.c @@ -147,7 +147,7 @@ di_init_driver(const char *drv_name, uint_t flag) di_node_t di_init_impl(const char *phys_path, uint_t flag, - struct di_priv_data *priv) + struct di_priv_data *priv) { caddr_t pa; int fd, map_size; @@ -467,7 +467,7 @@ di_drv_next_node(di_node_t node) pa = (caddr_t)node - DI_NODE(node)->self; - if (DI_NODE(node)->next == NULL) { + if (DI_NODE(node)->next == 0) { errno = ENXIO; return (DI_NODE_NIL); } @@ -770,7 +770,7 @@ update_node_list(int action, uint_t flag, struct node_list **headp) */ static void walk_one_node(struct node_list **headp, uint_t flag, void *arg, - int (*callback)(di_node_t, void *)) + int (*callback)(di_node_t, void *)) { DPRINTF((DI_TRACE, "Walking node %s\n", di_node_name((*headp)->node))); @@ -780,7 +780,7 @@ walk_one_node(struct node_list **headp, uint_t flag, void *arg, int di_walk_node(di_node_t root, uint_t flag, void *arg, - int (*node_callback)(di_node_t, void *)) + int (*node_callback)(di_node_t, void *)) { struct node_list *head; /* node_list for tree walk */ @@ -816,7 +816,7 @@ di_walk_node(di_node_t root, uint_t flag, void *arg, */ static void walk_one_minor_list(struct node_list **headp, const char *desired_type, - uint_t flag, void *arg, int (*callback)(di_node_t, di_minor_t, void *)) + uint_t flag, void *arg, int (*callback)(di_node_t, di_minor_t, void *)) { int ddm_type; int action = DI_WALK_CONTINUE; @@ -851,7 +851,7 @@ walk_one_minor_list(struct node_list **headp, const char *desired_type, int di_walk_minor(di_node_t root, const char *minor_type, uint_t flag, void *arg, - int (*minor_callback)(di_node_t, di_minor_t, void *)) + int (*minor_callback)(di_node_t, di_minor_t, void *)) { struct node_list *head; /* node_list for tree walk */ @@ -1709,7 +1709,7 @@ di_prop_find(dev_t match_dev, di_node_t node, const char *name) int di_prop_lookup_ints(dev_t dev, di_node_t node, const char *prop_name, - int **prop_data) + int **prop_data) { di_prop_t prop; @@ -1722,7 +1722,7 @@ di_prop_lookup_ints(dev_t dev, di_node_t node, const char *prop_name, int di_prop_lookup_int64(dev_t dev, di_node_t node, const char *prop_name, - int64_t **prop_data) + int64_t **prop_data) { di_prop_t prop; @@ -1748,7 +1748,7 @@ di_prop_lookup_strings(dev_t dev, di_node_t node, const char *prop_name, int di_prop_lookup_bytes(dev_t dev, di_node_t node, const char *prop_name, - uchar_t **prop_data) + uchar_t **prop_data) { di_prop_t prop; @@ -2376,7 +2376,7 @@ di_vhci_first_node(di_node_t root) pa = (caddr_t)root - DI_NODE(root)->self; dap = DI_ALL(pa); - if (dap->top_vhci_devinfo == NULL) { + if (dap->top_vhci_devinfo == 0) { errno = ENXIO; return (DI_NODE_NIL); } @@ -2397,7 +2397,7 @@ di_vhci_next_node(di_node_t node) DPRINTF((DI_TRACE, "next vhci node on the snap shot:" " current=%s\n", di_node_name(node))); - if (DI_NODE(node)->next_vhci == NULL) { + if (DI_NODE(node)->next_vhci == 0) { errno = ENXIO; return (DI_NODE_NIL); } @@ -2425,7 +2425,7 @@ di_phci_first_node(di_node_t vhci_node) pa = (caddr_t)vhci_node - DI_NODE(vhci_node)->self; - if (DI_NODE(vhci_node)->top_phci == NULL) { + if (DI_NODE(vhci_node)->top_phci == 0) { errno = ENXIO; return (DI_NODE_NIL); } @@ -2446,7 +2446,7 @@ di_phci_next_node(di_node_t node) DPRINTF((DI_TRACE, "next phci node on the snap shot:" " current=%s\n", di_node_name(node))); - if (DI_NODE(node)->next_phci == NULL) { + if (DI_NODE(node)->next_phci == 0) { errno = ENXIO; return (DI_NODE_NIL); } @@ -2535,7 +2535,7 @@ typedef struct { static int di_walk_hp_callback(di_node_t node, void *argp) { - di_walk_hp_arg_t *arg = (di_walk_hp_arg_t *)argp; + di_walk_hp_arg_t *arg = (di_walk_hp_arg_t *)argp; di_hp_t hp; char *type_str; @@ -2890,7 +2890,7 @@ di_prom_fini(di_prom_handle_t ph) */ static di_prom_prop_t di_prom_prop_found(di_prom_handle_t ph, int nodeid, - di_prom_prop_t prom_prop) + di_prom_prop_t prom_prop) { struct di_prom_handle *p = (struct di_prom_handle *)ph; struct openpromio *opp = &p->oppbuf.opp; @@ -3028,7 +3028,7 @@ di_prom_prop_data(di_prom_prop_t prom_prop, uchar_t **prom_prop_data) */ if (prom_prop == DI_PROM_PROP_NIL) { errno = EINVAL; - return (NULL); + return (0); } *prom_prop_data = ((struct di_prom_prop *)prom_prop)->data; @@ -3042,7 +3042,7 @@ di_prom_prop_data(di_prom_prop_t prom_prop, uchar_t **prom_prop_data) */ static struct di_prom_prop * di_prom_prop_lookup_common(di_prom_handle_t ph, di_node_t node, - const char *prom_prop_name) + const char *prom_prop_name) { struct openpromio *opp; struct di_prom_prop *prop; @@ -3142,7 +3142,7 @@ di_prom_prop_lookup_common(di_prom_handle_t ph, di_node_t node, int di_prom_prop_lookup_ints(di_prom_handle_t ph, di_node_t node, - const char *prom_prop_name, int **prom_prop_data) + const char *prom_prop_name, int **prom_prop_data) { int len; struct di_prom_prop *prop; @@ -3168,7 +3168,7 @@ di_prom_prop_lookup_ints(di_prom_handle_t ph, di_node_t node, int di_prom_prop_lookup_strings(di_prom_handle_t ph, di_node_t node, - const char *prom_prop_name, char **prom_prop_data) + const char *prom_prop_name, char **prom_prop_data) { int len; struct di_prom_prop *prop; @@ -3211,7 +3211,7 @@ di_prom_prop_lookup_strings(di_prom_handle_t ph, di_node_t node, int di_prom_prop_lookup_bytes(di_prom_handle_t ph, di_node_t node, - const char *prom_prop_name, uchar_t **prom_prop_data) + const char *prom_prop_name, uchar_t **prom_prop_data) { int len; struct di_prom_prop *prop; @@ -3460,11 +3460,11 @@ di_lnode_next(di_node_t node, di_lnode_t lnode) di_all = DI_ALL((caddr_t)node - DI_NODE(node)->self); if (lnode == DI_NODE_NIL) { - if (DI_NODE(node)->lnodes != NULL) + if (DI_NODE(node)->lnodes != 0) return (DI_LNODE((caddr_t)di_all + DI_NODE(node)->lnodes)); } else { - if (DI_LNODE(lnode)->node_next != NULL) + if (DI_LNODE(lnode)->node_next != 0) return (DI_LNODE((caddr_t)di_all + DI_LNODE(lnode)->node_next)); } @@ -3495,21 +3495,21 @@ di_link_next_by_node(di_node_t node, di_link_t link, uint_t endpoint) if (endpoint == DI_LINK_SRC) { if (link == DI_LINK_NIL) { - if (DI_NODE(node)->src_links != NULL) + if (DI_NODE(node)->src_links != 0) return (DI_LINK((caddr_t)di_all + DI_NODE(node)->src_links)); } else { - if (DI_LINK(link)->src_node_next != NULL) + if (DI_LINK(link)->src_node_next != 0) return (DI_LINK((caddr_t)di_all + DI_LINK(link)->src_node_next)); } } else { if (link == DI_LINK_NIL) { - if (DI_NODE(node)->tgt_links != NULL) + if (DI_NODE(node)->tgt_links != 0) return (DI_LINK((caddr_t)di_all + DI_NODE(node)->tgt_links)); } else { - if (DI_LINK(link)->tgt_node_next != NULL) + if (DI_LINK(link)->tgt_node_next != 0) return (DI_LINK((caddr_t)di_all + DI_LINK(link)->tgt_node_next)); } @@ -3541,24 +3541,24 @@ di_link_next_by_lnode(di_lnode_t lnode, di_link_t link, uint_t endpoint) if (endpoint == DI_LINK_SRC) { if (link == DI_LINK_NIL) { - if (DI_LNODE(lnode)->link_out == NULL) + if (DI_LNODE(lnode)->link_out == 0) return (DI_LINK_NIL); return (DI_LINK((caddr_t)di_all + DI_LNODE(lnode)->link_out)); } else { - if (DI_LINK(link)->src_link_next == NULL) + if (DI_LINK(link)->src_link_next == 0) return (DI_LINK_NIL); return (DI_LINK((caddr_t)di_all + DI_LINK(link)->src_link_next)); } } else { if (link == DI_LINK_NIL) { - if (DI_LNODE(lnode)->link_in == NULL) + if (DI_LNODE(lnode)->link_in == 0) return (DI_LINK_NIL); return (DI_LINK((caddr_t)di_all + DI_LNODE(lnode)->link_in)); } else { - if (DI_LINK(link)->tgt_link_next == NULL) + if (DI_LINK(link)->tgt_link_next == 0) return (DI_LINK_NIL); return (DI_LINK((caddr_t)di_all + DI_LINK(link)->tgt_link_next)); diff --git a/usr/src/lib/libdevinfo/devinfo_devperm.c b/usr/src/lib/libdevinfo/devinfo_devperm.c index b335150f97..b2eb13f502 100644 --- a/usr/src/lib/libdevinfo/devinfo_devperm.c +++ b/usr/src/lib/libdevinfo/devinfo_devperm.c @@ -676,7 +676,7 @@ getnexttoken(char *next, char **nextp, char **tokenpp, char *tchar) ; if (*cp1 == '=' || *cp1 == ':' || *cp1 == '&' || *cp1 == '|' || *cp1 == ';' || *cp1 == '\n' || *cp1 == '\0') { - *cp = NULL; /* terminate token */ + *cp = '\0'; /* terminate token */ cp = cp1; } } @@ -959,7 +959,7 @@ devfs_read_minor_perm(void (*errcb)(minorperm_err_t, int)) static struct mperm * i_devfs_read_minor_perm_by_driver(char *drvname, - void (*errcb)(minorperm_err_t mp_err, int key)) + void (*errcb)(minorperm_err_t mp_err, int key)) { return (i_devfs_read_minor_perm(drvname, errcb)); } @@ -1010,7 +1010,7 @@ i_devfs_add_perm_entry(nvlist_t *nvl, struct mperm *mp) static nvlist_t * i_devfs_minor_perm_nvlist(struct mperm *mplist, - void (*errcb)(minorperm_err_t, int)) + void (*errcb)(minorperm_err_t, int)) { int err; struct mperm *mp; @@ -1037,8 +1037,7 @@ i_devfs_minor_perm_nvlist(struct mperm *mplist, * Done at boot time via devfsadm */ int -devfs_load_minor_perm(struct mperm *mplist, - void (*errcb)(minorperm_err_t, int)) +devfs_load_minor_perm(struct mperm *mplist, void (*errcb)(minorperm_err_t, int)) { int err; char *buf = NULL; @@ -1066,7 +1065,7 @@ devfs_load_minor_perm(struct mperm *mplist, */ static int i_devfs_update_minor_perm(char *drv, int ctl, - void (*errcb)(minorperm_err_t, int)) + void (*errcb)(minorperm_err_t, int)) { int err; char *buf; @@ -1095,15 +1094,13 @@ i_devfs_update_minor_perm(char *drv, int ctl, } int -devfs_add_minor_perm(char *drv, - void (*errcb)(minorperm_err_t, int)) +devfs_add_minor_perm(char *drv, void (*errcb)(minorperm_err_t, int)) { return (i_devfs_update_minor_perm(drv, MODADDMINORPERM, errcb)); } int -devfs_rm_minor_perm(char *drv, - void (*errcb)(minorperm_err_t, int)) +devfs_rm_minor_perm(char *drv, void (*errcb)(minorperm_err_t, int)) { return (i_devfs_update_minor_perm(drv, MODREMMINORPERM, errcb)); } |