Hello,

Using GCC10 on Fedora 31, I built screen from a git clone of the latest
sources.
After running
$cd src && ./autogen.sh && ./configure && make
I got multiple warnings in acls.c:

acls.c: In function ‘GrowBitfield’:
acls.h:44:35: warning: dereferencing ‘void *’ pointer
   44 | #define ACLBYTE(data, w)   ((data)[(w) >> 3])
      |                                   ^
acls.c:95:49: note: in expansion of macro ‘ACLBYTE’
   95 |  if (!(n = (AclBits) calloc(1, (unsigned long)(&ACLBYTE(NULL, len +
delta + 1)))))
      |                                                 ^~~~~~~
acls.c: In function ‘DoSu’:
acls.c:400:6: warning: unused variable ‘sorry’ [-Wunused-variable]
  400 |  int sorry = 0;
      |      ^~~~~
acls.c:399:18: warning: unused variable ‘u’ [-Wunused-variable]
  399 |  struct acluser *u;
      |                  ^
acls.c:397:29: warning: unused parameter ‘up’ [-Wunused-parameter]
  397 | char *DoSu(struct acluser **up, char *name, char *pw1, char *pw2)
      |            ~~~~~~~~~~~~~~~~~^~
acls.c:397:39: warning: unused parameter ‘name’ [-Wunused-parameter]
  397 | char *DoSu(struct acluser **up, char *name, char *pw1, char *pw2)
      |                                 ~~~~~~^~~~
acls.c:397:51: warning: unused parameter ‘pw1’ [-Wunused-parameter]
  397 | char *DoSu(struct acluser **up, char *name, char *pw1, char *pw2)
      |                                             ~~~~~~^~~
acls.c:397:62: warning: unused parameter ‘pw2’ [-Wunused-parameter]
  397 | char *DoSu(struct acluser **up, char *name, char *pw1, char *pw2)
      |                                                        ~~~~~~^~~

In order to suppress the warning for GrowBitfield, I cast NULL as a char *
(patch 0001).
In order to suppress DoSu's unused-variable warnings, I moved the two
variable declarations into the #if-0'd block (patch 0002).
In order to suppress DoSu's unused-parameter warnings, I marked the four
parameters (patch 0005).

I then ran $make check and got a couple more warnings:

In file included from tests/test-winmsgbuf.c:24:
tests/test-winmsgbuf.c:45:17: warning: initialization of ‘char *
(*)(WinMsgBufContext *, WinMsgBuf *)’ from incompatible pointer type ‘const
char * (*)(WinMsgBufContext *, WinMsgBuf *)’ [-Wincompatible-pointer-types]
   45 | SIGNATURE_CHECK(wmbc_mergewmb, char *, (WinMsgBufContext *,
WinMsgBuf *));
      |                 ^~~~~~~~~~~~~
