Received: from eggs.gnu.org ([2001:4830:134:3::10]:53367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5uPd-0003bS-Ur for qemu-devel@nongnu.org; Wed, 03 May 2017 09:33:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5uPa-0005Se-S5 for qemu-devel@nongnu.org; Wed, 03 May 2017 09:33:49 -0400 From: Markus Armbruster References: <20170503104441.1349-1-pbonzini@redhat.com> <874lx21880.fsf@dusky.pond.sub.org> <8e6b18bc-eb3e-c77f-2b9a-c797c3c15680@redhat.com> <87pofqxfna.fsf@dusky.pond.sub.org> Date: Wed, 03 May 2017 15:33:41 +0200 In-Reply-To: (Paolo Bonzini's message of "Wed, 3 May 2017 15:10:24 +0200") Message-ID: <87inlivzd6.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] jazz_led: fix bad snprintf List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-trivial@nongnu.org, leon.alrae@imgtec.com, qemu-devel@nongnu.org Paolo Bonzini writes: > On 03/05/2017 14:56, Markus Armbruster wrote: >>> snprintf writes at most 2 bytes here including the terminating NUL, so >>> the result is truncated". >> >> You're right; I forgot that snprintf() always adds a NUL. So this *is* >> broken: we write NUL instead of the second digit. Mentioning this in >> the commit message wouldn't hurt. > > Well, it does, see the quote. :) Yes, snprintf() truncates, but that's *internal* to jazz_led_text_update(). The *external* effect isn't quite truncation, it's writing NUL to the console instead of the second digit. That's truncation only if the console ignores NUL. It might; I don't know. Anyway, no big deal.