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 AABF6F96C for ; Mon, 19 Dec 2016 18:49:41 +0100 (CET) Received: by mail-wm0-f53.google.com with SMTP id t79so107954968wmt.0 for ; Mon, 19 Dec 2016 09:49:41 -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=sQhM4DY3pY2YHRIDpqdkei9ll4OvLIRIEonWxS0ycDXO/Qws2VWOfkLDo4nw5r5oSf Y7GVGV4ZdBPw1mdgl9SfFtBuUl3h1f8xHd0VeXvPCWR6dJu6Iu9QyA6cXARbPvgtpKyJ +oCA/dbHt85w0ChH1ytcRbBN+t9JwBrmmDE2NN1KHAEoHh21tLFGLsAh9loOlXMiE3KY 1BIRjub6NSpUe2yUlWknfde9SQNpvvSXBxwnIsvLvq5qsE+X4LELipuWSvZEr9ARcKks SOPRbhTGNhjCI52aoDNeElJ6UyFajJnYZyRSy1wr8XBadt1s9PhH8afji1NtC89MkEXh /+Zw== 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=QWdEz/ayDQSb0LWmCAjxYOVYBoipiZRbd/Cin8liaIftkGFSCCgBXwuJ0v6O5ESZ9b f+legX+wAVUHiRJYVdZPOeRjrNgNoB00GUMmTvDdON4nxlOKwIKI5ungC9YKDUBb3Wq3 pSKqRu0dzvHt7Ln5Q+EKEW8cRVHObzRzO6z3eWfSqD3pm8T1Lhzk362oEfUOQmyiTyRP 5zx3FBIWUrVYMDmP4Yi2gfXjDcNRYsJObYsosmnDxKBHBbEA/fVR8cRIniOy022oQpdL 3bweVwnAhCOY6MVn3iSUmqmmCq12pKJkWkurKD5dg0IcrTihxknyaswUBHYhHto0E5AJ jEkw== X-Gm-Message-State: AIkVDXLdWHkdd0TUfM7zJBj86P7hVFzfKJTysl9r+oeLRjXD/yfOyrZ9QIKpi6Ue4jwI4QSI X-Received: by 10.28.152.79 with SMTP id a76mr15232997wme.47.1482169781180; Mon, 19 Dec 2016 09:49:41 -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 wg8sm21653260wjb.42.2016.12.19.09.49.40 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 19 Dec 2016 09:49:40 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Mon, 19 Dec 2016 18:48:55 +0100 Message-Id: <8c74c71a1477a1c9672753f688385d284274807d.1482168851.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 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: Mon, 19 Dec 2016 17:49:41 -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