public inbox for [email protected]
 help / color / mirror / Atom feed
* [GIT PULL tor v1 0/6] Build fixes for clang-15
@ 2022-05-26 11:41 Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 1/6] channel: Fix clang-15 complaint (unused variable) Ammar Faizi
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-05-26 11:41 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Nick Mathewson

Hi,

This series fixes build issue when compiling with clang-15.
There are 6 patches in this series:

  - Patch 1 to 5 are fixes of unused variable warnings.

  - Patch 6 is a fix for pragma that only exists in GCC but used in
    clang.

It's available in the git repository below...

Please pull, thank you!

---
The following changes since commit 69e3b8bb843aaab65ec3a740348f5481bac13513:

  Merge branch 'tor-gitlab/mr/567' (2022-05-24 15:24:48 -0400)

are available in the Git repository at:

  https://gitlab.torproject.org/ammarfaizi2/tor.git tags/clang-fixes

for you to fetch changes up to dee215fe16e37ec0a369519facdc4648074a35b1:

  test/test_hs_descriptor: Don't invoke GCC warning when compiling with clang (2022-05-26 18:28:01 +0700)

Signed-off-by: Ammar Faizi <[email protected]>
---

Ammar Faizi (6):
  channel: Fix clang-15 complaint (unused variable)
  connection_or: Fix clang-15 complaint (unused variable)
  routerlist: Fix clang-15 complaint (unused variable)
  compat_libevent: Fix clang-15 complaint (unused variable)
  test/bench: Fix clang-15 complaint (unused variable)
  test/test_hs_descriptor: Don't invoke GCC warning when compiling with clang

 src/core/or/channel.c             | 4 +---
 src/core/or/connection_or.c       | 4 ++++
 src/feature/nodelist/routerlist.c | 2 --
 src/lib/evloop/compat_libevent.c  | 2 --
 src/test/bench.c                  | 1 +
 src/test/test_hs_descriptor.c     | 3 +++
 6 files changed, 9 insertions(+), 7 deletions(-)


base-commit: 69e3b8bb843aaab65ec3a740348f5481bac13513
-- 
Ammar Faizi


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH tor v1 1/6] channel: Fix clang-15 complaint (unused variable)
  2022-05-26 11:41 [GIT PULL tor v1 0/6] Build fixes for clang-15 Ammar Faizi
@ 2022-05-26 11:41 ` Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 2/6] connection_or: " Ammar Faizi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-05-26 11:41 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Nick Mathewson

Commit faa752f3c9bd3faa ("Adjust the rules for warning about too many
connections") added an unused variable @total_dirauth_connections.
It results in the following clang-15 complaint:

```
  src/core/or/channel.c:752:7: error: variable 'total_dirauth_connections' set but not used [-Werror,-Wunused-but-set-variable]
    int total_dirauth_connections = 0, total_dirauths = 0;
        ^
  1 error generated.
```

Fix it by removing the variable.

Cc: Nick Mathewson <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/core/or/channel.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/core/or/channel.c b/src/core/or/channel.c
index c46fa93e58..84f0d7d852 100644
--- a/src/core/or/channel.c
+++ b/src/core/or/channel.c
@@ -749,7 +749,7 @@ channel_check_for_duplicates(void)
 {
   channel_idmap_entry_t **iter;
   channel_t *chan;
-  int total_dirauth_connections = 0, total_dirauths = 0;
+  int total_dirauths = 0;
   int total_relay_connections = 0, total_relays = 0, total_canonical = 0;
   int total_half_canonical = 0;
   int total_gt_one_connection = 0, total_gt_two_connections = 0;
@@ -777,8 +777,6 @@ channel_check_for_duplicates(void)
 
       connections_to_relay++;
       total_relay_connections++;
-      if (is_dirauth)
-        total_dirauth_connections++;
 
       if (chan->is_canonical(chan)) total_canonical++;
 
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH tor v1 2/6] connection_or: Fix clang-15 complaint (unused variable)
  2022-05-26 11:41 [GIT PULL tor v1 0/6] Build fixes for clang-15 Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 1/6] channel: Fix clang-15 complaint (unused variable) Ammar Faizi
@ 2022-05-26 11:41 ` Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 3/6] routerlist: " Ammar Faizi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-05-26 11:41 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Nick Mathewson

clang-15 throws the following complaints:

```
  src/core/or/connection_or.c:1075:7: error: variable 'n_old' set but not used [-Werror,-Wunused-but-set-variable]
    int n_old = 0, n_inprogress = 0, n_canonical = 0, n_other = 0;
        ^
  src/core/or/connection_or.c:1075:53: error: variable 'n_other' set but not used [-Werror,-Wunused-but-set-variable]
    int n_old = 0, n_inprogress = 0, n_canonical = 0, n_other = 0;
                                                      ^
  src/core/or/connection_or.c:1075:18: error: variable 'n_inprogress' set but not used [-Werror,-Wunused-but-set-variable]
    int n_old = 0, n_inprogress = 0, n_canonical = 0, n_other = 0;
                   ^
```

