[asterisk-bugs] [JIRA] Created: (ASTERISK-20408) constify astobj2's __ao2_ref_debug parameters

Matt Jordan (JIRA) noreply at issues.asterisk.org
Wed Sep 12 09:22:07 CDT 2012


constify astobj2's __ao2_ref_debug parameters
---------------------------------------------

                 Key: ASTERISK-20408
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-20408
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
            Reporter: Matt Jordan
            Severity: Trivial


In Asterisk 1.8, astobj2's __ao2_ref_debug has the following definition:

{noformat}
int __ao2_ref_debug(void *o, int delta, char *tag, char *file, int line, const char *funcname);
{noformat}

Because {{tag}} is not {{const}}, defining {{REF_DEBUG}} either in {{astobj2.h}} or in {{ccss.c}} results in the following warnings:

{noformat}
ccss.c:136:2: error: passing argument 3 of '__ao2_ref_debug' discards 'const' qualifier from pointer target type [-Werror]
workspace/1.8/include/asterisk/astobj2.h:468:5: note: expected 'char *' but argument is of type 'const char *'
ccss.c: In function 'cc_unref':
ccss.c:142:2: error: passing argument 3 of '__ao2_ref_debug' discards 'const' qualifier from pointer target type [-Werror]
workspace/1.8/include/asterisk/astobj2.h:468:5: note: expected 'char *' but argument is of type 'const char *'
cc1: all warnings being treated as errors
{noformat}

{{ccss.c}} attempts to treat the {{tag}} as a {{const}} character string (which it probably should be):

{noformat}
static inline void *cc_ref(void *obj, const char *debug)
{
	ao2_t_ref(obj, +1, debug);
	return obj;
}

static inline void *cc_unref(void *obj, const char *debug)
{
	ao2_t_ref(obj, -1, debug);
	return NULL;
}
{noformat}

There isn't any reason that I can think of to allow {{tag}} or {{file}} to be modified in {{astobj2}}.



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list