From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v7 08/14] Introduce chr-testdev Date: Tue, 22 Jul 2014 20:06:06 +0200 Message-ID: <20140722180606.GA12651@potion.brq.redhat.com> References: <1405500463-20713-1-git-send-email-drjones@redhat.com> <1405500463-20713-9-git-send-email-drjones@redhat.com> <1124400215.1863219.1405503093424.JavaMail.zimbra@redhat.com> <20140716093312.GA14882@hawk.usersys.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Levente Kurusa , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, christoffer dall , pbonzini@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51374 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbaGVSGP (ORCPT ); Tue, 22 Jul 2014 14:06:15 -0400 Content-Disposition: inline In-Reply-To: <20140716093312.GA14882@hawk.usersys.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 2014-07-16 11:33+0200, Andrew Jones: > On Wed, Jul 16, 2014 at 05:31:33AM -0400, Levente Kurusa wrote: > > ----- Original Message ----- > > > [...] > > > +void chr_testdev_exit(int code) > > > +{ > > > + char buf[8]; > > > + int len; > > > + > > > + snprintf(buf, sizeof(buf), "%dq", code); > > > + len = strlen(buf); > > > > AFAIK, snprintf returns the number of characters written, so > > these two statements can be merged into one. > > You are correct. I'll do this for v8 (if a v8 is needed). snprintf returns the number of characters that would be written without truncation, so it wouldn't handle a very long code ;) I'd prefer the obvious v7, to finding a minimum with 'sizeof(buf) - 1'.