diff options
author | Avra Sengupta <asengupt@redhat.com> | 2012-11-21 14:07:05 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-01-21 22:17:36 -0800 |
commit | 777d395feaa082a69e32d985bbc1cca3d3dad077 (patch) | |
tree | 0aa6c1a1390320bd8ac674e14ca1c3da58c39927 | |
parent | 6e18e3bd81f8dac9467aaa6cbe84499b891ca367 (diff) |
core: fixes for gcc's '-pedantic' flag build
* warnings on 'void *' arguments
* warnings on empty initializations
* warnings on empty array (array[0])
Change-Id: Iae440f54cbd59580eb69f3ecaed5a9926c0edf95
BUG: 875913
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/4219
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
27 files changed, 85 insertions, 98 deletions
diff --git a/api/src/glfs-master.c b/api/src/glfs-master.c index 0806c3077..e6c46e361 100644 --- a/api/src/glfs-master.c +++ b/api/src/glfs-master.c @@ -101,13 +101,10 @@ fini (xlator_t *this) } -struct xlator_dumpops dumpops = { -}; +struct xlator_dumpops dumpops; -struct xlator_fops fops = { -}; +struct xlator_fops fops; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; diff --git a/contrib/fuse-include/fuse_kernel.h b/contrib/fuse-include/fuse_kernel.h index 9ae25d6f9..e6fdcf809 100644 --- a/contrib/fuse-include/fuse_kernel.h +++ b/contrib/fuse-include/fuse_kernel.h @@ -556,7 +556,7 @@ struct fuse_dirent { __u64 off; __u32 namelen; __u32 type; - char name[0]; + char name[]; }; #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) diff --git a/contrib/libgen/basename_r.c b/contrib/libgen/basename_r.c index d63bce4e5..2c3a87afe 100644 --- a/contrib/libgen/basename_r.c +++ b/contrib/libgen/basename_r.c @@ -1,10 +1,10 @@ -#ifdef THREAD_UNSAFE_BASENAME /* - * borrowed from glibc-2.12.1/string/basename.c + * borrowed from glibc-2.12.1/string/basename.c * Modified to return "." for NULL or "", as required for SUSv2. */ #include <string.h> #include <stdlib.h> +#ifdef THREAD_UNSAFE_BASENAME /* Return the name-within-directory of a file name. Copyright (C) 1996,97,98,2002 Free Software Foundation, Inc. diff --git a/contrib/libgen/dirname_r.c b/contrib/libgen/dirname_r.c index 02981f5ec..131cbcf2a 100644 --- a/contrib/libgen/dirname_r.c +++ b/contrib/libgen/dirname_r.c @@ -1,4 +1,3 @@ -#ifdef THREAD_UNSAFE_DIRNAME /* * Borrowed from glibc-2.12.1/string/memrchr.c * Based on strlen implementation by Torbjorn Granlund (tege@sics.se), @@ -7,6 +6,7 @@ */ #include <string.h> #include <stdlib.h> +#ifdef THREAD_UNSAFE_DIRNAME /* memrchr -- find the last occurrence of a byte in a memory block Copyright (C) 1991, 93, 96, 97, 99, 2000 Free Software Foundation, Inc. diff --git a/libglusterfs/src/gf-dirent.h b/libglusterfs/src/gf-dirent.h index 26cb5a668..588d522db 100644 --- a/libglusterfs/src/gf-dirent.h +++ b/libglusterfs/src/gf-dirent.h @@ -45,7 +45,7 @@ struct _gf_dirent_t { struct iatt d_stat; dict_t *dict; inode_t *inode; - char d_name[0]; + char d_name[]; }; #define DT_ISDIR(mode) (mode == DT_DIR) diff --git a/libglusterfs/src/latency.c b/libglusterfs/src/latency.c index f143a8e46..9fe76efa0 100644 --- a/libglusterfs/src/latency.c +++ b/libglusterfs/src/latency.c @@ -26,87 +26,87 @@ gf_set_fop_from_fn_pointer (call_frame_t *frame, struct xlator_fops *fops, void { glusterfs_fop_t fop = -1; - if (fops->stat == fn) + if (fops->stat == *(fop_stat_t *)fn) fop = GF_FOP_STAT; - else if (fops->readlink == fn) + else if (fops->readlink == *(fop_readlink_t *)fn) fop = GF_FOP_READLINK; - else if (fops->mknod == fn) + else if (fops->mknod == *(fop_mknod_t *)fn) fop = GF_FOP_MKNOD; - else if (fops->mkdir == fn) + else if (fops->mkdir == *(fop_mkdir_t *)fn) fop = GF_FOP_MKDIR; - else if (fops->unlink == fn) + else if (fops->unlink == *(fop_unlink_t *)fn) fop = GF_FOP_UNLINK; - else if (fops->rmdir == fn) + else if (fops->rmdir == *(fop_rmdir_t *)fn) fop = GF_FOP_RMDIR; - else if (fops->symlink == fn) + else if (fops->symlink == *(fop_symlink_t *)fn) fop = GF_FOP_SYMLINK; - else if (fops->rename == fn) + else if (fops->rename == *(fop_rename_t *)fn) fop = GF_FOP_RENAME; - else if (fops->link == fn) + else if (fops->link == *(fop_link_t *)fn) fop = GF_FOP_LINK; - else if (fops->truncate == fn) + else if (fops->truncate == *(fop_truncate_t *)fn) fop = GF_FOP_TRUNCATE; - else if (fops->open == fn) + else if (fops->open == *(fop_open_t *)fn) fop = GF_FOP_OPEN; - else if (fops->readv == fn) + else if (fops->readv == *(fop_readv_t *)fn) fop = GF_FOP_READ; - else if (fops->writev == fn) + else if (fops->writev == *(fop_writev_t *)fn) fop = GF_FOP_WRITE; - else if (fops->statfs == fn) + else if (fops->statfs == *(fop_statfs_t *)fn) fop = GF_FOP_STATFS; - else if (fops->flush == fn) + else if (fops->flush == *(fop_flush_t *)fn) fop = GF_FOP_FLUSH; - else if (fops->fsync == fn) + else if (fops->fsync == *(fop_fsync_t *)fn) fop = GF_FOP_FSYNC; - else if (fops->setxattr == fn) + else if (fops->setxattr == *(fop_setxattr_t *)fn) fop = GF_FOP_SETXATTR; - else if (fops->getxattr == fn) + else if (fops->getxattr == *(fop_getxattr_t *)fn) fop = GF_FOP_GETXATTR; - else if (fops->removexattr == fn) + else if (fops->removexattr == *(fop_removexattr_t *)fn) fop = GF_FOP_REMOVEXATTR; - else if (fops->opendir == fn) + else if (fops->opendir == *(fop_opendir_t *)fn) fop = GF_FOP_OPENDIR; - else if (fops->fsyncdir == fn) + else if (fops->fsyncdir == *(fop_fsyncdir_t *)fn) fop = GF_FOP_FSYNCDIR; - else if (fops->access == fn) + else if (fops->access == *(fop_access_t *)fn) fop = GF_FOP_ACCESS; - else if (fops->create == fn) + else if (fops->create == *(fop_create_t *)fn) fop = GF_FOP_CREATE; - else if (fops->ftruncate == fn) + else if (fops->ftruncate == *(fop_ftruncate_t *)fn) fop = GF_FOP_FTRUNCATE; - else if (fops->fstat == fn) + else if (fops->fstat == *(fop_fstat_t *)fn) fop = GF_FOP_FSTAT; - else if (fops->lk == fn) + else if (fops->lk == *(fop_lk_t *)fn) fop = GF_FOP_LK; - else if (fops->lookup == fn) + else if (fops->lookup == *(fop_lookup_t *)fn) fop = GF_FOP_LOOKUP; - else if (fops->readdir == fn) + else if (fops->readdir == *(fop_readdir_t *)fn) fop = GF_FOP_READDIR; - else if (fops->inodelk == fn) + else if (fops->inodelk == *(fop_inodelk_t *)fn) fop = GF_FOP_INODELK; - else if (fops->finodelk == fn) + else if (fops->finodelk == *(fop_finodelk_t *)fn) fop = GF_FOP_FINODELK; - else if (fops->entrylk == fn) + else if (fops->entrylk == *(fop_entrylk_t *)fn) fop = GF_FOP_ENTRYLK; - else if (fops->fentrylk == fn) + else if (fops->fentrylk == *(fop_fentrylk_t *)fn) fop = GF_FOP_FENTRYLK; - else if (fops->xattrop == fn) + else if (fops->xattrop == *(fop_xattrop_t *)fn) fop = GF_FOP_XATTROP; - else if (fops->fxattrop == fn) + else if (fops->fxattrop == *(fop_fxattrop_t *)fn) fop = GF_FOP_FXATTROP; - else if (fops->fgetxattr == fn) + else if (fops->fgetxattr == *(fop_fgetxattr_t *)fn) fop = GF_FOP_FGETXATTR; - else if (fops->fsetxattr == fn) + else if (fops->fsetxattr == *(fop_fsetxattr_t *)fn) fop = GF_FOP_FSETXATTR; - else if (fops->rchecksum == fn) + else if (fops->rchecksum == *(fop_rchecksum_t *)fn) fop = GF_FOP_RCHECKSUM; - else if (fops->setattr == fn) + else if (fops->setattr == *(fop_setattr_t *)fn) fop = GF_FOP_SETATTR; - else if (fops->fsetattr == fn) + else if (fops->fsetattr == *(fop_fsetattr_t *)fn) fop = GF_FOP_FSETATTR; - else if (fops->readdirp == fn) + else if (fops->readdirp == *(fop_readdirp_t *)fn) fop = GF_FOP_READDIRP; - else if (fops->getspec == fn) + else if (fops->getspec == *(fop_getspec_t *)fn) fop = GF_FOP_GETSPEC; else fop = -1; diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 471ae1e05..0c807ef5d 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -220,7 +220,7 @@ synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, newtask->ctx.uc_stack.ss_sp = newtask->stack; newtask->ctx.uc_stack.ss_size = env->stacksize; - makecontext (&newtask->ctx, (void *) synctask_wrap, 2, newtask); + makecontext (&newtask->ctx, (void (*)(void)) synctask_wrap, 2, newtask); newtask->state = SYNCTASK_INIT; diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index b42bc3bcc..22c81f81b 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -218,19 +218,19 @@ xlator_dynload (xlator_t *xl) goto out; } - if (!(xl->init = dlsym (handle, "init"))) { + if (!(*VOID(&xl->init) = dlsym (handle, "init"))) { gf_log ("xlator", GF_LOG_WARNING, "dlsym(init) on %s", dlerror ()); goto out; } - if (!(xl->fini = dlsym (handle, "fini"))) { + if (!(*VOID(&(xl->fini)) = dlsym (handle, "fini"))) { gf_log ("xlator", GF_LOG_WARNING, "dlsym(fini) on %s", dlerror ()); goto out; } - if (!(xl->notify = dlsym (handle, "notify"))) { + if (!(*VOID(&(xl->notify)) = dlsym (handle, "notify"))) { gf_log ("xlator", GF_LOG_TRACE, "dlsym(notify) on %s -- neglecting", dlerror ()); } @@ -240,13 +240,13 @@ xlator_dynload (xlator_t *xl) "dlsym(dumpops) on %s -- neglecting", dlerror ()); } - if (!(xl->mem_acct_init = dlsym (handle, "mem_acct_init"))) { + if (!(*VOID(&(xl->mem_acct_init)) = dlsym (handle, "mem_acct_init"))) { gf_log (xl->name, GF_LOG_TRACE, "dlsym(mem_acct_init) on %s -- neglecting", dlerror ()); } - if (!(xl->reconfigure = dlsym (handle, "reconfigure"))) { + if (!(*VOID(&(xl->reconfigure)) = dlsym (handle, "reconfigure"))) { gf_log ("xlator", GF_LOG_TRACE, "dlsym(reconfigure) on %s -- neglecting", dlerror()); diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index a2f78726e..b3f88d2ea 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -444,7 +444,7 @@ rpc_clnt_reconnect (void *trans_ptr) int rpc_clnt_fill_request_info (struct rpc_clnt *clnt, rpc_request_info_t *info) { - struct saved_frame saved_frame = {{}, 0}; + struct saved_frame saved_frame; int ret = -1; pthread_mutex_lock (&clnt->conn.lock); diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index ef80e3358..695261a71 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -266,21 +266,21 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) goto fail; } - trans->init = dlsym (handle, "init"); + *VOID(&(trans->init)) = dlsym (handle, "init"); if (trans->init == NULL) { gf_log ("rpc-transport", GF_LOG_ERROR, "dlsym (gf_rpc_transport_init) on %s", dlerror ()); goto fail; } - trans->fini = dlsym (handle, "fini"); + *VOID(&(trans->fini)) = dlsym (handle, "fini"); if (trans->fini == NULL) { gf_log ("rpc-transport", GF_LOG_ERROR, "dlsym (gf_rpc_transport_fini) on %s", dlerror ()); goto fail; } - trans->reconfigure = dlsym (handle, "reconfigure"); + *VOID(&(trans->reconfigure)) = dlsym (handle, "reconfigure"); if (trans->fini == NULL) { gf_log ("rpc-transport", GF_LOG_DEBUG, "dlsym (gf_rpc_transport_reconfigure) on %s", dlerror()); diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 83ec345d6..764b37ac4 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -53,7 +53,7 @@ struct dht_layout { uint32_t start; uint32_t stop; xlator_t *xlator; - } list[0]; + } list[]; }; typedef struct dht_layout dht_layout_t; diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c index 2194a90ee..6bdb04195 100644 --- a/xlators/debug/error-gen/src/error-gen.c +++ b/xlators/debug/error-gen/src/error-gen.c @@ -2131,8 +2131,7 @@ struct xlator_dumpops dumpops = { .priv = error_gen_priv_dump, }; -struct xlator_fops cbks = { -}; +struct xlator_fops cbks; struct xlator_fops fops = { .lookup = error_gen_lookup, diff --git a/xlators/encryption/rot-13/src/rot-13.c b/xlators/encryption/rot-13/src/rot-13.c index c475e5cb5..b9ac29a72 100644 --- a/xlators/encryption/rot-13/src/rot-13.c +++ b/xlators/encryption/rot-13/src/rot-13.c @@ -186,8 +186,7 @@ struct xlator_fops fops = { .writev = rot13_writev }; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; struct volume_options options[] = { { .key = {"encrypt-write"}, diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index d061c4103..3245076ec 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -1183,8 +1183,7 @@ struct xlator_fops fops = { .unlink = index_unlink }; -struct xlator_dumpops dumpops = { -}; +struct xlator_dumpops dumpops; struct xlator_cbks cbks = { .forget = index_forget, diff --git a/xlators/features/mac-compat/src/mac-compat.c b/xlators/features/mac-compat/src/mac-compat.c index b50afe999..7cb550ad5 100644 --- a/xlators/features/mac-compat/src/mac-compat.c +++ b/xlators/features/mac-compat/src/mac-compat.c @@ -230,8 +230,7 @@ struct xlator_fops fops = { .fsetxattr = maccomp_fsetxattr, }; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; struct volume_options options[] = { { .key = {NULL} }, diff --git a/xlators/features/quiesce/src/quiesce.c b/xlators/features/quiesce/src/quiesce.c index 527a48b3e..73eb91947 100644 --- a/xlators/features/quiesce/src/quiesce.c +++ b/xlators/features/quiesce/src/quiesce.c @@ -2599,12 +2599,10 @@ struct xlator_fops fops = { }; -struct xlator_dumpops dumpops = { -}; +struct xlator_dumpops dumpops; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; struct volume_options options[] = { diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c index 34e7d6643..16c3eb3da 100644 --- a/xlators/features/read-only/src/worm.c +++ b/xlators/features/read-only/src/worm.c @@ -81,8 +81,7 @@ struct xlator_fops fops = { .lk = ro_lk, }; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; struct volume_options options[] = { { .key = {NULL} }, diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 014f1d55a..644c837ac 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1211,11 +1211,9 @@ notify (xlator_t *this, int32_t event, void *data, ...) } -struct xlator_fops fops = { -}; +struct xlator_fops fops; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; struct xlator_dumpops dumpops = { .priv = glusterd_priv, diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 214923dec..875abbe1d 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -4706,8 +4706,7 @@ static fuse_handler_t *fuse_std_ops[FUSE_OP_HIGH] = { }; -static fuse_handler_t *fuse_dump_ops[FUSE_OP_HIGH] = { -}; +static fuse_handler_t *fuse_dump_ops[FUSE_OP_HIGH]; static void @@ -4735,7 +4734,7 @@ fuse_dumper (xlator_t *this, fuse_in_header_t *finh, void *msg) "failed to dump fuse message (R): %s", strerror (errno)); - return priv->fuse_ops0[finh->opcode] (this, finh, msg); + priv->fuse_ops0[finh->opcode] (this, finh, msg); } @@ -5065,8 +5064,7 @@ fini (xlator_t *this_xl) kill (getpid (), SIGTERM); } -struct xlator_fops fops = { -}; +struct xlator_fops fops; struct xlator_cbks cbks = { .invalidate = fuse_invalidate, diff --git a/xlators/nfs/server/src/nfs-fops.h b/xlators/nfs/server/src/nfs-fops.h index 3ada863de..d846e14de 100644 --- a/xlators/nfs/server/src/nfs-fops.h +++ b/xlators/nfs/server/src/nfs-fops.h @@ -120,7 +120,7 @@ nfs_fop_local_wipe (xlator_t *xl, struct nfs_fop_local *l); nflocal = nfs_fop_local_init (nf); \ if (nflocal) { \ nflocal->proglocal = plocal; \ - nflocal->progcbk = pcbk; \ + nflocal->progcbk = *VOID(&pcbk); \ nflocal->nfsx = nf; \ if (fram) \ ((call_frame_t *)fram)->local = nflocal;\ diff --git a/xlators/nfs/server/src/nfs-inodes.c b/xlators/nfs/server/src/nfs-inodes.c index c9bf37206..a68f8b227 100644 --- a/xlators/nfs/server/src/nfs-inodes.c +++ b/xlators/nfs/server/src/nfs-inodes.c @@ -36,7 +36,7 @@ do { \ nflocal = fram->local; \ fram->local = nflocal->proglocal; \ - pcbk = nflocal->progcbk; \ + *VOID(&pcbk) = nflocal->progcbk; \ nfs_fop_local_wipe (nflocal->nfsx, nflocal); \ } while (0) \ diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c index 8e40698d3..466393e34 100644 --- a/xlators/nfs/server/src/nfs.c +++ b/xlators/nfs/server/src/nfs.c @@ -1004,7 +1004,7 @@ struct xlator_cbks cbks = { .forget = nfs_forget, }; -struct xlator_fops fops = { }; +struct xlator_fops fops; struct xlator_dumpops dumpops = { .priv = nfs_priv, diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c index dbf1929e8..ccbd41194 100644 --- a/xlators/performance/io-threads/src/io-threads.c +++ b/xlators/performance/io-threads/src/io-threads.c @@ -2738,8 +2738,7 @@ struct xlator_fops fops = { .rchecksum = iot_rchecksum, }; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; struct volume_options options[] = { { .key = {"thread-count"}, diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index 237acab9f..9ccd65538 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -65,7 +65,11 @@ static struct mdc_key { .load = 0, .check = 1, }, - {}, + { + .name = NULL, + .load = 0, + .check = 0, + } }; diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index d2bc4876c..cdf421ddd 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -1220,11 +1220,9 @@ notify (xlator_t *this, int32_t event, void *data, ...) } -struct xlator_fops fops = { -}; +struct xlator_fops fops; -struct xlator_cbks cbks = { -}; +struct xlator_cbks cbks; struct xlator_dumpops dumpops = { .priv = server_priv, diff --git a/xlators/system/posix-acl/src/posix-acl-xattr.h b/xlators/system/posix-acl/src/posix-acl-xattr.h index 9035d8761..c4e90f5f9 100644 --- a/xlators/system/posix-acl/src/posix-acl-xattr.h +++ b/xlators/system/posix-acl/src/posix-acl-xattr.h @@ -27,7 +27,7 @@ struct posix_acl_xattr_entry { struct posix_acl_xattr_header { uint32_t version; - struct posix_acl_xattr_entry entries[0]; + struct posix_acl_xattr_entry entries[]; }; struct posix_acl *posix_acl_from_xattr (xlator_t *this, const char *buf, int size); diff --git a/xlators/system/posix-acl/src/posix-acl.h b/xlators/system/posix-acl/src/posix-acl.h index 0c2b647aa..6ac2c6a84 100644 --- a/xlators/system/posix-acl/src/posix-acl.h +++ b/xlators/system/posix-acl/src/posix-acl.h @@ -43,7 +43,7 @@ struct posix_ace { struct posix_acl { int refcnt; int count; - struct posix_ace entries[0]; + struct posix_ace entries[]; }; |