From patchwork Tue Oct 23 19:57:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 1634921 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 662A2DF283 for ; Tue, 23 Oct 2012 21:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757377Ab2JWT6s (ORCPT ); Tue, 23 Oct 2012 15:58:48 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:61542 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757479Ab2JWT6q (ORCPT ); Tue, 23 Oct 2012 15:58:46 -0400 Received: by mail-gg0-f174.google.com with SMTP id k5so820742ggd.19 for ; Tue, 23 Oct 2012 12:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=iR3V63fGgRrcXFsz6pDwePaxA4aGemAdjIT3r7A76oE=; b=V2ypX6nn/gxWQKO7hBFvF+eEo9KQZXm21IPB4Q3vMvf9BiYno0aLwV1n3kA9cdMywa V2VlnvVvhEtVyAgS+7AHB7NGtOFXmVgeymWMs7Mn/iSrfa0AW2vJpdFunZ+S6BdyuiDy HpFyTzM5PNxRkF2vmsMOS30JT6SJw3A57vO7WwMmglR+2ZkLUe6yfzyE1uT5BGLncXOR Ha/G0zsFKBIaaMwhpp65PgLb/PNJbh5sPow6NUTyAgC4tovnl0JSmHpPEVU6Rp9U1hcI 7p8Mjv6JLxHBj385++02PAYQ1E445W5W6VPG2LVZaXjLvM6LEwXeorA1twmDTuhfPMAC ZhZg== Received: by 10.100.246.12 with SMTP id t12mr3920148anh.82.1351022326391; Tue, 23 Oct 2012 12:58:46 -0700 (PDT) Received: from localhost.localdomain ([186.153.120.250]) by mx.google.com with ESMTPS id k63sm12813347yhj.20.2012.10.23.12.58.44 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Oct 2012 12:58:45 -0700 (PDT) From: Ezequiel Garcia To: , Cc: Julia.Lawall@lip6.fr, kernel-janitors@vger.kernel.org, Ezequiel Garcia , Hans de Goede , Peter Senna Tschudin Subject: [PATCH 05/23] pwc: Replace memcpy with struct assignment Date: Tue, 23 Oct 2012 16:57:08 -0300 Message-Id: <1351022246-8201-5-git-send-email-elezegarcia@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1351022246-8201-1-git-send-email-elezegarcia@gmail.com> References: <1351022246-8201-1-git-send-email-elezegarcia@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This kind of memcpy() is error-prone. Its replacement with a struct assignment is prefered because it's type-safe and much easier to read. Found by coccinelle. Hand patched and reviewed. Tested by compilation only. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ identifier struct_name; struct struct_name to; struct struct_name from; expression E; @@ -memcpy(&(to), &(from), E); +to = from; // Cc: Hans de Goede Signed-off-by: Peter Senna Tschudin Signed-off-by: Ezequiel Garcia --- drivers/media/usb/pwc/pwc-if.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c index 42e36ba..cc5c7d8 100644 --- a/drivers/media/usb/pwc/pwc-if.c +++ b/drivers/media/usb/pwc/pwc-if.c @@ -1003,7 +1003,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id vb2_queue_init(&pdev->vb_queue); /* Init video_device structure */ - memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); + pdev->vdev = pwc_template; strcpy(pdev->vdev.name, name); pdev->vdev.queue = &pdev->vb_queue; pdev->vdev.queue->lock = &pdev->vb_queue_lock;