[exim-dev] Clang warnings for RC2 #6

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Richard Clayton
Ημερομηνία:  
Προς: exim-dev
Αντικείμενο: [exim-dev] Clang warnings for RC2 #6

malware.c

1004   /* read report, linewise */
1005   while (kav_reportlen > 0)
1006     {
1007     if ((bread = recv_line(sock, tmpbuf, sizeof(tmpbuf), tmo)) < 0)
1008       break;
1009     kav_reportlen -= bread+1;
1010
1011     /* try matcher on the line, grab substring */
1012     if ((malware_name = m_pcre_exec(kav_re, tmpbuf)))
1013       break;
1014     }


clang's complaint about line 1007 is

warning: comparison of unsigned expression < 0 is always false
[-Wtautological-compare]

This occurs because for this scanner type bread is defined to be an
"unsigned long" whereas for the other types it is an int (and indeed
that's what recv_line returns)

I think the fix (which I suspect will prevent an infinite loop in this
case) is to just change the type of the variable:

921,922c921
<       unsigned long kav_reportlen;
<       int bread;
---

>       unsigned long kav_reportlen, bread;


-- 
richard                                                   Richard Clayton


Those who would give up essential Liberty, to purchase a little temporary
Safety, deserve neither Liberty nor Safety. Benjamin Franklin 11 Nov 1755