These variables firstly introduced in commit df608fef4522 ("Checkpoint
my big bug-891 patch."). Now they are no longer used. But I personally
think these variables may still be useful for counting purpose someday.
As such add `(void)` cast to them to suppress the clang complaints.

Cc: Nick Mathewson <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/core/or/connection_or.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/core/or/connection_or.c b/src/core/or/connection_or.c
index 0018b1dfd8..5a387b54fe 100644
--- a/src/core/or/connection_or.c
+++ b/src/core/or/connection_or.c
@@ -1075,6 +1075,10 @@ connection_or_group_set_badness_(smartlist_t *group, int force)
   int n_old = 0, n_inprogress = 0, n_canonical = 0, n_other = 0;
   time_t now = time(NULL);
 
+  (void)n_old;
+  (void)n_inprogress;
+  (void)n_other;
+
   /* Pass 1: expire everything that's old, and see what the status of
    * everything else is. */
   SMARTLIST_FOREACH_BEGIN(group, or_connection_t *, or_conn) {
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH tor v1 3/6] routerlist: Fix clang-15 complaint (unused variable)
  2022-05-26 11:41 [GIT PULL tor v1 0/6] Build fixes for clang-15 Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 1/6] channel: Fix clang-15 complaint (unused variable) Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 2/6] connection_or: " Ammar Faizi
@ 2022-05-26 11:41 ` Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 4/6] compat_libevent: " Ammar Faizi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-05-26 11:41 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Nick Mathewson

clang-15 throws the following complaint:

```
  src/feature/nodelist/routerlist.c:246:7: error: variable 'nocache' set but not used [-Werror,-Wunused-but-set-variable]
    int nocache=0;
        ^
  1 error generated.
```

This variable firstly introduced in commit 3ad6dc0e2e91 ("r15806@catbus:
nickm | 2007-10-15 19:14:57 -0400"). Remove it.

Cc: Nick Mathewson <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/feature/nodelist/routerlist.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/feature/nodelist/routerlist.c b/src/feature/nodelist/routerlist.c
index 8bcc42bc3f..2df282733c 100644
--- a/src/feature/nodelist/routerlist.c
+++ b/src/feature/nodelist/routerlist.c
@@ -243,7 +243,6 @@ router_rebuild_store(int flags, desc_store_t *store)
   int r = -1;
   off_t offset = 0;
   smartlist_t *signed_descriptors = NULL;
-  int nocache=0;
   size_t total_expected_len = 0;
   int had_any;
   int force = flags & RRS_FORCE;
@@ -304,7 +303,6 @@ router_rebuild_store(int flags, desc_store_t *store)
         goto done;
       }
       if (sd->do_not_cache) {
-        ++nocache;
         continue;
       }
       c = tor_malloc(sizeof(sized_chunk_t));
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH tor v1 4/6] compat_libevent: Fix clang-15 complaint (unused variable)
  2022-05-26 11:41 [GIT PULL tor v1 0/6] Build fixes for clang-15 Ammar Faizi
                   ` (2 preceding siblings ...)
  2022-05-26 11:41 ` [PATCH tor v1 3/6] routerlist: " Ammar Faizi
@ 2022-05-26 11:41 ` Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 5/6] test/bench: " Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 6/6] test/test_hs_descriptor: Don't invoke GCC warning when compiling with clang Ammar Faizi
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-05-26 11:41 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Nick Mathewson

clang-15 throws the following complaint:

```
  src/lib/evloop/compat_libevent.c:140:9: error: variable 'attempts' set but not used [-Werror,-Wunused-but-set-variable]
      int attempts = 0;
          ^
  1 error generated.
```

