Skip to contentSkip to conversation

rbd: use watch/notify for changes in rbd header

DISCUSSION Dan Carpenter 3 participants 4 messages Feb 13, 2014

lore
Share & tools
lore
#0 lore raw

Hello Yehuda Sadeh,

The patch 59c2be1e4d42: "rbd: use watch/notify for changes in rbd header" from Mar 21, 2011, leads to the following static checker warning:

	drivers/block/rbd.c:687 parse_rbd_opts_token()
	warn: we tested 'token < 0' before and it was 'false'

drivers/block/rbd.c
677 static int parse_rbd_opts_token(char *c, void *private) 678 {

   679          struct rbd_options *rbd_opts = private;
   680          substring_t argstr[MAX_OPT_ARGS];
   681          int token, intval, ret;
   682  
   683          token = match_token(c, rbd_opts_tokens, argstr);
   684          if (token < 0)
                    ^^^^^^^^^
   685                  return -EINVAL;
   686  
   687          if (token < Opt_last_int) {
                    ^^^^^^^^^^^^^^^^^^^^

Opt_last_int is zero so this is never true. Should the < be == or something?

   688                  ret = match_int(&argstr[0], &intval);
   689                  if (ret < 0) {
   690                          pr_err("bad mount option arg (not int) "
   691                                 "at '%s'\n", c);
   692                          return ret;
   693                  }
   694                  dout("got int token %d val %d\n", token, intval);
   695          } else if (token > Opt_last_int && token < Opt_last_string) {
   696                  dout("got string token %d val %s\n", token,
   697                       argstr[0].from);
   698          } else if (token > Opt_last_string && token < Opt_last_bool) {
   699                  dout("got Boolean token %d\n", token);
   700          } else {
   701                  dout("got token %d\n", token);
   702          }

regards,
dan carpenter

#1 lore raw
Quoted 23 lines · Dan Carpenter

Hello Yehuda Sadeh,

The patch 59c2be1e4d42: "rbd: use watch/notify for changes in rbd header" from Mar 21, 2011, leads to the following static checker warning:

drivers/block/rbd.c:687 parse_rbd_opts_token()
warn: we tested 'token < 0' before and it was 'false'

drivers/block/rbd.c
677 static int parse_rbd_opts_token(char *c, void *private)

   678  {
   679          struct rbd_options *rbd_opts = private;
   680          substring_t argstr[MAX_OPT_ARGS];
   681          int token, intval, ret;
   682
   683          token = match_token(c, rbd_opts_tokens, argstr);
   684          if (token < 0)
                    ^^^^^^^^^
   685                  return -EINVAL;
   686
   687          if (token < Opt_last_int) {
                    ^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines

Opt_last_int is zero so this is never true. Should the < be == or something?

Probably not. It's there in case an integer option gets added to rbd in the future. See parse_fsopt_token() and the enums above it in fs/ceph/super.c.

Thanks,

Ilya

#2 lore raw
Quoted 28 lines · Ilya Dryomov
Quoted 23 lines · Dan Carpenter

Hello Yehuda Sadeh,

The patch 59c2be1e4d42: "rbd: use watch/notify for changes in rbd header" from Mar 21, 2011, leads to the following static checker warning:

drivers/block/rbd.c:687 parse_rbd_opts_token()
warn: we tested 'token < 0' before and it was 'false'

drivers/block/rbd.c
677 static int parse_rbd_opts_token(char *c, void *private)

   678  {
   679          struct rbd_options *rbd_opts = private;
   680          substring_t argstr[MAX_OPT_ARGS];
   681          int token, intval, ret;
   682
   683          token = match_token(c, rbd_opts_tokens, argstr);
   684          if (token < 0)
                    ^^^^^^^^^
   685                  return -EINVAL;
   686
   687          if (token < Opt_last_int) {
                    ^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines

Opt_last_int is zero so this is never true. Should the < be == or something?

Quoted 3 lines

Probably not. It's there in case an integer option gets added to rbd in the future. See parse_fsopt_token() and the enums above it in fs/ceph/super.c.

Yes, that's correct. There were once integer options and this code is a holdover from that time.

I think it should remain in case it's needed, but it could be #ifdef'd or something. (Or we could do some magic to get the warning to go away.)

-Alex

Quoted 9 lines

Thanks,

Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 33 lines · Alex Elder
Quoted 28 lines · Ilya Dryomov
Quoted 23 lines · Dan Carpenter

Hello Yehuda Sadeh,

The patch 59c2be1e4d42: "rbd: use watch/notify for changes in rbd header" from Mar 21, 2011, leads to the following static checker warning:

drivers/block/rbd.c:687 parse_rbd_opts_token()
warn: we tested 'token < 0' before and it was 'false'

drivers/block/rbd.c
677 static int parse_rbd_opts_token(char *c, void *private)

   678  {
   679          struct rbd_options *rbd_opts = private;
   680          substring_t argstr[MAX_OPT_ARGS];
   681          int token, intval, ret;
   682
   683          token = match_token(c, rbd_opts_tokens, argstr);
   684          if (token < 0)
                    ^^^^^^^^^
   685                  return -EINVAL;
   686
   687          if (token < Opt_last_int) {
                    ^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines

Opt_last_int is zero so this is never true. Should the < be == or something?

Quoted 3 lines

Probably not. It's there in case an integer option gets added to rbd in the future. See parse_fsopt_token() and the enums above it in fs/ceph/super.c.

Quoted 8 lines

Yes, that's correct. There were once integer options and this code is a holdover from that time.

I think it should remain in case it's needed, but it could be #ifdef'd or something. (Or we could do some magic to get the warning to go away.)

-Alex

These warnings are a one time thing. No need for ifdefs.

regards,
dan carpenter