[svn-commits] seanbright: trunk r129864 - in /trunk/res: res_config_ldap.c res_config_pgsql.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 10 19:55:06 CDT 2008


Author: seanbright
Date: Thu Jul 10 19:55:06 2008
New Revision: 129864

URL: http://svn.digium.com/view/asterisk?view=rev&rev=129864
Log:
Fix some usages of snprintf, and clarify a couple variable names.

Modified:
    trunk/res/res_config_ldap.c
    trunk/res/res_config_pgsql.c

Modified: trunk/res/res_config_ldap.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_config_ldap.c?view=diff&rev=129864&r1=129863&r2=129864
==============================================================================
--- trunk/res/res_config_ldap.c (original)
+++ trunk/res/res_config_ldap.c Thu Jul 10 19:55:06 2008
@@ -1525,7 +1525,7 @@
 
 static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	char status[256], status2[100] = "";
+	char status[256], credentials[100] = "";
 	int ctime = time(NULL) - connect_time;
 
 	switch (cmd) {
@@ -1546,26 +1546,26 @@
 		snprintf(status, sizeof(status), "Connected to '%s', baseDN %s", url, basedn);
 
 	if (!ast_strlen_zero(user))
-		snprintf(status2, sizeof(status2), " with username %s", user);
+		snprintf(credentials, sizeof(credentials), " with username %s", user);
 
 	if (ctime > 31536000) {
 		ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
-				status, status2, ctime / 31536000,
+				status, credentials, ctime / 31536000,
 				(ctime % 31536000) / 86400, (ctime % 86400) / 3600,
 				(ctime % 3600) / 60, ctime % 60);
 	} else if (ctime > 86400) {
 		ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n",
-				status, status2, ctime / 86400, (ctime % 86400) / 3600,
+				status, credentials, ctime / 86400, (ctime % 86400) / 3600,
 				(ctime % 3600) / 60, ctime % 60);
 	} else if (ctime > 3600) {
 		ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n",
-				status, status2, ctime / 3600, (ctime % 3600) / 60,
+				status, credentials, ctime / 3600, (ctime % 3600) / 60,
 				ctime % 60);
 	} else if (ctime > 60) {
-		ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, status2,
+		ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials,
 					ctime / 60, ctime % 60);
 	} else {
-		ast_cli(a->fd, "%s%s for %d seconds.\n", status, status2, ctime);
+		ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctime);
 	}
 
 	return CLI_SUCCESS;

Modified: trunk/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_config_pgsql.c?view=diff&rev=129864&r1=129863&r2=129864
==============================================================================
--- trunk/res/res_config_pgsql.c (original)
+++ trunk/res/res_config_pgsql.c Thu Jul 10 19:55:06 2008
@@ -1329,7 +1329,7 @@
 
 static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	char status[256], status2[100] = "";
+	char status[256], credentials[100] = "";
 	int ctime = time(NULL) - connect_time;
 
 	switch (cmd) {
@@ -1348,31 +1348,31 @@
 
 	if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
 		if (!ast_strlen_zero(dbhost))
-			snprintf(status, 255, "Connected to %s@%s, port %d", dbname, dbhost, dbport);
+			snprintf(status, sizeof(status), "Connected to %s@%s, port %d", dbname, dbhost, dbport);
 		else if (!ast_strlen_zero(dbsock))
-			snprintf(status, 255, "Connected to %s on socket file %s", dbname, dbsock);
+			snprintf(status, sizeof(status), "Connected to %s on socket file %s", dbname, dbsock);
 		else
-			snprintf(status, 255, "Connected to %s@%s", dbname, dbhost);
+			snprintf(status, sizeof(status), "Connected to %s@%s", dbname, dbhost);
 
 		if (!ast_strlen_zero(dbuser))
-			snprintf(status2, 99, " with username %s", dbuser);
+			snprintf(credentials, sizeof(credentials), " with username %s", dbuser);
 
 		if (ctime > 31536000)
 			ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
-					status, status2, ctime / 31536000, (ctime % 31536000) / 86400,
+					status, credentials, ctime / 31536000, (ctime % 31536000) / 86400,
 					(ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
 		else if (ctime > 86400)
 			ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status,
-					status2, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60,
+					credentials, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60,
 					ctime % 60);
 		else if (ctime > 3600)
-			ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, status2,
+			ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, credentials,
 					ctime / 3600, (ctime % 3600) / 60, ctime % 60);
 		else if (ctime > 60)
-			ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, status2, ctime / 60,
+			ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials, ctime / 60,
 					ctime % 60);
 		else
-			ast_cli(a->fd, "%s%s for %d seconds.\n", status, status2, ctime);
+			ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctime);
 
 		return CLI_SUCCESS;
 	} else {




More information about the svn-commits mailing list