From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08FE3C433B4 for ; Thu, 29 Apr 2021 17:00:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB3C461457 for ; Thu, 29 Apr 2021 17:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240893AbhD2RBH (ORCPT ); Thu, 29 Apr 2021 13:01:07 -0400 Received: from mga06.intel.com ([134.134.136.31]:56680 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233302AbhD2RBG (ORCPT ); Thu, 29 Apr 2021 13:01:06 -0400 IronPort-SDR: gBTLXNvyzLhruyqLUDzwFuych7UBmg6N+CD6erB+cUPxqXqZc2Gd0Q2Fg+ZXDkMVZz+NY6Vaog tKr1DwbtHdTQ== X-IronPort-AV: E=McAfee;i="6200,9189,9969"; a="258340398" X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="258340398" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 10:00:18 -0700 IronPort-SDR: sPMnJ7iYBKZ20TQo60hrEApkUvzma7NPBCj0POW5iwjRF52DANpT6gnviwZzDqPU3m773p/Z2M ZWbIxyPnWe5g== X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="387016290" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 10:00:17 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lcA1O-008C6C-Gy; Thu, 29 Apr 2021 20:00:14 +0300 Date: Thu, 29 Apr 2021 20:00:14 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Kent Gibson , Linus Walleij , "open list:GPIO SUBSYSTEM" Subject: Re: [libgpiod][PATCH 2/3] libgpiosim: new library for controlling the gpio-sim module Message-ID: References: <20210429094734.9585-1-brgl@bgdev.pl> <20210429094734.9585-3-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Thu, Apr 29, 2021 at 03:07:49PM +0200, Bartosz Golaszewski wrote: > On Thu, Apr 29, 2021 at 1:23 PM Andy Shevchenko > wrote: > > On Thu, Apr 29, 2021 at 11:47:33AM +0200, Bartosz Golaszewski wrote: ... > > > +/* We don't have mkdtempat()... :( */ > > > > But we have tmpnam() / tmpnam_r(), why to reinvent it below? > > > > Because of this: > > $man tmpnam_r > ... > The created pathname has a directory prefix P_tmpdir. > ... > > And this: > > ./stdio.h:120:# define P_tmpdir "/tmp" Still you may advance the pointer by the length of P_tmpdir + 1. ... > > > + for (i = 0; i < num_names; i++) > > > + written += snprintf(buf + written, size - written, > > > + "\"%s\", ", names[i] ?: ""); > > > + buf[size - 2] = '\0'; > > > > Dunno if you can use asprintf() and actually replace NULL by "" in the original > > array. Ah, see you already using it somewhere else, why not here? > > > > Not sure what you mean, we can't use asprintf() to create a composite > string like what is needed here. Can you give me an example? I have got this after sending. Either you need to create a format string with va_args, or do it manually. -- With Best Regards, Andy Shevchenko