#986263 db.c: move declaration of "*p" outside of a "while" and "if" construct

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-04-02 02:24:16 UTC
Severity:
normal
Tags:
#986263#5
Date:
2021-04-02 02:19:46 UTC
From:
To:
Dear Maintainer,

  The compiler reported:

db.c: In function 'readtimfile':
db.c:1428:11: warning: unused variable 'p' [-Wunused-variable]
 1428 |   char   *p = NULL;
      |           ^
db.c:1431:11: warning: unused variable 'p' [-Wunused-variable]
 1431 |   char   *p = strchr(line, ' ');
      |           ^
db.c:1433:6: error: 'p' undeclared (first use in this function)
 1433 |  if (p == NULL)
      |      ^

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 db.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/db.c b/db.c
index 257ee5c..90221d0 100644
--- a/db.c
+++ b/db.c
@@ -1415,6 +1415,7 @@ readtimfile(void)

     tprintf("Reading the \"active.times\" file ... ");
     fflush(stdout);
+    char *p;
 #ifdef NNTP
     while (use_nntp ? nntp_fgets(timline, sizeof timline)
 	   : fgets(timline, sizeof timline, timfp))
@@ -1425,10 +1426,10 @@ readtimfile(void)
     {
 	char   *line = strkeep(timline, 0, POOL_TIM);
 	if (line == NULL) {
-		char   *p = NULL;
+		p = NULL;
 	}
 	else {
-		char   *p = strchr(line, ' ');
+		p = strchr(line, ' ');
 	}
 	if (p == NULL)
 	    continue;