From patchwork Fri Sep 5 23:03:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 36909 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 768F3202E4 for ; Fri, 5 Sep 2014 23:03:49 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf61247360iec.4 for ; Fri, 05 Sep 2014 16:03:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=/dHymK6Xdsq1YO8d6qgsVCYbl34uLd+klfBo3NxVZdI=; b=fuW9a7u2EDAndYu6vlNZKbQWiX/gGzmNwUZN1JgcPV5ElLv075zlIJEcJKT4YveFvJ Ws7Ic4vhCZIBYJaGDRz3saf7qOxMgiogLYA9mujbcBbTYysSjY9W33vyHnrqyHmZrxWV jNEM17aTs5oOSww2lkcCgrXR6PvTNgiZgqjmn38x/bpgbE3FC+WgqazD0r5rdnp+LyP5 ZwBFOWOdy3H9Zy+rrpUKaCEgFH1aTDGAx2lLFgjP8ExsisFjscb/NTTx41f2GjA3pYYu Uh5+7805l7MOOBArZnJQ4+RNRBxBVApGbXXB4bI/HajMIX2tJT/WvSLsc4JoxLfFEqTk NxtQ== X-Gm-Message-State: ALoCoQktVsksFIwdZ7mNa4d7GsBIb4oz6Vb1w2YAjnrXWMCUlhh8J25FG4fyHBXVk6Ubw6joH5qq X-Received: by 10.182.18.8 with SMTP id s8mr8246948obd.21.1409958229106; Fri, 05 Sep 2014 16:03:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.230 with SMTP id j93ls914188qgd.40.gmail; Fri, 05 Sep 2014 16:03:49 -0700 (PDT) X-Received: by 10.220.172.8 with SMTP id j8mr4054308vcz.32.1409958229001; Fri, 05 Sep 2014 16:03:49 -0700 (PDT) Received: from mail-vc0-x232.google.com (mail-vc0-x232.google.com [2607:f8b0:400c:c03::232]) by mx.google.com with ESMTPS id sq9si2100436vdb.90.2014.09.05.16.03.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 16:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::232 as permitted sender) client-ip=2607:f8b0:400c:c03::232; Received: by mail-vc0-f178.google.com with SMTP id la4so12878248vcb.23 for ; Fri, 05 Sep 2014 16:03:48 -0700 (PDT) X-Received: by 10.52.253.39 with SMTP id zx7mr10836363vdc.2.1409958228909; Fri, 05 Sep 2014 16:03:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp148556vcb; Fri, 5 Sep 2014 16:03:48 -0700 (PDT) X-Received: by 10.68.68.134 with SMTP id w6mr162783pbt.110.1409958228071; Fri, 05 Sep 2014 16:03:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si6470739pdc.28.2014.09.05.16.03.46 for ; Fri, 05 Sep 2014 16:03:48 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754500AbaIEXDp (ORCPT + 26 others); Fri, 5 Sep 2014 19:03:45 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:50133 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752334AbaIEXDn (ORCPT ); Fri, 5 Sep 2014 19:03:43 -0400 Received: by mail-pa0-f54.google.com with SMTP id lj1so72348pab.13 for ; Fri, 05 Sep 2014 16:03:43 -0700 (PDT) X-Received: by 10.68.135.70 with SMTP id pq6mr277784pbb.10.1409958222910; Fri, 05 Sep 2014 16:03:42 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id b14sm2672217pdk.2.2014.09.05.16.03.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 16:03:41 -0700 (PDT) From: behanw@converseincode.com To: davem@davemloft.net, gustavo@padovan.org, johan.hedberg@gmail.com, marcel@holtmann.org Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, torvalds@linux-foundation.org, Behan Webster , Mark Charlebois , =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= Subject: [PATCH] bluetooth: LLVMLinux: Remove VLAIS from bluetooth/amp.c Date: Fri, 5 Sep 2014 16:03:34 -0700 Message-Id: <1409958214-5651-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: behanw@converseincode.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::232 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Behan Webster Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This patch allocates the appropriate amount of memory using an char array. The new code can be compiled with both gcc and clang. struct shash_desc contains a flexible array member member ctx declared with CRYPTO_MINALIGN_ATTR, so sizeof(struct shash_desc) aligns the beginning of the array declared after struct shash_desc with long long. No trailing padding is required because it is not a struct type that can be used in an array. The CRYPTO_MINALIGN_ATTR is required so that desc is aligned with long long as would be the case for a struct containing a member with CRYPTO_MINALIGN_ATTR. Signed-off-by: Behan Webster Signed-off-by: Mark Charlebois Signed-off-by: Jan-Simon Möller --- net/bluetooth/amp.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c index 016cdb6..2640d78 100644 --- a/net/bluetooth/amp.c +++ b/net/bluetooth/amp.c @@ -149,15 +149,14 @@ static int hmac_sha256(u8 *key, u8 ksize, char *plaintext, u8 psize, u8 *output) if (ret) { BT_DBG("crypto_ahash_setkey failed: err %d", ret); } else { - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(tfm)]; - } desc; + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(tfm)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)desc; - desc.shash.tfm = tfm; - desc.shash.flags = CRYPTO_TFM_REQ_MAY_SLEEP; + shash->tfm = tfm; + shash->flags = CRYPTO_TFM_REQ_MAY_SLEEP; - ret = crypto_shash_digest(&desc.shash, plaintext, psize, + ret = crypto_shash_digest(shash, plaintext, psize, output); }