From patchwork Wed Aug 29 01:50:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 420TBb1MP5z9s1x for ; Wed, 29 Aug 2018 11:51:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VxzZJ+AZ"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 420TBZ6FT1zF1RN for ; Wed, 29 Aug 2018 11:51:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VxzZJ+AZ"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62e; helo=mail-pl1-x62e.google.com; envelope-from=rashmica.g@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VxzZJ+AZ"; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 420TB73j32zF0ph for ; Wed, 29 Aug 2018 11:51:27 +1000 (AEST) Received: by mail-pl1-x62e.google.com with SMTP id e11-v6so1559159plb.3 for ; Tue, 28 Aug 2018 18:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NrJEwkdu2XaewiiEXe6Dzlw2dXnsvYp40QLfkK5/1l4=; b=VxzZJ+AZMeBsqz/jAm6pF26unmSpULfrXn40QNd0EkEpgATFKvdWXDKzXQzoumW/p8 2MFx+DeoqxxE/r9sV40OiudH/+T8xdmIirZVTe11ToOS56VV9enENDjvSPJAQmPbUklI MH7wCnx3L0tvypqmbRGrFFimMQA3atSrwRHAZSRGdOJRuuF9GHNUavTZ3De73UqsYR54 zdmMdh0d0CuLQeotgekxECvC2M1+ihXFxNETuIDlUPBzAwtjKSmaccBVIw0J4QRuASfo c4SMwDl6OhkaCx4WrJwhOkVJLI6nS6kZua4ZoWcQ1pdETOLi8f8IzcwDH4JQp3QEz7B+ aGaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NrJEwkdu2XaewiiEXe6Dzlw2dXnsvYp40QLfkK5/1l4=; b=tIa7d4s1jNjMoW0M5ABvq4aeZoybHwWis068L8iR0A9vf++e8zWYktGBQN2vdDrH++ a3aL7P3ZDx6vPpttQNM9wMyUi2yH+lAQ4P5zKPZO5fzhYIdyEH/fYCtrp0fft0IgthbA 01kFlLWFhnweSK8FI/rAWMDWrpX3mXws4CDkgujY45QQAut4hxbdiauxGFVLrAOlZeqs cmLsfh9wHf0II3K0NlTNIN3MKAov47+TtPEbtzzEwDRi0VTjDbfbwCEWrmkumYbyShc6 DY/SjfnUu7DO/5v4WYVqAEyN6OopDJsesxOnMZIqcP8e+hIUGPok9WVburjE6RyTshux 1TWg== X-Gm-Message-State: APzg51C9e70h4MPsfvywLMBa09EjeYtSrNpaaZgBBSEApDjCLS1u2yWa DYx4V/afTeOhtS/fbZV9GVWMOeYj X-Google-Smtp-Source: ANB0VdYUk7+1MmKzTpoCXywj6bY1IETJf5+bObEl8PFXhgmrNrL0cAgpx6w2Li3t9YBFM0m1WrUMiA== X-Received: by 2002:a17:902:187:: with SMTP id b7-v6mr3886856plb.269.1535507485615; Tue, 28 Aug 2018 18:51:25 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:25 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:39 +1000 Message-Id: <20180829015047.7355-12-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 11/19] pdbg: Add in parser for uint16_t X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/parsers.c | 18 ++++++++++++++++++ src/parsers.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/parsers.c b/src/parsers.c index 6cbe06d..868c383 100644 --- a/src/parsers.c +++ b/src/parsers.c @@ -37,6 +37,24 @@ uint32_t *parse_number32(const char *argv) return n; } +uint16_t *parse_number16(const char *argv) +{ + unsigned long long tmp; + uint16_t *n = malloc(sizeof(*n)); + char *endptr; + + if (!argv) + return NULL; + + errno = 0; + tmp = strtoul(argv, &endptr, 0); + if (errno || *endptr != '\0' || tmp > UINT16_MAX) + return NULL; + + *n = tmp; + return n; +} + /* Parse a GPR number, returning an error if it's greater than 32 */ int *parse_gpr(const char *argv) { diff --git a/src/parsers.h b/src/parsers.h index b5f23cf..935c242 100644 --- a/src/parsers.h +++ b/src/parsers.h @@ -8,12 +8,14 @@ #define ADDRESS32 (parse_number32, NULL) #define DATA (parse_number64, NULL) #define DATA32 (parse_number32, NULL) +#define DATA16 (parse_number16, NULL) #define DEFAULT_DATA(default) (parse_number64, default) #define GPR (parse_gpr, NULL) #define SPR (parse_spr, NULL) uint64_t *parse_number64(const char *argv); uint32_t *parse_number32(const char *argv); +uint16_t *parse_number16(const char *argv); int *parse_gpr(const char *argv); int *parse_spr(const char *argv); bool *parse_flag_noarg(const char *argv);