From: Jeff Layton <jlayton@kernel.org>
To: Steve Dickson <steved@redhat.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH 2/2] nfsdctl: fix compiler warnings
Date: Mon, 15 Jul 2024 07:43:02 -0400 [thread overview]
Message-ID: <20240715-nfsdctl-v1-2-c09c314f540d@kernel.org> (raw)
In-Reply-To: <20240715-nfsdctl-v1-0-c09c314f540d@kernel.org>
Fix a pile of compiler warnings.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
utils/nfsdctl/nfsdctl.c | 48 ++++++++++++++----------------------------------
1 file changed, 14 insertions(+), 34 deletions(-)
diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c
index eb2c8cca4f42..f7c276320085 100644
--- a/utils/nfsdctl/nfsdctl.c
+++ b/utils/nfsdctl/nfsdctl.c
@@ -44,7 +44,6 @@
*/
static int debug_level;
-static int nl_family_id;
struct nfs_version {
uint8_t major;
@@ -84,16 +83,6 @@ static const struct option help_only_options[] = {
{ },
};
-static void debug(int level, const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- if (level <= debug_level)
- vprintf(fmt, args);
- va_end(args);
-}
-
#define NFSD4_OPS_MAX_LEN sizeof(nfsd4_ops) / sizeof(nfsd4_ops[0])
static const char *nfsd4_ops[] = {
[OP_ACCESS] = "OP_ACCESS",
@@ -317,8 +306,6 @@ static void parse_threads_get(struct genlmsghdr *gnlh)
nla_for_each_attr(attr, genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), rem) {
- struct nlattr *a;
-
switch (nla_type(attr)) {
case NFSD_A_SERVER_GRACETIME:
printf("gracetime: %u\n", nla_get_u32(attr));
@@ -327,7 +314,7 @@ static void parse_threads_get(struct genlmsghdr *gnlh)
printf("leasetime: %u\n", nla_get_u32(attr));
break;
case NFSD_A_SERVER_SCOPE:
- printf("scope: %s\n", nla_data(attr));
+ printf("scope: %s\n", (const char *)nla_data(attr));
break;
case NFSD_A_SERVER_THREADS:
pool_threads[i++] = nla_get_u32(attr);
@@ -352,7 +339,7 @@ static void parse_pool_mode_get(struct genlmsghdr *gnlh)
genlmsg_attrlen(gnlh, 0), rem) {
switch (nla_type(attr)) {
case NFSD_A_POOL_MODE_MODE:
- printf("pool-mode: %s\n", nla_data(attr));
+ printf("pool-mode: %s\n", (const char *)nla_data(attr));
break;
case NFSD_A_POOL_MODE_NPOOLS:
printf("npools: %u\n", nla_get_u32(attr));
@@ -366,7 +353,6 @@ static void parse_pool_mode_get(struct genlmsghdr *gnlh)
static int recv_handler(struct nl_msg *msg, void *arg)
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
- const struct nlattr *attr = genlmsg_attrdata(gnlh, 0);
switch (gnlh->cmd) {
case NFSD_CMD_RPC_STATUS_GET:
@@ -573,7 +559,7 @@ static void threads_usage(void)
static int threads_func(struct nl_sock *sock, int argc, char **argv)
{
uint8_t cmd = NFSD_CMD_THREADS_GET;
- uint32_t *pool_threads = NULL;
+ int *pool_threads = NULL;
int opt, pools = 0;
optind = 1;
@@ -589,7 +575,7 @@ static int threads_func(struct nl_sock *sock, int argc, char **argv)
char **targv = &argv[optind];
int i;
- pools = argc - optind, i;
+ pools = argc - optind;
pool_threads = alloca(pools * sizeof(*pool_threads));
cmd = NFSD_CMD_THREADS_SET;
@@ -785,8 +771,7 @@ static void version_usage(void)
static int version_func(struct nl_sock *sock, int argc, char ** argv)
{
- char *endptr = NULL;
- int opt, ret, threads, i;
+ int ret, i;
/* help is only valid as first argument after command */
if (argc > 1 &&
@@ -940,7 +925,7 @@ static int update_listeners(const char *str)
char buf[INET6_ADDRSTRLEN + 16];
char sign = *str;
char *netid, *addr, *port, *end;
- struct addrinfo *res, *ai;
+ struct addrinfo *res;
int i, ret;
struct addrinfo hints = { .ai_flags = AI_PASSIVE,
.ai_family = AF_INET,
@@ -1156,9 +1141,7 @@ static void listener_usage(void)
static int listener_func(struct nl_sock *sock, int argc, char ** argv)
{
- char *endptr = NULL;
- int ret, opt, threads, i;
- int argidx;
+ int ret, i;
/* help is only valid as first argument after command */
if (argc > 1 &&
@@ -1255,16 +1238,14 @@ static int pool_mode_func(struct nl_sock *sock, int argc, char **argv)
if (optind < argc) {
char **targv = &argv[optind];
- int i;
cmd = NFSD_CMD_POOL_MODE_SET;
/* empty string? */
- if (targv[i][0] == '\0') {
- fprintf(stderr, "Invalid threads value %s.\n", targv[i]);
+ if (*targv[0] == '\0') {
+ fprintf(stderr, "Invalid threads value %s.\n", targv[0]);
return 1;
}
-
pool_mode = targv[0];
}
return pool_mode_doit(sock, cmd, pool_mode);
@@ -1272,18 +1253,17 @@ static int pool_mode_func(struct nl_sock *sock, int argc, char **argv)
#define MAX_LISTENER_LEN (64 * 2 + 16)
-static int
+static void
add_listener(const char *netid, const char *addr, const char *port)
{
char buf[MAX_LISTENER_LEN];
- int ret;
if (strchr(addr, ':'))
- ret = snprintf(buf, MAX_LISTENER_LEN, "+%s:[%s]:%s",
- netid, addr, port);
+ snprintf(buf, MAX_LISTENER_LEN, "+%s:[%s]:%s",
+ netid, addr, port);
else
- ret = snprintf(buf, MAX_LISTENER_LEN, "+%s:%s:%s",
- netid, addr, port);
+ snprintf(buf, MAX_LISTENER_LEN, "+%s:%s:%s",
+ netid, addr, port);
buf[MAX_LISTENER_LEN - 1] = '\0';
update_listeners(buf);
}
--
2.45.2
prev parent reply other threads:[~2024-07-15 11:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-15 11:43 [PATCH 0/2] nfsdctl: fix default threads and clean up compiler warnings Jeff Layton
2024-07-15 11:43 ` [PATCH 1/2] nfsdctl: make "autostart" default to 16 threads Jeff Layton
2024-07-15 11:43 ` Jeff Layton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240715-nfsdctl-v1-2-c09c314f540d@kernel.org \
--to=jlayton@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=neilb@suse.de \
--cc=steved@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox