From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id 382A0FBD9 for ; Tue, 20 Dec 2016 19:43:06 +0100 (CET) Received: by mail-wm0-f42.google.com with SMTP id a197so128379295wmd.0 for ; Tue, 20 Dec 2016 10:43:06 -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=LjvnZQ+MLoxY/yt9YU4jRGncnz58BvIiY3B6+cSW4mbPXW4EJzWJws8RzDd4PlHAkI QGc23EcoIpRqpr2E+z4OOsG8advF0k4y0gE0Cn+yezZlBIksDx+07YG5CTHQG/iy3OWJ VCJT23CO/EqveMkKqkclfJZv9V2uqShV1WdQ/lROjEup3j1/SSdDSZ6+9BJafE3z7o5d HZQp3efgye9VUrqZyUyovSsFE6Ve0slIF0aXpTpcl+lA4EElKK8xDN6g/wZi5X5kBGFE 8ToOkxaIBwOIR01M0s6r1cHHb4LmyGLZbsXK/1o4ATkwiYuQqSyG8rILGBL1Q4jCFVI+ dUKA== 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=SOlnkMmla7AIqWE2rehEyAd3WHs2q7uWXvgekIuv27VNNmNsaszlLOUg2+F5xN3XKG aaJtInL63Sp12tm6WncrXMWkuwQXvjGEdx68trDTgi+O0TxoafgP5+0ADS+F+IxKZMa1 IRhobig0Yc28SoFv42mYevLftfjBvqeMW9sPR+FN36L3LGsYM7Zk+2IZ3kWDhc5/w0wt 8tdPOq+eo019hdfos0PmV7zBeNp2wna7GbMUjuxEVZNMrdGxZSsiVIkHK2LKl4aE4tt2 lOGHN/kbEi+fWae1P+v7Wxsz8XUsfBINp0g9GM36toGZC3Q8UV2lJ0VwQnN7QzSgRyjK +yqg== X-Gm-Message-State: AIkVDXJOEKZfwkbUsTNOl59AUUQq7I9JItupRI4a4+clQVAEWoAeI16S+WVByyrQi1WTg9Gl X-Received: by 10.28.163.5 with SMTP id m5mr1240375wme.98.1482259385739; Tue, 20 Dec 2016 10:43: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 k2sm26923921wjv.11.2016.12.20.10.43.04 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 20 Dec 2016 10:43:04 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 20 Dec 2016 19:42:22 +0100 Message-Id: <525d3d04cfc47fa950fe7068de159152a364be6d.1482257521.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 05/25] 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: Tue, 20 Dec 2016 18:43:06 -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