mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 11:29:36 +03:00
Update for cppcheck v1.80
Resolve new warnings and errors from cppcheck v1.80. * [lib/libshare/libshare.c:543]: (warning) Possible null pointer dereference: protocol * [lib/libzfs/libzfs_dataset.c:2323]: (warning) Possible null pointer dereference: srctype * [lib/libzfs/libzfs_import.c:318]: (error) Uninitialized variable: link * [module/zfs/abd.c:353]: (error) Uninitialized variable: sg * [module/zfs/abd.c:353]: (error) Uninitialized variable: i * [module/zfs/abd.c:385]: (error) Uninitialized variable: sg * [module/zfs/abd.c:385]: (error) Uninitialized variable: i * [module/zfs/abd.c:553]: (error) Uninitialized variable: i * [module/zfs/abd.c:553]: (error) Uninitialized variable: sg * [module/zfs/abd.c:763]: (error) Uninitialized variable: i * [module/zfs/abd.c:763]: (error) Uninitialized variable: sg * [module/zfs/abd.c:305]: (error) Uninitialized variable: tmp_page * [module/zfs/zpl_xattr.c:342]: (warning) Possible null pointer dereference: value * [module/zfs/zvol.c:208]: (error) Uninitialized variable: p Convert the following suppression to inline. * [module/zfs/zfs_vnops.c:840]: (error) Possible null pointer dereference: aiov Exclude HAVE_UIO_ZEROCOPY and HAVE_DNLC from analysis since these macro's will never be defined until this functionality is implemented. Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #6879
This commit is contained in:
parent
7a8bef3983
commit
aebc5df418
1
.github/suppressions.txt
vendored
1
.github/suppressions.txt
vendored
@ -1,4 +1,3 @@
|
|||||||
nullPointer:./module/zfs/zfs_vnops.c:839
|
|
||||||
preprocessorErrorDirective:./module/zfs/vdev_raidz_math_avx512f.c:243
|
preprocessorErrorDirective:./module/zfs/vdev_raidz_math_avx512f.c:243
|
||||||
preprocessorErrorDirective:./module/zfs/vdev_raidz_math_sse2.c:266
|
preprocessorErrorDirective:./module/zfs/vdev_raidz_math_sse2.c:266
|
||||||
|
|
||||||
|
@ -65,10 +65,10 @@ lint: cppcheck paxcheck
|
|||||||
|
|
||||||
cppcheck:
|
cppcheck:
|
||||||
@if type cppcheck > /dev/null 2>&1; then \
|
@if type cppcheck > /dev/null 2>&1; then \
|
||||||
cppcheck --quiet --force --error-exitcode=2 \
|
cppcheck --quiet --force --error-exitcode=2 --inline-suppr \
|
||||||
--suppressions-list=.github/suppressions.txt \
|
--suppressions-list=.github/suppressions.txt \
|
||||||
-UHAVE_SSE2 -UHAVE_AVX512F \
|
-UHAVE_SSE2 -UHAVE_AVX512F -UHAVE_UIO_ZEROCOPY \
|
||||||
${top_srcdir}; \
|
-UHAVE_DNLC ${top_srcdir}; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
paxcheck:
|
paxcheck:
|
||||||
|
@ -493,20 +493,10 @@ int
|
|||||||
sa_enable_share(sa_share_t share, char *protocol)
|
sa_enable_share(sa_share_t share, char *protocol)
|
||||||
{
|
{
|
||||||
sa_share_impl_t impl_share = (sa_share_impl_t)share;
|
sa_share_impl_t impl_share = (sa_share_impl_t)share;
|
||||||
int rc, ret;
|
int rc, ret = SA_OK;
|
||||||
boolean_t found_protocol;
|
boolean_t found_protocol = B_FALSE;
|
||||||
sa_fstype_t *fstype;
|
sa_fstype_t *fstype;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "sa_enable_share: share->sharepath=%s, protocol=%s\n",
|
|
||||||
impl_share->sharepath, protocol);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(impl_share->handle != NULL);
|
|
||||||
|
|
||||||
ret = SA_OK;
|
|
||||||
found_protocol = B_FALSE;
|
|
||||||
|
|
||||||
fstype = fstypes;
|
fstype = fstypes;
|
||||||
while (fstype != NULL) {
|
while (fstype != NULL) {
|
||||||
if (protocol == NULL || strcmp(fstype->name, protocol) == 0) {
|
if (protocol == NULL || strcmp(fstype->name, protocol) == 0) {
|
||||||
@ -534,18 +524,10 @@ int
|
|||||||
sa_disable_share(sa_share_t share, char *protocol)
|
sa_disable_share(sa_share_t share, char *protocol)
|
||||||
{
|
{
|
||||||
sa_share_impl_t impl_share = (sa_share_impl_t)share;
|
sa_share_impl_t impl_share = (sa_share_impl_t)share;
|
||||||
int rc, ret;
|
int rc, ret = SA_OK;
|
||||||
boolean_t found_protocol;
|
boolean_t found_protocol = B_FALSE;
|
||||||
sa_fstype_t *fstype;
|
sa_fstype_t *fstype;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "sa_disable_share: share->sharepath=%s, protocol=%s\n",
|
|
||||||
impl_share->sharepath, protocol);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = SA_OK;
|
|
||||||
found_protocol = B_FALSE;
|
|
||||||
|
|
||||||
fstype = fstypes;
|
fstype = fstypes;
|
||||||
while (fstype != NULL) {
|
while (fstype != NULL) {
|
||||||
if (protocol == NULL || strcmp(fstype->name, protocol) == 0) {
|
if (protocol == NULL || strcmp(fstype->name, protocol) == 0) {
|
||||||
@ -696,11 +678,6 @@ sa_parse_legacy_options(sa_group_t group, char *options, char *proto)
|
|||||||
{
|
{
|
||||||
sa_fstype_t *fstype;
|
sa_fstype_t *fstype;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "sa_parse_legacy_options: options=%s, proto=%s\n",
|
|
||||||
options, proto);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fstype = fstypes;
|
fstype = fstypes;
|
||||||
while (fstype != NULL) {
|
while (fstype != NULL) {
|
||||||
if (strcmp(fstype->name, proto) != 0) {
|
if (strcmp(fstype->name, proto) != 0) {
|
||||||
@ -787,12 +764,6 @@ sa_zfs_process_share(sa_handle_t handle, sa_group_t group, sa_share_t share,
|
|||||||
sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
|
sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
|
||||||
sa_share_impl_t impl_share = (sa_share_impl_t)share;
|
sa_share_impl_t impl_share = (sa_share_impl_t)share;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "sa_zfs_process_share: mountpoint=%s, proto=%s, "
|
|
||||||
"shareopts=%s, sourcestr=%s, dataset=%s\n", mountpoint, proto,
|
|
||||||
shareopts, sourcestr, dataset);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (process_share(impl_handle, impl_share, mountpoint, NULL,
|
return (process_share(impl_handle, impl_share, mountpoint, NULL,
|
||||||
proto, shareopts, NULL, dataset, B_FALSE));
|
proto, shareopts, NULL, dataset, B_FALSE));
|
||||||
}
|
}
|
||||||
|
@ -2244,8 +2244,10 @@ static void
|
|||||||
get_source(zfs_handle_t *zhp, zprop_source_t *srctype, char *source,
|
get_source(zfs_handle_t *zhp, zprop_source_t *srctype, char *source,
|
||||||
char *statbuf, size_t statlen)
|
char *statbuf, size_t statlen)
|
||||||
{
|
{
|
||||||
if (statbuf == NULL || *srctype == ZPROP_SRC_TEMPORARY)
|
if (statbuf == NULL ||
|
||||||
|
srctype == NULL || *srctype == ZPROP_SRC_TEMPORARY) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
*srctype = ZPROP_SRC_NONE;
|
*srctype = ZPROP_SRC_NONE;
|
||||||
|
@ -309,7 +309,7 @@ zpool_label_disk_wait(char *path, int timeout_ms)
|
|||||||
dev = udev_device_new_from_subsystem_sysname(udev,
|
dev = udev_device_new_from_subsystem_sysname(udev,
|
||||||
"block", sysname);
|
"block", sysname);
|
||||||
if ((dev != NULL) && udev_device_is_ready(dev)) {
|
if ((dev != NULL) && udev_device_is_ready(dev)) {
|
||||||
struct udev_list_entry *links, *link;
|
struct udev_list_entry *links, *link = NULL;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
links = udev_device_get_devlinks_list_entry(dev);
|
links = udev_device_get_devlinks_list_entry(dev);
|
||||||
|
@ -250,7 +250,7 @@ abd_alloc_pages(abd_t *abd, size_t size)
|
|||||||
struct list_head pages;
|
struct list_head pages;
|
||||||
struct sg_table table;
|
struct sg_table table;
|
||||||
struct scatterlist *sg;
|
struct scatterlist *sg;
|
||||||
struct page *page, *tmp_page;
|
struct page *page, *tmp_page = NULL;
|
||||||
gfp_t gfp = __GFP_NOWARN | GFP_NOIO;
|
gfp_t gfp = __GFP_NOWARN | GFP_NOIO;
|
||||||
gfp_t gfp_comp = (gfp | __GFP_NORETRY | __GFP_COMP) & ~__GFP_RECLAIM;
|
gfp_t gfp_comp = (gfp | __GFP_NORETRY | __GFP_COMP) & ~__GFP_RECLAIM;
|
||||||
int max_order = MIN(zfs_abd_scatter_max_order, MAX_ORDER - 1);
|
int max_order = MIN(zfs_abd_scatter_max_order, MAX_ORDER - 1);
|
||||||
@ -334,12 +334,12 @@ abd_alloc_pages(abd_t *abd, size_t size)
|
|||||||
static void
|
static void
|
||||||
abd_alloc_pages(abd_t *abd, size_t size)
|
abd_alloc_pages(abd_t *abd, size_t size)
|
||||||
{
|
{
|
||||||
struct scatterlist *sg;
|
struct scatterlist *sg = NULL;
|
||||||
struct sg_table table;
|
struct sg_table table;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
gfp_t gfp = __GFP_NOWARN | GFP_NOIO;
|
gfp_t gfp = __GFP_NOWARN | GFP_NOIO;
|
||||||
int nr_pages = abd_chunkcnt_for_bytes(size);
|
int nr_pages = abd_chunkcnt_for_bytes(size);
|
||||||
int i;
|
int i = 0;
|
||||||
|
|
||||||
while (sg_alloc_table(&table, nr_pages, gfp)) {
|
while (sg_alloc_table(&table, nr_pages, gfp)) {
|
||||||
ABDSTAT_BUMP(abdstat_scatter_sg_table_retry);
|
ABDSTAT_BUMP(abdstat_scatter_sg_table_retry);
|
||||||
@ -370,11 +370,11 @@ abd_alloc_pages(abd_t *abd, size_t size)
|
|||||||
static void
|
static void
|
||||||
abd_free_pages(abd_t *abd)
|
abd_free_pages(abd_t *abd)
|
||||||
{
|
{
|
||||||
struct scatterlist *sg;
|
struct scatterlist *sg = NULL;
|
||||||
struct sg_table table;
|
struct sg_table table;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
int nr_pages = ABD_SCATTER(abd).abd_nents;
|
int nr_pages = ABD_SCATTER(abd).abd_nents;
|
||||||
int order, i;
|
int order, i = 0;
|
||||||
|
|
||||||
if (abd->abd_flags & ABD_FLAG_MULTI_ZONE)
|
if (abd->abd_flags & ABD_FLAG_MULTI_ZONE)
|
||||||
ABDSTAT_BUMPDOWN(abdstat_scatter_page_multi_zone);
|
ABDSTAT_BUMPDOWN(abdstat_scatter_page_multi_zone);
|
||||||
@ -543,8 +543,8 @@ abd_verify(abd_t *abd)
|
|||||||
ASSERT3P(abd->abd_u.abd_linear.abd_buf, !=, NULL);
|
ASSERT3P(abd->abd_u.abd_linear.abd_buf, !=, NULL);
|
||||||
} else {
|
} else {
|
||||||
size_t n;
|
size_t n;
|
||||||
int i;
|
int i = 0;
|
||||||
struct scatterlist *sg;
|
struct scatterlist *sg = NULL;
|
||||||
|
|
||||||
ASSERT3U(ABD_SCATTER(abd).abd_nents, >, 0);
|
ASSERT3U(ABD_SCATTER(abd).abd_nents, >, 0);
|
||||||
ASSERT3U(ABD_SCATTER(abd).abd_offset, <,
|
ASSERT3U(ABD_SCATTER(abd).abd_offset, <,
|
||||||
@ -749,8 +749,8 @@ abd_get_offset_impl(abd_t *sabd, size_t off, size_t size)
|
|||||||
abd->abd_u.abd_linear.abd_buf =
|
abd->abd_u.abd_linear.abd_buf =
|
||||||
(char *)sabd->abd_u.abd_linear.abd_buf + off;
|
(char *)sabd->abd_u.abd_linear.abd_buf + off;
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i = 0;
|
||||||
struct scatterlist *sg;
|
struct scatterlist *sg = NULL;
|
||||||
size_t new_offset = sabd->abd_u.abd_scatter.abd_offset + off;
|
size_t new_offset = sabd->abd_u.abd_scatter.abd_offset + off;
|
||||||
|
|
||||||
abd = abd_alloc_struct();
|
abd = abd_alloc_struct();
|
||||||
|
@ -836,6 +836,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
|
|||||||
aiov->iov_base != abuf->b_data)) {
|
aiov->iov_base != abuf->b_data)) {
|
||||||
ASSERT(xuio);
|
ASSERT(xuio);
|
||||||
dmu_write(zfsvfs->z_os, zp->z_id, woff,
|
dmu_write(zfsvfs->z_os, zp->z_id, woff,
|
||||||
|
/* cppcheck-suppress nullPointer */
|
||||||
aiov->iov_len, aiov->iov_base, tx);
|
aiov->iov_len, aiov->iov_base, tx);
|
||||||
dmu_return_arcbuf(abuf);
|
dmu_return_arcbuf(abuf);
|
||||||
xuio_stat_wbuf_copied();
|
xuio_stat_wbuf_copied();
|
||||||
|
@ -333,7 +333,7 @@ zpl_xattr_get_sa(struct inode *ip, const char *name, void *value, size_t size)
|
|||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
if (!size)
|
if (size == 0 || value == NULL)
|
||||||
return (nv_size);
|
return (nv_size);
|
||||||
|
|
||||||
if (size < nv_size)
|
if (size < nv_size)
|
||||||
|
@ -202,7 +202,7 @@ static zvol_state_t *
|
|||||||
zvol_find_by_name_hash(const char *name, uint64_t hash, int mode)
|
zvol_find_by_name_hash(const char *name, uint64_t hash, int mode)
|
||||||
{
|
{
|
||||||
zvol_state_t *zv;
|
zvol_state_t *zv;
|
||||||
struct hlist_node *p;
|
struct hlist_node *p = NULL;
|
||||||
|
|
||||||
mutex_enter(&zvol_state_lock);
|
mutex_enter(&zvol_state_lock);
|
||||||
hlist_for_each(p, ZVOL_HT_HEAD(hash)) {
|
hlist_for_each(p, ZVOL_HT_HEAD(hash)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user