From patchwork Wed Sep 6 09:39:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 810469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xnJSb6LXzz9s8J; Wed, 6 Sep 2017 19:39:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1dpWnd-0000Qj-M5; Wed, 06 Sep 2017 09:39:09 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1dpWnb-0000QH-Os for fwts-devel@lists.ubuntu.com; Wed, 06 Sep 2017 09:39:07 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dpWnb-0008Cq-8q; Wed, 06 Sep 2017 09:39:07 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] fwts_log: make line_number to a uint32_t type Date: Wed, 6 Sep 2017 10:39:06 +0100 Message-Id: <20170906093906.30475-1-colin.king@canonical.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King Line numbers are never negative, so make line_number a uint32_t type Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/include/fwts_log.h | 2 +- src/lib/src/fwts_log_plaintext.c | 3 ++- src/lib/src/fwts_log_xml.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/include/fwts_log.h b/src/lib/include/fwts_log.h index da8cb42b..3d4ecf9a 100644 --- a/src/lib/include/fwts_log.h +++ b/src/lib/include/fwts_log.h @@ -97,7 +97,7 @@ typedef struct log_t { */ typedef struct { FILE *fp; /* file descriptor for log */ - int line_number; /* keeps track of the line numbering */ + uint32_t line_number; /* keeps track of the line numbering */ fwts_log *log; /* parent log struct */ fwts_log_type type; /* log type */ fwts_log_filename_type filename_type; /* log filename type */ diff --git a/src/lib/src/fwts_log_plaintext.c b/src/lib/src/fwts_log_plaintext.c index a4fbcec4..0cde841f 100644 --- a/src/lib/src/fwts_log_plaintext.c +++ b/src/lib/src/fwts_log_plaintext.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,7 @@ static int fwts_log_header_plaintext( ptr++; if (!strncmp(ptr, "line", 4)) { n += snprintf(buffer + n, len - n, - "%5.5d", log_file->line_number); + "%5.5" PRIu32, log_file->line_number); ptr += 4; } if (!strncmp(ptr, "date", 4)) { diff --git a/src/lib/src/fwts_log_xml.c b/src/lib/src/fwts_log_xml.c index 273f0500..2954bb24 100644 --- a/src/lib/src/fwts_log_xml.c +++ b/src/lib/src/fwts_log_xml.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -67,7 +68,7 @@ static int fwts_log_print_xml( fprintf(log_file->fp, "%*s\n", xml_stack_index * XML_INDENT, ""); - fprintf(log_file->fp, "%*s%d\n", + fprintf(log_file->fp, "%*s%" PRIu32 "\n", (xml_stack_index + 1) * XML_INDENT, "", log_file->line_number);