Skip to content

Commit 5b9a3b6

Browse files
committed
libcli: fix compilation with GCC14
GCC 14 does not like 1 as the second parameter to calloc. Clean up definition to avoid using PKG_SOURCE_DATE and to just use PKG_VERSION. Signed-off-by: Rosen Penev <rosenp@gmail.com>
1 parent 39dad4f commit 5b9a3b6

2 files changed

Lines changed: 100 additions & 5 deletions

File tree

libs/libcli/Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
include $(TOPDIR)/rules.mk
66

77
PKG_NAME:=libcli
8+
PKG_VERSION:=1.10.7
89

910
PKG_SOURCE_PROTO:=git
10-
PKG_SOURCE_URL=https://github.com/dparrish/libcli.git
11-
PKG_SOURCE_DATE:=2022-07-06
12-
PKG_SOURCE_VERSION:=V1.10.7
13-
PKG_MIRROR_HASH:=ee686c27f80317680d151423b621ed0643992e28f6b5be2caca28318a25fe98c
11+
PKG_SOURCE_VERSION:=V$(PKG_VERSION)
12+
PKG_SOURCE_URL=https://github.com/dparrish/libcli
13+
PKG_MIRROR_HASH:=a9842266ae80f78b838f71c98bbfeed6c7082fadedd2d9a301aedc3e47a88af7
1414

1515
PKG_MAINTAINER:=Martin Blumenstingl <martin.blumenstingl@googlemail.com>
1616
PKG_LICENSE:=LGPL-2.1
@@ -25,7 +25,6 @@ define Package/libcli
2525
CATEGORY:=Libraries
2626
TITLE:=libcli
2727
URL:=https://dparrish.com/link/libcli
28-
DEPENDS:=+libc
2928
endef
3029

3130
define Package/libcli/description
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
--- a/libcli.c
2+
+++ b/libcli.c
3+
@@ -427,7 +427,7 @@ struct cli_command *cli_register_command
4+
struct cli_command *c;
5+
6+
if (!command) return NULL;
7+
- if (!(c = calloc(sizeof(struct cli_command), 1))) return NULL;
8+
+ if (!(c = calloc(1, sizeof(struct cli_command)))) return NULL;
9+
c->command_type = CLI_REGULAR_COMMAND;
10+
c->callback = callback;
11+
c->next = NULL;
12+
@@ -597,10 +597,10 @@ struct cli_def *cli_init() {
13+
struct cli_def *cli;
14+
struct cli_command *c;
15+
16+
- if (!(cli = calloc(sizeof(struct cli_def), 1))) return 0;
17+
+ if (!(cli = calloc(1, sizeof(struct cli_def)))) return 0;
18+
19+
cli->buf_size = 1024;
20+
- if (!(cli->buffer = calloc(cli->buf_size, 1))) {
21+
+ if (!(cli->buffer = calloc(1, cli->buf_size))) {
22+
cli_done(cli);
23+
return 0;
24+
}
25+
@@ -778,7 +778,7 @@ static char *cli_int_return_newword(cons
26+
27+
// allocate space (including terminal NULL, then go through and deal with escaping characters as we copy them
28+
29+
- if (!(newword = calloc(len + 1, 1))) return 0;
30+
+ if (!(newword = calloc(1, len + 1))) return 0;
31+
to = newword;
32+
while (start != end) {
33+
if (*start == '\\')
34+
@@ -1940,7 +1940,7 @@ int cli_match_filter_init(struct cli_def
35+
char *search_flags = cli_get_optarg_value(cli, "search_flags", NULL);
36+
37+
filt->filter = cli_match_filter;
38+
- filt->data = state = calloc(sizeof(struct cli_match_filter_state), 1);
39+
+ filt->data = state = calloc(1, sizeof(struct cli_match_filter_state));
40+
if (!state) return CLI_ERROR;
41+
42+
if (!strcmp(cli->pipeline->current_stage->words[0], "include")) {
43+
@@ -2033,7 +2033,7 @@ int cli_range_filter_init(struct cli_def
44+
// from the command line processing and continue
45+
46+
filt->filter = cli_range_filter;
47+
- filt->data = state = calloc(sizeof(struct cli_range_filter_state), 1);
48+
+ filt->data = state = calloc(1, sizeof(struct cli_range_filter_state));
49+
if (state) {
50+
state->from = from;
51+
state->to = to;
52+
@@ -2070,7 +2070,7 @@ int cli_count_filter_init(struct cli_def
53+
}
54+
55+
filt->filter = cli_count_filter;
56+
- if (!(filt->data = calloc(sizeof(int), 1))) return CLI_ERROR;
57+
+ if (!(filt->data = calloc(1, sizeof(int)))) return CLI_ERROR;
58+
59+
return CLI_OK;
60+
}
61+
@@ -2127,7 +2127,7 @@ struct cli_command *cli_register_filter(
62+
struct cli_command *c;
63+
64+
if (!command) return NULL;
65+
- if (!(c = calloc(sizeof(struct cli_command), 1))) return NULL;
66+
+ if (!(c = calloc(1, sizeof(struct cli_command)))) return NULL;
67+
68+
c->command_type = CLI_FILTER_COMMAND;
69+
c->init = init;
70+
@@ -2239,7 +2239,7 @@ struct cli_optarg *cli_register_optarg(s
71+
goto CLEANUP;
72+
}
73+
}
74+
- if (!(optarg = calloc(sizeof(struct cli_optarg), 1))) goto CLEANUP;
75+
+ if (!(optarg = calloc(1, sizeof(struct cli_optarg)))) goto CLEANUP;
76+
if (!(optarg->name = strdup(name))) goto CLEANUP;
77+
if (help && !(optarg->help = strdup(help))) goto CLEANUP;
78+
79+
@@ -2505,7 +2505,7 @@ struct cli_command *cli_int_register_bui
80+
struct cli_command *c;
81+
82+
if (!command) return NULL;
83+
- if (!(c = calloc(sizeof(struct cli_command), 1))) return NULL;
84+
+ if (!(c = calloc(1, sizeof(struct cli_command)))) return NULL;
85+
86+
c->flags = flags;
87+
c->callback = callback;
88+
@@ -3068,7 +3068,7 @@ int cli_int_execute_pipeline(struct cli_
89+
struct cli_pipeline_stage *stage = &pipeline->stage[stage_num];
90+
pipeline->current_stage = stage;
91+
cli->found_optargs = stage->found_optargs;
92+
- *filt = calloc(sizeof(struct cli_filter), 1);
93+
+ *filt = calloc(1, sizeof(struct cli_filter));
94+
if (*filt) {
95+
if ((rc = stage->command->init(cli, stage->num_words, stage->words, *filt) != CLI_OK)) {
96+
break;

0 commit comments

Comments
 (0)