From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZGsk4-0001Vh-UJ for qemu-devel@nongnu.org; Sun, 19 Jul 2015 13:51:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZGsjw-0000YQ-UO for qemu-devel@nongnu.org; Sun, 19 Jul 2015 13:51:12 -0400 Received: from mail-wg0-x232.google.com ([2a00:1450:400c:c00::232]:36051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZGsjw-0000YM-NO for qemu-devel@nongnu.org; Sun, 19 Jul 2015 13:51:04 -0400 Received: by wgbcc4 with SMTP id cc4so22313396wgb.3 for ; Sun, 19 Jul 2015 10:51:04 -0700 (PDT) Sender: Paolo Bonzini References: <5b903011386171258cca188ac2b35ae320cdb340.1437263259.git.carlos.torres@rackspace.com> From: Paolo Bonzini Message-ID: <55ABE384.2040905@redhat.com> Date: Sun, 19 Jul 2015 19:51:00 +0200 MIME-Version: 1.0 In-Reply-To: <5b903011386171258cca188ac2b35ae320cdb340.1437263259.git.carlos.torres@rackspace.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 5/5] qmp: Add example usage of strto*l() qemu wrapper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Carlos L. Torres" , qemu-devel@nongnu.org Cc: stefanha@redhat.com On 19/07/2015 01:52, Carlos L. Torres wrote: > + int err; > > info->qemu = g_new0(VersionTriple, 1); > - info->qemu->major = strtol(version, &tmp, 10); > + err = qemu_strtol(version, &tmp, 10, &(info->qemu->major)); There are usually no parentheses around the argument of the & operator. > + if (err) { > + error_setg(errp, "There was a problem retrieving QEMU major version."); > + } I think it's okay to just assert that err is zero. Otherwise, this simple example is okay. Thanks! Paolo > tmp++; > - info->qemu->minor = strtol(tmp, &tmp, 10); > + > + err = qemu_strtol(tmp, &tmp, 10, &(info->qemu->minor)); > + if (err) { > + error_setg(errp, "There was a problem retrieving QEMU minor version."); > + } > tmp++; > - info->qemu->micro = strtol(tmp, &tmp, 10); > + > + err = qemu_strtol(tmp, &tmp, 10, &(info->qemu->micro)); > + if (err) { > + error_setg(errp, "There was a problem retrieving QEMU micro version."); > + }