Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

do not printf errors on stdout, please use fprintf(stderr,...) instead #9

Closed
devZer0 opened this issue Dec 28, 2014 · 4 comments
Closed

Comments

@devZer0
Copy link

devZer0 commented Dec 28, 2014

libsml prints errors on stdout and not on stderr.

please consider using fprintf(stderr,"error.....\n",value); instead

2 reasons for that:

1st:
root@wheezy:~/libsml# while true;do cat /dev/ttyUSB0 |./sml_server_stdio ;done
error: unknown type in sml_value_to_double
error: unknown type in sml_value_to_double
14797050.70 Wh
2012.40 Wh
error: unknown type in sml_value_to_double
20.70 W
^C

root@wheezy:~/libsml# while true;do cat /dev/ttyUSB0 |./sml_server_stdio ;done 2>/dev/null
14797050.80 Wh
2012.40 Wh
21.10 W
^C

2nd:
People re-implement sml_value_to_double() within their code - see: http://knx-user-forum.de/201949-post60.html

regards
roland

root@wheezy:~/libsml/libsml/sml/src# grep print * |egrep "warning|error"
sml_file.c: printf("warning: could not read the whole file\n");
sml_message.c: printf("error: message type %04X not yet implemented\n", *(msg_body->tag));
sml_message.c: printf("error: message type %04X not yet implemented\n", *(message_body->tag));
sml_transport.c: printf("error: unrecognized sequence\n");
sml_tree.c: printf("error: unknown tag in %s\n", FUNCTION);
sml_value.c: printf("error: unknown type in %s\n", FUNCTION);

@devZer0
Copy link
Author

devZer0 commented Dec 30, 2014

oh, and please consider using fprintf(stderr,"libsml error.....\n",value) or similar, so it`s more clear that the error is from libsml and not from the program implementing it

@r00t-
Copy link

r00t- commented Dec 31, 2014

more correctly, a library should ideally not print errors itself at all,
but report them to the caller.
(for example through a configurable error logging callback.)

@hmueller01
Copy link

@devZer0 I think you can close this with reference to volkszaehler.

@devZer0
Copy link
Author

devZer0 commented Jan 17, 2018

yes, i also just added this one: #14

@devZer0 devZer0 closed this as completed Jan 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants