From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 55161A00C5; Wed, 16 Feb 2022 00:01:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D58C741142; Wed, 16 Feb 2022 00:01:05 +0100 (CET) Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by mails.dpdk.org (Postfix) with ESMTP id A8CF841142 for ; Wed, 16 Feb 2022 00:01:04 +0100 (CET) Received: by mail-pg1-f181.google.com with SMTP id d16so392724pgd.9 for ; Tue, 15 Feb 2022 15:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=60EbKOV+AQFZ961Tcrtc1mYU0iVRDKrHkSwKARumyEY=; b=5/8926etA58if29xHPi6Twd0dUKmNFcQpc0vINHESczh6ir2kRfc08ycPs+SUcupCY d05OVVIHKAKEL/lXhmm4atlpp54s7Zol0cpW81/I5RojcLbDR/iNRCdt6xEzL1y0ZvYl Z9lnIYCufD14s4ah3tu8rFtg0HMsZImJdnA/qnZ2DgghxuurQ8qX2aM54Io2KBcc3/0R S9ff55aBj8WnGe7/t5BmnIBCRE+Npj8rW35jdEVadcXbMOidDhVeR2txDSOoSEUolGyf UC53RIzS8PsxqGJWghxEsPsM+0WYAoYwQxlpRBFBhuYN6BkWIYwBV8GJ9wZUtBJhx0sD gpFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=60EbKOV+AQFZ961Tcrtc1mYU0iVRDKrHkSwKARumyEY=; b=hYjxDTdo0IZ7LSY6aHeSGlTZvxCy5GRQVZMV49pLo9kooMcv1yzNZWuWfnpYryUUIV fOqsEh2SLrTfe9YiD8IGG0o/8upnF9Ez8GSKlsieYC85MHxJ+j9309sTLiwfu/p2gaMq keqCo2kQGFpj8M5fCcAW3XQX6xdiGhEAarvA2mTEqBw2CJmGoQZcdFG+KNR6TL3rRRY6 Byu46BMT2z7CA8Ev+dy/JRm60XgPDgenraQvYpZzGpnvfbyU5bqwSO/uYNJ2hFqwk7eO tvKstMEAiiS5Bgdtcz0JzbJ1LAUAtS8oo0y0WiJ7MYzEfIxUIKPeTi8k4sWO3Gnpb7sF hu/w== X-Gm-Message-State: AOAM5328uedFTwRPTHVCEkpd1ZCq8EKBXz1s8Au0rGmalVRuOtwHIqwY GwgYusEoDcmehpqhbXuQggIkg/k9cMjj09Fs X-Google-Smtp-Source: ABdhPJxjdkCGxV7JajagIVp3P4Shu1+4JuVCUEhfOt0lCOyoM8/os/hPJNOYipWrb7mB6zLOZIpJMQ== X-Received: by 2002:a63:5662:: with SMTP id g34mr905563pgm.569.1644966062006; Tue, 15 Feb 2022 15:01:02 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id h25sm38204574pfn.208.2022.02.15.15.01.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 15:01:01 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC 1/2] devtools: add script to check for zero length array Date: Tue, 15 Feb 2022 15:00:57 -0800 Message-Id: <20220215230058.64760-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215230058.64760-1-stephen@networkplumber.org> References: <20220215230058.64760-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use the same script as Linux kernel to find and replace zero length arrays at end of structures. Flexible arrays were introduced in C99 and help catch some obvious errors (like incorrect sizeof). Signed-off-by: Stephen Hemminger --- devtools/cocci/zerolengtharray.cocci | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 devtools/cocci/zerolengtharray.cocci diff --git a/devtools/cocci/zerolengtharray.cocci b/devtools/cocci/zerolengtharray.cocci new file mode 100644 index 000000000000..50d8b00716ae --- /dev/null +++ b/devtools/cocci/zerolengtharray.cocci @@ -0,0 +1,17 @@ +// +// Replace all older style of one-element or zero length arrays +// with current flexible member arraya +// + +@@ +identifier S, member, array; +type T1, T2; +@@ + +struct S { + ... + T1 member; + T2 array[ +- 0 + ]; +}; -- 2.34.1