Package: qcontrol
Version: 0.4.2-1
Severity: wishlist
Tags: patch

        Hey,

 I was reading the qcontrol source and found a couple oddities which
 are probably harmless but could as well be fixed.

 If you build with signed-char, you get these warnings:
ts409.c:78: attention : case label value exceeds maximum value for type
ts409.c:79: attention : case label value exceeds maximum value for type
ts409.c:80: attention : case label value exceeds maximum value for type
ts409.c:81: attention : case label value exceeds maximum value for type
ts409.c:82: attention : case label value exceeds maximum value for type

 This can easily be fixed by declaring:
    char buf[100]
 in ts409.c:58:ts409_read_serial_events() as:
    unsigned char buf[100]
 (NB: unsigned char is the default on arm/armel)

 A similar buffer exists in ts209.c:57:ts209_read_serial_events(), but
 isn't checked against >= 128 values.

 Another oddity is with serial_read() -- again in both ts209.c and
 ts409.c:
static int serial_read(char *buf, int len)
{
        int err;

        err = read(serial, buf, len);
        buf[err] = 0;

        return err;
}

 if read returns an error, buf is still written to; it would be best to
 check for read errors before writing the trailing \0.


 These probably don't cause any error in practice, but I thought it was
 best to report them.


 While I'm at it, I also spotted this grep|head| sed constructs in 4
 places:
device=$(grep "Hardware[[:space:]]*:" /proc/cpuinfo 2>/dev/null | \
         head -n1 | sed "s/^[^:]*: //")

 You might want to use something like:
device=$(sed -rn 's/^Hardware[[:space:]]+: //p' /proc/cpuinfo | head -1)
 for readability or the following pure sed implementation:
device=$(sed -rn '/^Hardware[[:space:]]+:/ { s/[^:]+: //p; q }' /proc/cpuinfo)
 albeit I'm not sure why you need 2>/dev/null.

   HTH,
-- 
Loïc Minier



--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to