[PATCH] append _unused to the expression defined using unused() macro

classic Classic list List threaded Threaded
3 messages Options
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

[PATCH] append _unused to the expression defined using unused() macro

This way if variables defined using unused() macro are actually
used then code will not compile...

- removed unused usage around one argc and one argv since those
  were used

- changed one unused (char *argv[]) to unused (char **argv) to
  work with modified unused() macro definition
---

Noticed this when looking some dkg's changes (not in his code,
but in diff context).

I cannot think of a case where this would not work.

(and note to self: fix similar unused() definition on some
 of my own projects, forgot '##' there (a_unused does not
 expand macro variable a ;))

 notmuch-client.h | 2 +-
 notmuch-setup.c  | 2 +-
 notmuch.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 39e26f2e..b3a501a9 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -53,7 +53,7 @@
 #include "talloc-extra.h"
 #include "crypto.h"
 
-#define unused(x) x __attribute__ ((unused))
+#define unused(x) x ## _unused __attribute__ ((unused))
 
 #define STRINGIFY(s) STRINGIFY_(s)
 #define STRINGIFY_(s) #s
diff --git a/notmuch-setup.c b/notmuch-setup.c
index 53048005..81419ccf 100644
--- a/notmuch-setup.c
+++ b/notmuch-setup.c
@@ -121,7 +121,7 @@ parse_tag_list (void *ctx, char *response)
 
 int
 notmuch_setup_command (notmuch_config_t *config,
-       unused (int argc), unused (char *argv[]))
+       int argc, char *argv[])
 {
     char *response = NULL;
     size_t response_size = 0;
diff --git a/notmuch.c b/notmuch.c
index eeb794e8..2ddc8fbc 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -358,7 +358,7 @@ notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]
  */
 static int
 notmuch_command (notmuch_config_t *config,
- unused(int argc), unused(char *argv[]))
+ unused(int argc), unused(char **argv))
 {
     char *db_path;
     struct stat st;
--
2.21.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Daniel Kahn Gillmor Daniel Kahn Gillmor
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] append _unused to the expression defined using unused() macro

On Thu 2019-05-30 22:56:14 +0300, Tomi Ollila wrote:
> This way if variables defined using unused() macro are actually
> used then code will not compile...
>
> - removed unused usage around one argc and one argv since those
>   were used
>
> - changed one unused (char *argv[]) to unused (char **argv) to
>   work with modified unused() macro definition

lgtm.  i've tested it against the master branch, and it works fine.  I
like the belt-and-suspenders approach.

       --dkg

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (233 bytes) Download Attachment
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] append _unused to the expression defined using unused() macro

In reply to this post by Tomi Ollila-2
Tomi Ollila <[hidden email]> writes:

> This way if variables defined using unused() macro are actually
> used then code will not compile...

pushed to master

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch