Hi, Tiwei, On 04/04, Tiwei Bie wrote: [snip] >> @@ -515,7 +515,7 @@ rte_vhost_get_ifname(int vid, char *buf, size_t len) >> { >> struct virtio_net *dev = get_device(vid); >> >> - if (dev == NULL) >> + if (dev == NULL || !buf) > >It would be better to do the check in this way: (!dev || !buf) >for consistency. >
According to DPDK coding conventions 1.8.1 on NULL pointers [1], shouldn't it be if (dev == NULL || buf == NULL)? [1] https://doc.dpdk.org/guides/contributing/coding_style.html#null-pointers Thanks, Xiaolong >Thanks for the work! >Tiwei > > >> return -1; >> >> len = RTE_MIN(len, sizeof(dev->ifname)); >> @@ -532,7 +532,7 @@ rte_vhost_get_negotiated_features(int vid, uint64_t >> *features) >> struct virtio_net *dev; >> >> dev = get_device(vid); >> - if (!dev) >> + if (!dev || !features) >> return -1; >> >> *features = dev->features; >> @@ -547,7 +547,7 @@ rte_vhost_get_mem_table(int vid, struct rte_vhost_memory >> **mem) >> size_t size; >> >> dev = get_device(vid); >> - if (!dev) >> + if (!dev || !mem) >> return -1; >> >> size = dev->mem->nregions * sizeof(struct rte_vhost_mem_region); >> @@ -570,7 +570,7 @@ rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, >> struct vhost_virtqueue *vq; >> >> dev = get_device(vid); >> - if (!dev) >> + if (!dev || !vring) >> return -1; >> >> if (vring_idx >= VHOST_MAX_VRING) >> @@ -763,7 +763,7 @@ int rte_vhost_get_log_base(int vid, uint64_t *log_base, >> { >> struct virtio_net *dev = get_device(vid); >> >> - if (!dev) >> + if (!dev || !log_base || !log_size) >> return -1; >> >> *log_base = dev->log_base; >> @@ -777,7 +777,7 @@ int rte_vhost_get_vring_base(int vid, uint16_t queue_id, >> { >> struct virtio_net *dev = get_device(vid); >> >> - if (!dev) >> + if (!dev || !last_avail_idx || !last_used_idx) >> return -1; >> >> *last_avail_idx = dev->virtqueue[queue_id]->last_avail_idx; >> @@ -805,7 +805,7 @@ int rte_vhost_extern_callback_register(int vid, >> { >> struct virtio_net *dev = get_device(vid); >> >> - if (!dev) >> + if (!dev || !ops) >> return -1; >> >> dev->extern_ops = *ops; >> -- >> 2.17.1 >>