[Asterisk-code-review] app: Remove silly usage of RAII VAR. (asterisk[15])

Joshua Colp asteriskteam at digium.com
Tue Nov 21 09:27:32 CST 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/7320 )

Change subject: app: Remove silly usage of RAII_VAR.
......................................................................

app: Remove silly usage of RAII_VAR.

Change-Id: Ideb594f7aae134974fb78d5477ba0853b97b8625
---
M main/app.c
1 file changed, 5 insertions(+), 8 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/main/app.c b/main/app.c
index 69c96c0..f35c4b7 100644
--- a/main/app.c
+++ b/main/app.c
@@ -3138,7 +3138,7 @@
 
 struct ast_mwi_state *ast_mwi_create(const char *mailbox, const char *context)
 {
-	RAII_VAR(struct ast_mwi_state *, mwi_state, NULL, ao2_cleanup);
+	struct ast_mwi_state *mwi_state;
 
 	ast_assert(!ast_strlen_zero(mailbox));
 
@@ -3148,6 +3148,7 @@
 	}
 
 	if (ast_string_field_init(mwi_state, 256)) {
+		ao2_ref(mwi_state, -1);
 		return NULL;
 	}
 	if (!ast_strlen_zero(context)) {
@@ -3156,7 +3157,6 @@
 		ast_string_field_set(mwi_state, uniqueid, mailbox);
 	}
 
-	ao2_ref(mwi_state, +1);
 	return mwi_state;
 }
 
@@ -3329,8 +3329,8 @@
 					       struct stasis_message_type *message_type,
 					       struct ast_json *blob)
 {
-	RAII_VAR(struct ast_mwi_blob *, obj, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+	struct ast_mwi_blob *obj;
+	struct stasis_message *msg;
 
 	ast_assert(blob != NULL);
 
@@ -3349,11 +3349,8 @@
 
 	/* This is not a normal MWI event.  Only used by the MinivmNotify app. */
 	msg = stasis_message_create(message_type, obj);
-	if (!msg) {
-		return NULL;
-	}
+	ao2_ref(obj, -1);
 
-	ao2_ref(msg, +1);
 	return msg;
 }
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Ideb594f7aae134974fb78d5477ba0853b97b8625
Gerrit-Change-Number: 7320
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171121/ae0d55e2/attachment.html>


More information about the asterisk-code-review mailing list