]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
build: Fix a few gcc 13 issues
authorGeorge Joseph <gjoseph@sangoma.com>
Fri, 9 Jun 2023 14:41:32 +0000 (08:41 -0600)
committerasterisk-org-access-app[bot] <120671045+asterisk-org-access-app[bot]@users.noreply.github.com>
Fri, 9 Jun 2023 18:19:53 +0000 (18:19 +0000)
* gcc 13 is now catching when a function is declared as returning
  an enum but defined as returning an int or vice versa.  Fixed
  a few in app.h, loader.c, stasis_message.c.

* gcc 13 is also now (incorrectly) complaining of dangling pointers
  when assigning a pointer to a local char array to a char *. Had
  to change that to an ast_alloca.

Resolves: #155

include/asterisk/app.h
main/loader.c
main/stasis_message.c
tests/test_utils.c

index e65ead892e9e476e7d24e75114fe86fa4b9cfe94..35101a79a00e3af88219b3b431ea6d92266ee705 100644 (file)
@@ -137,7 +137,7 @@ int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbd
  *  is pressed during playback, it will immediately break out of the message and continue
  *  execution of your code.
  */
-int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout);
+enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout);
 
 /*! \brief Plays a stream and gets DTMF data from a channel
  * \param c Which channel one is interacting with
@@ -154,7 +154,7 @@ int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxl
  *  is pressed during playback, it will immediately break out of the message and continue
  *  execution of your code.
  */
-int ast_app_getdata_terminator(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator);
+enum ast_getdata_result ast_app_getdata_terminator(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator);
 
 /*! \brief Full version with audiofd and controlfd.  NOTE: returns '2' on ctrlfd available, not '1' like other full functions */
 int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd);
index 1c06d6e648f940a7ef1490ae6738822a37f209e1..9f8587d731d6662ece034c0b33f420e6abfba707 100644 (file)
@@ -1821,10 +1821,10 @@ prestart_error:
        return res;
 }
 
-int ast_load_resource(const char *resource_name)
+enum ast_module_load_result ast_load_resource(const char *resource_name)
 {
        struct ast_module *mod;
-       int res;
+       enum ast_module_load_result res;
 
        /* If we're trying to load a module that previously declined to load,
         * transparently unload it first so we dlclose, then dlopen it afresh.
index d3f304cc77a16ed70ffd6184a1229ef99358aa4a..5221027aacae1b54dd22f443c5d7991471c9ea68 100644 (file)
@@ -53,7 +53,7 @@ static void message_type_dtor(void *obj)
        type->name = NULL;
 }
 
-int stasis_message_type_create(const char *name,
+enum stasis_message_type_result stasis_message_type_create(const char *name,
        struct stasis_message_vtable *vtable,
        struct stasis_message_type **result)
 {
index 0f9400e9aa3084e4a16cb13c92f40f3bf6f87f51..73b2e3a6ceeeadd10434738b242a7035a1cbc102 100644 (file)
@@ -130,9 +130,9 @@ AST_TEST_DEFINE(quoted_escape_test)
 {
        int res = AST_TEST_PASS;
        const char *in = "a\"bcdefg\"hijkl\\mnopqrs tuv\twxyz";
-       char out[256] = { 0 };
-       char small[4] = { 0 };
        int i;
+#define LONG_SIZE 256
+#define SHORT_SIZE 4
 
        static struct {
                char *buf;
@@ -140,14 +140,14 @@ AST_TEST_DEFINE(quoted_escape_test)
 
                const char *output;
        } tests[] = {
-               {0, sizeof(out),
+               {NULL, LONG_SIZE,
                        "a\\\"bcdefg\\\"hijkl\\\\mnopqrs tuv\twxyz"},
-               {0, sizeof(small),
+               {NULL, SHORT_SIZE,
                        "a\\\""},
        };
 
-       tests[0].buf = out;
-       tests[1].buf = small;
+       tests[0].buf = ast_alloca(LONG_SIZE);
+       tests[1].buf = ast_alloca(SHORT_SIZE);
 
        switch (cmd) {
        case TEST_INIT:
@@ -171,6 +171,8 @@ AST_TEST_DEFINE(quoted_escape_test)
                }
        }
 
+#undef LONG_SIZE
+#undef SHORT_SIZE
        return res;
 }