From patchwork Sat Jun 15 18:36:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 10997247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77B0814BB for ; Sat, 15 Jun 2019 18:36:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CE512873E for ; Sat, 15 Jun 2019 18:36:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DB7D28748; Sat, 15 Jun 2019 18:36:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1C892873E for ; Sat, 15 Jun 2019 18:36:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726781AbfFOSgn (ORCPT ); Sat, 15 Jun 2019 14:36:43 -0400 Received: from mout.web.de ([212.227.15.3]:55135 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbfFOSgm (ORCPT ); Sat, 15 Jun 2019 14:36:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1560623796; bh=Wmfgh3fPFhvEssLU81wgEHXAg+65tIQud1oFnvhWvX4=; h=X-UI-Sender-Class:Subject:From:To:Cc:References:Date:In-Reply-To; b=ZD647P41qtJkZ7Rj3916HueAimoeuFneCSAph+QPeZams94h0OzrbRRCuMk7pLysS FKlKFo5m48xba0xj+cL+XiaUQ0lSryF9bgdqlyoYy+liiWvjz8nftYF8IbulZlvkXk k0tFrTEzI+/ybV7Gd2NcGZC8ZEUL0RT7t2e1DcDs= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.23] ([79.203.26.169]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MYefK-1i7a3K0SjS-00VMyR; Sat, 15 Jun 2019 20:36:36 +0200 Subject: [PATCH 2/2] use COPY_ARRAY for copying arrays From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git Mailing List Cc: Junio C Hamano References: Message-ID: Date: Sat, 15 Jun 2019 20:36:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:lr3DFxOYjUI/L1lKNEuf1jr0ZWzyDhNcFqMD/0jwcayue2YsCrj 2Pjt0Wwp/822Gk9/GMy2MR/MW8i21GVto1sntyA6Ka8J7FnZZpS55K9nIB2DQb+HhAZSJBr c7sQp2lUsrRzqWyrnZ+TMh4VnOmHe9320f9tXJOqNtBZs5xQygqLxnS2n9dPinaMS+2T0nb qTx1al+vTLqy15WrK3TCg== X-UI-Out-Filterresults: notjunk:1;V03:K0:A/5XySQxjCQ=:HWe4SjuipQZxt54Ku/g7Ty dYSk1ZfjPpQnkA4AGLZWHaLmWGK+8xiPceSCBMOi2VQi7lVKzlOep/rXHomLxTL8Rw5aom7TG N5ecUcL4hl3WP/6PWYwYwOpgptnhpbIVyKcqi2VWMaliigjEhWsr8Ro2jtzCXXoCgOghaj4ON gfR84sC7qN8VMtqaTMJ2s8C1tTs2rk/wBVfXX62ocl9S7X5EzRME9+gX2WSVkC+EN89IuUbs/ WmkRdbzfKggObNqzcBQyfzkXZ5QG0XMpEfBMLPojaVuxdU3LUtbOPikheSq9sYYp9FZ6g8Cb/ HLnSpmA9j1B0/pl9O/83Ivi6JDl8nv8H5RhdvI/l3hVL0JOr+fkbb7GdzBnikt6Y7qs2MUDuO vrNknIVPY+b9Fo4aIxV3sIeahUsjuz3kroppFPCTIEDKd1mKrGVnFhCJv4J41CNCZMAuzeAH9 kCc3umtgR7TCL7xKYwinG1znOXnRXOWreVnzBw5VkJJFz8GaYboV1lzCZXKKLUz7NFqj0pDM+ eYF1kqYTwczJz7/13N+3CLp+FCOCYlDPxwdKga2ifAluM41seQE1W+MGw1wuP/h9TMAjZB4lw STddDu5P20/5wqbOLACIbHRq/XnCbil1cadBpxVjS/ht27dkhd1Rrrn9fPCMsLWcZl8ugaXmM 30Oi6M8VUodJlM8itAd/YSxNiwMH04KPfDj8Ai8fteeCKYebdxbaoTrCZQowu/x1ljJD4MCX7 n5RiBWCXWR2cm8f88ODDvxePUgy8yZgqSf+9p0tJgGP+TzQ701RTZttxd1XFgegIVszfGCPAp UiRjAT2O3Ac+Ra87QYMQwgIugSYYNLj7AqLK/CuDZkk+l1ChpoUKBbXUEmS13EsuuB2wOAqtk SI673lzEwyo5mlZH1S3hEKoCmmKCDwcIDAQu6pYPgyQw9KbmQWLLdRQTmbK4siMpFR9zjcPYB +4IIGanZl2UP7ro18INcymL+mcW8sEYU= Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert calls of memcpy(3) to use COPY_ARRAY, which shortens and simplifies the code a bit. Patch generated by Coccinelle and contrib/coccinelle/array.cocci. Signed-off-by: Rene Scharfe --- fast-import.c | 2 +- kwset.c | 2 +- packfile.c | 6 +++--- pretty.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) -- 2.22.0 diff --git a/fast-import.c b/fast-import.c index 76a7bd3699..6dfdd6801c 100644 --- a/fast-import.c +++ b/fast-import.c @@ -644,7 +644,7 @@ static struct tree_content *grow_tree_content( struct tree_content *r = new_tree_content(t->entry_count + amt); r->entry_count = t->entry_count; r->delta_depth = t->delta_depth; - memcpy(r->entries,t->entries,t->entry_count*sizeof(t->entries[0])); + COPY_ARRAY(r->entries, t->entries, t->entry_count); release_tree_content(t); return r; } diff --git a/kwset.c b/kwset.c index 4fb6455aca..090ffcafa2 100644 --- a/kwset.c +++ b/kwset.c @@ -475,7 +475,7 @@ kwsprep (kwset_t kws) for (i = 0; i < NCHAR; ++i) kwset->next[i] = next[U(trans[i])]; else - memcpy(kwset->next, next, NCHAR * sizeof(struct trie *)); + COPY_ARRAY(kwset->next, next, NCHAR); } /* Fix things up for any translation table. */ diff --git a/packfile.c b/packfile.c index d786ec7312..d55cb7f013 100644 --- a/packfile.c +++ b/packfile.c @@ -1269,7 +1269,7 @@ static enum object_type packed_to_object_type(struct repository *r, if (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) { poi_stack_alloc = alloc_nr(poi_stack_nr); ALLOC_ARRAY(poi_stack, poi_stack_alloc); - memcpy(poi_stack, small_poi_stack, sizeof(off_t)*poi_stack_nr); + COPY_ARRAY(poi_stack, small_poi_stack, poi_stack_nr); } else { ALLOC_GROW(poi_stack, poi_stack_nr+1, poi_stack_alloc); } @@ -1679,8 +1679,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset, && delta_stack == small_delta_stack) { delta_stack_alloc = alloc_nr(delta_stack_nr); ALLOC_ARRAY(delta_stack, delta_stack_alloc); - memcpy(delta_stack, small_delta_stack, - sizeof(*delta_stack)*delta_stack_nr); + COPY_ARRAY(delta_stack, small_delta_stack, + delta_stack_nr); } else { ALLOC_GROW(delta_stack, delta_stack_nr+1, delta_stack_alloc); } diff --git a/pretty.c b/pretty.c index ced0485257..e4ed14effe 100644 --- a/pretty.c +++ b/pretty.c @@ -106,8 +106,8 @@ static void setup_commit_formats(void) commit_formats_len = ARRAY_SIZE(builtin_formats); builtin_formats_len = commit_formats_len; ALLOC_GROW(commit_formats, commit_formats_len, commit_formats_alloc); - memcpy(commit_formats, builtin_formats, - sizeof(*builtin_formats)*ARRAY_SIZE(builtin_formats)); + COPY_ARRAY(commit_formats, builtin_formats, + ARRAY_SIZE(builtin_formats)); git_config(git_pretty_formats_config, NULL); }