Skip to content

Commit

Permalink
BUILD: stick-table: fix build error on 32-bit platforms
Browse files Browse the repository at this point in the history
Commit 9b2717e ("MINOR: stktable: use {show,set,clear} table with ptr")
stores a pointer in a long long (64bit), which fails the cas to void* on
32-bit platforms:

  src/stick_table.c: In function 'table_process_entry_per_ptr':
  src/stick_table.c:5136:37: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   5136 |         ts = stktable_lookup_ptr(t, (void *)ptr);

On all our supported platforms, longs and pointers are of the same size,
so let's just turn this to a ulong instead.
  • Loading branch information
wtarreau committed Jan 21, 2024
1 parent 6e5aa16 commit cdc993b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/stick_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -5121,15 +5121,15 @@ static int table_process_entry_per_ptr(struct appctx *appctx, char **args)
{
struct show_table_ctx *ctx = appctx->svcctx;
struct stktable *t = ctx->target;
long long int ptr;
ulong ptr;
char *error;
struct stksess *ts;

if (!*args[4] || args[4][0] != '0' || args[4][1] != 'x')
return cli_err(appctx, "Pointer expected (0xffff notation)\n");

/* Convert argument to integer value */
ptr = strtoll(args[4], &error, 16);
ptr = strtoul(args[4], &error, 16);
if (*error != '\0')
return cli_err(appctx, "Malformed ptr.\n");

Expand Down

0 comments on commit cdc993b

Please sign in to comment.