Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp130371imm; Wed, 4 Jul 2018 19:48:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd+NGGho6neyWkCu5MKU8tK0pzik2e5JseZaMoMpW0llQl7BmDl9V9NMQtIqAghA+jpNfyu X-Received: by 2002:a65:5cc5:: with SMTP id b5-v6mr3791514pgt.425.1530758910803; Wed, 04 Jul 2018 19:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530758910; cv=none; d=google.com; s=arc-20160816; b=AW6fOmltSeGR/qnMNQqljwoubXB09aGKd2GbUYOFvu04F1iUcE02d3oTZkXoETpqBK u6AnOHIAZXCLUFNycxWx3VXFFcCCxgErpWBwp7AirCg2/tW1CWl/M7o3H6HrtxyYbtqB uimvDO37VfyN9WieuhHPkQlo13fu1+bTbEkj8Wq+Tp454H/t+UXZv7jTITbi3psn4/mn Y1bE4jBKslbdT2qp7r8CIHyWtjlDA/Gj9iiAcynMUf4ddVuf5O0xg2N59dT71ZsLZ3+3 xD/0KyfOFhLlwPhQlBeZQH+kky4AhPQJtEbiAfcmLbiiUoClW1eMeyr7QxH08zTRwd8t Q8aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=fdnpxHKbOELjeXkWRoa6WFaxD+raM8Vq4RmRYOI3p3I=; b=v/joGt4hAEMMfQU1/mXm2P5lmRG2HFmJmvrVYAGYtmm6qOIAhDsRbnEHev8OEyvS+b k2mg9n/59JkpRx2RiP8Hua85FgHGsuhCoIj6iwEBpZb+1PiDuHhwWHD2vCNMnIa0FeEa sbJaG4jREFO1cFgqHj/5/qea/sl5zogl5QQ198wIhZxMyfdaYtcUPpqN7867TUVvcLCV N3y7yvMDQp9/B4gcwWFa/5qKYhGhdoaqf6LjTbWSsBGiP740hfavLfWk+TmJHVH6fG5X 5dbi1+Y1cPWlWpiwo5ZtXE2OTmtPQTSXkwGR/gzSZ4n76iYyU7LQPL9uzTK0jYKYo9+x qpiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="G4p8DHY/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a67-v6si5243265pfb.348.2018.07.04.19.48.16; Wed, 04 Jul 2018 19:48:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="G4p8DHY/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753287AbeGECrh (ORCPT + 99 others); Wed, 4 Jul 2018 22:47:37 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:54678 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753012AbeGECrg (ORCPT ); Wed, 4 Jul 2018 22:47:36 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id w652kGfH001144; Thu, 5 Jul 2018 11:46:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w652kGfH001144 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1530758777; bh=fdnpxHKbOELjeXkWRoa6WFaxD+raM8Vq4RmRYOI3p3I=; h=From:To:Cc:Subject:Date:From; b=G4p8DHY/3PSxcsY7Xbbh+TFcre8CT9u8g7Qu79Nkn9lDL6Xtzm7r6aDLeAuCyyWKg UkAyXqVf/lDFQg4uI1Ifvzak4B33HGr8fuZHr5CmrPgIP7l9LVaeJdQwAD5ffgx/Gf EnKZ6V/yLCpuIRmMUePdJUr64NdRMusmG47SYB6ZJ6Ist2fZVANZ0UVIisEtsCaszK W/LUvZAi5ZnuLtv4TmlUynBd+r4XXaHIcN+INPQCyl6OPoRsUit20jx+DxFDn9p5Ct Qzjo400uRvOInRrlhvjpaaxQLOIU8N+g8I1Nnca3wBtGbaOLtdoYXONO5AnYONVvqf LS85s5ZzAPaiQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Dirk Gouders , Ulf Magnusson , Sam Ravnborg , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH] kconfig: handle format string before calling conf_message_callback() Date: Thu, 5 Jul 2018 11:46:12 +0900 Message-Id: <1530758772-31832-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As you see in mconf.c and nconf.c, conf_message_callback() hooks are likely to end up with the boilerplate of vsnprintf(). Process the string format before calling conf_message_callback() so that it receives a simple string. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 17 +++++++++++------ scripts/kconfig/lkc_proto.h | 2 +- scripts/kconfig/mconf.c | 9 +++------ scripts/kconfig/nconf.c | 7 ++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 5af25a0..d0988a9 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -105,16 +105,16 @@ static void conf_warning(const char *fmt, ...) conf_warnings++; } -static void conf_default_message_callback(const char *fmt, va_list ap) +static void conf_default_message_callback(const char *s) { printf("#\n# "); - vprintf(fmt, ap); + printf("%s", s); printf("\n#\n"); } -static void (*conf_message_callback) (const char *fmt, va_list ap) = +static void (*conf_message_callback)(const char *s) = conf_default_message_callback; -void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) +void conf_set_message_callback(void (*fn)(const char *s)) { conf_message_callback = fn; } @@ -122,10 +122,15 @@ void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) static void conf_message(const char *fmt, ...) { va_list ap; + char buf[4096]; + + if (!conf_message_callback) + return; va_start(ap, fmt); - if (conf_message_callback) - conf_message_callback(fmt, ap); + + vsnprintf(buf, sizeof(buf), fmt, ap); + conf_message_callback(buf); va_end(ap); } diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index b0cd52f..86c2675 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -10,7 +10,7 @@ int conf_write(const char *name); int conf_write_autoconf(int overwrite); bool conf_get_changed(void); void conf_set_changed_callback(void (*fn)(void)); -void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap)); +void conf_set_message_callback(void (*fn)(const char *s)); /* menu.c */ extern struct menu rootmenu; diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 82b27a0..83b5836 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -772,16 +772,13 @@ static void show_helptext(const char *title, const char *text) show_textbox(title, text, 0, 0); } -static void conf_message_callback(const char *fmt, va_list ap) +static void conf_message_callback(const char *s) { - char buf[PATH_MAX+1]; - - vsnprintf(buf, sizeof(buf), fmt, ap); if (save_and_exit) { if (!silent) - printf("%s", buf); + printf("%s", s); } else { - show_textbox(NULL, buf, 6, 60); + show_textbox(NULL, s, 6, 60); } } diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 208f7be..1ef232a 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1211,12 +1211,9 @@ static void conf(struct menu *menu) } } -static void conf_message_callback(const char *fmt, va_list ap) +static void conf_message_callback(const char *s) { - char buf[1024]; - - vsnprintf(buf, sizeof(buf), fmt, ap); - btn_dialog(main_window, buf, 1, ""); + btn_dialog(main_window, s, 1, ""); } static void show_help(struct menu *menu) -- 2.7.4