From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 7A55210C46 for ; Wed, 21 Dec 2016 15:52:09 +0100 (CET) Received: by mail-wm0-f53.google.com with SMTP id g23so24617182wme.1 for ; Wed, 21 Dec 2016 06:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=A2apPivsRj3IuHtY3xj+RLqhKlEFGyZYb8kKxgPpWxk=; b=LSt4f4dw833LmBUQC2CJQ/S6QIarAi6kGoZNwlTE+9cBcfk/J+eiz2zTlwudskx4l3 OesBAFk0+vqhk/K/BDuK1jqteSbxh7xK9+nGibs+DKgIxbDwpPmXqhZ+1hp2B8E7aU7u gz3AzdmU7XZmmhhIBbNA0wRNdtwht48i0Qpxoa4VHCk5AyxANsP+kJtm0ysGZY15Bnaf 03fbw1wm7qY3HVqWLup6pwDaRRfEULBLlyaJ5nAuAUTIIAYv/YwP/zp+14Rbp1+/pYap 0YuknbbYvstwU10v7ft/q4S14uh8+5g6FIEdVsDx1SsaTmePysfxcn8fKaVEjOItElem LZQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=A2apPivsRj3IuHtY3xj+RLqhKlEFGyZYb8kKxgPpWxk=; b=jmVas5TqauqSBjfHRfyZ4Zi94AAWgEs27xlb5P65EgRKLJOK8rD23GF9hEoXBL0SNC PKgh/Z6k+M+/OSVSn48zKGlnoTle/w8P4JOcUDFq25SIOjNe3jarmXyIzY6nejVYGATG w89/wyHibUpp0qLRX5L++XhwppptJkcjOLJsElyyH06bUqThEGYjGk6LdvJxIe+cSgzo etePprEqqGmR3KEAAQZNUKKYjFjdKa2klloaLfDVsgl88ZqWknjx1M2aa+klxkZNmosr QA/hUrGswlW9wK92Wc/mel5VdpqBZeGhTEueItN8Spsd1fQb826Q63F3kDOWPyQpi771 bUUA== X-Gm-Message-State: AIkVDXK8B6+9cVr5+XGpUiGZCC6bPxJHWneOHCmPXyrqnbWZx9UKbEq9x/tdieOfe+kiWKh9 X-Received: by 10.28.153.10 with SMTP id b10mr7020001wme.103.1482331929053; Wed, 21 Dec 2016 06:52:09 -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 l74sm27486908wmg.2.2016.12.21.06.52.07 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 21 Dec 2016 06:52:08 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Wed, 21 Dec 2016 15:51:21 +0100 Message-Id: <0f6f2565bf0447dfe163b61325700ead47f5c538.1482331076.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 05/26] cmdline: add alignment constraint X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2016 14:52:09 -0000 This prevents sigbus errors on architectures that cannot handle unexpected unaligned accesses to the output buffer. Signed-off-by: Adrien Mazarguil Acked-by: Olga Shern --- 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 */ -- 2.1.4