This variable firstly introduced in commit 7be50c26e8b2 ("Disable IOCP
and retry event_base_new_with_config once on failure"). It's not used.
Remove it.

Cc: Nick Mathewson <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/lib/evloop/compat_libevent.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/lib/evloop/compat_libevent.c b/src/lib/evloop/compat_libevent.c
index fd840f8085..c882d3478e 100644
--- a/src/lib/evloop/compat_libevent.c
+++ b/src/lib/evloop/compat_libevent.c
@@ -137,10 +137,8 @@ tor_libevent_initialize(tor_libevent_cfg_t *torcfg)
   (void)torcfg;
 
   {
-    int attempts = 0;
     struct event_config *cfg;
 
-    ++attempts;
     cfg = event_config_new();
     tor_assert(cfg);
 
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH tor v1 5/6] test/bench: Fix clang-15 complaint (unused variable)
  2022-05-26 11:41 [GIT PULL tor v1 0/6] Build fixes for clang-15 Ammar Faizi
                   ` (3 preceding siblings ...)
  2022-05-26 11:41 ` [PATCH tor v1 4/6] compat_libevent: " Ammar Faizi
@ 2022-05-26 11:41 ` Ammar Faizi
  2022-05-26 11:41 ` [PATCH tor v1 6/6] test/test_hs_descriptor: Don't invoke GCC warning when compiling with clang Ammar Faizi
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-05-26 11:41 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Nick Mathewson

clang-15 throws the following complaint:

```
  src/test/bench.c:380:14: error: variable 't' set but not used [-Werror,-Wunused-but-set-variable]
      uint32_t t=0;
               ^
  1 error generated.
```

This variable firstly introduced in commit 490e187056d8 ("Add a
benchmark for our several PRNGs."). Suppress the complaint by
casting it to `(void)`.

Cc: Nick Mathewson <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/test/bench.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/test/bench.c b/src/test/bench.c
index a76ea67eb8..8a4a998e8d 100644
--- a/src/test/bench.c
+++ b/src/test/bench.c
@@ -381,6 +381,7 @@ bench_rand_len(int len)
     for (i = 0; i < N; ++i) {
       t += tor_weak_random(&weak);
     }
+    (void)t;
     end = perftime();
     printf("weak_rand(4): %f nsec.\n", NANOCOUNT(start,end,N));
   }
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH tor v1 6/6] test/test_hs_descriptor: Don't invoke GCC warning when compiling with clang
  2022-05-26 11:41 [GIT PULL tor v1 0/6] Build fixes for clang-15 Ammar Faizi
                   ` (4 preceding siblings ...)
  2022-05-26 11:41 ` [PATCH tor v1 5/6] test/bench: " Ammar Faizi
@ 2022-05-26 11:41 ` Ammar Faizi
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-05-26 11:41 UTC (permalink / raw)
  To: GNU/Weeb Mailing List; +Cc: Ammar Faizi, Nick Mathewson

Compiling with clang-15 yields the following errors:

```
  src/test/test_hs_descriptor.c:36:1: error: pragma diagnostic pop could not pop, no matching push [-Werror,-Wunknown-pragmas]
  ENABLE_GCC_WARNING("-Woverlength-strings")
  ^
  ./src/lib/cc/compat_compiler.h:104:11: note: expanded from macro 'ENABLE_GCC_WARNING'
            PRAGMA_DIAGNOSTIC_(pop)
            ^
  ./src/lib/cc/compat_compiler.h:94:35: note: expanded from macro 'PRAGMA_DIAGNOSTIC_'
  #    define PRAGMA_DIAGNOSTIC_(x) PRAGMA_(clang diagnostic x)
                                    ^
  ./src/lib/cc/compat_compiler.h:92:22: note: expanded from macro 'PRAGMA_'
  #  define PRAGMA_(x) _Pragma (#x)
                       ^
  <scratch space>:188:19: note: expanded from here
   clang diagnostic pop
                    ^
  1 error generated.
```

Do not invoke `ENABLE_GCC_WARNING("-Woverlength-strings")` when we are
compiling with clang. This issue was introduced by commit 3ce2304c6d03
("Use new ENABLE/DISABLE_GCC_WARNING").

Cc: Nick Mathewson <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/test/test_hs_descriptor.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c
index 469e3c39f9..4280b2be38 100644
--- a/src/test/test_hs_descriptor.c
+++ b/src/test/test_hs_descriptor.c
@@ -33,7 +33,10 @@ DISABLE_GCC_WARNING("-Woverlength-strings")
  * at large. */
 #endif
 #include "test_hs_descriptor.inc"
+
+#ifndef __clang__
 ENABLE_GCC_WARNING("-Woverlength-strings")
+#endif
 
 /* Test certificate encoding put in a descriptor. */
 static void
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-26 11:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-26 11:41 [GIT PULL tor v1 0/6] Build fixes for clang-15 Ammar Faizi
2022-05-26 11:41 ` [PATCH tor v1 1/6] channel: Fix clang-15 complaint (unused variable) Ammar Faizi
2022-05-26 11:41 ` [PATCH tor v1 2/6] connection_or: " Ammar Faizi
2022-05-26 11:41 ` [PATCH tor v1 3/6] routerlist: " Ammar Faizi
2022-05-26 11:41 ` [PATCH tor v1 4/6] compat_libevent: " Ammar Faizi
2022-05-26 11:41 ` [PATCH tor v1 5/6] test/bench: " Ammar Faizi
2022-05-26 11:41 ` [PATCH tor v1 6/6] test/test_hs_descriptor: Don't invoke GCC warning when compiling with clang Ammar Faizi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox