[Nut-upsuser] functional bug in code /clients/nutclient.cpp

Charles Lepple clepple at gmail.com
Thu Sep 3 13:11:52 UTC 2015


On Sep 1, 2015, at 4:26 AM, Paul Vermeer <paul at elspaulnz.com> wrote:
> 
> Hi nut users, (this is a re-send from the correct account)
>  
> With pleasure, I have been using the code provided. Managed to get all working properly, except for the nutclient lib in C.

As you have noticed, nutclient has a few rough edges. The original upsclient library has had a lot more testing, although it is written in straight C.

Be careful with some of the other nutclient wrappers. There are try/catch blocks that mask exceptions.
 
> Both functions stringset_to_strarr and stringvector_to_strarr have a similar bug in play. Although trivial in code, the coded function does not operate as intended.
> The pointer increment is missing (see added line marked yellow below [pstr++;]), which results in the same element being updated over and over again, and then only leaving the last element of the list in the array.
 
I created an issue on Github to track this: https://github.com/networkupstools/nut/issues/232 <https://github.com/networkupstools/nut/issues/232>

Should be easy to fix, but we also need to add some unit tests to keep this sort of thing from cropping up again.

> Kind regards, Paul Vermeer.
>  
>  
> (also I could not find out how to ‘install’ the include files properly using the autogen.sh / .configure and make and make install scripts. – had to copy them manually as I’m no expert in make scripts)
 
I was going to suggest that we should compare your settings to what Linux distributions do to package nutclient, but neither Debian nor Ubuntu has packaged it (only libupsclient*), and I haven't looked at other distributions yet. (This might be a sign...)

Which options are you passing to ./configure?

-- 
Charles Lepple
clepple at gmail



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20150903/e50434e8/attachment.html>


More information about the Nut-upsuser mailing list