tests/signature.h:46:71: note: in definition of macro ‘SIGNATURE_CHECK2’
   46 |   static ret (* __attribute__((unused)) signature_check ## id) args
= fn
      |
  ^~
tests/signature.h:39:3: note: in expansion of macro ‘SIGNATURE_CHECK1’
   39 |   SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
      |   ^~~~~~~~~~~~~~~~
tests/test-winmsgbuf.c:45:1: note: in expansion of macro ‘SIGNATURE_CHECK’
   45 | SIGNATURE_CHECK(wmbc_mergewmb, char *, (WinMsgBufContext *,
WinMsgBuf *));
      | ^~~~~~~~~~~~~~~
tests/test-winmsgbuf.c: In function ‘main’:
tests/test-winmsgbuf.c:298:19: warning: implicit declaration of function
‘alloca’; did you mean ‘calloc’? [-Wimplicit-function-declaration]
  298 |   char *expect2 = alloca(strlen(expect) + szadd + 1);
      |                   ^~~~~~
      |                   calloc

I fixed the incompatible-pointer-type warning by adding const to the macro
on line 45 in test-winmsgbuf (patch 0003).
Finally, I replaced the alloca call to a malloc/free pair to fix the
implicit-funtion-declaration warning (patch 0004).
Another option would be to #include <alloca.h>

Chris Meyering
From f7d219551f1f6f25910519c97645f046dbcfd8f2 Mon Sep 17 00:00:00 2001
From: Chris Meyering <christophe.meyer...@gmail.com>
Date: Fri, 31 Jan 2020 21:01:45 -0800
Subject: [PATCH 1/5] build: cast NULL to (char *) to prevent GCC 10 warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/acls.c (GrowBitfield): replace NULL by (char *)NULL.
This avoids the following warning:
acls.h:44:35: warning: dereferencing ‘void *’ pointer
---
 src/acls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/acls.c b/src/acls.c
index 7cf56e2..9b4e801 100644
--- a/src/acls.c
+++ b/src/acls.c
@@ -92,7 +92,7 @@ static int GrowBitfield(AclBits * bfp, int len, int delta, int defaultbit)
 {
 	AclBits n, o = *bfp;
 
-	if (!(n = (AclBits) calloc(1, (unsigned long)(&ACLBYTE(NULL, len + delta + 1)))))
+	if (!(n = (AclBits) calloc(1, (unsigned long)(&ACLBYTE((char *)NULL, len + delta + 1)))))
 		return -1;
 	for (int i = 0; i < (len + delta); i++) {
 		if (((i < len) && (ACLBIT(i) & ACLBYTE(o, i))) || ((i >= len) && (defaultbit)))
-- 
2.24.1

From b38d2d36d7d1a9727a59504907877d78388d1bdc Mon Sep 17 00:00:00 2001
From: Chris Meyering <christophe.meyer...@gmail.com>
Date: Fri, 31 Jan 2020 21:14:06 -0800
Subject: [PATCH 3/5] build: test-winmsgbuf.c: add const to avoid GCC 10
 warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/tests/test-winmsgbuf.c:45: make char * const
This avoids the following warning:
tests/test-winmsgbuf.c:45:17: warning: initialization of\
‘char *[...]'from incompatible pointer type ‘const char *[...]'
---
 src/tests/test-winmsgbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tests/test-winmsgbuf.c b/src/tests/test-winmsgbuf.c
index c752899..681d81c 100644
--- a/src/tests/test-winmsgbuf.c
+++ b/src/tests/test-winmsgbuf.c
@@ -42,7 +42,7 @@ SIGNATURE_CHECK(wmbc_strcpy, const char *, (WinMsgBufContext *, const char *));
 SIGNATURE_CHECK(wmbc_printf, int, (WinMsgBufContext *, const char *, ...));
 SIGNATURE_CHECK(wmbc_offset, size_t, (WinMsgBufContext *));
 SIGNATURE_CHECK(wmbc_bytesleft, size_t, (WinMsgBufContext *));
-SIGNATURE_CHECK(wmbc_mergewmb, char *, (WinMsgBufContext *, WinMsgBuf *));
+SIGNATURE_CHECK(wmbc_mergewmb, const char *, (WinMsgBufContext *, WinMsgBuf *));
 SIGNATURE_CHECK(wmbc_finish, const char *, (WinMsgBufContext *));
 SIGNATURE_CHECK(wmbc_free, void, (WinMsgBufContext *));
 
-- 
2.24.1

From cbc0f0ba3c78fa011a3a367b821c200425a85c0c Mon Sep 17 00:00:00 2001
From: Chris Meyering <christophe.meyer...@gmail.com>
Date: Fri, 31 Jan 2020 22:05:13 -0800
Subject: [PATCH 4/5] build: tests/test-winmsgbuf.c: avoid GCC 10 alloca
 warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/tests/test-winmsgbuf.c (main): Replace alloca with malloc/free
to prevent the following warning: tests/test-winmsgbuf.c:298:19:\
  warning: implicit declaration of function ‘alloca’; did you mean \
  ‘calloc’?
---
 src/tests/test-winmsgbuf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/tests/test-winmsgbuf.c b/src/tests/test-winmsgbuf.c
index 681d81c..acf8386 100644
--- a/src/tests/test-winmsgbuf.c
+++ b/src/tests/test-winmsgbuf.c
@@ -295,7 +295,7 @@ int main(void)
 		 * concatenation */
 		char *add = "bar";
 		size_t szadd = strlen(add);
-		char *expect2 = alloca(strlen(expect) + szadd + 1);
+		char *expect2 = malloc(strlen(expect) + szadd + 1);
 		strcpy(expect2, expect);
 		strcat(expect2, add);
 		ASSERT(wmbc_printf(wmbc, "%s", add) == (int)szadd);
@@ -322,6 +322,7 @@ int main(void)
 
 		wmbc_free(wmbc);
 		wmb_free(wmb);
+		free(expect2);
 	}
 
 	/* scenerio: merging the contents of two separate buffers, also
-- 
2.24.1

From 2315eb236c53aa58b483c2e6674ffc4318930a64 Mon Sep 17 00:00:00 2001
From: Chris Meyering <christophe.meyer...@gmail.com>
Date: Fri, 31 Jan 2020 22:37:49 -0800
Subject: [PATCH 5/5] build: acls.c: mark unused parameters

* src/acls.c (DoSu): avoid four unused-variable warnings
---
 src/acls.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/acls.c b/src/acls.c
index 8971b64..de7321f 100644
--- a/src/acls.c
+++ b/src/acls.c
@@ -396,6 +396,10 @@ int AclLinkUser(char *from, char *to)
  */
 char *DoSu(struct acluser **up, char *name, char *pw1, char *pw2)
 {
+	(void) up;
+	(void) name;
+	(void) pw1;
+	(void) pw2;
 
 #if 0
 	struct acluser *u;
-- 
2.24.1

From 299e9c4ec211137deeda5fd90cd57aea4f4e285d Mon Sep 17 00:00:00 2001
From: Chris Meyering <christophe.meyer...@gmail.com>
Date: Fri, 31 Jan 2020 21:06:27 -0800
Subject: [PATCH 2/5] cleanup: acls.c: move unused variables into #if-0 block

* src/acls.c (DoSu): avoid two unused-variable warnings
---
 src/acls.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/acls.c b/src/acls.c
index 9b4e801..8971b64 100644
--- a/src/acls.c
+++ b/src/acls.c
@@ -396,10 +396,10 @@ int AclLinkUser(char *from, char *to)
  */
 char *DoSu(struct acluser **up, char *name, char *pw1, char *pw2)
 {
-	struct acluser *u;
-	int sorry = 0;
 
 #if 0
+	struct acluser *u;
+	int sorry = 0;
 	if (!(u = *FindUserPtr(name)))
 		sorry++;
 	else {
-- 
2.24.1

Reply via email to