diff --git a/examples/ax25dump.c b/examples/ax25dump.c index 496692b..5bd3385 100644 --- a/examples/ax25dump.c +++ b/examples/ax25dump.c @@ -98,8 +98,7 @@ int main(int argc, char **argv) { patty_ax25_frame frame; if ((decoded = patty_ax25_frame_decode_address(&frame, buf, readlen)) < 0) { - fprintf(stderr, "%s: %s: %s\n", - argv[0], "patty_ax25_frame_decode_address()", strerror(errno)); + printf("Invalid frame address\n"); goto error_ax25_frame_decode_address; } else { @@ -107,8 +106,7 @@ int main(int argc, char **argv) { } if ((decoded = patty_ax25_frame_decode_control(&frame, PATTY_AX25_FRAME_NORMAL, buf, decoded, readlen)) < 0) { - fprintf(stderr, "%s: %s: %s\n", - argv[0], "patty_ax25_frame_decode_control()", strerror(errno)); + printf("Invalid frame control\n"); goto error_ax25_frame_decode_control; } else { @@ -129,17 +127,19 @@ int main(int argc, char **argv) { buf, offset, readlen) < 0) { - fprintf(stderr, "%s: %s: %s\n", - argv[0], "patty_ax25_frame_decode_xid()", strerror(errno)); + printf("Invalid XID parameters\n"); goto error_ax25_frame_decode_xid; - } - - if (patty_print_params(stdout, ¶ms) < 0) { - goto error_io; + } else { + if (patty_print_params(stdout, ¶ms) < 0) { + goto error_io; + } } } +error_ax25_frame_decode_xid: +error_ax25_frame_decode_control: +error_ax25_frame_decode_address: if (patty_print_hexdump(stdout, buf, readlen) < 0) { goto error_io; } @@ -158,9 +158,6 @@ int main(int argc, char **argv) { return 0; error_io: -error_ax25_frame_decode_xid: -error_ax25_frame_decode_control: -error_ax25_frame_decode_address: patty_kiss_tnc_destroy(raw); error_kiss_tnc_new: diff --git a/examples/decode.c b/examples/decode.c index bbd68e2..e742d8b 100644 --- a/examples/decode.c +++ b/examples/decode.c @@ -65,8 +65,7 @@ int main(int argc, char **argv) { } if ((decoded = patty_ax25_frame_decode_address(&frame, buf, len)) < 0) { - fprintf(stderr, "%s: %s: %s\n", - argv[0], "patty_ax25_frame_decode_address()", strerror(errno)); + printf("Invalid frame address\n"); goto error_ax25_frame_decode_address; } else { @@ -74,8 +73,7 @@ int main(int argc, char **argv) { } if ((decoded = patty_ax25_frame_decode_control(&frame, PATTY_AX25_FRAME_NORMAL, buf, offset, len)) < 0) { - fprintf(stderr, "%s: %s: %s\n", - argv[0], "patty_ax25_frame_decode_control()", strerror(errno)); + printf("Invalid frame control\n"); goto error_ax25_frame_decode_control; } else { @@ -86,7 +84,7 @@ int main(int argc, char **argv) { fprintf(stderr, "%s: %s: %s\n", argv[0], "patty_print_frame_header()", strerror(errno)); - goto error_print; + goto error_io; } if (frame.type == PATTY_AX25_FRAME_XID) { @@ -96,19 +94,25 @@ int main(int argc, char **argv) { buf, offset, len) < 0) { - fprintf(stderr, "%s: %s: %s\n", - argv[0], "patty_ax25_frame_decode_xid()", strerror(errno)); + printf("Invalid XID parameters\n"); goto error_ax25_frame_decode_xid; - } - - if (patty_print_params(stdout, ¶ms) < 0) { - goto error_print; + } else { + if (patty_print_params(stdout, ¶ms) < 0) { + goto error_io; + } } } +error_ax25_frame_decode_xid: +error_ax25_frame_decode_control: +error_ax25_frame_decode_address: if (patty_print_hexdump(stdout, buf, len) < 0) { - goto error_print; + goto error_io; + } + + if (fflush(stdout) < 0) { + goto error_io; } } @@ -118,10 +122,7 @@ int main(int argc, char **argv) { return 0; -error_print: -error_ax25_frame_decode_xid: -error_ax25_frame_decode_control: -error_ax25_frame_decode_address: +error_io: error_kiss_tnc_recv: free(buf);