From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 608D1F618 for ; Fri, 16 Dec 2016 17:25:46 +0100 (CET) Received: by mail-wm0-f41.google.com with SMTP id f82so40844827wmf.1 for ; Fri, 16 Dec 2016 08:25:46 -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=+8GUAyymP84eUgMhSLwntCNOdrjSS/jJDwQc29owzig=; b=OQAWkKGixANYaTcWQTA2t4aGxetXKlOqXrEzHY0E6+hHO83TOWfQyih6k+mFv1vQ1g aqBY2kk6skKsg9uSld1Ya69Uj/HAYFWE1nlvwQyROuqefe9pfovnrAM6uTP9/iA9dFTu nmenK0tymNGgbx/ZUKO9Fa/zFxanNvRfZpuGtZ9bV4hX+TFSxhdYj6azGvNbF0DxYh/P ucZXFcfK2mo2eMXpNuttvBowTOOc9+q+K84AM4jIcfSNzxbBbp6NCr13kYtczuXTvnSq I7UYGFLV+LLwxhvyFcZTvo9evVVH3iKuPgS+PBm0IJMZMihFUF0UT9stqC/pBcck0j5z QyGQ== 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=+8GUAyymP84eUgMhSLwntCNOdrjSS/jJDwQc29owzig=; b=Rwdy2iFZA1D3AvtgavQAE36J0Ke5vrcTqApEkpoydsej2vZjlxPLOej4vCOD5obJnD i14leCfxwJVirnrFr9USsmChAi36pYCN8vHWudvajwmQdXBy9EM/CiNHxj2m4PetyKdm UEGJE/v2euK5oAtRFKpO6hsXNBFGDfCG4MN22E6SNM9gKB8K999lW9UiLsdjfIKE3QX1 tixpDdMpsK4Tf6XocbblCpWHXQhDn1n9C4D9GDBL7LymOcbDPxqobZLDuw6wHQY1u5Wy w+59kcnrPJjKbFqRyJIMbsJ+5kojg9XrFKM/nrvKFsln2YvtCYztEedY8AEupfoyPtiB CMXA== X-Gm-Message-State: AIkVDXLAwXFpzfQxftjcbrAF5T/ejuzcV8/8WY+LJt3O//n0zBs2XAFr50+66T3ziVIAGF+B X-Received: by 10.28.18.194 with SMTP id 185mr3736964wms.124.1481905545858; Fri, 16 Dec 2016 08:25:45 -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 cl10sm7530839wjb.4.2016.12.16.08.25.44 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 16 Dec 2016 08:25:45 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Fri, 16 Dec 2016 17:25:02 +0100 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 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: Fri, 16 Dec 2016 16:25:46 -0000 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 */ -- 2.1.4