From patchwork Thu Sep 23 03:08:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 65488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4D04AB70CE for ; Thu, 23 Sep 2010 13:10:58 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OycBS-0003tf-CR; Thu, 23 Sep 2010 03:09:18 +0000 Received: from smtp.gentoo.org ([140.211.166.183]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1OycBP-0003tL-Qg for linux-mtd@lists.infradead.org; Thu, 23 Sep 2010 03:09:16 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 6040E641C6 for ; Thu, 23 Sep 2010 03:09:04 +0000 (UTC) From: Mike Frysinger To: linux-mtd@lists.infradead.org Subject: [PATCH] libfec: fix up pointer warnings in fec magic computation Date: Wed, 22 Sep 2010 23:08:03 -0400 Message-Id: <1285211283-17618-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.3 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100922_230915_991132_DA6C7E10 X-CRM114-Status: GOOD ( 12.46 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [140.211.166.183 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The current fec code casts a pointer to an int which causes warnings on 64bit systems. So create a macro for the duplicate/complicated magic computation, and add an unsigned long cast in it to fix the original problem. Signed-off-by: Mike Frysinger --- lib/libfec.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libfec.c b/lib/libfec.c index 924701f..b19ed6e 100644 --- a/lib/libfec.c +++ b/lib/libfec.c @@ -629,12 +629,13 @@ struct fec_parms { int k, n ; /* parameters of the code */ gf *enc_matrix ; } ; +#define COMP_FEC_MAGIC(fec) \ + (((FEC_MAGIC ^ (fec)->k) ^ (fec)->n) ^ (unsigned long)((fec)->enc_matrix)) void fec_free(struct fec_parms *p) { - if (p==NULL || - p->magic != ( ( (FEC_MAGIC ^ p->k) ^ p->n) ^ (int)(p->enc_matrix)) ) { + if (p==NULL || p->magic != COMP_FEC_MAGIC(p)) { fprintf(stderr, "bad parameters to fec_free\n"); return ; } @@ -666,7 +667,7 @@ fec_new(int k, int n) retval->k = k ; retval->n = n ; retval->enc_matrix = NEW_GF_MATRIX(n, k); - retval->magic = ( ( FEC_MAGIC ^ k) ^ n) ^ (int)(retval->enc_matrix) ; + retval->magic = COMP_FEC_MAGIC(retval); tmp_m = NEW_GF_MATRIX(n, k); /* * fill the matrix with powers of field elements, starting from 0.