<div class="gmail_quote"><div>Hi Michal,<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>

> >     Log:<br>
> >     Creating a branch for Coverity reported problems<br>
><br>
><br>
> I'm very interested there!<br>
> Have you been able to get NUT part of the Coverity Scan program, or are<br>
> you running Coverity on your own?<br>
<br></div>
we have bought Coverity license, so I've checked it on my own.</blockquote><div><br>cool ^_^<br>I appreciate a lot, since this is a task, sweet to my heart, that has been neglected for years.<br>I've btw affected you the related task on Alioth...<br>





<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
> I'd love to see a summary report, to get an overall idea of the situation.<br>
><br>
> cheers,<br>
> Arnaud<br>
<br></div>
I was thinking what's the best way to send you several patches. I think new branch is the easiest way to do so.<br></blockquote><div> <br>it's indeed a good way!<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">






I've parsed Coverity scan result, removed false positives and fixed several issues. Not all of them are bugs, so check that branch and pick those you think are worthy. Coverity reports a lot of issues that are only "not that pretty code, but not worth to change it". So it's always a question where you should draw the line :)<br>






<br>
I've fixed everything I've found worth to fix, except 2 issues I don't know whether/how to fix. There are also a lot of reports about sprintf (Coverity reports every sprintf as "possibly dangerous", but hard to tell if it's worth it to fix it.</blockquote>





<div><br>the possibly dangerous nature is quite probably due to the possibility of overflow of the target buffer.<br>the simplest fix there is to replace sprintf calls by snprintf, and add the max size of the container.<br>
 </div>




<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> I've checked all of them if there was any obvious issue.)<br>
<br>
The two issues I did not fix:<br>
1) Error: REVERSE_INULL:<br>
clients/upsmon.c:789: deref_ptr_in_call: Dereferencing pointer "un". (The dereference is assumed on the basis of the 'nonnull' parameter attribute.)<br>
clients/upsmon.c:795: check_after_deref: Dereferencing "un" before a null check.<br>
<br>
I don't know if 'un' can be null, but it is checked for null after strcmp, if it can really be null, it should be checked before strcmp<br></blockquote><div> <br>"un" is the username inherited from upsmon.con->MONITOR line(s)<br>





all fields in this line are mandatory.<br>note that, historically, username was not mandatory.<br>no, it's mandatory, so the logic has changed, but not all the code.<br><br>there, prior to calling redefine_ups() (in addups()), all fields are checked (including username 'un').<br>
if 1 is NULL, the line is ignored.<br><br>thus, we can safely consider 'un' to be non NULL in redefine_ups()<br>I've fixed it in r3557.<br>



<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

2) Error: CONSTANT_EXPRESSION_RESULT: (4x)<br>
drivers/libshut.c:731: result_independent_of_<u></u>operands: (Start[0] & 0x80) == 5 is always false regardless of the values of its operands. This occurs as the logical operand of if.<br>
<br>
and exactly the same thing at<br>
libshut.c:973,<br>
mge-shut.c:527,<br>
mge-shut.c:839,<br>
<br>
in libshut.c and mge-shut.h, there are<br>
#define SHUT_TYPE_NOTIFY        0x05<br>
#define SHUT_PKT_LAST           0x80<br>
<br>
so if ((c & SHUT_PKT_LAST) == SHUT_TYPE_NOTIFY) can't be true<br>
(c & 0x80) == 0x05<br></blockquote><div><br>waow, the developer (sigh) was indeed brain damaged when he (I) did that ;-)<br>fixed in r3556<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


And that's all for first round :) Let me know if you have any question.<br>
</blockquote></div><br>very nice, thanks a lot ;-)<br><br>I've just merged your branch into the trunk (r3555).<br><br>cheers,<br clear="all">Arnaud<br>-- <br>Linux / Unix Expert R&D - Eaton - <a href="http://powerquality.eaton.com" target="_blank">http://powerquality.eaton.com</a><br>




Network UPS Tools (NUT) Project Leader - <a href="http://www.networkupstools.org/" target="_blank">http://www.networkupstools.org/</a><br>
Debian Developer - <a href="http://www.debian.org" target="_blank">http://www.debian.org</a><br>Free Software Developer - <a href="http://arnaud.quette.free.fr/" target="_blank">http://arnaud.quette.free.fr/</a><br><br>