Project

General

Profile

Bug #167 » errors_to_stderr.patch

M W, 12/04/2012 03:09 AM

View differences:

bisect_iv.c
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;
}
......
}
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;
}
......
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;
}
......
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);
......
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;
}
......
}
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
}
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;
......
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:
......
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_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
/* 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
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;
}
......
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");
}
}
......
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
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;
}
......
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;
}
......
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;
}
......
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;
}
......
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
if ((argc > 1) && (strcmp(argv[1], "-m") == 0)) {
if (argc < 3) {
printf("Error - the option '-m' needs a parameter\n");
fprintf(stderr, "Error - the option '-m' needs a parameter\n");
goto err;
}
......
}
if (argc < 2) {
printf("Error - no command specified\n");
fprintf(stderr, "Error - no command specified\n");
goto err;
}
if (strcmp(argv[1], "-h") == 0)
goto err;
if (strcmp(argv[1], "-h") == 0) {
print_usage();
exit(EXIT_SUCCESS);
}
if (strcmp(argv[1], "-v") == 0) {
printf("batctl %s [batman-adv: ", SOURCE_VERSION);
......
goto out;
}
printf("Error - no valid command or debug table specified: %s\n", argv[1]);
fprintf(stderr, "Error - no valid command or debug table specified: %s\n", argv[1]);
print_usage();
}
ping.c
}
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;
}
......
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;
}
}
......
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;
}
......
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;
......
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;
}
......
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;
}
......
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
int res;
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");
goto err;
}
path_buff = malloc(PATH_BUFF_LEN);
if (!path_buff) {
printf("Error - could not allocate path buffer: out of memory ?\n");
fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
goto err;
}
iface_base_dir = opendir(SYS_IFACE_PATH);
if (!iface_base_dir) {
printf("Error - the directory '%s' could not be read: %s\n",
fprintf(stderr, "Error - the directory '%s' could not be read: %s\n",
SYS_IFACE_PATH, strerror(errno));
printf("Is the batman-adv module loaded and sysfs mounted ?\n");
fprintf(stderr, "Is the batman-adv module loaded and sysfs mounted ?\n");
goto err_buff;
}
......
if ((strcmp(argv[1], "add") != 0) && (strcmp(argv[1], "a") != 0) &&
(strcmp(argv[1], "del") != 0) && (strcmp(argv[1], "d") != 0)) {
printf("Error - unknown argument specified: %s\n", argv[1]);
fprintf(stderr, "Error - unknown argument specified: %s\n", argv[1]);
interface_usage();
goto err;
}
if (argc == 2) {
printf("Error - missing interface name(s) after '%s'\n", argv[1]);
fprintf(stderr, "Error - missing interface name(s) after '%s'\n", argv[1]);
interface_usage();
goto err;
}
path_buff = malloc(PATH_BUFF_LEN);
if (!path_buff) {
printf("Error - could not allocate path buffer: out of memory ?\n");
fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
goto err;
}
......
path_buff[PATH_BUFF_LEN - 1] = '\0';
if (!file_exists(path_buff)) {
printf("Error - interface does not exist: %s\n", argv[i]);
fprintf(stderr, "Error - interface does not exist: %s\n", argv[i]);
continue;
}
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");
goto err;
}
printf("Error - interface type not supported by batman-adv: %s\n", argv[i]);
fprintf(stderr, "Error - interface type not supported by batman-adv: %s\n", argv[i]);
continue;
}
......
ptr++;
}
printf("Error - the supplied argument is invalid: %s\n", argv[1]);
printf("The following values are allowed:\n");
fprintf(stderr, "Error - the supplied argument is invalid: %s\n", argv[1]);
fprintf(stderr, "The following values are allowed:\n");
ptr = batctl_settings[setting].params;
while (*ptr) {
......
goto out;
opt_err:
printf("Error - the supplied argument is invalid: %s\n", argv[1]);
printf("The following values are allowed:\n");
fprintf(stderr, "Error - the supplied argument is invalid: %s\n", argv[1]);
fprintf(stderr, "The following values are allowed:\n");
ptr = sysfs_param_server;
while (*ptr) {
traceroute.c
}
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;
}
......
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;
}
}
......
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;
}
......
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;
}
......
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;
}
......
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;
}
......
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);
vis.c
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;
}
(1-1/2)