skiselkov / libacfutils

58 stars 19 forks source link

conf_write_impl returns 0 instead of something positive when is_buf=FALSE #37

Closed olivierbutler closed 10 months ago

olivierbutler commented 10 months ago

with this fix conf_write_impl() returns 1 on the normal exit flow.

Other fix : widget.c about tts->font_face not initialized see https://github.com/skiselkov/libacfutils/issues/35 and https://github.com/skiselkov/libacfutils/issues/36

skiselkov commented 10 months ago

This doesn't seem right. conf_write_impl is supposed to return >= 0 on success, so 0 is a valid return value. There is an outstanding sign dropping issue in conf_write_buf, which might occur if conf_write_impl returns a negative number (this should never happen when buffer-writing, but I added explicit checks and casts to make that clear). I won't be changing conf_write_impl to always return a positive number, as a zero-length configuration is a valid state.

olivierbutler commented 10 months ago

My bad, I was thinking that 0 is not valid ( just see now that fprintf returning 0 is not an error )

anyway on Bpb need a small fix

if (fp != NULL && conf_write(bp_conf, fp)) { <------ logMsg(BP_INFO_LOG "Write config file %s", path); res = B_TRUE; } else { logMsg(BP_ERROR_LOG "Error writing configuration %s: %s", path, strerror(errno)); }

thank you for answering