mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 22:12:36 +00:00
Merge pull request #2540 from tcharding/checkatch-cmd
cmd: Fix up checkpatch warnings
This commit is contained in:
commit
3278fdc26c
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
/* option keys for long only options */
|
/* option keys for long only options */
|
||||||
#define OPT_USAGE 0x1000
|
#define OPT_USAGE 0x1000
|
||||||
#define OPT_VERSION OPT_USAGE - 1
|
#define OPT_VERSION (OPT_USAGE - 1)
|
||||||
|
|
||||||
#define QUOTE(macro) #macro
|
#define QUOTE(macro) #macro
|
||||||
#define QUOTEVAL(macro) QUOTE(macro)
|
#define QUOTEVAL(macro) QUOTE(macro)
|
||||||
@ -73,7 +73,7 @@ static struct option long_options[] = {
|
|||||||
{ "lxcpath", required_argument, 0, 'P' },
|
{ "lxcpath", required_argument, 0, 'P' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
static char short_options[] = "n:hqo:l:P:";
|
static const char short_options[] = "n:hqo:l:P:";
|
||||||
|
|
||||||
struct arguments {
|
struct arguments {
|
||||||
const struct option *options;
|
const struct option *options;
|
||||||
@ -91,7 +91,7 @@ struct arguments {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int arguments_parse(struct arguments *my_args, int argc,
|
static int arguments_parse(struct arguments *my_args, int argc,
|
||||||
char *const argv[]);
|
char *const argv[]);
|
||||||
|
|
||||||
static struct arguments my_args = {
|
static struct arguments my_args = {
|
||||||
.options = long_options,
|
.options = long_options,
|
||||||
@ -468,18 +468,18 @@ out:
|
|||||||
static void print_usage(const struct option longopts[])
|
static void print_usage(const struct option longopts[])
|
||||||
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: lxc-init [-n|--name=NAME] [-h|--help] [--usage] [--version] \n\
|
fprintf(stderr, "Usage: lxc-init [-n|--name=NAME] [-h|--help] [--usage] [--version]\n\
|
||||||
[-q|--quiet] [-o|--logfile=LOGFILE] [-l|--logpriority=LOGPRIORITY] [-P|--lxcpath=LXCPATH]\n");
|
[-q|--quiet] [-o|--logfile=LOGFILE] [-l|--logpriority=LOGPRIORITY] [-P|--lxcpath=LXCPATH]\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_version()
|
static void print_version(void)
|
||||||
{
|
{
|
||||||
printf("%s\n", LXC_VERSION);
|
printf("%s\n", LXC_VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_help()
|
static void print_help(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\
|
fprintf(stderr, "\
|
||||||
Usage: lxc-init --name=NAME -- COMMAND\n\
|
Usage: lxc-init --name=NAME -- COMMAND\n\
|
||||||
@ -500,11 +500,10 @@ Mandatory or optional arguments to long options are also mandatory or optional\n
|
|||||||
for any corresponding short options.\n\
|
for any corresponding short options.\n\
|
||||||
\n\
|
\n\
|
||||||
See the lxc-init man page for further information.\n\n");
|
See the lxc-init man page for further information.\n\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int arguments_parse(struct arguments *args, int argc,
|
static int arguments_parse(struct arguments *args, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
int c;
|
int c;
|
||||||
@ -550,9 +549,8 @@ static int arguments_parse(struct arguments *args, int argc,
|
|||||||
args->argc = argc - optind;
|
args->argc = argc - optind;
|
||||||
|
|
||||||
/* If no lxcpath was given, use default */
|
/* If no lxcpath was given, use default */
|
||||||
if (!args->lxcpath) {
|
if (!args->lxcpath)
|
||||||
args->lxcpath = lxc_global_config_value("lxc.lxcpath");
|
args->lxcpath = lxc_global_config_value("lxc.lxcpath");
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the command options */
|
/* Check the command options */
|
||||||
if (!args->name) {
|
if (!args->name) {
|
||||||
|
@ -89,7 +89,7 @@ static int lxc_monitord_fifo_create(struct lxc_monitor *mon)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = mknod(fifo_path, S_IFIFO|S_IRUSR|S_IWUSR, 0);
|
ret = mknod(fifo_path, S_IFIFO | S_IRUSR | S_IWUSR, 0);
|
||||||
if (ret < 0 && errno != EEXIST) {
|
if (ret < 0 && errno != EEXIST) {
|
||||||
SYSINFO("Failed to mknod monitor fifo %s", fifo_path);
|
SYSINFO("Failed to mknod monitor fifo %s", fifo_path);
|
||||||
return -1;
|
return -1;
|
||||||
@ -208,7 +208,7 @@ static int lxc_monitord_sock_accept(int fd, uint32_t events, void *data,
|
|||||||
|
|
||||||
clientfds = realloc(mon->clientfds,
|
clientfds = realloc(mon->clientfds,
|
||||||
(mon->clientfds_size + CLIENTFDS_CHUNK) * sizeof(mon->clientfds[0]));
|
(mon->clientfds_size + CLIENTFDS_CHUNK) * sizeof(mon->clientfds[0]));
|
||||||
if (clientfds == NULL) {
|
if (!clientfds) {
|
||||||
ERROR("Failed to realloc memory for %d client file descriptors",
|
ERROR("Failed to realloc memory for %d client file descriptors",
|
||||||
mon->clientfds_size + CLIENTFDS_CHUNK);
|
mon->clientfds_size + CLIENTFDS_CHUNK);
|
||||||
goto err1;
|
goto err1;
|
||||||
|
@ -219,7 +219,7 @@ static char **get_groupnames(void)
|
|||||||
usernic_error("%s", "Could not find matched group record\n");
|
usernic_error("%s", "Could not find matched group record\n");
|
||||||
|
|
||||||
usernic_error("Failed to get group name: %s(%u)\n",
|
usernic_error("Failed to get group name: %s(%u)\n",
|
||||||
strerror(errno), group_ids[i]);
|
strerror(errno), group_ids[i]);
|
||||||
free(buf);
|
free(buf);
|
||||||
free(group_ids);
|
free(group_ids);
|
||||||
free_groupnames(groupnames);
|
free_groupnames(groupnames);
|
||||||
@ -512,7 +512,8 @@ static int instantiate_veth(char *veth1, char *veth2)
|
|||||||
|
|
||||||
/* Changing the high byte of the mac address to 0xfe, the bridge
|
/* Changing the high byte of the mac address to 0xfe, the bridge
|
||||||
* interface will always keep the host's mac address and not take the
|
* interface will always keep the host's mac address and not take the
|
||||||
* mac address of a container. */
|
* mac address of a container.
|
||||||
|
*/
|
||||||
ret = setup_private_host_hw_addr(veth1);
|
ret = setup_private_host_hw_addr(veth1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
usernic_error("Failed to change mac address of host interface "
|
usernic_error("Failed to change mac address of host interface "
|
||||||
@ -686,7 +687,7 @@ static bool cull_entries(int fd, char *name, char *net_type, char *net_link,
|
|||||||
static int count_entries(char *buf, off_t len, char *name, char *net_type, char *net_link)
|
static int count_entries(char *buf, off_t len, char *name, char *net_type, char *net_link)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool owner = false;;
|
bool owner = false;
|
||||||
char *buf_end;
|
char *buf_end;
|
||||||
|
|
||||||
buf_end = &buf[len];
|
buf_end = &buf[len];
|
||||||
@ -751,7 +752,7 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid,
|
|||||||
lxc_strmunmap(buf, sb.st_size);
|
lxc_strmunmap(buf, sb.st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owner == NULL)
|
if (!owner)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ret = snprintf(nicname, sizeof(nicname), "vethXXXXXX");
|
ret = snprintf(nicname, sizeof(nicname), "vethXXXXXX");
|
||||||
|
Loading…
Reference in New Issue
Block a user