From patchwork Fri Sep 7 06:40:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4267Bh2kRQz9sCD for ; Fri, 7 Sep 2018 16:41:32 +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="Rtvkc4Ue"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267Bg2Xs3zF3Sc for ; Fri, 7 Sep 2018 16:41:31 +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="Rtvkc4Ue"; 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=209.85.214.178; helo=mail-pl1-f178.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="Rtvkc4Ue"; dkim-atps=neutral Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 4267BN5NjxzF3Sh for ; Fri, 7 Sep 2018 16:41:16 +1000 (AEST) Received: by mail-pl1-f178.google.com with SMTP id g2-v6so5175210plo.2 for ; Thu, 06 Sep 2018 23:41:16 -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=Rtvkc4Ue/1lSMO0osnru+Z/GopAi8tClSmByXqx27L5I8hG5AKrrgVe4Jn34n0zK69 8W+TIAcjsklFL0dYvNvFl4EAYF3FH2kN/4iN3mOEerBtM3LSp3lDpl+GE+Z+kvXTMYqf e0KBpL0Xt0Sw4SLj2T6APtR++n3den7M2cpYST0keHtPyanyLfUBnuP/JUdE1VeXbpKX +f73aj9cG2yHU5QBrIUBA5NKSPHnUgIPxZPuhY13Ad7h1VYCUNvrWCCBMjUCJhaanWHe 5u7vZaDIZPLXLTbLZjkyx8WQjjJY5/79IdcnZxgq9V1C1eZHXTG3wr1+3+hQ3seSJzHA QGiQ== 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=mpJAUQnAHqyCdKY9CZZWEuDiWKS0kx9SS0o084uPZOAUbi0PIWBcJmMy2MJDJ4AJXT F7JRph5v5yTdoeseEQClh1kyxBJ6ubsUON/KrpZQg/ACxJ5D7UkZ+4O+5IQqUd6WKotI l+t+etdgX8FC+II0zP0HPpEYf7MfWD/ZQguIv5zmgBRCfTfUmw/tyGhwvlnKMtGQpbeG nGKB5XK1WFU3JighXPHw5yd22hC0lTIcBmKR0UqugHZ/ejaM/rTL6F7Z7EbDPgFy+yhN jxPcWMUcPeMhEqYzG9J6fEEBzdTk/OlUmAJyB+ksErfvC1oiDSfwn+qr9Iu7a+0wSHsB RCkQ== X-Gm-Message-State: APzg51ApqD36N3tStot95k3XviPZuuJTQYXwxF6W1AIN8Ph5Pwn6e8vB aAC3x9NbctMlgSdHOd1qA1jkJ3qx1o4= X-Google-Smtp-Source: ANB0VdZMKi/UEyusuVux1WGZmhBdOqvXQHbQjGBip4JLkjs1QKQwyT/jHerdBRsEZS1eNjgE1TYyMw== X-Received: by 2002:a17:902:47c2:: with SMTP id d2-v6mr6536428plh.317.1536302474554; Thu, 06 Sep 2018 23:41:14 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:14 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:10 +1000 Message-Id: <20180907064015.1058-12-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 11/16] 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);