aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-03-01 15:34:17 -0600
committerRob Landley <rob@landley.net>2019-03-01 15:34:17 -0600
commit8f6554366bcf6f7b07a52ea802856aeedc36645a (patch)
tree12de7ba8acb5be26b584136d70867e344e945170
parent044c0d9030859c059d1dbce9dc9eb963a828605f (diff)
downloadtoybox-8f6554366bcf6f7b07a52ea802856aeedc36645a.tar.gz
Minor tweaks.
-rw-r--r--toys/other/vconfig.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/toys/other/vconfig.c b/toys/other/vconfig.c
index fd785273..83674d8b 100644
--- a/toys/other/vconfig.c
+++ b/toys/other/vconfig.c
@@ -4,8 +4,6 @@
* Copyright 2012 Kyungwan Han <asura321@gmail.com>
*
* No standard
- *
- * TODO: cleanup
USE_VCONFIG(NEWTOY(vconfig, "<2>4", TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
@@ -32,17 +30,15 @@ config VCONFIG
void vconfig_main(void)
{
struct vlan_ioctl_args request;
- char *cmd;
- int fd;
+ char *cmd = *toys.optargs;
+ int fd = xsocket(AF_INET, SOCK_STREAM, 0);
- fd = xsocket(AF_INET, SOCK_STREAM, 0);
memset(&request, 0, sizeof(struct vlan_ioctl_args));
- cmd = toys.optargs[0];
if (!strcmp(cmd, "set_name_type")) {
char *types[] = {"VLAN_PLUS_VID", "DEV_PLUS_VID", "VLAN_PLUS_VID_NO_PAD",
"DEV_PLUS_VID_NO_PAD"};
- int i, j = sizeof(types)/sizeof(*types);
+ int i, j = ARRAY_LEN(types);
for (i=0; i<j; i++) if (!strcmp(toys.optargs[1], types[i])) break;
if (i == j) {
@@ -53,11 +49,12 @@ void vconfig_main(void)
request.u.name_type = i;
request.cmd = SET_VLAN_NAME_TYPE_CMD;
xioctl(fd, SIOCSIFVLAN, &request);
+
return;
}
// Store interface name
- xstrncpy(request.device1, toys.optargs[1], 16);
+ xstrncpy(request.device1, toys.optargs[1], sizeof(request.device1));
if (!strcmp(cmd, "add")) {
request.cmd = ADD_VLAN_CMD;