[svn-commits] twilson: branch twilson/calendaring r160446 - /team/twilson/calendaring/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 2 23:52:36 CST 2008


Author: twilson
Date: Tue Dec  2 23:52:35 2008
New Revision: 160446

URL: http://svn.digium.com/view/asterisk?view=rev&rev=160446
Log:
More reviewboard cleanup

Modified:
    team/twilson/calendaring/main/calendar.c

Modified: team/twilson/calendaring/main/calendar.c
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/main/calendar.c?view=diff&rev=160446&r1=160445&r2=160446
==============================================================================
--- team/twilson/calendaring/main/calendar.c (original)
+++ team/twilson/calendaring/main/calendar.c Tue Dec  2 23:52:35 2008
@@ -303,7 +303,7 @@
 struct ast_calendar_event *ast_calendar_event_alloc(struct ast_calendar *cal)
 {
 	struct ast_calendar_event *event;
-	if (!(event = ao2_alloc(sizeof(struct ast_calendar_event), calendar_event_destructor))) {
+	if (!(event = ao2_alloc(sizeof(*event), calendar_event_destructor))) {
 		ast_log(LOG_ERROR, "Could not allocate memory for event!\n");
 		return NULL;
 	}
@@ -546,7 +546,7 @@
 static int load_config(void *data)
 {
 	struct ast_config *cfg;
-	char *cat = NULL;
+	const char *cat = NULL;
 	struct ast_variable *v;
 	struct ast_flags config_flags = { 0 };
 	const char *val;
@@ -675,7 +675,7 @@
 		return -1;
 	}
 
-	calendar_is_busy(cal) ? strcpy(buf, "1") : strcpy(buf, "");
+	strcpy(buf, calendar_is_busy(cal) ? "1" : "0");
 
 	return 0;
 }
@@ -769,8 +769,9 @@
 	long val[4];
 	int x;
 
-	for (x=0; x<4; x++)
+	for (x = 0; x < 4; x++) {
 		val[x] = ast_random();
+	}
 	snprintf(buf, size, "%08lx%08lx%08lx%08lx", val[0], val[1], val[2], val[3]);
 
 	return buf;
@@ -911,10 +912,12 @@
 		return -1;
 	}
 
+	ast_channel_lock(chan);
 	if (!(datastore = ast_channel_datastore_find(chan, &eventlist_datastore_info, args.id))) {
 		ast_log(LOG_WARNING, "There is no event notification datastore with id '%s' on '%s'!\n", args.id, chan->name);
 		return -1;
 	}
+	ast_channel_unlock(chan);
 
 	if (!(events = datastore->data)) {
 		ast_log(LOG_WARNING, "The datastore contains no data!\n");
@@ -1060,9 +1063,15 @@
 	}
 
 write_cleanup:
-	if (cal) cal = unref_calendar(cal);
-	if (event) event = ast_calendar_unref_event(event);
-	if (val_dup) ast_free(val_dup);
+	if (cal) {
+		cal = unref_calendar(cal);
+	}
+	if (event) {
+		event = ast_calendar_unref_event(event);
+	}
+	if (val_dup) {
+		ast_free(val_dup);
+	}
 
 	return ret;
 }
@@ -1212,11 +1221,9 @@
 
 		ts.tv_sec = (now.tv_sec + wait / 1000) + 1;
 
-		pthread_testcancel();
 		ast_mutex_lock(&refreshlock);
 		res = ast_cond_timedwait(&refresh_condition, &refreshlock, &ts);
 		ast_mutex_unlock(&refreshlock);
-		pthread_testcancel();
 		ast_sched_runq(sched);
 	}
 
@@ -1227,7 +1234,10 @@
 {
 	struct ast_taskprocessor *load_task;
 
-	calendars = ao2_container_alloc(MAX_BUCKETS, calendar_hash_fn, calendar_cmp_fn);
+	if (!(calendars = ao2_container_alloc(MAX_BUCKETS, calendar_hash_fn, calendar_cmp_fn))) {
+		ast_log(LOG_ERROR, "Unable to allocate calendars container!\n");
+		return -1;
+	}
 
 	__ast_custom_function_register(&calendar_busy_function, NULL);
 	__ast_custom_function_register(&calendar_event_function, NULL);
@@ -1239,7 +1249,10 @@
 	ast_mutex_init(&refreshlock);
 	ast_cond_init(&refresh_condition, NULL);
 
-	sched = sched_context_create();
+	if (!(sched = sched_context_create())) {
+		ast_log(LOG_ERROR, "Unable to create sched context\n");
+		return -1;
+	}
 
 	if (ast_pthread_create_background(&refresh_thread, NULL, do_refresh, NULL) < 0) {
 		ast_log(LOG_ERROR, "Unable to start refresh thread--notifications disabled!\n");
@@ -1247,7 +1260,10 @@
 
 	/* The calendar.conf file shold not be read until all modules are loaded
 	 * else the actual calendar res modules might not be loaded */
-	load_task = ast_taskprocessor_get("calendar_load", TPS_REF_DEFAULT);
+	if (!(load_task = ast_taskprocessor_get("calendar_load", TPS_REF_DEFAULT))) {
+		ast_log(LOG_ERROR, "Could not create taskprocessor!\n");
+		return -1;
+	}
 	ast_taskprocessor_push(load_task, load_config, NULL);
 
 	ast_devstate_prov_add("Calendar", calendarstate);




More information about the svn-commits mailing list