* [PATCH] cangw: Print error message on misspelled interface
@ 2014-02-05 15:48 Michal Sojka
2014-02-05 17:59 ` Oliver Hartkopp
0 siblings, 1 reply; 2+ messages in thread
From: Michal Sojka @ 2014-02-05 15:48 UTC (permalink / raw)
To: linux-can; +Cc: Michal Sojka
If can interface is misspelled or the kernel is configured without netlink
cangw displayed only generic usage instruction. Now, an appropriate error
message is displayed.
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
---
cangw.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/cangw.c b/cangw.c
index b908fe4..effb7ed 100644
--- a/cangw.c
+++ b/cangw.c
@@ -595,10 +595,18 @@ int main(int argc, char **argv)
case 's':
src_ifindex = if_nametoindex(optarg);
+ if (src_ifindex == 0) {
+ perror(optarg);
+ return 1;
+ }
break;
case 'd':
dst_ifindex = if_nametoindex(optarg);
+ if (dst_ifindex == 0) {
+ perror(optarg);
+ return 1;
+ }
break;
case 't':
--
1.8.5.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cangw: Print error message on misspelled interface
2014-02-05 15:48 [PATCH] cangw: Print error message on misspelled interface Michal Sojka
@ 2014-02-05 17:59 ` Oliver Hartkopp
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Hartkopp @ 2014-02-05 17:59 UTC (permalink / raw)
To: Michal Sojka, linux-can
On 05.02.2014 16:48, Michal Sojka wrote:
> If can interface is misspelled or the kernel is configured without netlink
> cangw displayed only generic usage instruction. Now, an appropriate error
> message is displayed.
>
> Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Tnx Michal!
> ---
> cangw.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/cangw.c b/cangw.c
> index b908fe4..effb7ed 100644
> --- a/cangw.c
> +++ b/cangw.c
> @@ -595,10 +595,18 @@ int main(int argc, char **argv)
>
> case 's':
> src_ifindex = if_nametoindex(optarg);
> + if (src_ifindex == 0) {
> + perror(optarg);
> + return 1;
> + }
> break;
>
> case 'd':
> dst_ifindex = if_nametoindex(optarg);
> + if (dst_ifindex == 0) {
> + perror(optarg);
> + return 1;
> + }
> break;
>
> case 't':
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-05 17:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-05 15:48 [PATCH] cangw: Print error message on misspelled interface Michal Sojka
2014-02-05 17:59 ` Oliver Hartkopp
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.