[Asterisk-code-review] core: Remove incorrect usage of attribute malloc. (asterisk[13])

Jenkins2 asteriskteam at digium.com
Wed Mar 14 20:53:38 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8518 )

Change subject: core: Remove incorrect usage of attribute_malloc.
......................................................................

core: Remove incorrect usage of attribute_malloc.

GCC documentation states that when __attribute__((malloc)) is used it
should not return storage which contains any valid pointers.  It
specifically mentions that realloc functions should not have the malloc
attribute, but this also means that complex initializers which could
contain initialized pointers should not use this attribute.

Change-Id: If507f33ffb3ca3b83b702196eb0e8215d27fc7d2
---
M include/asterisk/channel.h
M include/asterisk/datastore.h
M include/asterisk/stringfields.h
M include/asterisk/utils.h
M main/channel.c
M utils/extconf.c
6 files changed, 7 insertions(+), 7 deletions(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 393c020..7b406e5 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -1098,7 +1098,7 @@
  * \deprecated You should use the ast_datastore_alloc() generic function instead.
  * \version 1.6.1 deprecated
  */
-struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
+struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
 	__attribute__((deprecated));
 
 /*!
@@ -1157,7 +1157,7 @@
  *       and "default" context.
  * \note Since 12.0.0 this function returns with the newly created channel locked.
  */
-struct ast_channel * attribute_malloc __attribute__((format(printf, 15, 16)))
+struct ast_channel * __attribute__((format(printf, 15, 16)))
 	__ast_channel_alloc(int needqueue, int state, const char *cid_num,
 		const char *cid_name, const char *acctcode,
 		const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
diff --git a/include/asterisk/datastore.h b/include/asterisk/datastore.h
index 8f59fd3..e920fc0b 100644
--- a/include/asterisk/datastore.h
+++ b/include/asterisk/datastore.h
@@ -80,7 +80,7 @@
  * \param file, line, function
  * \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc
  */
-struct ast_datastore * attribute_malloc __ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid,
+struct ast_datastore *__ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid,
 							      const char *file, int line, const char *function);
 
 #define ast_datastore_alloc(info, uid) __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__)
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index 0e0d20a..81575ac 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -443,7 +443,7 @@
  * \internal
  * \brief internal version of ast_calloc_with_stringfields
  */
-void * attribute_malloc __ast_calloc_with_stringfields(unsigned int num_structs,
+void *__ast_calloc_with_stringfields(unsigned int num_structs,
 	size_t struct_size, size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size,
 	const char *file, int lineno, const char *func);
 
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 876e53c..290f7a3 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -610,7 +610,7 @@
 	_ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 AST_INLINE_API(
-void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
+void *_ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
 {
 	void *newp;
 
diff --git a/main/channel.c b/main/channel.c
index 48963c7..70e0bff 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -790,7 +790,7 @@
 }
 
 /*! \brief Create a new channel structure */
-static struct ast_channel * attribute_malloc __attribute__((format(printf, 15, 0)))
+static struct ast_channel *__attribute__((format(printf, 15, 0)))
 __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name,
 		       const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
 		       const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint,
diff --git a/utils/extconf.c b/utils/extconf.c
index 690d06e..97cfaa9 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -816,7 +816,7 @@
 	_ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 AST_INLINE_API(
-void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
+void *_ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
 {
 	void *newp;
 

-- 
To view, visit https://gerrit.asterisk.org/8518
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: If507f33ffb3ca3b83b702196eb0e8215d27fc7d2
Gerrit-Change-Number: 8518
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180314/1f1c5fb0/attachment.html>


More information about the asterisk-code-review mailing list