From patchwork Wed Nov 16 16:23:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 17027 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3237D58CB; Wed, 16 Nov 2016 17:25:01 +0100 (CET) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id CE548567E for ; Wed, 16 Nov 2016 17:24:05 +0100 (CET) Received: by mail-wm0-f54.google.com with SMTP id f82so83915009wmf.1 for ; Wed, 16 Nov 2016 08:24:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+8GUAyymP84eUgMhSLwntCNOdrjSS/jJDwQc29owzig=; b=YFGZMgzSFFWx1tU1qFs3LCREwzzMOiDNv5wc9IUJUdvMhQhJAazSe3cbe8z5pxiGJV ddBGc42DyAagaUA5ESJ75jdsQEjJVyotAA/qab5WFgZ5VKXrWmQrkzmDI5q+H11Ojt8m aDFe0fnae4EfqkxhqFJGfcdlVNpTGtdsy7MNvIISpbdFUgYPs2yaIkjvngx7aHSvUk1T XbjJ8xZpev2qZWB9WU/WE/X3mQ8Z0EHSmneyBbZKgDAp2GLPOAFJaTpxK//rHBYo5Uqc l91auzeY0P5Ss07rbypAx605a8HdgJfS4/UGsAabxWim9pA0bgUhZFjzaw/4twT8JJvH b1Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+8GUAyymP84eUgMhSLwntCNOdrjSS/jJDwQc29owzig=; b=HMlNNnCHmk7ygmQdui8ECZkoM9bIW+yIRbvam5BFg2vpomq3pf2FVCkKlUzt5+phhQ 5k5rwS2PdJvUotSoqHNsjS4vHzAdR99qdF+aJh/Lq2AaL9uZe6lKfuGPM19KLlgi3gHM 8xo2tzqUhYNMEslp3NAt4rpBP2rWXn4XEBZGv6DYf3hZ1lA1yty8liGk/rTyrOQIe1Pq /C26CNpR+epb2uOtPlrU6ICGrjxQSmmfttA//ElX6Hg71iHAFAkmNh1HPRuzjDeTBibN Md9EosxL7A9nqvH2qRZiWZHO6awkaTqDQDgylxPgkU73QYDIOgo7Lw9APOBAbC8j/hqp ceNQ== X-Gm-Message-State: ABUngvfFbEvrB7CD+IaKIlOA1F4K1m57Rv6Mu+jzTnx0z1H4h8voUi9hTtPlWx6JxDQWoDME X-Received: by 10.28.128.211 with SMTP id b202mr11285359wmd.7.1479313445566; Wed, 16 Nov 2016 08:24:05 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id j1sm22631586wjm.26.2016.11.16.08.24.04 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 16 Nov 2016 08:24:04 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Cc: Thomas Monjalon , Pablo de Lara , Olivier Matz Date: Wed, 16 Nov 2016 17:23:29 +0100 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 03/22] cmdline: add alignment constraint X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This prevents sigbus errors on architectures that cannot handle unexpected unaligned accesses to the output buffer. Signed-off-by: Adrien Mazarguil --- lib/librte_cmdline/cmdline_parse.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 14f5553..763c286 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -255,7 +255,10 @@ cmdline_parse(struct cmdline *cl, const char * buf) unsigned int inst_num=0; cmdline_parse_inst_t *inst; const char *curbuf; - char result_buf[CMDLINE_PARSE_RESULT_BUFSIZE]; + union { + char buf[CMDLINE_PARSE_RESULT_BUFSIZE]; + long double align; /* strong alignment constraint for buf */ + } result; cmdline_parse_token_hdr_t *dyn_tokens[CMDLINE_PARSE_DYNAMIC_TOKENS]; void (*f)(void *, struct cmdline *, void *) = NULL; void *data = NULL; @@ -318,7 +321,7 @@ cmdline_parse(struct cmdline *cl, const char * buf) debug_printf("INST %d\n", inst_num); /* fully parsed */ - tok = match_inst(inst, buf, 0, result_buf, sizeof(result_buf), + tok = match_inst(inst, buf, 0, result.buf, sizeof(result.buf), &dyn_tokens); if (tok > 0) /* we matched at least one token */ @@ -353,7 +356,7 @@ cmdline_parse(struct cmdline *cl, const char * buf) /* call func */ if (f) { - f(result_buf, cl, data); + f(result.buf, cl, data); } /* no match */