[Rpm-maint] [PATCH] Remove set, but unused, variables in macro.c and rpmlua.c

Panu Matilainen pmatilai at redhat.com
Fri Oct 23 11:37:45 UTC 2020


On 10/23/20 1:58 PM, Mark Wielaard wrote:
> macro.c: In function ‘mbopt’:
> macro.c:895:19: warning: unused variable ‘me’ [-Wunused-variable]
>    895 |     rpmMacroEntry me = mb->me;
>        |                   ^~
> 
> rpmlua.c: In function ‘fd_seek’:
> rpmlua.c:985:22: warning: unused variable ‘mode’ [-Wunused-variable]
>    985 |     static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
>        |                      ^~~~
> ---
>   rpmio/macro.c  | 1 -
>   rpmio/rpmlua.c | 1 -
>   2 files changed, 2 deletions(-)
> 
> diff --git a/rpmio/macro.c b/rpmio/macro.c
> index 800861418..1edcb39e6 100644
> --- a/rpmio/macro.c
> +++ b/rpmio/macro.c
> @@ -892,7 +892,6 @@ static void splitQuoted(ARGV_t *av, const char * str, const char * seps)
>   static int mbopt(int c, const char *oarg, int oint, void *data)
>   {
>       MacroBuf mb = data;
> -    rpmMacroEntry me = mb->me;
>       char *name = NULL, *body = NULL;
>   
>       /* Define option macros. */

Oops, seems my local builds had a leftover override to disable these 
warnings. This is indeed an unused variable...

> diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
> index 8314a296c..2ea985e6e 100644
> --- a/rpmio/rpmlua.c
> +++ b/rpmio/rpmlua.c
> @@ -982,7 +982,6 @@ static int fd_flush(lua_State *L)
>   
>   static int fd_seek(lua_State *L)
>   {
> -    static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
>       static const char *const modenames[] = {"set", "cur", "end", NULL};
>       FD_t *fdp = checkfd(L, 1);
>       int op = luaL_checkoption(L, 2, "cur", modenames);
> 

...but this is actually points out a bug, it should be instead:

@@ -988,7 +988,7 @@ static int fd_seek(lua_State *L)
      int op = luaL_checkoption(L, 2, "cur", modenames);
      off_t offset = luaL_optinteger(L, 3, 0);

-    op = Fseek(*fdp, offset, op);
+    op = Fseek(*fdp, offset, mode[op]);

      if (op < 0 || Ferror(*fdp)) {
         return luaL_error(L, "%s: seek failed: %s",

I'll fixup and commit, thanks!

	- Panu -



More information about the Rpm-maint mailing list