Break long lines, and use bool where possible.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
* TODO:
* - parse to be passed a filedescriptor for logging purposes
*
* TODO:
* - parse to be passed a filedescriptor for logging purposes
*
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
* with any action .so from the old days. But if someone really
* does that, they would know how to fix this ..
*
* with any action .so from the old days. But if someone really
* does that, they would know how to fix this ..
*
fprintf(stderr, "usage: tc actions <ACTSPECOP>*\n");
fprintf(stderr,
"Where: \tACTSPECOP := ACR | GD | FL\n"
fprintf(stderr, "usage: tc actions <ACTSPECOP>*\n");
fprintf(stderr,
"Where: \tACTSPECOP := ACR | GD | FL\n"
-static int parse_noaopt(struct action_util *au, int *argc_p, char ***argv_p, int code, struct nlmsghdr *n)
+static int parse_noaopt(struct action_util *au, int *argc_p,
+ char ***argv_p, int code, struct nlmsghdr *n)
{
int argc = *argc_p;
char **argv = *argv_p;
{
int argc = *argc_p;
char **argv = *argv_p;
- if (argc) {
- fprintf(stderr, "Unknown action \"%s\", hence option \"%s\" is unparsable\n", au->id, *argv);
- } else {
+ if (argc)
+ fprintf(stderr,
+ "Unknown action \"%s\", hence option \"%s\" is unparsable\n",
+ au->id, *argv);
+ else
fprintf(stderr, "Unknown action \"%s\"\n", au->id);
fprintf(stderr, "Unknown action \"%s\"\n", au->id);
- if ((matches(*argv, "change") == 0) ||
+ return (matches(*argv, "change") == 0) ||
(matches(*argv, "replace") == 0) ||
(matches(*argv, "delete") == 0) ||
(matches(*argv, "get") == 0) ||
(matches(*argv, "replace") == 0) ||
(matches(*argv, "delete") == 0) ||
(matches(*argv, "get") == 0) ||
- (matches(*argv, "add") == 0))
- return 1;
-
- return 0;
-
+ (matches(*argv, "add") == 0);
}
int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
}
int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
argv++;
eap = 1;
#ifdef CONFIG_GACT
argv++;
eap = 1;
#ifdef CONFIG_GACT
#endif
continue;
} else if (strcmp(*argv, "flowid") == 0) {
#endif
continue;
} else if (strcmp(*argv, "flowid") == 0) {
tail = NLMSG_TAIL(n);
addattr_l(n, MAX_MSG, ++prio, NULL, 0);
tail = NLMSG_TAIL(n);
addattr_l(n, MAX_MSG, ++prio, NULL, 0);
return 0;
bad_val:
/* no need to undo things, returning from here should
return 0;
bad_val:
/* no need to undo things, returning from here should
+ * cause enough pain
+ */
fprintf(stderr, "parse_action: bad value (%d:%s)!\n", argc, *argv);
return -1;
}
fprintf(stderr, "parse_action: bad value (%d:%s)!\n", argc, *argv);
return -1;
}
-static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p)
+static int tc_action_gd(int cmd, unsigned int flags,
+ int *argc_p, char ***argv_p)
{
char k[FILTER_NAMESZ];
struct action_util *a = NULL;
{
char k[FILTER_NAMESZ];
struct action_util *a = NULL;
argc -= 1;
argv += 1;
if (argc <= 0) {
argc -= 1;
argv += 1;
if (argc <= 0) {
- fprintf(stderr, "Error: no index specified action: %s\n", k);
+ fprintf(stderr,
+ "Error: no index specified action: %s\n", k);
ret = -1;
goto bad_val;
}
ret = -1;
goto bad_val;
}
argc -= 1;
argv += 1;
} else {
argc -= 1;
argv += 1;
} else {
- fprintf(stderr, "Error: no index specified action: %s\n", k);
+ fprintf(stderr,
+ "Error: no index specified action: %s\n", k);
ret = -1;
goto bad_val;
}
ret = -1;
goto bad_val;
}
-static int tc_action_modify(int cmd, unsigned int flags, int *argc_p, char ***argv_p)
+static int tc_action_modify(int cmd, unsigned int flags,
+ int *argc_p, char ***argv_p)
{
int argc = *argc_p;
char **argv = *argv_p;
{
int argc = *argc_p;
char **argv = *argv_p;
strncpy(k, *argv, sizeof(k) - 1);
#ifdef CONFIG_GACT
strncpy(k, *argv, sizeof(k) - 1);
#ifdef CONFIG_GACT
#endif
a = get_action_kind(k);
if (a == NULL) {
#endif
a = get_action_kind(k);
if (a == NULL) {
addattr32(&req.n, MAX_MSG, TCA_ROOT_TIME_DELTA, msec_since);
tail4->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail4;
}
addattr32(&req.n, MAX_MSG, TCA_ROOT_TIME_DELTA, msec_since);
tail4->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail4;
}
- msg_size = NLMSG_ALIGN(req.n.nlmsg_len) - NLMSG_ALIGN(sizeof(struct nlmsghdr));
+ msg_size = NLMSG_ALIGN(req.n.nlmsg_len)
+ - NLMSG_ALIGN(sizeof(struct nlmsghdr));
if (event == RTM_GETACTION) {
if (event == RTM_GETACTION) {
- if (rtnl_dump_request(&rth, event, (void *)&req.t, msg_size) < 0) {
+ if (rtnl_dump_request(&rth, event,
+ (void *)&req.t, msg_size) < 0) {
perror("Cannot send dump request");
return 1;
}
perror("Cannot send dump request");
return 1;
}
while (argc > 0) {
if (matches(*argv, "add") == 0) {
while (argc > 0) {
if (matches(*argv, "add") == 0) {
- ret = tc_action_modify(RTM_NEWACTION, NLM_F_EXCL|NLM_F_CREATE, &argc, &argv);
+ ret = tc_action_modify(RTM_NEWACTION,
+ NLM_F_EXCL | NLM_F_CREATE,
+ &argc, &argv);
} else if (matches(*argv, "change") == 0 ||
matches(*argv, "replace") == 0) {
} else if (matches(*argv, "change") == 0 ||
matches(*argv, "replace") == 0) {
- ret = tc_action_modify(RTM_NEWACTION, NLM_F_CREATE|NLM_F_REPLACE, &argc, &argv);
+ ret = tc_action_modify(RTM_NEWACTION,
+ NLM_F_CREATE | NLM_F_REPLACE,
+ &argc, &argv);
} else if (matches(*argv, "delete") == 0) {
argc -= 1;
argv += 1;
} else if (matches(*argv, "delete") == 0) {
argc -= 1;
argv += 1;
argc -= 1;
argv += 1;
ret = tc_action_gd(RTM_GETACTION, 0, &argc, &argv);
argc -= 1;
argv += 1;
ret = tc_action_gd(RTM_GETACTION, 0, &argc, &argv);
- } else if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0
- || matches(*argv, "lst") == 0) {
+ } else if (matches(*argv, "list") == 0 ||
+ matches(*argv, "show") == 0 ||
+ matches(*argv, "lst") == 0) {
if (argc <= 2) {
act_usage();
return -1;
if (argc <= 2) {
act_usage();
return -1;
act_usage();
return -1;
} else {
act_usage();
return -1;
} else {
- fprintf(stderr, "Command \"%s\" is unknown, try \"tc actions help\".\n", *argv);
+ fprintf(stderr,
+ "Command \"%s\" is unknown, try \"tc actions help\".\n",
+ *argv);