Date: Wed, 19 May 2010 16:52:37 +0200 From: Christian Siebert <christian.siebert@cs.tu-chemnitz.de> To: freebsd-bugs@FreeBSD.org, bugs@openbsd.org Subject: wrong datatype in stdlib/merge.c Message-ID: <20100519165237.80222q5mxazqxtth@mail.tu-chemnitz.de>
next in thread | raw e-mail | index | archive | help
Hi all, this file hasn't been touch for quite a while, so I'm wondering why nobody discovered this bug before. Location: in src/lib/libc/stdlib/merge.c in function setup() What is wrong: variable 'tmp' is an 'int' type Correction: this variable 'tmp' should be an 'u_char' type While this variable 'tmp' is used correctly in the other function insertionsort(), it is here (in setup) used incorrectly. At best, the compiler detects this problem (icc for example issues a remark) and corrects it automatically. More likely (gcc?) it just turns into unnecessary type conversions, leading to some performance loss. In the worst case (I think/hope not), this might even be problematic, because the result is written back to memory within the macros swap() and reverse(). Since the bug should be easy to fix, I'm looking forward to the appropriate commit. Best regards, Christian PS: I don't know who is responsible for this function, but it seems to be no standard ANSI/ISO C, but rather a BSD extension (according to the man pages at least). So I just checked the OpenBSD and FreeBSD web cvs and both showed this bug.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100519165237.80222q5mxazqxtth>