From patchwork Thu Jul 5 02:46:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 141101 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1412636ljj; Wed, 4 Jul 2018 19:47:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdaMVbvn7KtRw6rZGtDVWq+7TUDTCAHrNg0tAGTuA/KBiIkECI8YKAkBaE3kvbaUNZ5k+Nt X-Received: by 2002:a62:4a41:: with SMTP id x62-v6mr2610050pfa.45.1530758859699; Wed, 04 Jul 2018 19:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530758859; cv=none; d=google.com; s=arc-20160816; b=Cy+jIzlO1R9kxipqxuojZ25iP7zu8bVJJDKFFox4H4wpiuiuf33UBBx3Up1WNapqxl OI5CbyMERXg/KSPTW7M7JJKTpjTsA7LjfJ6peRCw1ouTAYHoEIFXQDJUO/4lmGbhiaZu HbLcNytLod1xSDPC89KfEYbVEtAFmEDCxkuIm1feVVg4f1ByZIs425LPFd/cr9G4NJtf Q2adrn01mN9SfrfLgEdPEz3yLJVcu2vn+/7KeOD3ss6XaYZnhyoOP+jpOcPCoX2qwlKb mfB4XOnl5Dj562lcee8xntKzkpSDlRc8xe9/qusVQIzQyBCv6kUbAAJ9qlpxDz4m29WK g0qw== 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 y23-v6si4712930pgk.427.2018.07.04.19.47.39; Wed, 04 Jul 2018 19:47:39 -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 S1753297AbeGECrh (ORCPT + 31 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(-) -- 2.7.4 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)