Tautological comparison in gcc 6.1.1
Michael Adam
obnox at samba.org
Wed Jul 13 00:37:38 UTC 2016
On 2016-07-13 at 02:01 +0200, Michael Adam wrote:
> On 2016-07-13 at 00:15 +0200, Michael Adam wrote:
> >
> > Attached are patches that cover all definitions of DLIST_ADD_END
> > as above. We could add those with your authorship, amitay.
> >
> > These are not the only problems encountered with gcc6.
> >
> > Continuing now ...
>
> One problem is that we have quite a number of
> uses of DLIST_REMOVE in the form of
>
> DLIST_REMOVE(p, p)
>
> which will lead to a comparison if ((p) == (p))...
>
> This is a completely valid pattern.
> Not sure yet how to fix this in a conceptually good way.
Attached patches (with the previous patches for DLIST_ADD_END)
fix the gcc6 build (on f24) for me.
Not super elegant but does the job...
review / push / comments welcome!
Cheers - Michael
-------------- next part --------------
From 39b8c416393dc29d9ef05ff89d323c6689ed3baf Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 01:50:46 +0200
Subject: [PATCH 1/9] smbXcli: fix -Wtautological-compare error
Signed-off-by: Michael Adam <obnox at samba.org>
---
libcli/smb/smbXcli_base.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 0a2473e..9dd4594 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -301,8 +301,10 @@ static int smbXcli_conn_destructor(struct smbXcli_conn *conn)
smbXcli_conn_disconnect(conn, NT_STATUS_OK);
while (conn->sessions) {
+ struct smbXcli_session *session = conn->sessions;
+
conn->sessions->conn = NULL;
- DLIST_REMOVE(conn->sessions, conn->sessions);
+ DLIST_REMOVE(conn->sessions, session);
}
if (conn->smb1.trans_enc) {
--
2.7.4
From 549df25af27823738a961f1d92321b8b209b3494 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:09:58 +0200
Subject: [PATCH 2/9] s3:lib: fix -Wtautological-compare error in
gfree_interfaces()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/lib/interface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index a3bc5d2..60e1d91 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -658,7 +658,7 @@ void gfree_interfaces(void)
{
while (local_interfaces) {
struct interface *iface = local_interfaces;
- DLIST_REMOVE(local_interfaces, local_interfaces);
+ DLIST_REMOVE(local_interfaces, iface);
SAFE_FREE(iface->name);
SAFE_FREE(iface);
}
--
2.7.4
From 801bc0a192e65a1b1937be050d26a9c6a326c02c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:13:57 +0200
Subject: [PATCH 3/9] s3:dns_server: fix -Wtautological-compare errors
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/dns_server/dns_query.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c
index 3e9359e..3360f6f 100644
--- a/source4/dns_server/dns_query.c
+++ b/source4/dns_server/dns_query.c
@@ -1050,7 +1050,8 @@ static void dns_server_process_query_got_response(struct tevent_req *subreq)
/* If you get an error, attempt a different forwarder */
if (!W_ERROR_IS_OK(werr)) {
if (state->forwarders != NULL) {
- DLIST_REMOVE(state->forwarders, state->forwarders);
+ struct forwarder_string *forwarder = state->forwarders;
+ DLIST_REMOVE(state->forwarders, forwarder);
}
/* If you have run out of forwarders, simply finish */
@@ -1092,7 +1093,8 @@ static void dns_server_process_query_got_auth(struct tevent_req *subreq)
/* If you get an error, attempt a different forwarder */
if (!W_ERROR_IS_OK(werr)) {
if (state->forwarders != NULL) {
- DLIST_REMOVE(state->forwarders, state->forwarders);
+ struct forwarder_string *forwarder = state->forwarders;
+ DLIST_REMOVE(state->forwarders, forwarder);
}
/* If you have run out of forwarders, simply finish */
--
2.7.4
From 79e19b8caae19dd0fc0d234ac8a11ae33647657a Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:17:06 +0200
Subject: [PATCH 4/9] pampass: fix -Wtautological-compare error in
free_pw_chat()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/auth/pampass.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c
index 1a82fe7..4cc4590 100644
--- a/source3/auth/pampass.c
+++ b/source3/auth/pampass.c
@@ -274,7 +274,7 @@ static void free_pw_chat(struct chat_struct *list)
{
while (list) {
struct chat_struct *old_head = list;
- DLIST_REMOVE(list, list);
+ DLIST_REMOVE(list, old_head);
SAFE_FREE(old_head);
}
}
--
2.7.4
From 249035a8942dde52eaae9a4b4deac3b6292793aa Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:23:13 +0200
Subject: [PATCH 5/9] s4:ldap_server: fix -Wtautological-compare error in
ldapsrv_call_process_done
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/ldap_server/ldap_server.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 8b21fbb..d26df12 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -590,10 +590,11 @@ static void ldapsrv_call_process_done(struct tevent_req *subreq)
while (call->replies) {
DATA_BLOB b;
bool ret;
+ struct ldapsrv_reply *reply = call->replies;
- if (!ldap_encode(call->replies->msg, samba_ldap_control_handlers(), &b, call)) {
+ if (!ldap_encode(reply->msg, samba_ldap_control_handlers(), &b, call)) {
DEBUG(0,("Failed to encode ldap reply of type %d\n",
- call->replies->msg->type));
+ reply->msg->type));
ldapsrv_terminate_connection(conn, "ldap_encode failed");
return;
}
@@ -608,7 +609,7 @@ static void ldapsrv_call_process_done(struct tevent_req *subreq)
return;
}
- DLIST_REMOVE(call->replies, call->replies);
+ DLIST_REMOVE(call->replies, reply);
}
if (blob.length == 0) {
--
2.7.4
From 2cff1cbde4cb648cc0da1e9bcb8fe6df589ffcf3 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:25:46 +0200
Subject: [PATCH 6/9] lib: fix -Wtautological-compare error in dlinklist
testsuite
Signed-off-by: Michael Adam <obnox at samba.org>
---
lib/util/tests/dlinklist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/util/tests/dlinklist.c b/lib/util/tests/dlinklist.c
index 50adab3..5004db86 100644
--- a/lib/util/tests/dlinklist.c
+++ b/lib/util/tests/dlinklist.c
@@ -49,7 +49,7 @@ static bool torture_local_dlinklist_simple(struct torture_context *tctx)
torture_comment(tctx, "delete 3 from front\n");
for (i=0; i < 3; i++) {
el = l1;
- DLIST_REMOVE(l1, l1);
+ DLIST_REMOVE(l1, el);
DLIST_ADD(l2, el);
}
--
2.7.4
From c79a07d98d061ffa00ba86fe243c9ef69885af93 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:27:13 +0200
Subject: [PATCH 7/9] s4:client: fix -Wtautological-compare error in
free_file_list()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/client/client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/client/client.c b/source4/client/client.c
index 4807123..384ddc6 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -1301,7 +1301,7 @@ static void free_file_list (struct file_list * list)
while (list)
{
tmp = list;
- DLIST_REMOVE(list, list);
+ DLIST_REMOVE(list, tmp);
SAFE_FREE(tmp->file_path);
SAFE_FREE(tmp);
}
--
2.7.4
From cc74fd6112219c5567b2493ac2ae17a5ae492471 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:28:22 +0200
Subject: [PATCH 8/9] nmbd: fix -Wtautological-compare error in run_dns_queue()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/nmbd/asyncdns.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c
index b4532fa..2767ef6 100644
--- a/source3/nmbd/asyncdns.c
+++ b/source3/nmbd/asyncdns.c
@@ -273,7 +273,7 @@ void run_dns_queue(struct messaging_context *msg)
if (dns_queue) {
dns_current = dns_queue;
- DLIST_REMOVE(dns_queue, dns_queue);
+ DLIST_REMOVE(dns_queue, dns_current);
if (!write_child(dns_current)) {
DEBUG(3,("failed to send DNS query to child!\n"));
--
2.7.4
From 82dfea75cd2700695debb31bf7ea0e660a848a5c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 02:30:20 +0200
Subject: [PATCH 9/9] s3:smbtree: fix -Wtautological compare error in
free_name_list()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/utils/smbtree.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 58410e8..ea9e74e 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -45,8 +45,10 @@ static struct smb_name_list *workgroups, *servers, *shares;
static void free_name_list(struct smb_name_list *list)
{
- while(list)
- DLIST_REMOVE(list, list);
+ while(list) {
+ struct smb_name_list *current = list;
+ DLIST_REMOVE(list, current);
+ }
}
static void add_name(const char *machine_name, uint32_t server_type,
--
2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160713/1f31a5b3/signature.sig>
More information about the samba-technical
mailing list