ACK: [PATCH] fwts_args: constify fields in struct fwts_option

Alex Hung alex.hung at canonical.com
Sun Apr 11 20:51:29 UTC 2021


On 2021-04-10 4:05 p.m., Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> The fields are not meant to be modified so constify them.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/include/fwts_args.h | 8 ++++----
>  src/lib/src/fwts_args.c     | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/lib/include/fwts_args.h b/src/lib/include/fwts_args.h
> index 9cab3d7f..8d085e36 100644
> --- a/src/lib/include/fwts_args.h
> +++ b/src/lib/include/fwts_args.h
> @@ -26,10 +26,10 @@
>  #include <getopt.h>
>  
>  typedef struct {
> -	char		*long_name;	/* e.g. "quiet", long name */
> -	char		*short_name;	/* e.g. "q", short help info */
> -	int		has_arg;
> -	char		*explanation;	/* explanation: "Enabled quiet mode..." */
> +	const char *long_name;		/* e.g. "quiet", long name */
> +	const char *short_name;		/* e.g. "q", short help info */
> +	const int  has_arg;
> +	const char *explanation;	/* explanation: "Enabled quiet mode..." */
>  } fwts_option;
>  
>  #include "fwts.h"
> diff --git a/src/lib/src/fwts_args.c b/src/lib/src/fwts_args.c
> index a4af2f5d..4df36334 100644
> --- a/src/lib/src/fwts_args.c
> +++ b/src/lib/src/fwts_args.c
> @@ -125,7 +125,7 @@ int fwts_args_parse(fwts_framework *fw, const int argc, char * const argv[])
>  		options_table = fwts_list_data(fwts_options_table *, item);
>  
>  		for (i = 0; i < options_table->num_options; i++, n++) {
> -			char *short_name = options_table->options[i].short_name;
> +			const char *short_name = options_table->options[i].short_name;
>  			size_t len;
>  
>  			long_options[n].name    = options_table->options[i].long_name;
> 


Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list