From patchwork Tue Oct 23 19:57:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 1632551 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 0E206DF283 for ; Tue, 23 Oct 2012 20:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757488Ab2JWT7N (ORCPT ); Tue, 23 Oct 2012 15:59:13 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:62157 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756781Ab2JWT7J (ORCPT ); Tue, 23 Oct 2012 15:59:09 -0400 Received: by mail-gh0-f174.google.com with SMTP id g15so834680ghb.19 for ; Tue, 23 Oct 2012 12:59:09 -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=rCMjQrTcoroepE3yxILGUk0m5l3t4V+a4ITtIJ8HvrE=; b=Gha1KFf2kosBoL4U/ebhyK6vP0L0rzLlQGNJN9pdeKVMX7/IiCBk3vB3BU5Uj8adyP u3sNMU2sQKv39tSuPmpBZ146HHFrteYtwNhPO5o/EhZGfY9gdiFJMv2Jc11dFjuONuA5 JAjWTVayI/s0WBVZuyv9y5XlKazfADz7xl6xeSc6/ZzYQIOoG/6lvCmWTpqr0pxAKVZF VxYsXsgnGykloPY1q2xhUNeySaFMDO/DgFPkfjRxuy6S3kbJySctl1M2yXAwe0KfQk7f nsyPBUWjfu4L6p2T/PPy6dVFjKSb6arutpgSj+sYNpHLQ35KXzVH2qncE8smn5zh1YKV vhmQ== Received: by 10.236.77.229 with SMTP id d65mr12593715yhe.124.1351022349122; Tue, 23 Oct 2012 12:59:09 -0700 (PDT) Received: from localhost.localdomain ([186.153.120.250]) by mx.google.com with ESMTPS id k63sm12813347yhj.20.2012.10.23.12.59.06 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Oct 2012 12:59:08 -0700 (PDT) From: Ezequiel Garcia To: , Cc: Julia.Lawall@lip6.fr, kernel-janitors@vger.kernel.org, Ezequiel Garcia , Peter Senna Tschudin Subject: [PATCH 14/23] tuners/tda18271: Replace memcpy with struct assignment Date: Tue, 23 Oct 2012 16:57:17 -0300 Message-Id: <1351022246-8201-14-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; // Signed-off-by: Peter Senna Tschudin Signed-off-by: Ezequiel Garcia --- drivers/media/tuners/tda18271-maps.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/tuners/tda18271-maps.c b/drivers/media/tuners/tda18271-maps.c index fb881c6..b62e925 100644 --- a/drivers/media/tuners/tda18271-maps.c +++ b/drivers/media/tuners/tda18271-maps.c @@ -1290,13 +1290,11 @@ int tda18271_assign_map_layout(struct dvb_frontend *fe) switch (priv->id) { case TDA18271HDC1: priv->maps = &tda18271c1_map_layout; - memcpy(&priv->std, &tda18271c1_std_map, - sizeof(struct tda18271_std_map)); + priv->std = tda18271c1_std_map; break; case TDA18271HDC2: priv->maps = &tda18271c2_map_layout; - memcpy(&priv->std, &tda18271c2_std_map, - sizeof(struct tda18271_std_map)); + priv->std = tda18271c2_std_map; break; default: ret = -EINVAL;