From patchwork Fri Jan 2 21:26:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 42706 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 63AF426CD1 for ; Fri, 2 Jan 2015 21:26:44 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id w7sf10714757lbi.8 for ; Fri, 02 Jan 2015 13:26:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=JpJivEAisbAF5tM8UXIdHapocq+GsB1X+zNQw10YezQ=; b=lO5uCgMYOz6dC028xcs6jTMYwGfsKgrAdyunucVCsIG9UKfiBQFIueVxvC6L8s5xmp oumuaBgKX6y6zUyH9OTJG6QI2g6GCrSyO6Q6ra6xi8DJFy5SiHGaT/uzuELVMgUqHEK0 QgZ5Yz1+K0897s0zVDpg3CdJLyVW1dc4AqvXDuNhtGo69IFAgZs+tuySPj+vma2OMW77 Qr2WEcqgKBDk7K0XdV/NwS/+MPZm67kJO7XcIIhZmPLdiX20uFoRdxVklgN9m8iV5p1D l8ew+U/3NE5CowU4uR1EdwJQBqKj7W66BFAK4+m0SGQsgUHUW7er5ofE8H900ApU1JLn 0e4A== X-Gm-Message-State: ALoCoQnRyt0xDjXVeUyaawCr0JoD64x86VSVZ8eTvztJHQ25klaRXEC2FXxoyTeLmFt0rOXVbJcJ X-Received: by 10.180.89.211 with SMTP id bq19mr68056wib.4.1420234003237; Fri, 02 Jan 2015 13:26:43 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.131 with SMTP id t3ls1718216lag.44.gmail; Fri, 02 Jan 2015 13:26:43 -0800 (PST) X-Received: by 10.112.27.133 with SMTP id t5mr78514581lbg.45.1420234003079; Fri, 02 Jan 2015 13:26:43 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id q2si52751096lbb.130.2015.01.02.13.26.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 13:26:42 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id pv20so15490904lab.41 for ; Fri, 02 Jan 2015 13:26:42 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr78477113lav.34.1420234002842; Fri, 02 Jan 2015 13:26:42 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp293614lbb; Fri, 2 Jan 2015 13:26:42 -0800 (PST) X-Received: by 10.140.82.136 with SMTP id h8mr119981955qgd.75.1420234001464; Fri, 02 Jan 2015 13:26:41 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k1si30091958qan.132.2015.01.02.13.26.39 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Jan 2015 13:26:41 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y79jw-0004bP-A8; Fri, 02 Jan 2015 21:26:36 +0000 Received: from mail-qg0-f47.google.com ([209.85.192.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y79jp-0004Ub-4E for lng-odp@lists.linaro.org; Fri, 02 Jan 2015 21:26:29 +0000 Received: by mail-qg0-f47.google.com with SMTP id q108so13282559qgd.6 for ; Fri, 02 Jan 2015 13:26:23 -0800 (PST) X-Received: by 10.224.103.195 with SMTP id l3mr114333581qao.38.1420233983856; Fri, 02 Jan 2015 13:26:23 -0800 (PST) Received: from localhost.localdomain ([98.221.136.245]) by mx.google.com with ESMTPSA id p38sm1817885qgd.31.2015.01.02.13.26.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jan 2015 13:26:23 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Fri, 2 Jan 2015 16:26:14 -0500 Message-Id: <1420233974-2790-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: odp_coremask: add ODP_ERR for bad str length X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Provide feed back on string length error, matching the handling for the other APIs in the file. Improve the readability of the code. Signed-off-by: Mike Holmes --- platform/linux-generic/odp_coremask.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/odp_coremask.c b/platform/linux-generic/odp_coremask.c index 54cd333..5b4e961 100644 --- a/platform/linux-generic/odp_coremask.c +++ b/platform/linux-generic/odp_coremask.c @@ -10,19 +10,21 @@ #include #include -#define MAX_CORE_NUM 64 +#define MAX_CORE_NUM 64 +#define MASK_STR_LEN 18 +#define BASE_16 16 void odp_coremask_from_str(const char *str, odp_coremask_t *mask) { uint64_t mask_u64; - if (strlen(str) > 18) { - /* more than 64 bits */ + if (strlen(str) > MASK_STR_LEN) { + ODP_ERR("string longer than reqired for bit mask supported"); return; } - mask_u64 = strtoull(str, NULL, 16); + mask_u64 = strtoull(str, NULL, BASE_16); odp_coremask_from_u64(&mask_u64, 1, mask); }