linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).