[Gluster-devel] integer options in gluster volume set help

Niels de Vos ndevos at redhat.com
Sun Jul 26 10:22:45 UTC 2015


On Fri, Jul 24, 2015 at 06:35:38AM +0200, Emmanuel Dreyfus wrote:
> gluster volume set help shows option default values. I note that the
> default_value field is a char * and where the option is integer, it seems the
> practice is to duplicate the value as a string.
> 
> Why not use a macro? Indeed it is a bit tricky, but it removes the risk of
> having obsolete values: Here is the definition:
> #define GF_ITOA(s) _GF_ITOA(s)
> #define _GF_ITOA(s) #s

We have this already, see libglusterfs/src/common-utils.h:

    #define STRINGIFY(val) #val
    #define TOSTRING(val) STRINGIFY(val)

An integer can be converted with TOSTRING(1234) and similar. But indeed,
there are only very few parts that use this macro. It would be a good
cleanup to replace the static integer values and call TOSTRING() on the
#define'd defaults.

This seems like an easy fix, and makes it very suitable for new
contributors. Any volunteers to take this on?

Thanks,
Niels


> 
> 
> And usage:
> #define DEFAULT_VERIFY_DEPTH 1
> (...)
>        { .key   = {"ssl-cert-depth"},
>          .type  = GF_OPTION_TYPE_INT, 
>          .default_value = GF_ITOA(DEFAULT_VERIFY_DEPTH),
>          .description = "Maximum certificate-chain depth.  If zero, the "
>                           "peer's certificate itself must be in the local "
>                           "certificate list.  Otherwise, there may be up to N "
>                           "signing certificates between the peer's and the "
>                           "local list.  Ignored if SSL is not enabled."
>          },
> 
> 
> Reference: https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
> 
> -- 
> Emmanuel Dreyfus
> http://hcpnet.free.fr/pubz
> manu at netbsd.org
> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at gluster.org
> http://www.gluster.org/mailman/listinfo/gluster-devel


More information about the Gluster-devel mailing list