All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] makedumpfile: Assign non-printable value as short options
@ 2013-06-28  8:13 Baoquan He
  2013-06-28  8:13 ` [PATCH 2/2] makedumpfile: Add help and man message for '--help' Baoquan He
  2013-07-02  1:59 ` [PATCH 1/2] makedumpfile: Assign non-printable value as short options Atsushi Kumagai
  0 siblings, 2 replies; 3+ messages in thread
From: Baoquan He @ 2013-06-28  8:13 UTC (permalink / raw)
  To: kexec; +Cc: Baoquan He

Characters for short options is limited, and now makedumpfile has
considerably many options. As times go on, no enough reasonable
letters can be assigned to each functionality with short options.

E.g non-cyclic vs Y, cyclic-buffer vs Z, eppic vs S.

Now assign non-printable value to these kind of short optins, meanwhile
define them as indicative MACRO which can make code more readable.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 makedumpfile.c | 88 +++++++++++++++++++++++++++++-----------------------------
 makedumpfile.h | 35 +++++++++++++++++++++++
 2 files changed, 79 insertions(+), 44 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index b42565c..801eda0 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -8555,20 +8555,20 @@ calculate_cyclic_buffer_size(void) {
 }
 
 static struct option longopts[] = {
-	{"split", no_argument, NULL, 's'}, 
-	{"reassemble", no_argument, NULL, 'r'},
-	{"xen-syms", required_argument, NULL, 'y'},
-	{"xen-vmcoreinfo", required_argument, NULL, 'z'},
-	{"xen_phys_start", required_argument, NULL, 'P'},
-	{"message-level", required_argument, NULL, 'm'},
-	{"vtop", required_argument, NULL, 'V'},
-	{"dump-dmesg", no_argument, NULL, 'M'}, 
-	{"config", required_argument, NULL, 'C'},
-	{"help", no_argument, NULL, 'h'},
-	{"diskset", required_argument, NULL, 'k'},
-	{"non-cyclic", no_argument, NULL, 'Y'},
-	{"cyclic-buffer", required_argument, NULL, 'Z'},
-	{"eppic", required_argument, NULL, 'S'},
+	{"split", no_argument, NULL, OPT_SPLIT}, 
+	{"reassemble", no_argument, NULL, OPT_REASSEMBLE},
+	{"xen-syms", required_argument, NULL, OPT_XEN_SYMS},
+	{"xen-vmcoreinfo", required_argument, NULL, OPT_XEN_VMCOREINFO},
+	{"xen_phys_start", required_argument, NULL, OPT_XEN_PHYS_START},
+	{"message-level", required_argument, NULL, OPT_MESSAGE_LEVEL},
+	{"vtop", required_argument, NULL, OPT_VTOP},
+	{"dump-dmesg", no_argument, NULL, OPT_DUMP_DMESG}, 
+	{"config", required_argument, NULL, OPT_CONFIG},
+	{"help", no_argument, NULL, OPT_HELP},
+	{"diskset", required_argument, NULL, OPT_DISKSET},
+	{"non-cyclic", no_argument, NULL, OPT_NON_CYCLIC},
+	{"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER},
+	{"eppic", required_argument, NULL, OPT_EPPIC},
 	{0, 0, 0, 0}
 };
 
@@ -8597,29 +8597,29 @@ main(int argc, char *argv[])
 	
 	info->block_order = DEFAULT_ORDER;
 	message_level = DEFAULT_MSG_LEVEL;
-	while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lMpRrsvXx:", longopts,
+	while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lpRvXx:", longopts,
 	    NULL)) != -1) {
 		switch (opt) {
-		case 'b':
+		case OPT_BLOCK_ORDER:
 			info->block_order = atoi(optarg);
 			break;
-		case 'C':
+		case OPT_CONFIG:
 			info->name_filterconfig = optarg;
 			break;
-		case 'c':
+		case OPT_COMPRESS_ZLIB:
 			info->flag_compress = DUMP_DH_COMPRESSED_ZLIB;
 			break;
-		case 'D':
+		case OPT_DEBUG:
 			flag_debug = TRUE;
 			break;
-		case 'd':
+		case OPT_DUMP_LEVEL:
 			if (!parse_dump_level(optarg))
 				goto out;
 			break;
-		case 'E':
+		case OPT_ELF_DUMPFILE:
 			info->flag_elf_dumpfile = 1;
 			break;
-		case 'F':
+		case OPT_FLATTEN:
 			info->flag_flatten = 1;
 			/*
 			 * All messages are output to STDERR because STDOUT is
@@ -8627,75 +8627,75 @@ main(int argc, char *argv[])
 			 */
 			flag_strerr_message = TRUE;
 			break;
-		case 'f':
+		case OPT_FORCE:
 			info->flag_force = 1;
 			break;
-		case 'g':
+		case OPT_GENERATE_VMCOREINFO:
 			info->flag_generate_vmcoreinfo = 1;
 			info->name_vmcoreinfo = optarg;
 			break;
-		case 'h':
+		case OPT_HELP:
 			info->flag_show_usage = 1;
 			break;
-		case 'i':
+		case OPT_READ_VMCOREINFO:
 			info->flag_read_vmcoreinfo = 1;
 			info->name_vmcoreinfo = optarg;
 			break;
-		case 'k':
+		case OPT_DISKSET:
 			if (!sadump_add_diskset_info(optarg))
 				goto out;
 			info->flag_sadump_diskset = 1;
 			break;
-		case 'l':
+		case OPT_COMPRESS_LZO:
 			info->flag_compress = DUMP_DH_COMPRESSED_LZO;
 			break;
-		case 'm':
+		case OPT_MESSAGE_LEVEL:
 			message_level = atoi(optarg);
 			break;
-		case 'M':
+		case OPT_DUMP_DMESG:
 			info->flag_dmesg = 1;
 			break;
-		case 'p':
+		case OPT_COMPRESS_SNAPPY:
 			info->flag_compress = DUMP_DH_COMPRESSED_SNAPPY;
 			break;
-		case 'P':
+		case OPT_XEN_PHYS_START:
 			info->xen_phys_start = strtoul(optarg, NULL, 0);
 			break;
-		case 'R':
+		case OPT_REARRANGE:
 			info->flag_rearrange = 1;
 			break;
-		case 's':
+		case OPT_SPLIT:
 			info->flag_split = 1;
 			break;
-		case 'S':
+		case OPT_EPPIC:
 			info->name_eppic_config = optarg;
 			break;
-		case 'r':
+		case OPT_REASSEMBLE:
 			info->flag_reassemble = 1;
 			break;
-		case 'V':
+		case OPT_VTOP:
 			info->vaddr_for_vtop = strtoul(optarg, NULL, 0);
 			break;
-		case 'v':
+		case OPT_VERSION:
 			info->flag_show_version = 1;
 			break;
-		case 'X':
+		case OPT_EXCLUDE_XEN_DOM:
 			info->flag_exclude_xen_dom = 1;
 			break;
-		case 'x':
+		case OPT_VMLINUX:
 			info->name_vmlinux = optarg;
 			break;
-		case 'y':
+		case OPT_XEN_SYMS:
 			info->name_xen_syms = optarg;
 			break;
-		case 'Y':
+		case OPT_NON_CYCLIC:
 			info->flag_cyclic = FALSE;
 			break;
-		case 'z':
+		case OPT_XEN_VMCOREINFO:
 			info->flag_read_vmcoreinfo = 1;
 			info->name_vmcoreinfo = optarg;
 			break;
-		case 'Z':
+		case OPT_CYCLIC_BUFFER:
 			info->bufsize_cyclic = atoi(optarg);
 			break;
 		case '?':
diff --git a/makedumpfile.h b/makedumpfile.h
index 2a6b6f2..0a2198e 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1671,6 +1671,41 @@ struct elf_prstatus {
 #endif
 
 /*
+ * Below are options which getopt_long can recognize. From OPT_START options are
+ * non-printable, just used for implementation.
+ */
+#define OPT_BLOCK_ORDER         'b'
+#define OPT_COMPRESS_ZLIB       'c'
+#define OPT_DEBUG               'D'
+#define OPT_DUMP_LEVEL          'd'
+#define OPT_ELF_DUMPFILE        'E'
+#define OPT_FLATTEN             'F'
+#define OPT_FORCE               'f'
+#define OPT_GENERATE_VMCOREINFO 'g'
+#define OPT_HELP                'h'
+#define OPT_READ_VMCOREINFO     'i'
+#define OPT_COMPRESS_LZO        'l'
+#define OPT_COMPRESS_SNAPPY     'p'
+#define OPT_REARRANGE           'R'
+#define OPT_VERSION             'v'
+#define OPT_EXCLUDE_XEN_DOM     'X'
+#define OPT_VMLINUX             'x'
+#define OPT_START               256
+#define OPT_SPLIT               OPT_START+0
+#define OPT_REASSEMBLE          OPT_START+1
+#define OPT_XEN_SYMS            OPT_START+2
+#define OPT_XEN_VMCOREINFO      OPT_START+3
+#define OPT_XEN_PHYS_START      OPT_START+4
+#define OPT_MESSAGE_LEVEL       OPT_START+5
+#define OPT_VTOP                OPT_START+6
+#define OPT_DUMP_DMESG          OPT_START+7
+#define OPT_CONFIG              OPT_START+8
+#define OPT_DISKSET             OPT_START+9
+#define OPT_NON_CYCLIC          OPT_START+10
+#define OPT_CYCLIC_BUFFER       OPT_START+11
+#define OPT_EPPIC               OPT_START+12
+
+/*
  * Function Prototype.
  */
 unsigned long long get_num_dumpable_cyclic(void);
-- 
1.8.2.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] makedumpfile: Add help and man message for '--help'
  2013-06-28  8:13 [PATCH 1/2] makedumpfile: Assign non-printable value as short options Baoquan He
@ 2013-06-28  8:13 ` Baoquan He
  2013-07-02  1:59 ` [PATCH 1/2] makedumpfile: Assign non-printable value as short options Atsushi Kumagai
  1 sibling, 0 replies; 3+ messages in thread
From: Baoquan He @ 2013-06-28  8:13 UTC (permalink / raw)
  To: kexec; +Cc: Baoquan He

Conventionally '-h' and '--help' are all provided. Currently makedumpfile
lacks help and man message for '--help'. Here add it.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 makedumpfile.8 | 2 +-
 print_info.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.8 b/makedumpfile.8
index 61bd5f2..eb2cf3d 100644
--- a/makedumpfile.8
+++ b/makedumpfile.8
@@ -539,7 +539,7 @@ order from left to right.  \fIVMCORE\fRs are assembled into a single
 Print debugging message.
 
 .TP
-\fB\-h\fR
+\fB\-h (\-\-help)\fR
 Show help message and LZO/snappy support status (enabled/disabled).
 
 .TP
diff --git a/print_info.c b/print_info.c
index 06939e0..3527970 100644
--- a/print_info.c
+++ b/print_info.c
@@ -255,7 +255,7 @@ print_usage(void)
 	MSG("  [-f]:\n");
 	MSG("      Overwrite DUMPFILE even if it already exists.\n");
 	MSG("\n");
-	MSG("  [-h]:\n");
+	MSG("  [-h, --help]:\n");
 	MSG("      Show help message and LZO/snappy support status (enabled/disabled).\n");
 	MSG("\n");
 	MSG("  [-v]:\n");
-- 
1.8.2.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] makedumpfile: Assign non-printable value as short options
  2013-06-28  8:13 [PATCH 1/2] makedumpfile: Assign non-printable value as short options Baoquan He
  2013-06-28  8:13 ` [PATCH 2/2] makedumpfile: Add help and man message for '--help' Baoquan He
@ 2013-07-02  1:59 ` Atsushi Kumagai
  1 sibling, 0 replies; 3+ messages in thread
From: Atsushi Kumagai @ 2013-07-02  1:59 UTC (permalink / raw)
  To: bhe; +Cc: kexec

On Fri, 28 Jun 2013 16:13:51 +0800
Baoquan He <bhe@redhat.com> wrote:

> Characters for short options is limited, and now makedumpfile has
> considerably many options. As times go on, no enough reasonable
> letters can be assigned to each functionality with short options.
> 
> E.g non-cyclic vs Y, cyclic-buffer vs Z, eppic vs S.
> 
> Now assign non-printable value to these kind of short optins, meanwhile
> define them as indicative MACRO which can make code more readable.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>

Looks good to me, thanks Baoquan.

v1.5.4 is almost ready to be released, so I'll merge this patch set
into v1.5.5.


Thanks
Atsushi Kumagai

> ---
>  makedumpfile.c | 88 +++++++++++++++++++++++++++++-----------------------------
>  makedumpfile.h | 35 +++++++++++++++++++++++
>  2 files changed, 79 insertions(+), 44 deletions(-)
> 
> diff --git a/makedumpfile.c b/makedumpfile.c
> index b42565c..801eda0 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -8555,20 +8555,20 @@ calculate_cyclic_buffer_size(void) {
>  }
>  
>  static struct option longopts[] = {
> -	{"split", no_argument, NULL, 's'}, 
> -	{"reassemble", no_argument, NULL, 'r'},
> -	{"xen-syms", required_argument, NULL, 'y'},
> -	{"xen-vmcoreinfo", required_argument, NULL, 'z'},
> -	{"xen_phys_start", required_argument, NULL, 'P'},
> -	{"message-level", required_argument, NULL, 'm'},
> -	{"vtop", required_argument, NULL, 'V'},
> -	{"dump-dmesg", no_argument, NULL, 'M'}, 
> -	{"config", required_argument, NULL, 'C'},
> -	{"help", no_argument, NULL, 'h'},
> -	{"diskset", required_argument, NULL, 'k'},
> -	{"non-cyclic", no_argument, NULL, 'Y'},
> -	{"cyclic-buffer", required_argument, NULL, 'Z'},
> -	{"eppic", required_argument, NULL, 'S'},
> +	{"split", no_argument, NULL, OPT_SPLIT}, 
> +	{"reassemble", no_argument, NULL, OPT_REASSEMBLE},
> +	{"xen-syms", required_argument, NULL, OPT_XEN_SYMS},
> +	{"xen-vmcoreinfo", required_argument, NULL, OPT_XEN_VMCOREINFO},
> +	{"xen_phys_start", required_argument, NULL, OPT_XEN_PHYS_START},
> +	{"message-level", required_argument, NULL, OPT_MESSAGE_LEVEL},
> +	{"vtop", required_argument, NULL, OPT_VTOP},
> +	{"dump-dmesg", no_argument, NULL, OPT_DUMP_DMESG}, 
> +	{"config", required_argument, NULL, OPT_CONFIG},
> +	{"help", no_argument, NULL, OPT_HELP},
> +	{"diskset", required_argument, NULL, OPT_DISKSET},
> +	{"non-cyclic", no_argument, NULL, OPT_NON_CYCLIC},
> +	{"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER},
> +	{"eppic", required_argument, NULL, OPT_EPPIC},
>  	{0, 0, 0, 0}
>  };
>  
> @@ -8597,29 +8597,29 @@ main(int argc, char *argv[])
>  	
>  	info->block_order = DEFAULT_ORDER;
>  	message_level = DEFAULT_MSG_LEVEL;
> -	while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lMpRrsvXx:", longopts,
> +	while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lpRvXx:", longopts,
>  	    NULL)) != -1) {
>  		switch (opt) {
> -		case 'b':
> +		case OPT_BLOCK_ORDER:
>  			info->block_order = atoi(optarg);
>  			break;
> -		case 'C':
> +		case OPT_CONFIG:
>  			info->name_filterconfig = optarg;
>  			break;
> -		case 'c':
> +		case OPT_COMPRESS_ZLIB:
>  			info->flag_compress = DUMP_DH_COMPRESSED_ZLIB;
>  			break;
> -		case 'D':
> +		case OPT_DEBUG:
>  			flag_debug = TRUE;
>  			break;
> -		case 'd':
> +		case OPT_DUMP_LEVEL:
>  			if (!parse_dump_level(optarg))
>  				goto out;
>  			break;
> -		case 'E':
> +		case OPT_ELF_DUMPFILE:
>  			info->flag_elf_dumpfile = 1;
>  			break;
> -		case 'F':
> +		case OPT_FLATTEN:
>  			info->flag_flatten = 1;
>  			/*
>  			 * All messages are output to STDERR because STDOUT is
> @@ -8627,75 +8627,75 @@ main(int argc, char *argv[])
>  			 */
>  			flag_strerr_message = TRUE;
>  			break;
> -		case 'f':
> +		case OPT_FORCE:
>  			info->flag_force = 1;
>  			break;
> -		case 'g':
> +		case OPT_GENERATE_VMCOREINFO:
>  			info->flag_generate_vmcoreinfo = 1;
>  			info->name_vmcoreinfo = optarg;
>  			break;
> -		case 'h':
> +		case OPT_HELP:
>  			info->flag_show_usage = 1;
>  			break;
> -		case 'i':
> +		case OPT_READ_VMCOREINFO:
>  			info->flag_read_vmcoreinfo = 1;
>  			info->name_vmcoreinfo = optarg;
>  			break;
> -		case 'k':
> +		case OPT_DISKSET:
>  			if (!sadump_add_diskset_info(optarg))
>  				goto out;
>  			info->flag_sadump_diskset = 1;
>  			break;
> -		case 'l':
> +		case OPT_COMPRESS_LZO:
>  			info->flag_compress = DUMP_DH_COMPRESSED_LZO;
>  			break;
> -		case 'm':
> +		case OPT_MESSAGE_LEVEL:
>  			message_level = atoi(optarg);
>  			break;
> -		case 'M':
> +		case OPT_DUMP_DMESG:
>  			info->flag_dmesg = 1;
>  			break;
> -		case 'p':
> +		case OPT_COMPRESS_SNAPPY:
>  			info->flag_compress = DUMP_DH_COMPRESSED_SNAPPY;
>  			break;
> -		case 'P':
> +		case OPT_XEN_PHYS_START:
>  			info->xen_phys_start = strtoul(optarg, NULL, 0);
>  			break;
> -		case 'R':
> +		case OPT_REARRANGE:
>  			info->flag_rearrange = 1;
>  			break;
> -		case 's':
> +		case OPT_SPLIT:
>  			info->flag_split = 1;
>  			break;
> -		case 'S':
> +		case OPT_EPPIC:
>  			info->name_eppic_config = optarg;
>  			break;
> -		case 'r':
> +		case OPT_REASSEMBLE:
>  			info->flag_reassemble = 1;
>  			break;
> -		case 'V':
> +		case OPT_VTOP:
>  			info->vaddr_for_vtop = strtoul(optarg, NULL, 0);
>  			break;
> -		case 'v':
> +		case OPT_VERSION:
>  			info->flag_show_version = 1;
>  			break;
> -		case 'X':
> +		case OPT_EXCLUDE_XEN_DOM:
>  			info->flag_exclude_xen_dom = 1;
>  			break;
> -		case 'x':
> +		case OPT_VMLINUX:
>  			info->name_vmlinux = optarg;
>  			break;
> -		case 'y':
> +		case OPT_XEN_SYMS:
>  			info->name_xen_syms = optarg;
>  			break;
> -		case 'Y':
> +		case OPT_NON_CYCLIC:
>  			info->flag_cyclic = FALSE;
>  			break;
> -		case 'z':
> +		case OPT_XEN_VMCOREINFO:
>  			info->flag_read_vmcoreinfo = 1;
>  			info->name_vmcoreinfo = optarg;
>  			break;
> -		case 'Z':
> +		case OPT_CYCLIC_BUFFER:
>  			info->bufsize_cyclic = atoi(optarg);
>  			break;
>  		case '?':
> diff --git a/makedumpfile.h b/makedumpfile.h
> index 2a6b6f2..0a2198e 100644
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -1671,6 +1671,41 @@ struct elf_prstatus {
>  #endif
>  
>  /*
> + * Below are options which getopt_long can recognize. From OPT_START options are
> + * non-printable, just used for implementation.
> + */
> +#define OPT_BLOCK_ORDER         'b'
> +#define OPT_COMPRESS_ZLIB       'c'
> +#define OPT_DEBUG               'D'
> +#define OPT_DUMP_LEVEL          'd'
> +#define OPT_ELF_DUMPFILE        'E'
> +#define OPT_FLATTEN             'F'
> +#define OPT_FORCE               'f'
> +#define OPT_GENERATE_VMCOREINFO 'g'
> +#define OPT_HELP                'h'
> +#define OPT_READ_VMCOREINFO     'i'
> +#define OPT_COMPRESS_LZO        'l'
> +#define OPT_COMPRESS_SNAPPY     'p'
> +#define OPT_REARRANGE           'R'
> +#define OPT_VERSION             'v'
> +#define OPT_EXCLUDE_XEN_DOM     'X'
> +#define OPT_VMLINUX             'x'
> +#define OPT_START               256
> +#define OPT_SPLIT               OPT_START+0
> +#define OPT_REASSEMBLE          OPT_START+1
> +#define OPT_XEN_SYMS            OPT_START+2
> +#define OPT_XEN_VMCOREINFO      OPT_START+3
> +#define OPT_XEN_PHYS_START      OPT_START+4
> +#define OPT_MESSAGE_LEVEL       OPT_START+5
> +#define OPT_VTOP                OPT_START+6
> +#define OPT_DUMP_DMESG          OPT_START+7
> +#define OPT_CONFIG              OPT_START+8
> +#define OPT_DISKSET             OPT_START+9
> +#define OPT_NON_CYCLIC          OPT_START+10
> +#define OPT_CYCLIC_BUFFER       OPT_START+11
> +#define OPT_EPPIC               OPT_START+12
> +
> +/*
>   * Function Prototype.
>   */
>  unsigned long long get_num_dumpable_cyclic(void);
> -- 
> 1.8.2.1
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-02  2:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-28  8:13 [PATCH 1/2] makedumpfile: Assign non-printable value as short options Baoquan He
2013-06-28  8:13 ` [PATCH 2/2] makedumpfile: Add help and man message for '--help' Baoquan He
2013-07-02  1:59 ` [PATCH 1/2] makedumpfile: Assign non-printable value as short options Atsushi Kumagai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.