From patchwork Mon Oct 5 01:59:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11815999 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F168139F for ; Mon, 5 Oct 2020 02:00:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6D4C2073A for ; Mon, 5 Oct 2020 02:00:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vdv9KB6s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725848AbgJECAK (ORCPT ); Sun, 4 Oct 2020 22:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbgJECAK (ORCPT ); Sun, 4 Oct 2020 22:00:10 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40568C0613CE for ; Sun, 4 Oct 2020 19:00:10 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id e2so7161158wme.1 for ; Sun, 04 Oct 2020 19:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i986Yb8/I7uUX3wjqlQH37k3bwP/SWF3dFyy4q0txHI=; b=vdv9KB6su9IrPJdTSJM8LeJO+NwoJA1qQNizXSwt/eKAgwHJThCdTtzgytL/ogHG1i saV3Hlc/QHNTEpFOjmbVEOI/PLmIZURPZsI3JCrmMAN9xe8TVml0ZwytT2uLY4t3b3Oo Ta91WWUxfQjq25zRlAIDAuflBKkhnbLgq22gdQYY6CiCZ/spNR0xIRLxuGA1Em/8gCez BZu5BIIm9ZE6A2rLAI9IfveAH0UnuBW6C33eXW8qkVmBxwtiVhBRfTXFOa5kZcXlTYQY bhcisVve2FgFkAZbmlX/rbEF47Vk8kFBEw4BgvqULTwOf3xsKXX7okxQaGqpiYYSwsWn CvfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i986Yb8/I7uUX3wjqlQH37k3bwP/SWF3dFyy4q0txHI=; b=QhvbdwL10gfFX7CVHyoz5YnXBaAniNGeehidKWyiOrY4FVXekgUGUSS+ab86Raj2Wy 7672yikf78Bn6VTKloSDzxqwIiVpIzvxgBBe7imHw8qupOF49FLEzxmSCuIVPUQgtvoO HOzH1vLezen2tXXILhgI/mYx4N0e7IZe6ub+nbwcdzDttGq78phPc3jD1Cf509nvpU6b D0s2hTBQ6aS1Eck/YWeGwPSKB12RCwd3ddzFDZxfnn0J60zg+G6Z1HooSFvSa3jknOis xdA9IhS/T1PS4yiYcQFBzmn7RstkhJmBGvzpgkHpFm+QK/Kug3D1aU5Mpl/o/X0yFKAa gu+w== X-Gm-Message-State: AOAM532/wq+43OZ43FZVM76LKhluv5EtDm/xx4kDVptJZ3WYhxGrAPd0 +iTaK76SZe6kNpjSIvAd3jNIIMBsvYk= X-Google-Smtp-Source: ABdhPJy6/eK9z3U6XLYOWGguxM5KkKaycQUB7oWixEwwhxLlmughKVl7CiNX3/te3fHQKaUQmjqdgQ== X-Received: by 2002:a7b:c359:: with SMTP id l25mr13641968wmj.125.1601863208670; Sun, 04 Oct 2020 19:00:08 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:08 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 1/8] need to strip SYM_NODE before comparing types Date: Mon, 5 Oct 2020 03:59:55 +0200 Message-Id: <20201005020002.1108-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Every variable has a 'symbol type' of SYM_NODE which needs to be stripped before comparing with builtin types like int_ctype. Signed-off-by: Luc Van Oostenryck --- validation/varargs-format-dyn-prec.c | 11 +++++++++++ verify-format.c | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 validation/varargs-format-dyn-prec.c diff --git a/validation/varargs-format-dyn-prec.c b/validation/varargs-format-dyn-prec.c new file mode 100644 index 000000000000..a143f1661c84 --- /dev/null +++ b/validation/varargs-format-dyn-prec.c @@ -0,0 +1,11 @@ +extern void pf(const char *msg, ...) __attribute__((format(printf, 1, 2))); + +static void test(int prec) +{ + pf("%*s\n", prec, "xyz"); +} + +/* + * check-name: variadic formatting test dynamic precision + * check-command: sparse -Wformat $file + */ diff --git a/verify-format.c b/verify-format.c index 2da9d2069121..ba6cb5646dba 100644 --- a/verify-format.c +++ b/verify-format.c @@ -325,6 +325,9 @@ static int parse_format_printf_argfield(const char **fmtptr, if (ctype) { struct symbol *target = &int_ctype; + if (ctype->type == SYM_NODE) + ctype = ctype->ctype.base_type; + if (ctype != &int_ctype && ctype != &uint_ctype) { warning(expr->pos, "incorrect type for %s argument %d", which, argpos); info(expr->pos, " expected %s", show_typename(target)); From patchwork Mon Oct 5 01:59:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11816003 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8790139F for ; Mon, 5 Oct 2020 02:00:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD4532073A for ; Mon, 5 Oct 2020 02:00:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QqulwyJE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725841AbgJECAN (ORCPT ); Sun, 4 Oct 2020 22:00:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbgJECAN (ORCPT ); Sun, 4 Oct 2020 22:00:13 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54CB4C0613CE for ; Sun, 4 Oct 2020 19:00:11 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id g4so7715641wrs.5 for ; Sun, 04 Oct 2020 19:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=keH3L0wzalXZ10eUs6TPOk0xur2Z4Lt0B/mMQOdREuE=; b=QqulwyJEQsXtzX19scsAMYMJVmDnbzKFWdwSaSHQrAPabVW3EA5DnPUCDx3+p7O4fz BiiH5HupGtj7oqjGwddEg0NfJDBleU8ZIJIa878fUNATsUPCFjFJtmgab7tnzgoep5gu V3W2YCBVTAxyYa+kn91kO2vG8Afl4+VBn0D95Ttf9rysxZKdBtJv0uEQd1enDVjnSVJB hkmaV3pJBCzRICVnbPbGO3i8sSaWKJDkCRl5bp8AfPrTBEYnOveoKKLuOnXM1xECVi3Y zJPtgE+hvRZ6SfTvItg8gc7M6Zimn3Mq52AqsYw2p33Wpk7jYRu9s5WFTR8RUlm5V4Qh gt/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=keH3L0wzalXZ10eUs6TPOk0xur2Z4Lt0B/mMQOdREuE=; b=ty5jXbqEROjUd9K2T/BSzMmXDJermyQ6b0jGqQeQ9l28T3adV9F57IfJTvbjkgyH49 5+yIOR4Zrj31ahgCw85OvZL8vzDTpEF94b4XyckO2LbiPCjjmncfYKBzmixaLAQ27QSn QQO/0hN6NStu/MXk8U7yhj48HvvguCWl8CqQmsoyx1NL6T6H1zWQ3h0kg32FDyaSqIIf c8kvbV5If2SJHU3+8ec0xs8AsZYs5+NXJ0bOhpLeCeXIxQhP2pIwTv7Zps0W4SDc2ZpQ aJ3R6Q05WfrR7UyVrh06IBjobWK+RXBze2QTpNxiYKacuB2EUn05+IW5mOPl30WGsmmS 5P+A== X-Gm-Message-State: AOAM5306j2DgtcJiV8Yp37+rIv60BpxuMj36gQLS7rDJhRzq8vrhnLyN gwIo9b7A8v3B59k5NqL52w+WQuXMGko= X-Google-Smtp-Source: ABdhPJzp5qeuZb32hx5PcVgHhrTwdC1HivK1xcD7ejLY6RdpD+r06y5obnf0aiKpKLqvlaCNsy93yw== X-Received: by 2002:adf:ef03:: with SMTP id e3mr8419954wro.146.1601863209498; Sun, 04 Oct 2020 19:00:09 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:09 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 2/8] add helper get_nth_expression() Date: Mon, 5 Oct 2020 03:59:56 +0200 Message-Id: <20201005020002.1108-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org This will be used for -Wformat. Signed-off-by: Luc Van Oostenryck --- lib.h | 5 +++++ verify-format.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib.h b/lib.h index b35debc83288..957586dbd80a 100644 --- a/lib.h +++ b/lib.h @@ -199,6 +199,11 @@ static inline struct expression *first_expression(struct expression_list *head) return first_ptr_list((struct ptr_list *)head); } +static inline struct expression *get_nth_expression(struct expression_list *head, unsigned int n) +{ + return ptr_list_nth_entry((struct ptr_list *)head, n); +} + static inline pseudo_t first_pseudo(struct pseudo_list *head) { return first_ptr_list((struct ptr_list *)head); diff --git a/verify-format.c b/verify-format.c index ba6cb5646dba..939605f55ef5 100644 --- a/verify-format.c +++ b/verify-format.c @@ -113,11 +113,6 @@ static struct format_type printf_fmt_ptr_ref = { .test = printf_fmt_pointer, }; -static struct expression *get_nth_expression(struct expression_list *args, int nr) -{ - return ptr_list_nth_entry((struct ptr_list *)args, nr); -} - static int is_float_spec(char t) { return t == 'f' || t == 'g' || t == 'F' || t == 'G'; From patchwork Mon Oct 5 01:59:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11816007 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05BF2139F for ; Mon, 5 Oct 2020 02:00:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D622420759 for ; Mon, 5 Oct 2020 02:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bkc0cJSJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725869AbgJECAP (ORCPT ); Sun, 4 Oct 2020 22:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbgJECAN (ORCPT ); Sun, 4 Oct 2020 22:00:13 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C96C0613E9 for ; Sun, 4 Oct 2020 19:00:11 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id y15so7165913wmi.0 for ; Sun, 04 Oct 2020 19:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hu98vzIkNm3yxy0wFUENMtNDO91sLHD/IdNSpdq23q0=; b=bkc0cJSJe1d3OEdSp3l07H4Nxa+LLTaQvGP7TT3twSCPv3hl3z4UiUiCHebH8m+M8e Fqv8FUHT7yCjU5ufUhR+COAxns+l0xXLgSRlHXKUvnb0uKrREMZbsz7p3AJT52b79zwL QMIBQQ8U4bm6Fr20BGtuD3xo915/2UCvcEr9jYl1Hx/orhf6GUV4t6D/FVqIAErrcTz/ cQC8mN8iID5MbKP8tdoqbHrUObh3Csg1GuO74QI7SgZZj5xwW+ON9gZEBX652fOiDe1t mJGhY8fZtPl/KAvIbhumQoTAWr9eKDz62ErM1ChNgi+s9WKpZXpsf4a5Z2JfGdOwBa4o 9pQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hu98vzIkNm3yxy0wFUENMtNDO91sLHD/IdNSpdq23q0=; b=Gn2YJSTg1uRVbW8eQCOs9Y320vBpSq4D3gTFSxjzECWSweAleSkHusjfjhxvPDNG0o ZkBFTPbxGl4WRh4+BvNq9153M+LN1DtG7olCkMUwp2hcPUKgFWFzqmmIQ1Umt52rl/Oi HToNn48JhJsZeK6zJ3Ve/QQkmwi4oL8uioynzCuiPUzBxrA97djDzQ8Gd2hdsuAFVCJT A09gBrRuVXH0UaVEDU4NtBPN5hw14fe97geq7aJKcUrM/b2bwMGZBa/9ZvgW1c0a0ZRM NPDPn9oDIZZevXxkRW8OcrsEGc2Vxiik9hMzbytYBgU9X5ICo/wV07DycqWLDYpoRNbA yHAA== X-Gm-Message-State: AOAM5332xxiZcbRknFdwJblu0DYzwJbp7DVqjghb73iCtLgxjAEvRznr vS9ieNZfdEvLtUeQoXDwJkP4vhroatU= X-Google-Smtp-Source: ABdhPJzbFgQpmXI8RpywoL5wiPcfY8/2GhNHFNM76zRV7xiOJkqrorQ6rwF3+LEK1os5+Jk/JqoEFw== X-Received: by 2002:a1c:bc46:: with SMTP id m67mr14037833wmf.119.1601863210240; Sun, 04 Oct 2020 19:00:10 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:09 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 3/8] move the definition of FMT_{PRINTF,SCANF} Date: Mon, 5 Oct 2020 03:59:57 +0200 Message-Id: <20201005020002.1108-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Move these from parse.c to symbol.h so that they can be reused when verifying the format. Also, add a definition for unknown format type: FMT_UNKNOWN Signed-off-by: Luc Van Oostenryck --- parse.c | 6 ------ symbol.h | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/parse.c b/parse.c index 1b021b87549e..c2d29318149f 100644 --- a/parse.c +++ b/parse.c @@ -120,12 +120,6 @@ static void asm_modifier(struct token *token, unsigned long *mods, unsigned long *mods |= mod; } -/* the types of formatting from __attribute__((format)) */ -enum { - FMT_PRINTF = 0, - FMT_SCANF, -}; - static struct symbol_op typedef_op = { .type = KW_MODIFIER, .declarator = storage_specifier, diff --git a/symbol.h b/symbol.h index 55c7e3330ec3..0d5439ee93f7 100644 --- a/symbol.h +++ b/symbol.h @@ -95,6 +95,13 @@ extern struct context *alloc_context(void); DECLARE_PTR_LIST(context_list, struct context); +/* the types of formatting from __attribute__((format)) */ +enum { + FMT_UNKNOWN, + FMT_PRINTF, + FMT_SCANF, +}; + struct attr_format { unsigned short index; /* index in argument list for format string */ unsigned short first; /* where first variadic argument is */ From patchwork Mon Oct 5 01:59:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11816001 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DE8D92C for ; Mon, 5 Oct 2020 02:00:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 800B52073A for ; Mon, 5 Oct 2020 02:00:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pOiONhfh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725862AbgJECAN (ORCPT ); Sun, 4 Oct 2020 22:00:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbgJECAN (ORCPT ); Sun, 4 Oct 2020 22:00:13 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6AFEC061787 for ; Sun, 4 Oct 2020 19:00:12 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id s12so7703091wrw.11 for ; Sun, 04 Oct 2020 19:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UxhPmAqPArGssF1zP8+xwULOvnoGBLqwv1doNDi1zGs=; b=pOiONhfh5x2nH1FFCHoEPT1SCyB9gihG8mZ+/4Yc8dIHNQsVui5vVZeXetOukejUbI kZRBCMPubvTch/AJMVB9Kn/pyK/O5ah8x1nB3Lpk7j1XHH0D/oj/1h+iC6ogVTqRyYO0 tZdgj1T2IdqABxMcSD+wS6ZU0REwBAD63H1fPuRWcUgP6ruGGYBu1QU0CsywvDkbvPBu JG+JvQTzW00KImotgu2wRYZCIfE+1ePEwV0y/QHZQypbr5x+aoOnJplAYLsu5vGPdlfy sqQOzCeh4zuzSQvTgvbmfGlSk+LUKpIXwOLcFMAh1OKdHbsjynISVHcxxF01W7X/IIDu t2pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UxhPmAqPArGssF1zP8+xwULOvnoGBLqwv1doNDi1zGs=; b=HFCQPxX3h30zGK6d1+JejsZNf/tmypBI9O3nQgjYwJJyJX/ub1Bnl/RJfgqL9+/C5h fDXTgSQ7eCSJBy5qZFXbPQapbYvnJ/FjHwj2KbDe3Vs1EpU78mpxAsLCVDyfxGrGas1D ikJ6xWWR10nG/z3asCeLcwdY09pt0IdzAeA1s7yEHzA4IqH868XF3gE2PU6CyBQD54fE ilTZsPl/YMRVdHyvpJH4Ijo/TmUjG2Vdi2uIbSds1zd3NeI8DSaVzVLZ1NB/4OIjQyNQ krywxbRF4RKViu1ZmXLxh7gFw2JkTaT5xU7+Z/ybeVAP9Z6Ldyxt0KX/0zDl8OgCnONY OQow== X-Gm-Message-State: AOAM531Ps5JUEmAWntVdn7lKbu9OJdViadWbD5e7IrvzkA1E25UymOMG 0zzwZ2KqRnb8CNlmpc3UpEz9g1zgEHY= X-Google-Smtp-Source: ABdhPJyczHkjCrBB8n9TP18JVp8U2fjWeWzcPHsvE37l0Pb8pdsE0nf5xhlppCZKDafdKvqiqYsKUg== X-Received: by 2002:adf:f885:: with SMTP id u5mr14214307wrp.382.1601863211041; Sun, 04 Oct 2020 19:00:11 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:10 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 4/8] parse format attribute less verbosely Date: Mon, 5 Oct 2020 03:59:58 +0200 Message-Id: <20201005020002.1108-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The error handling in the parsing of the format attribute is a bit too verbose and to strict: *) the message "only printf format attribute supported" is just noise for any file using 'format(scanf, ...)' when -Wformat is set and is not needed if -Wformat is disabled, so remove it. *) the message "incorrect format attribute" is not needed because any parsing error will already be reported. OTOH, it is useful to check that the first argument is an identifier, so check this. Signed-off-by: Luc Van Oostenryck --- parse.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/parse.c b/parse.c index c2d29318149f..55cca01ec381 100644 --- a/parse.c +++ b/parse.c @@ -1215,17 +1215,18 @@ static int invalid_format_args(long long start, long long at) static struct token *attribute_format(struct token *token, struct symbol *attr, struct decl_state *ctx) { struct expression *args[3]; - struct symbol *fmt_sym = NULL; + int type = FMT_UNKNOWN; /* expecting format ( type, start, va_args at) */ token = expect(token, '(', "after format attribute"); - if (token_type(token) == TOKEN_IDENT) - fmt_sym = lookup_keyword(token->ident, NS_KEYWORD); - if (fmt_sym) - if (!fmt_sym->op || fmt_sym->op->type != KW_FORMAT) - fmt_sym = NULL; - + if (token_type(token) != TOKEN_IDENT) { + sparse_error(token->pos, "identifier expected for format type"); + } else { + struct symbol *sym = lookup_keyword(token->ident, NS_KEYWORD); + if (sym && sym->op && sym->op->type == KW_FORMAT) + type = sym->op->class; + } token = conditional_expression(token, &args[0]); token = expect(token, ',', "format attribute type"); token = conditional_expression(token, &args[1]); @@ -1233,11 +1234,10 @@ static struct token *attribute_format(struct token *token, struct symbol *attr, token = conditional_expression(token, &args[2]); token = expect(token, ')', "format attribute arg position"); - if (!fmt_sym || !args[0] || !args[1] || !args[2]) { - warning(token->pos, "incorrect format attribute"); - } else if (fmt_sym->op->class != FMT_PRINTF) { - /* skip anything that isn't printf for the moment */ - warning(token->pos, "only printf format attribute supported"); + if (!args[0] || !args[1] || !args[2]) { + // incorrect format attribute + } else if (type != FMT_PRINTF) { + // only printf-style is supported, skip anything else } else { long long start, at; From patchwork Mon Oct 5 01:59:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11816005 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB861112E for ; Mon, 5 Oct 2020 02:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF0412074F for ; Mon, 5 Oct 2020 02:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kmBpanVU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725898AbgJECAP (ORCPT ); Sun, 4 Oct 2020 22:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbgJECAO (ORCPT ); Sun, 4 Oct 2020 22:00:14 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F171C0613CE for ; Sun, 4 Oct 2020 19:00:13 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id o5so7701027wrn.13 for ; Sun, 04 Oct 2020 19:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R+9lZLwYpN0V305kUch8/+ndJnDuSCSGvACGMwx84qc=; b=kmBpanVUrQZWCKahOZ1k3Y0g9F8T2hVJMZiP7z7Pi5GiiAMgBdlRlF6YHY7WZ/vnVN 0VY4xHnUCKlo5RxO6q4x4/kisfNcGz3+3QFwKD0lRF62PtFDK/xfzDVZW7F45oOihATf NQljLBo3KS90GXwIa/yJqkACqO+wDHUJ7jw5n2yRARWQwk7eRqxRxwgr86NVStfbENFR eZS7j4/DsC4XyCRX6veC0KAm+z5kwhUlgS0WekSNO7j6WnuwWHnwISuKKeazyinGyDit xCwCuuZR/K8Eq7u3aar007Cvlv7iO3g3zFw1vkWrAEd9XWRD+8M5+aCUTuhCJ3O/JdsN sDxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R+9lZLwYpN0V305kUch8/+ndJnDuSCSGvACGMwx84qc=; b=EXD8EURaurKWvHTnu/2h4PoyY3LKFSWJk5zE3Qf5GLuNlt8STskiydtsDGmJOKB/6k 40bW9S/2WfwlvG4jN0DgKlJIstaP9d4Lbke8FWLZ2voSBBe3PGo3x50Vk3hGviCDeh9u ri8nCm5b0ZzgUB46/Gr9uPs8QnoNT4SlhCA455cCQBsvMylC2TeYjN/lsKutKAQW/bfT W+4czkNezlQv/Esl8uxSAsj6vbNuICvukw8g0yc+PR4wRccBdv78T9jdYIaf5R7kFvcJ fGTf8Aj6SQcZk7a1eHgUCh6VmLJ9Tp2bl01+VpsrDK9GFTMxt8WXwh7kcfYSsZrdm+4r c2oQ== X-Gm-Message-State: AOAM533K1QRxAlwRDke12HNkywDLcOnlvd3iC3S0IRt4w+VzXuifzwMs +VyssknwP3hHweIS5rVAT2AsgpZDfsQ= X-Google-Smtp-Source: ABdhPJxZa0JVlA/lP1T2CkgGo6L37TR0M8d1vWFSB/TDnFWeqbFzVCjhSkkxFGdlVM3EUcLVL/RNWg== X-Received: by 2002:adf:fe48:: with SMTP id m8mr148002wrs.127.1601863211877; Sun, 04 Oct 2020 19:00:11 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:11 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 5/8] call verify_format_attribute() unconditionally Date: Mon, 5 Oct 2020 03:59:59 +0200 Message-Id: <20201005020002.1108-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- evaluate.c | 4 +--- verify-format.c | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/evaluate.c b/evaluate.c index fb3c0adb2220..35ced8cb6fb5 100644 --- a/evaluate.c +++ b/evaluate.c @@ -2388,9 +2388,7 @@ int evaluate_arguments(struct symbol *fn, struct symbol_list *argtypes, } END_FOR_EACH_PTR(expr); FINISH_PTR_LIST(argtype); - if (fn && Wformat) - verify_format_attribute(fn, head); - + verify_format_attribute(fn, head); return 1; } diff --git a/verify-format.c b/verify-format.c index 939605f55ef5..2eaba6653686 100644 --- a/verify-format.c +++ b/verify-format.c @@ -452,6 +452,8 @@ void verify_format_attribute(struct symbol *fn, struct expression_list *args) struct expression *init; const char *fmt_string; + if (!fn || !Wformat) + return; if (!fn->ctype.format.index) return; From patchwork Mon Oct 5 02:00:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11816013 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 481CA139F for ; Mon, 5 Oct 2020 02:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A9022074F for ; Mon, 5 Oct 2020 02:00:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JiHnNxAC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725903AbgJECAS (ORCPT ); Sun, 4 Oct 2020 22:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbgJECAQ (ORCPT ); Sun, 4 Oct 2020 22:00:16 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DD4DC061787 for ; Sun, 4 Oct 2020 19:00:14 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id n15so1954476wrq.2 for ; Sun, 04 Oct 2020 19:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bCEyELoVH8XRyPWAiyQx08ewxKkaNHdJ7cxYj0FXCwI=; b=JiHnNxACqQaqdoYBDJteAsAqDq6YyR3OqLrdMMgG6kEO4tl8tHt2ybz20ukPqEF9n8 5+7984ClHGhQIGYR08Ftpo4HMSO5SViKU4ZwKpsU552JLLLkdFUPf+Xcz4aaZvxv1T0O hFFoDNzG76Fa9MOD//ho6JsYB5GCKfYEmpfYTFhgeCck40rnrd4SuXuidFtXYRn33DEJ /8ug2x6cftiKQlxDoeRaFRBkrqf6bk0tNSNqwG75ifEkfXafbH/hQRlQnov/bQtoxtil JOjuY1DkkkFZEtyyu6iSM1NaWS58YwSzhWuUu+e19E+M4FIGQPZzJ6QBWNdT7uhdJAKq lRSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bCEyELoVH8XRyPWAiyQx08ewxKkaNHdJ7cxYj0FXCwI=; b=jaAPgxKQTMypr537PYabJ8PAYKKNjsImxuupCgl28go1RgvZQMkbe3mj97KETvZ65e a1LCv+7DgR47K5GCHEL8WV3pzDkI1UYMEes4XFeKDrReDh3FxaHPpsfvJy0haR37WDLC 913ZRtUFA9UmhD3qvPhm7auGRM1UP9h+vLKwaeCP4qoBavIePJhrvP4uhdQNugg8DjMe 8GZUMrGMrVDp7NNIOZ16tYyyk3ICNnEol5lfDbznIwPvICrO2coUXrfuaYCDdU5XPRE7 jVRHtnrWZVnolZReSSLF1fZ+2EaHgFAsYzNVA1myLIJb4A8MCBWlWqgPih1BbzOZ+mj9 puig== X-Gm-Message-State: AOAM531WcBTPaopKf4wp6BUu68FoEw/F75BSxbx5nmv3lQWHfKG+PQb4 WP80sMs1+WtPhCH2dRfavQrTR6Q3yM4= X-Google-Smtp-Source: ABdhPJwfNqcl+SndPjOTTOl7g8V7799DzQC5iAM890pvAnaHCUFboruMh/qQnAt8oxrhn04Ttd39GA== X-Received: by 2002:adf:8484:: with SMTP id 4mr5401589wrg.334.1601863212642; Sun, 04 Oct 2020 19:00:12 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:12 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 6/8] s/data/type/ for struct format_type Date: Mon, 5 Oct 2020 04:00:00 +0200 Message-Id: <20201005020002.1108-7-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The name of the field 'data' in struct format_type seems to indicate that it can contain arbitrary untyped stuff but it's a 'struct symbol' pointer and always contains the expected type of the argument. So use a more specific name for it 'type'. Signed-off-by: Luc Van Oostenryck --- verify-format.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/verify-format.c b/verify-format.c index 2eaba6653686..95ff524c03cf 100644 --- a/verify-format.c +++ b/verify-format.c @@ -51,7 +51,7 @@ struct format_type { struct symbol *ctype, struct symbol **target, const char **typediff); - struct symbol *data; + struct symbol *type; }; struct format_state { @@ -67,7 +67,7 @@ static int printf_fmt_numtype(struct format_type *fmt, struct symbol *ctype, struct symbol **target, const char **typediff) { - struct symbol *type = fmt->data; + struct symbol *type = fmt->type; *target = type; return check_assignment_types(*target, expr, typediff); } @@ -133,7 +133,7 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type, } else if (*ptr == 'c') { ptr++; type->test = printf_fmt_numtype; - type->data = &char_ctype; + type->type = &char_ctype; } else if (*ptr == 'p') { ptr++; type->test = printf_fmt_print_pointer; @@ -152,12 +152,12 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type, if (*ptr == 'd' || *ptr == 'i') { ptr++; type->test = printf_fmt_numtype; - type->data = ssize_t_ctype; + type->type = ssize_t_ctype; } else if (*ptr == 'u' || *ptr == 'x' || *ptr == 'X' || *ptr == 'o') { ptr++; type->test = printf_fmt_numtype; - type->data = size_t_ctype; + type->type = size_t_ctype; } } else { if (*ptr == 'l') { @@ -190,16 +190,16 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type, type->test = printf_fmt_numtype; switch (szmod) { case -1: - type->data = &ushort_ctype; + type->type = &ushort_ctype; break; case 0: - type->data = &uint_ctype; + type->type = &uint_ctype; break; case 1: - type->data = &ulong_ctype; + type->type = &ulong_ctype; break; case 2: - type->data = &ullong_ctype; + type->type = &ullong_ctype; break; default: type->test = NULL; @@ -209,27 +209,27 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type, type->test = printf_fmt_numtype; switch (szmod) { case -1: - type->data = &short_ctype; + type->type = &short_ctype; break; case 0: - type->data = &int_ctype; + type->type = &int_ctype; break; case 1: - type->data = &long_ctype; + type->type = &long_ctype; break; case 2: - type->data = &llong_ctype; + type->type = &llong_ctype; break; default: type->test = NULL; } } else if (*ptr == 'L' && is_float_spec(ptr[1])) { type->test = printf_fmt_numtype; - type->data = &ldouble_ctype; + type->type = &ldouble_ctype; ptr += 2; } else if (is_float_spec(*ptr)) { type->test = printf_fmt_numtype; - type->data = szmod == 1 ? &ldouble_ctype : &double_ctype; + type->type = szmod == 1 ? &ldouble_ctype : &double_ctype; ptr++; } else if (*ptr == 'n') { /* pointer to an de-referenced int/etc */ // todo - we should construct pointer to int/etc // From patchwork Mon Oct 5 02:00:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11816009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BC1D92C for ; Mon, 5 Oct 2020 02:00:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D9E32073A for ; Mon, 5 Oct 2020 02:00:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IKW9nf9b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbgJECAP (ORCPT ); Sun, 4 Oct 2020 22:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbgJECAP (ORCPT ); Sun, 4 Oct 2020 22:00:15 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05208C0613A5 for ; Sun, 4 Oct 2020 19:00:15 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id l15so4860091wmh.1 for ; Sun, 04 Oct 2020 19:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZVoCPWeQx/wZcqHkMLZpG8oS9R3J5zBGi+HHDe26Vm4=; b=IKW9nf9bBEI7Z2qkOqOn+sKbTFkH5iebwImz1uogz3a7+4azvJ87UtTyeJh/+cQJsr V6dj8qCoBbfvA0nsUUyey+GSU0TUAS0rs8WvABelLCtZJ78N5nybgp+CP+qXFedDo42i ipKxFMLnMrsUqu/CwVnpatD2OjFywah/OdEEM9ZNuH78HmpDNnA4qk5IHj0JJC5wdvTD IHXGB/MT/B759hbDla5vhCHo15jI9L2PEjq1VqkwL+krefNtEikywcvzTooHqmky1xrg OZ4vv6yJM4G382NbGRnXORXflWjcOVTn3MM2+M5NF3VmvBpw+Us0/sWPGZnGf+w5b4au ulhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZVoCPWeQx/wZcqHkMLZpG8oS9R3J5zBGi+HHDe26Vm4=; b=Q16JGnvegaMfRhJjIW4PIOCfg+iwbMhrEUPV9otnnnMV87T+cF29x8xi8xgngwqkCL XCy4FF2XzsxQGv0A8Fb+Qcu/Ms/iAPMctk/AKTY5cHePkSh6BJKs35mFjbV+YXE3NPJm 6kBcqBcv96JOev6Ya+mmrQOM8RyhNvtzr0IIokNoheEyfsEhes6nURa04GGyvpB6xVnC 3bS/kTStvSfauwxk1wE40rnm+Ri9jPD1ymPwKQPEQmDyVJoi6uL+pVCzCV1CxNX4ZWGC xzI1PK7qEp6ofjgKH3p52m37Kii/0I4ViiYOcYp4cS67RIh6684gJOikhGp1dVn9lJ3C 3qfQ== X-Gm-Message-State: AOAM532GaeLrIUMpTke4uk91Voc+PqZo4SkrPuwT4rncPfLCUp6k6x8n x9UWxxLQL2kD2icanVRAEB0lbnNXPfE= X-Google-Smtp-Source: ABdhPJwyExTrnf2tc4pDQ7IyCj1et246Re65NqWF4NdwjqSrLbOqm9+DR84BknE8Mef75xNkefVgWw== X-Received: by 2002:a05:600c:219a:: with SMTP id e26mr15169177wme.185.1601863213458; Sun, 04 Oct 2020 19:00:13 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:12 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 7/8] add support for "%ls" Date: Mon, 5 Oct 2020 04:00:01 +0200 Message-Id: <20201005020002.1108-8-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- verify-format.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/verify-format.c b/verify-format.c index 95ff524c03cf..b27440b87c6b 100644 --- a/verify-format.c +++ b/verify-format.c @@ -77,7 +77,7 @@ static int printf_fmt_string(struct format_type *fmt, struct symbol *ctype, struct symbol **target, const char **typediff) { - *target = &const_string_ctype; + *target = fmt->type; return check_assignment_types(*target, expr, typediff); } @@ -130,6 +130,7 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type, if (*ptr == 's') { ptr++; type->test = printf_fmt_string; + type->type = &const_string_ctype; } else if (*ptr == 'c') { ptr++; type->test = printf_fmt_numtype; @@ -231,6 +232,10 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type, type->test = printf_fmt_numtype; type->type = szmod == 1 ? &ldouble_ctype : &double_ctype; ptr++; + } else if (*ptr == 's') { + type->test = printf_fmt_string; + type->type = &const_wstring_ctype; + ptr++; } else if (*ptr == 'n') { /* pointer to an de-referenced int/etc */ // todo - we should construct pointer to int/etc // // also should not have any flags or widths for this From patchwork Mon Oct 5 02:00:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11816011 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C94A92C for ; Mon, 5 Oct 2020 02:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF03A2074F for ; Mon, 5 Oct 2020 02:00:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gfwzySgH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725904AbgJECAS (ORCPT ); Sun, 4 Oct 2020 22:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbgJECAQ (ORCPT ); Sun, 4 Oct 2020 22:00:16 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2E76C0613CE for ; Sun, 4 Oct 2020 19:00:15 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id e18so1808021wrw.9 for ; Sun, 04 Oct 2020 19:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CtuCivygniPd6EyrCt51z5m0F/aX4W1u/gPyV7KoBuc=; b=gfwzySgHivtl7We/o04KoAzXiIFHQyMBhx1Oe1u/LoB17UEokAIuHSaRyNM4QsaBEd vPyutgl5g+qAFmTl/3mngXx8WCeVA0EdhSKxKdklpOP1caZU82zbAFzK2zsSkMyQzBAF f8jr/eBo49jBXl/H945HbDn8gffOsZ9AL24fZkHcrHW1x6aRkiiWrekxcRHmkwLYhkF/ XwrNQRHT6CCXV2CrC+XkDReHl9SdR+7h15UavFVhs3XnzL8sFXEojot6kpxA8DgAP+zm eVouI134VYedUsmDjhVw8B508alcYAif820Sst2yIOZCX2ruwF2sjGv9FXxo5BCbmwtW uP7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CtuCivygniPd6EyrCt51z5m0F/aX4W1u/gPyV7KoBuc=; b=ckJanZ6OR40EwRquQSnKWxcT3ytplKog9KivmgsKBHS3OJtfzVbIbULfsu9Kk32oga kLyuirWBjO0NsmtPprSnU6qphoMkzShH0LoN7bBBzQSJhAFLtBP+s5tQKcsXFjtOIYrQ maODPuf3MN6sAQ3GUlinANl7xxS4FUEZiQefMYBIcLCoQZozk72/r7KpolGcLU6A/IB/ Hvj1sfuOhr1iAXXFbOBJ9qSfXFBdE1jbqbm/RZDSQeN/OGDHoCucijqTVG0aRRrVpoDE 02LnTGwjIkd6q25gGoP0hQrVM9KxXfSyjG+JTv32BZSIuGNB2dENoXVAvPoD2wpER4bi /Ndw== X-Gm-Message-State: AOAM533TeeKGrplg7nejucQN0EcDNXsUkVq0a74WGTYsZCRpa2ATUh8o VCX1Xi3jfsrCn//Bfy8wNpWvTqqYo3I= X-Google-Smtp-Source: ABdhPJxzbEjmMldOIl1lUXQvpn0h8iz6ytvBfRCkDB0wc/RJ2t6dbMYPhBXU649XcC5ZYFq9Tdqs7w== X-Received: by 2002:adf:b1cb:: with SMTP id r11mr9249666wra.339.1601863214224; Sun, 04 Oct 2020 19:00:14 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:f14e:9b66:59e7:4769]) by smtp.gmail.com with ESMTPSA id b189sm5541132wmb.37.2020.10.04.19.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 19:00:13 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ben Dooks , Luc Van Oostenryck Subject: [PATCH 8/8] add support for "%Lx" (and "%Ls") Date: Mon, 5 Oct 2020 04:00:02 +0200 Message-Id: <20201005020002.1108-9-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> References: <20201005020002.1108-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- verify-format.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/verify-format.c b/verify-format.c index b27440b87c6b..4b4730285237 100644 --- a/verify-format.c +++ b/verify-format.c @@ -168,6 +168,9 @@ static struct format_type *parse_printf_get_fmt(struct format_type *type, szmod++; ptr++; } + } else if (*ptr == 'L') { + szmod++; + ptr++; } else { if (*ptr == 'h') { // short/char to int szmod = -1;