Received: from eggs.gnu.org ([2001:4830:134:3::10]:59868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ywpbu-0002xJ-2g for qemu-devel@nongnu.org; Mon, 25 May 2015 06:27:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ywpbq-0001ot-3Y for qemu-devel@nongnu.org; Mon, 25 May 2015 06:27:54 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:51460) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ywpbp-0001oe-Dq for qemu-devel@nongnu.org; Mon, 25 May 2015 06:27:50 -0400 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 May 2015 15:57:46 +0530 From: Nikunj A Dadhania In-Reply-To: <5562F416.2040301@ozlabs.ru> References: <1432023962-32406-1-git-send-email-nikunj@linux.vnet.ibm.com> <1432023962-32406-5-git-send-email-nikunj@linux.vnet.ibm.com> <5561B504.9050604@ozlabs.ru> <87a8wt8d8i.fsf@abhimanyu.in.ibm.com> <5562F416.2040301@ozlabs.ru> Date: Mon, 25 May 2015 15:57:41 +0530 Message-ID: <87y4kd6jfm.fsf@abhimanyu.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v5 4/4] spapr_pci: populate ibm,loc-code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy , qemu-devel@nongnu.org, david@gibson.dropbear.id.au Cc: qemu-ppc@nongnu.org, agraf@suse.de, mdroth@linux.vnet.ibm.com Alexey Kardashevskiy writes: > On 05/25/2015 02:58 PM, Nikunj A Dadhania wrote: >> Alexey Kardashevskiy writes: >> >>> >>>> + } >>>> + /* >>>> + * For emulated devices and VFIO-failure case, make up >>>> + * the loc-code. >>>> + */ >>>> + buf = g_strdup_printf("%s_%s:%02d:%02d.%1d", >>> >>> How is "1d" different here from just "d"? If @devfn>10, all digits will be >>> printed. >> >> A device can have only 8 functions, right ? > > > Yes. It is "%d" (decimal) so "1" is a minimum field length anyway ("1" only > makes sense for strings imho). And if a function number is bigger than 9, > print() will print all digits, not just the last one. So %d==%1d but I > would never grep for "%02d:%02d.%1d", I would grep for "%02d:%02d.%d". > > [few minutes later] And I just did. And I found that most places actually > use "%02x:%02x.%x" (trace-events, hw/pci/pci.c, hw/vfio/pci.c) and only one > (get_pci_host_devaddr) uses "%d" for a function (and even there "%02x" is > used for a bus and a slot, not "%02d"). Using "%02x:%02x.%x" should be fine then, I will change the code accordingly. Regards Nikunj