batctl: output errors to stderr
PATCH 1/1 batctl: output errors to stderr
batctl outputs many errors to stdout instead of stderr. This patch corrects this behavior by redirecting errors and the usage texts to stderr.
---
From: Moritz Warning <[email protected]>
Date: Wed, 5 Dec 2012 00:59:21 +0100
Subject: [PATCH] batctl: output errors to stderr
Context: http://www.open-mesh.org/issues/167
--- bisect_iv.c | 34 ++++++++++++------------- debug.c | 36 +++++++++++++------------- debugfs.c | 2 +- functions.c | 18 ++++++------- ioctl.c | 10 ++++---- main.c | 68 +++++++++++++++++++++++++------------------------ ping.c | 30 +++++++++++----------- sys.c | 80 +++++++++++++++++++++++++++++----------------------------- tcpdump.c | 34 ++++++++++++------------- traceroute.c | 28 ++++++++++---------- translate.c | 2 +- vis.c | 8 +++--- 12 files changed, 176 insertions(+), 174 deletions(-)
bisect_iv.c +17 -17
@@ -37,15 +37,15 @@ static struct bat_node *curr_bat_node = NULL;static void bisect_iv_usage (void ) { -printf ("Usage: batctl bisect_iv [parameters] <file1> <file2> .. <fileN>\n" ); -printf ("parameters:\n" ); -printf (" \t -h print this help\n" ); -printf (" \t -l run a loop detection of given mac address or bat-host (default)\n" ); -printf (" \t -n don't convert addresses to bat-host names\n" ); -printf (" \t -o only display orig events that affect given mac address or bat-host\n" ); -printf (" \t -r print routing tables of given mac address or bat-host\n" ); -printf (" \t -s seqno range to limit the output\n" ); -printf (" \t -t trace seqnos of given mac address or bat-host\n" ); +fprintf (stderr,"Usage: batctl bisect_iv [parameters] <file1> <file2> .. <fileN>\n" ); +fprintf (stderr,"parameters:\n" ); +fprintf (stderr," \t -h print this help\n" ); +fprintf (stderr," \t -l run a loop detection of given mac address or bat-host (default)\n" ); +fprintf (stderr," \t -n don't convert addresses to bat-host names\n" ); +fprintf (stderr," \t -o only display orig events that affect given mac address or bat-host\n" ); +fprintf (stderr," \t -r print routing tables of given mac address or bat-host\n" ); +fprintf (stderr," \t -s seqno range to limit the output\n" ); +fprintf (stderr," \t -t trace seqnos of given mac address or bat-host\n" ); }static int compare_name (void *data1,void *data2)
@@ -1425,7 +1425,7 @@ static int get_orig_addr(char *orig_name, char *orig_addr) orig_mac =ether_aton (orig_name_tmp);if (!orig_mac) { -printf ("Error - the originator is not a mac address or bat-host name: %s\n" , orig_name); +fprintf (stderr,"Error - the originator is not a mac address or bat-host name: %s\n" , orig_name); goto err; }
@@ -1509,7 +1509,7 @@ int bisect_iv(int argc, char **argv) }if (argc <= found_args +1 ) { -printf ("Error - need at least 2 log files to compare\n" ); +fprintf (stderr,"Error - need at least 2 log files to compare\n" );bisect_iv_usage (); goto err; }
@@ -1517,7 +1517,7 @@ int bisect_iv(int argc, char **argv) node_hash =hash_new (64 , compare_name, choose_name);if (!node_hash) { -printf ("Error - could not create node hash table\n" ); +fprintf (stderr,"Error - could not create node hash table\n" ); goto err; }
@@ -1525,13 +1525,13 @@ int bisect_iv(int argc, char **argv) num_parsed_files =0 ;if ((rt_orig_ptr) && (trace_orig_ptr)) { -printf ("Error - the 'print routing table' option can't be used together with the the 'trace seqno' option\n" ); +fprintf (stderr,"Error - the 'print routing table' option can't be used together with the the 'trace seqno' option\n" ); goto err; }else if ((loop_orig_ptr) && (trace_orig_ptr)) { -printf ("Error - the 'loop detection' option can't be used together with the the 'trace seqno' option\n" ); +fprintf (stderr,"Error - the 'loop detection' option can't be used together with the the 'trace seqno' option\n" ); goto err; }else if ((loop_orig_ptr) && (rt_orig_ptr)) { -printf ("Error - the 'loop detection' option can't be used together with the the 'print routing table' option\n" ); +fprintf (stderr,"Error - the 'loop detection' option can't be used together with the the 'print routing table' option\n" ); goto err; }else if (rt_orig_ptr) { res =get_orig_addr (rt_orig_ptr, orig);
@@ -1555,7 +1555,7 @@ int bisect_iv(int argc, char **argv) seqno_max = seqno_min;if (seqno_min > seqno_max) { -printf ("Error - the sequence range minimum (%lli) should be smaller than the maximum (%lli)\n" , +fprintf (stderr,"Error - the sequence range minimum (%lli) should be smaller than the maximum (%lli)\n" , seqno_min, seqno_max); goto err; }
@@ -1577,7 +1577,7 @@ int bisect_iv(int argc, char **argv) }if (num_parsed_files <2 ) { -printf ("Error - need at least 2 log files to compare\n" ); +fprintf (stderr,"Error - need at least 2 log files to compare\n" ); goto err; }
debug.c +18 -18
@@ -80,16 +80,16 @@ const struct debug_table_data batctl_debug_tables[BATCTL_TABLE_NUM] = {void debug_table_usage (int debug_table) { -printf ("Usage: batctl [options] %s|%s [parameters]\n" , +fprintf (stderr,"Usage: batctl [options] %s|%s [parameters]\n" , batctl_debug_tables[debug_table].opt_long, batctl_debug_tables[debug_table].opt_short); -printf ("parameters:\n" ); -printf (" \t -h print this help\n" ); -printf (" \t -n don't replace mac addresses with bat-host names\n" ); -printf (" \t -H don't show the header\n" ); -printf (" \t -w [interval] watch mode - refresh the table continuously\n" ); +fprintf (stderr,"parameters:\n" ); +fprintf (stderr," \t -h print this help\n" ); +fprintf (stderr," \t -n don't replace mac addresses with bat-host names\n" ); +fprintf (stderr," \t -H don't show the header\n" ); +fprintf (stderr," \t -w [interval] watch mode - refresh the table continuously\n" );if (debug_table ==BATCTL_TABLE_ORIGINATORS ) -printf (" \t -t timeout interval - don't print originators not seen for x.y seconds \n" ); +fprintf (stderr," \t -t timeout interval - don't print originators not seen for x.y seconds \n" ); }int handle_debug_table (char *mesh_iface,int debug_table,int argc,char **argv)
@@ -117,20 +117,20 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv) }if (!sscanf (optarg,"%f" , &watch_interval)) { -printf ("Error - provided argument of '-%c' is not a number\n" , optchar); +fprintf (stderr,"Error - provided argument of '-%c' is not a number\n" , optchar);return EXIT_FAILURE ; }break ;case 't' :if (debug_table !=BATCTL_TABLE_ORIGINATORS ) { -printf ("Error - unrecognised option '-%c'\n" , optchar); +fprintf (stderr,"Error - unrecognised option '-%c'\n" , optchar);debug_table_usage (debug_table);return EXIT_FAILURE ; } read_opt |=NO_OLD_ORIGS ;if (!sscanf (optarg,"%f" , &orig_timeout)) { -printf ("Error - provided argument of '-%c' is not a number\n" , optchar); +fprintf (stderr,"Error - provided argument of '-%c' is not a number\n" , optchar);return EXIT_FAILURE ; }break ;
@@ -139,14 +139,14 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)break ;case '?' :if (optopt =='t' ) -printf ("Error - option '-t' needs a number as argument\n" ); +fprintf (stderr,"Error - option '-t' needs a number as argument\n" );else if (optopt =='w' ) { read_opt |=CLR_CONT_READ ;break ; }else -printf ("Error - unrecognised option: '-%c'\n" , optopt); +fprintf (stderr,"Error - unrecognised option: '-%c'\n" , optopt);return EXIT_FAILURE ;default :
@@ -157,7 +157,7 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv) debugfs_mnt =debugfs_mount (NULL );if (!debugfs_mnt) { -printf ("Error - can't mount or find debugfs\n" ); +fprintf (stderr,"Error - can't mount or find debugfs\n" );return EXIT_FAILURE ; }
@@ -169,10 +169,10 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)static void log_usage (void ) { -printf ("Usage: batctl [options] log [parameters]\n" ); -printf ("parameters:\n" ); -printf (" \t -h print this help\n" ); -printf (" \t -n don't replace mac addresses with bat-host names\n" ); +fprintf (stderr,"Usage: batctl [options] log [parameters]\n" ); +fprintf (stderr,"parameters:\n" ); +fprintf (stderr," \t -h print this help\n" ); +fprintf (stderr," \t -n don't replace mac addresses with bat-host names\n" ); }int log_print (char *mesh_iface,int argc,char **argv)
@@ -197,7 +197,7 @@ int log_print(char *mesh_iface, int argc, char **argv) debugfs_mnt =debugfs_mount (NULL );if (!debugfs_mnt) { -printf ("Error - can't mount or find debugfs\n" ); +fprintf (stderr,"Error - can't mount or find debugfs\n" );return EXIT_FAILURE ; }
debugfs.c +1 -1
@@ -85,7 +85,7 @@ const char *debugfs_find_mountpoint(void)/* give up and parse /proc/mounts */ fp =fopen ("/proc/mounts" ,"r" );if (fp ==NULL ) { -printf ("Error - can't open /proc/mounts for read: %s\n" , +fprintf (stderr,"Error - can't open /proc/mounts for read: %s\n" ,strerror (errno));return NULL ; }
functions.c +9 -9
@@ -130,20 +130,20 @@ static void file_open_problem_dbg(char *dir, char *fname, char *full_path)if (strstr (dir,"/sys/" )) {if (stat ("/sys/" , &st) !=0 ) { -printf ("Error - the folder '/sys/' was not found on the system\n" ); -printf ("Please make sure that the sys filesystem is properly mounted\n" ); +fprintf (stderr,"Error - the folder '/sys/' was not found on the system\n" ); +fprintf (stderr,"Please make sure that the sys filesystem is properly mounted\n" );return ; } }if (!file_exists (module_ver_path)) { -printf ("Error - batman-adv module has not been loaded\n" ); +fprintf (stderr,"Error - batman-adv module has not been loaded\n" );return ; }if (!file_exists (dir)) { -printf ("Error - mesh has not been enabled yet\n" ); -printf ("Activate your mesh by adding interfaces to batman-adv\n" ); +fprintf (stderr,"Error - mesh has not been enabled yet\n" ); +fprintf (stderr,"Activate your mesh by adding interfaces to batman-adv\n" );return ; }
@@ -154,10 +154,10 @@ static void file_open_problem_dbg(char *dir, char *fname, char *full_path)break ; } -printf ("Error - can't open file '%s': %s\n" , full_path,strerror (errno)); +fprintf (stderr,"Error - can't open file '%s': %s\n" , full_path,strerror (errno));if (*ptr) { -printf ("The option you called seems not to be compiled into your batman-adv kernel module.\n" ); -printf ("Consult the README if you wish to learn more about compiling options into batman-adv.\n" ); +fprintf (stderr,"The option you called seems not to be compiled into your batman-adv kernel module.\n" ); +fprintf (stderr,"Consult the README if you wish to learn more about compiling options into batman-adv.\n" ); } }
@@ -318,7 +318,7 @@ int write_file(char *dir, char *fname, char *arg1, char *arg2) write_len =write (fd, arg1,strlen (arg1) +1 );if (write_len <0 ) { -printf ("Error - can't write to file '%s': %s\n" , full_path,strerror (errno)); +fprintf (stderr,"Error - can't write to file '%s': %s\n" , full_path,strerror (errno)); goto out; }
ioctl.c +5 -5
@@ -50,7 +50,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr) ifr->ifr_data = (caddr_t)&drvinfo; err =ioctl (fd,SIOCETHTOOL , ifr);if (err <0 ) { -printf ("Error - can't open driver information: %s\n" ,strerror (errno)); +fprintf (stderr,"Error - can't open driver information: %s\n" ,strerror (errno)); goto out; }
@@ -64,7 +64,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr) strings =calloc (1 , sz_str +sizeof (struct ethtool_gstrings )); stats =calloc (1 , sz_stats +sizeof (struct ethtool_stats ));if (!strings || !stats) { -printf ("Error - out of memory\n" ); +fprintf (stderr,"Error - out of memory\n" ); goto out; }
@@ -74,7 +74,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr) ifr->ifr_data = (caddr_t )strings; err =ioctl (fd,SIOCETHTOOL , ifr);if (err <0 ) { -printf ("Error - can't get stats strings information: %s\n" ,strerror (errno)); +fprintf (stderr,"Error - can't get stats strings information: %s\n" ,strerror (errno)); goto out; }
@@ -83,7 +83,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr) ifr->ifr_data = (caddr_t ) stats; err =ioctl (fd,SIOCETHTOOL , ifr);if (err <0 ) { -printf ("Error - can't get stats information: %s\n" ,strerror (errno)); +fprintf (stderr,"Error - can't get stats information: %s\n" ,strerror (errno)); goto out; }
@@ -111,7 +111,7 @@ int ioctl_statistics_get(char *mesh_iface) fd =socket (AF_INET ,SOCK_DGRAM ,0 );if (fd <0 ) { -printf ("Error - can't open socket: %s\n" ,strerror (errno)); +fprintf (stderr,"Error - can't open socket: %s\n" ,strerror (errno)); goto out; }
main.c +35 -33
108 lines not on this page · raw message
ping.c +15 -15
@@ -44,14 +44,14 @@ char is_aborted = 0;void ping_usage (void ) { -printf ("Usage: batctl [options] ping [parameters] mac|bat-host|host_name|IPv4_address \n" ); -printf ("parameters:\n" ); -printf (" \t -c ping packet count \n" ); -printf (" \t -h print this help\n" ); -printf (" \t -i interval in seconds\n" ); -printf (" \t -t timeout in seconds\n" ); -printf (" \t -R record route\n" ); -printf (" \t -T don't try to translate mac to originator address\n" ); +fprintf (stderr,"Usage: batctl [options] ping [parameters] mac|bat-host|host_name|IPv4_address \n" ); +fprintf (stderr,"parameters:\n" ); +fprintf (stderr," \t -c ping packet count \n" ); +fprintf (stderr," \t -h print this help\n" ); +fprintf (stderr," \t -i interval in seconds\n" ); +fprintf (stderr," \t -t timeout in seconds\n" ); +fprintf (stderr," \t -R record route\n" ); +fprintf (stderr," \t -T don't try to translate mac to originator address\n" ); }void sig_handler (int sig)
@@ -124,7 +124,7 @@ int ping(char *mesh_iface, int argc, char **argv) }if (argc <= found_args) { -printf ("Error - target mac address or bat-host name not specified\n" ); +fprintf (stderr,"Error - target mac address or bat-host name not specified\n" );ping_usage ();return EXIT_FAILURE ; }
@@ -140,7 +140,7 @@ int ping(char *mesh_iface, int argc, char **argv) dst_mac =resolve_mac (dst_string);if (!dst_mac) { -printf ("Error - mac address of the ping destination could not be resolved and is not a bat-host name: %s\n" , dst_string); +fprintf (stderr,"Error - mac address of the ping destination could not be resolved and is not a bat-host name: %s\n" , dst_string); goto out; } }
@@ -154,7 +154,7 @@ int ping(char *mesh_iface, int argc, char **argv) debugfs_mnt =debugfs_mount (NULL );if (!debugfs_mnt) { -printf ("Error - can't mount or find debugfs\n" ); +fprintf (stderr,"Error - can't mount or find debugfs\n" ); goto out; }
@@ -163,7 +163,7 @@ int ping(char *mesh_iface, int argc, char **argv) ping_fd =open (icmp_socket,O_RDWR );if (ping_fd <0 ) { -printf ("Error - can't open a connection to the batman adv kernel module via the socket '%s': %s\n" , +fprintf (stderr,"Error - can't open a connection to the batman adv kernel module via the socket '%s': %s\n" , icmp_socket,strerror (errno));printf ("Check whether the module is loaded and active.\n" ); goto out;
@@ -203,7 +203,7 @@ int ping(char *mesh_iface, int argc, char **argv) icmp_packet_out.seqno =htons (++seq_counter);if (write (ping_fd, (char *)&icmp_packet_out, packet_len) <0 ) { -printf ("Error - can't write to batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno)); +fprintf (stderr,"Error - can't write to batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno)); goto sleep; }
@@ -231,7 +231,7 @@ read_packet: read_len =read (ping_fd, (char *)&icmp_packet_in, packet_len);if (read_len <0 ) { -printf ("Error - can't read from batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno)); +fprintf (stderr,"Error - can't read from batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno)); goto sleep; }
@@ -298,7 +298,7 @@ read_packet:printf ("From %s: Time to live exceeded (icmp_seq %hu)\n" , dst_string,ntohs (icmp_packet_in.seqno));break ;case BATADV_PARAMETER_PROBLEM : -printf ("Error - the batman adv kernel module version (%d) differs from ours (%d)\n" , +fprintf (stderr,"Error - the batman adv kernel module version (%d) differs from ours (%d)\n" , icmp_packet_in.header.version,BATADV_COMPAT_VERSION );printf ("Please make sure to use compatible versions!\n" ); goto out;
sys.c +40 -40
181 lines not on this page · raw message
tcpdump.c +17 -17
@@ -62,23 +62,23 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int readstatic void tcpdump_usage (void ) { -printf ("Usage: batctl tcpdump [parameters] interface [interface]\n" ); -printf ("parameters:\n" ); -printf (" \t -c compat filter - only display packets matching own compat version (%i)\n" ,BATADV_COMPAT_VERSION ); -printf (" \t -h print this help\n" ); -printf (" \t -n don't convert addresses to bat-host names\n" ); -printf (" \t -p dump specific packet type\n" ); -printf (" \t -x dump all packet types except specified\n" ); -printf ("packet types:\n" ); -printf (" \t\t%3d - batman ogm packets\n" ,DUMP_TYPE_BATOGM ); -printf (" \t\t%3d - batman icmp packets\n" ,DUMP_TYPE_BATICMP ); -printf (" \t\t%3d - batman unicast packets\n" ,DUMP_TYPE_BATUCAST ); -printf (" \t\t%3d - batman broadcast packets\n" ,DUMP_TYPE_BATBCAST ); -printf (" \t\t%3d - batman vis packets\n" ,DUMP_TYPE_BATVIS ); -printf (" \t\t%3d - batman fragmented packets\n" ,DUMP_TYPE_BATFRAG ); -printf (" \t\t%3d - batman tt / roaming packets\n" ,DUMP_TYPE_BATTT ); -printf (" \t\t%3d - non batman packets\n" ,DUMP_TYPE_NONBAT ); -printf (" \t\t%3d - batman ogm & non batman packets\n" ,DUMP_TYPE_BATOGM |DUMP_TYPE_NONBAT ); +fprintf (stderr,"Usage: batctl tcpdump [parameters] interface [interface]\n" ); +fprintf (stderr,"parameters:\n" ); +fprintf (stderr," \t -c compat filter - only display packets matching own compat version (%i)\n" ,BATADV_COMPAT_VERSION ); +fprintf (stderr," \t -h print this help\n" ); +fprintf (stderr," \t -n don't convert addresses to bat-host names\n" ); +fprintf (stderr," \t -p dump specific packet type\n" ); +fprintf (stderr," \t -x dump all packet types except specified\n" ); +fprintf (stderr,"packet types:\n" ); +fprintf (stderr," \t\t%3d - batman ogm packets\n" ,DUMP_TYPE_BATOGM ); +fprintf (stderr," \t\t%3d - batman icmp packets\n" ,DUMP_TYPE_BATICMP ); +fprintf (stderr," \t\t%3d - batman unicast packets\n" ,DUMP_TYPE_BATUCAST ); +fprintf (stderr," \t\t%3d - batman broadcast packets\n" ,DUMP_TYPE_BATBCAST ); +fprintf (stderr," \t\t%3d - batman vis packets\n" ,DUMP_TYPE_BATVIS ); +fprintf (stderr," \t\t%3d - batman fragmented packets\n" ,DUMP_TYPE_BATFRAG ); +fprintf (stderr," \t\t%3d - batman tt / roaming packets\n" ,DUMP_TYPE_BATTT ); +fprintf (stderr," \t\t%3d - non batman packets\n" ,DUMP_TYPE_NONBAT ); +fprintf (stderr," \t\t%3d - batman ogm & non batman packets\n" ,DUMP_TYPE_BATOGM |DUMP_TYPE_NONBAT ); }static int print_time (void )
traceroute.c +14 -14
@@ -43,11 +43,11 @@void traceroute_usage (void ) { -printf ("Usage: batctl [options] traceroute [parameters] mac|bat-host|host_name|IPv4_address \n" ); -printf ("parameters:\n" ); -printf (" \t -h print this help\n" ); -printf (" \t -n don't convert addresses to bat-host names\n" ); -printf (" \t -T don't try to translate mac to originator address\n" ); +fprintf (stderr,"Usage: batctl [options] traceroute [parameters] mac|bat-host|host_name|IPv4_address \n" ); +fprintf (stderr,"parameters:\n" ); +fprintf (stderr," \t -h print this help\n" ); +fprintf (stderr," \t -n don't convert addresses to bat-host names\n" ); +fprintf (stderr," \t -T don't try to translate mac to originator address\n" ); }int traceroute (char *mesh_iface,int argc,char **argv)
@@ -86,7 +86,7 @@ int traceroute(char *mesh_iface, int argc, char **argv) }if (argc <= found_args) { -printf ("Error - target mac address or bat-host name not specified\n" ); +fprintf (stderr,"Error - target mac address or bat-host name not specified\n" );traceroute_usage ();return EXIT_FAILURE ; }
@@ -102,7 +102,7 @@ int traceroute(char *mesh_iface, int argc, char **argv) dst_mac =resolve_mac (dst_string);if (!dst_mac) { -printf ("Error - mac address of the ping destination could not be resolved and is not a bat-host name: %s\n" , dst_string); +fprintf (stderr,"Error - mac address of the ping destination could not be resolved and is not a bat-host name: %s\n" , dst_string); goto out; } }
@@ -114,7 +114,7 @@ int traceroute(char *mesh_iface, int argc, char **argv) debugfs_mnt =debugfs_mount (NULL );if (!debugfs_mnt) { -printf ("Error - can't mount or find debugfs\n" ); +fprintf (stderr,"Error - can't mount or find debugfs\n" ); goto out; }
@@ -123,9 +123,9 @@ int traceroute(char *mesh_iface, int argc, char **argv) trace_fd =open (icmp_socket,O_RDWR );if (trace_fd <0 ) { -printf ("Error - can't open a connection to the batman adv kernel module via the socket '%s': %s\n" , +fprintf (stderr,"Error - can't open a connection to the batman adv kernel module via the socket '%s': %s\n" , icmp_socket,strerror (errno)); -printf ("Check whether the module is loaded and active.\n" ); +fprintf (stderr,"Check whether the module is loaded and active.\n" ); goto out; }
@@ -148,7 +148,7 @@ int traceroute(char *mesh_iface, int argc, char **argv) time_delta[i] =0.0 ;if (write (trace_fd, (char *)&icmp_packet_out,sizeof (icmp_packet_out)) <0 ) { -printf ("Error - can't write to batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno)); +fprintf (stderr,"Error - can't write to batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno));continue ; }
@@ -169,7 +169,7 @@ read_packet: read_len =read (trace_fd, (char *)&icmp_packet_in,sizeof (icmp_packet_in));if (read_len <0 ) { -printf ("Error - can't read from batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno)); +fprintf (stderr,"Error - can't read from batman adv kernel file '%s': %s\n" , icmp_socket,strerror (errno));continue ; }
@@ -202,9 +202,9 @@ read_packet:printf ("%s: Destination Host Unreachable\n" , dst_string); goto out;case BATADV_PARAMETER_PROBLEM : -printf ("Error - the batman adv kernel module version (%d) differs from ours (%d)\n" , +fprintf (stderr,"Error - the batman adv kernel module version (%d) differs from ours (%d)\n" , icmp_packet_in.header.version,BATADV_COMPAT_VERSION ); -printf ("Please make sure to use compatible versions!\n" ); +fprintf (stderr,"Please make sure to use compatible versions!\n" ); goto out;default :printf ("Unknown message type %d len %zd received\n" , icmp_packet_in.msg_type, read_len);
translate.c +1 -1
@@ -31,7 +31,7 @@static void translate_usage (void ) { -printf ("Usage: batctl [options] translate mac|bat-host|host_name|IPv4_address\n" ); +fprintf (stderr,"Usage: batctl [options] translate mac|bat-host|host_name|IPv4_address\n" ); }int translate (char *mesh_iface,int argc,char **argv)
vis.c +4 -4
@@ -58,9 +58,9 @@ static bool with_names = true;static void usage (void ) { -printf ("batctl vis_data dot {-h}{--no-TT|-T} {--no-2nd|-2} {--numbers|-n}\n" ); -printf ("or\n" ); -printf ("batctl vis_data json {-h}{--no-TT|-T} {--no-2nd|-2} {--numbers|-n}\n" ); +fprintf (stderr,"batctl vis_data dot {-h}{--no-TT|-T} {--no-2nd|-2} {--numbers|-n}\n" ); +fprintf (stderr,"or\n" ); +fprintf (stderr,"batctl vis_data json {-h}{--no-TT|-T} {--no-2nd|-2} {--numbers|-n}\n" ); }static void dot_print_tq (char *orig,char *from,const long tq)
@@ -171,7 +171,7 @@ static FILE *open_vis(char *mesh_iface) debugfs_mnt =debugfs_mount (NULL );if (!debugfs_mnt) { -printf ("Error - can't mount or find debugfs\n" ); +fprintf (stderr,"Error - can't mount or find debugfs\n" );return NULL ; }
Before someone asks - yes, it compiles and appears to work as intended.
Quoted 6 lines · Moritz Warning
batctl outputs many errors to stdout instead of stderr. This patch corrects this behavior by redirecting errors and the usage texts to stderr.
Signed-off-by Moritz Warning <moritzwarning at web.de>---
[..]
Quoted 5 lines · On Wednesday 05 December 2012 01:16:16 Moritz Warning wrote:
batctl outputs many errors to stdout instead of stderr. This patch corrects this behavior by redirecting errors and the usage texts to stderr.
Signed-off-by Moritz Warning <moritzwarning at web.de>
Your mail address looks wrong.
main.c int main(int argc, char **argv) · line 120
Quoted 7 lines
main.c +4
-2-if (strcmp (argv[1 ],"-h" ) ==0 ) - goto err; +if (strcmp (argv[1 ],"-h" ) ==0 ) { +print_usage (); +exit (EXIT_SUCCESS ); + }
This seems to be unrelated. Please remove it from the patch.
Kind regards,
Sven