lib: Use the same style in the 'struct option'

Use same style in the 'struct option' as:
    struct option opt[] = {
        { a, b },
        { a, b },
        ...
        { a, b },
    };

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiang Jiacheng 2022-11-22 09:50:01 +08:00 committed by Michal Privoznik
parent d6ecd766aa
commit 4b90adf65a
11 changed files with 69 additions and 69 deletions

View File

@ -86,11 +86,11 @@ parse_argv(int argc, char *argv[],
unsigned long val; unsigned long val;
char *p; char *p;
struct option opt[] = { struct option opt[] = {
{"debug", no_argument, NULL, 'd'}, { "debug", no_argument, NULL, 'd' },
{"help", no_argument, NULL, 'h'}, { "help", no_argument, NULL, 'h' },
{"connect", required_argument, NULL, 'c'}, { "connect", required_argument, NULL, 'c' },
{"delay", required_argument, NULL, 'D'}, { "delay", required_argument, NULL, 'D' },
{NULL, 0, NULL, 0} { NULL, 0, NULL, 0 },
}; };
while ((arg = getopt_long(argc, argv, "+:dhc:D:", opt, NULL)) != -1) { while ((arg = getopt_long(argc, argv, "+:dhc:D:", opt, NULL)) != -1) {

View File

@ -76,11 +76,11 @@ parse_argv(int argc, char *argv[],
unsigned long val; unsigned long val;
char *p; char *p;
struct option opt[] = { struct option opt[] = {
{"debug", no_argument, NULL, 'd'}, { "debug", no_argument, NULL, 'd' },
{"help", no_argument, NULL, 'h'}, { "help", no_argument, NULL, 'h' },
{"connect", required_argument, NULL, 'c'}, { "connect", required_argument, NULL, 'c' },
{"seconds", required_argument, NULL, 's'}, { "seconds", required_argument, NULL, 's' },
{NULL, 0, NULL, 0} { NULL, 0, NULL, 0 },
}; };
while ((arg = getopt_long(argc, argv, "+:dhc:s:", opt, NULL)) != -1) { while ((arg = getopt_long(argc, argv, "+:dhc:s:", opt, NULL)) != -1) {

View File

@ -809,14 +809,14 @@ int main(int argc, char **argv) {
int rv; int rv;
struct option opts[] = { struct option opts[] = {
{ "verbose", no_argument, &verbose, 'v'}, { "verbose", no_argument, &verbose, 'v' },
{ "daemon", no_argument, &godaemon, 'd'}, { "daemon", no_argument, &godaemon, 'd' },
{ "config", required_argument, NULL, 'f'}, { "config", required_argument, NULL, 'f' },
{ "timeout", required_argument, NULL, 't'}, { "timeout", required_argument, NULL, 't' },
{ "pid-file", required_argument, NULL, 'p'}, { "pid-file", required_argument, NULL, 'p' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{0, 0, 0, 0} { 0, 0, 0, 0 },
}; };
privileged = geteuid() == 0; privileged = geteuid() == 0;

View File

@ -613,14 +613,14 @@ int main(int argc, char **argv) {
int rv; int rv;
struct option opts[] = { struct option opts[] = {
{ "verbose", no_argument, &verbose, 'v'}, { "verbose", no_argument, &verbose, 'v' },
{ "daemon", no_argument, &godaemon, 'd'}, { "daemon", no_argument, &godaemon, 'd' },
{ "config", required_argument, NULL, 'f'}, { "config", required_argument, NULL, 'f' },
{ "timeout", required_argument, NULL, 't'}, { "timeout", required_argument, NULL, 't' },
{ "pid-file", required_argument, NULL, 'p'}, { "pid-file", required_argument, NULL, 'p' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{0, 0, 0, 0} { 0, 0, 0, 0 },
}; };
privileged = geteuid() == 0; privileged = geteuid() == 0;

View File

@ -807,17 +807,17 @@ int main(int argc, char **argv) {
mode_t old_umask; mode_t old_umask;
struct option opts[] = { struct option opts[] = {
{ "verbose", no_argument, &verbose, 'v'}, { "verbose", no_argument, &verbose, 'v' },
{ "daemon", no_argument, &godaemon, 'd'}, { "daemon", no_argument, &godaemon, 'd' },
#if defined(WITH_IP) && defined(LIBVIRTD) #if defined(WITH_IP) && defined(LIBVIRTD)
{ "listen", no_argument, &ipsock, 'l'}, { "listen", no_argument, &ipsock, 'l' },
#endif /* !(WITH_IP && LIBVIRTD) */ #endif /* !(WITH_IP && LIBVIRTD) */
{ "config", required_argument, NULL, 'f'}, { "config", required_argument, NULL, 'f' },
{ "timeout", required_argument, NULL, 't'}, { "timeout", required_argument, NULL, 't' },
{ "pid-file", required_argument, NULL, 'p'}, { "pid-file", required_argument, NULL, 'p' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{0, 0, 0, 0} { 0, 0, 0, 0 },
}; };
if (virGettextInitialize() < 0 || if (virGettextInitialize() < 0 ||

View File

@ -1337,17 +1337,17 @@ vahParseArgv(vahControl * ctl, int argc, char **argv)
{ {
int arg, idx = 0; int arg, idx = 0;
struct option opt[] = { struct option opt[] = {
{"add", 0, 0, 'a'}, { "add", 0, 0, 'a' },
{"create", 0, 0, 'c'}, { "create", 0, 0, 'c' },
{"dryrun", 0, 0, 'd'}, { "dryrun", 0, 0, 'd' },
{"delete", 0, 0, 'D'}, { "delete", 0, 0, 'D' },
{"add-file", 0, 0, 'f'}, { "add-file", 0, 0, 'f' },
{"append-file", 0, 0, 'F'}, { "append-file", 0, 0, 'F' },
{"help", 0, 0, 'h'}, { "help", 0, 0, 'h' },
{"replace", 0, 0, 'r'}, { "replace", 0, 0, 'r' },
{"remove", 0, 0, 'R'}, { "remove", 0, 0, 'R' },
{"uuid", 1, 0, 'u'}, { "uuid", 1, 0, 'u' },
{0, 0, 0, 0} { 0, 0, 0, 0 },
}; };
while ((arg = getopt_long(argc, argv, "acdDhrRH:b:u:p:f:F:", opt, while ((arg = getopt_long(argc, argv, "acdDhrRH:b:u:p:f:F:", opt,

View File

@ -638,18 +638,18 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
int longindex = -1; int longindex = -1;
virshControl *priv = ctl->privData; virshControl *priv = ctl->privData;
struct option opt[] = { struct option opt[] = {
{"connect", required_argument, NULL, 'c'}, { "connect", required_argument, NULL, 'c' },
{"debug", required_argument, NULL, 'd'}, { "debug", required_argument, NULL, 'd' },
{"escape", required_argument, NULL, 'e'}, { "escape", required_argument, NULL, 'e' },
{"help", no_argument, NULL, 'h'}, { "help", no_argument, NULL, 'h' },
{"keepalive-interval", required_argument, NULL, 'k'}, { "keepalive-interval", required_argument, NULL, 'k' },
{"keepalive-count", required_argument, NULL, 'K'}, { "keepalive-count", required_argument, NULL, 'K' },
{"log", required_argument, NULL, 'l'}, { "log", required_argument, NULL, 'l' },
{"quiet", no_argument, NULL, 'q'}, { "quiet", no_argument, NULL, 'q' },
{"readonly", no_argument, NULL, 'r'}, { "readonly", no_argument, NULL, 'r' },
{"timing", no_argument, NULL, 't'}, { "timing", no_argument, NULL, 't' },
{"version", optional_argument, NULL, 'v'}, { "version", optional_argument, NULL, 'v' },
{NULL, 0, NULL, 0} { NULL, 0, NULL, 0 },
}; };
/* Standard (non-command) options. The leading + ensures that no /* Standard (non-command) options. The leading + ensures that no

View File

@ -1318,13 +1318,13 @@ vshAdmParseArgv(vshControl *ctl, int argc, char **argv)
size_t i; size_t i;
int longindex = -1; int longindex = -1;
struct option opt[] = { struct option opt[] = {
{"connect", required_argument, NULL, 'c'}, { "connect", required_argument, NULL, 'c' },
{"debug", required_argument, NULL, 'd'}, { "debug", required_argument, NULL, 'd' },
{"help", no_argument, NULL, 'h'}, { "help", no_argument, NULL, 'h' },
{"log", required_argument, NULL, 'l'}, { "log", required_argument, NULL, 'l' },
{"quiet", no_argument, NULL, 'q'}, { "quiet", no_argument, NULL, 'q' },
{"version", optional_argument, NULL, 'v'}, { "version", optional_argument, NULL, 'v' },
{NULL, 0, NULL, 0} { NULL, 0, NULL, 0 },
}; };
/* Standard (non-command) options. The leading + ensures that no /* Standard (non-command) options. The leading + ensures that no

View File

@ -73,10 +73,10 @@ show_version(FILE *out, const char *argv0)
} }
static const struct option argOptions[] = { static const struct option argOptions[] = {
{ "help", 0, NULL, 'h', }, { "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v', }, { "version", 0, NULL, 'v' },
{ "quiet", 0, NULL, 'q', }, { "quiet", 0, NULL, 'q' },
{ NULL, 0, NULL, '\0', } { NULL, 0, NULL, '\0' },
}; };
int int

View File

@ -179,9 +179,9 @@ main(int argc, char **argv)
bool autoshell = false; bool autoshell = false;
struct option opt[] = { struct option opt[] = {
{"help", no_argument, NULL, 'h'}, { "help", no_argument, NULL, 'h' },
{"version", optional_argument, NULL, 'V'}, { "version", optional_argument, NULL, 'V' },
{NULL, 0, NULL, 0} { NULL, 0, NULL, 0 },
}; };
if (virInitialize() < 0) { if (virInitialize() < 0) {
fprintf(stderr, _("Failed to initialize libvirt error handling")); fprintf(stderr, _("Failed to initialize libvirt error handling"));

View File

@ -61,9 +61,9 @@ main(int argc,
int rv = 0; int rv = 0;
struct option opt[] = { struct option opt[] = {
{"help", no_argument, NULL, 'h'}, { "help", no_argument, NULL, 'h' },
{"version", optional_argument, NULL, 'v'}, { "version", optional_argument, NULL, 'v' },
{NULL, 0, NULL, 0} { NULL, 0, NULL, 0 },
}; };
if (virGettextInitialize() < 0) if (virGettextInitialize() < 0)