* [B.A.T.M.A.N.] [PATCH] batctl: exit on parse error in batctl ll
@ 2012-01-22 13:22 Simon Wunderlich
2012-01-22 13:46 ` Marek Lindner
0 siblings, 1 reply; 4+ messages in thread
From: Simon Wunderlich @ 2012-01-22 13:22 UTC (permalink / raw)
To: b.a.t.m.a.n
If the argument could not be understood, we should not try to
apply something, but return from the function.
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
sys.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/sys.c b/sys.c
index 9cdccba..ab7d75f 100644
--- a/sys.c
+++ b/sys.c
@@ -221,8 +221,11 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
log_level |= (1 << 1);
else if (strcmp(argv[i], "tt") == 0)
log_level |= (1 << 2);
- else
+ else {
log_level_usage();
+ free(path_buff);
+ return EXIT_FAILURE;
+ }
}
snprintf(str, sizeof(str), "%i", log_level);
--
1.7.8.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batctl: exit on parse error in batctl ll
2012-01-22 13:22 [B.A.T.M.A.N.] [PATCH] batctl: exit on parse error in batctl ll Simon Wunderlich
@ 2012-01-22 13:46 ` Marek Lindner
2012-01-22 18:31 ` [B.A.T.M.A.N.] [PATCHv2] " Simon Wunderlich
0 siblings, 1 reply; 4+ messages in thread
From: Marek Lindner @ 2012-01-22 13:46 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
On Sunday, January 22, 2012 21:22:12 Simon Wunderlich wrote:
> If the argument could not be understood, we should not try to
> apply something, but return from the function.
>
> Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> ---
> sys.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/sys.c b/sys.c
> index 9cdccba..ab7d75f 100644
> --- a/sys.c
> +++ b/sys.c
> @@ -221,8 +221,11 @@ int handle_loglevel(char *mesh_iface, int argc, char
> **argv) log_level |= (1 << 1);
> else if (strcmp(argv[i], "tt") == 0)
> log_level |= (1 << 2);
> - else
> + else {
> log_level_usage();
> + free(path_buff);
> + return EXIT_FAILURE;
> + }
> }
>
> snprintf(str, sizeof(str), "%i", log_level);
Can't we do "goto out" instead of duplicating the free/return. If we do so,
res should be initialized with EXIT_FAILURE.
Regards,
Marek
^ permalink raw reply [flat|nested] 4+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2] batctl: exit on parse error in batctl ll
2012-01-22 13:46 ` Marek Lindner
@ 2012-01-22 18:31 ` Simon Wunderlich
2012-01-26 19:47 ` Marek Lindner
0 siblings, 1 reply; 4+ messages in thread
From: Simon Wunderlich @ 2012-01-22 18:31 UTC (permalink / raw)
To: b.a.t.m.a.n
If the argument could not be understood, we should not try to
apply something, but return from the function.
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
sys.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/sys.c b/sys.c
index 9cdccba..56f55dd 100644
--- a/sys.c
+++ b/sys.c
@@ -221,8 +221,11 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
log_level |= (1 << 1);
else if (strcmp(argv[i], "tt") == 0)
log_level |= (1 << 2);
- else
+ else {
log_level_usage();
+ res = EXIT_FAILURE;
+ goto out;
+ }
}
snprintf(str, sizeof(str), "%i", log_level);
--
1.7.8.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2] batctl: exit on parse error in batctl ll
2012-01-22 18:31 ` [B.A.T.M.A.N.] [PATCHv2] " Simon Wunderlich
@ 2012-01-26 19:47 ` Marek Lindner
0 siblings, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2012-01-26 19:47 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
On Monday, January 23, 2012 02:31:03 Simon Wunderlich wrote:
> If the argument could not be understood, we should not try to
> apply something, but return from the function.
Applied in revision b320bf2.
Thanks,
Marek
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-26 19:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-22 13:22 [B.A.T.M.A.N.] [PATCH] batctl: exit on parse error in batctl ll Simon Wunderlich
2012-01-22 13:46 ` Marek Lindner
2012-01-22 18:31 ` [B.A.T.M.A.N.] [PATCHv2] " Simon Wunderlich
2012-01-26 19:47 ` Marek Lindner
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.