[asterisk-commits] seanbright: trunk r123009 - /trunk/cdr/cdr_tds.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jun 16 10:25:03 CDT 2008
Author: seanbright
Date: Mon Jun 16 10:25:03 2008
New Revision: 123009
URL: http://svn.digium.com/view/asterisk?view=rev&rev=123009
Log:
Coding guidelines stuff only.
Modified:
trunk/cdr/cdr_tds.c
Modified: trunk/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_tds.c?view=diff&rev=123009&r1=123008&r2=123009
==============================================================================
--- trunk/cdr/cdr_tds.c (original)
+++ trunk/cdr/cdr_tds.c Mon Jun 16 10:25:03 2008
@@ -239,30 +239,26 @@
char *known_bad[] = {"select", "insert", "update", "delete", "drop", ";", "--", "\0"};
int idx;
- if ((buf = ast_malloc(len + 1)) == NULL)
- {
+ if (!(buf = ast_calloc(1, len + 1))) {
ast_log(LOG_ERROR, "cdr_tds: Out of memory error\n");
return NULL;
}
- memset(buf, 0, len);
buf_ptr = buf;
/* Escape single quotes */
- for (; *str && strlen(buf) < len; str++)
- {
- if (*str == '\'')
+ for (; *str && strlen(buf) < len; str++) {
+ if (*str == '\'') {
*buf_ptr++ = '\'';
+ }
*buf_ptr++ = *str;
}
*buf_ptr = '\0';
/* Erase known bad input */
- for (idx=0; *known_bad[idx]; idx++)
- {
- while((srh_ptr = strcasestr(buf, known_bad[idx])))
- {
- memmove(srh_ptr, srh_ptr+strlen(known_bad[idx]), strlen(srh_ptr+strlen(known_bad[idx]))+1);
+ for (idx = 0; *known_bad[idx]; idx++) {
+ while ((srh_ptr = strcasestr(buf, known_bad[idx]))) {
+ memmove(srh_ptr, srh_ptr + strlen(known_bad[idx]), strlen(srh_ptr + strlen(known_bad[idx])) + 1);
}
}
@@ -275,14 +271,11 @@
char buf[80];
/* To make sure we have date variable if not insert null to SQL */
- if (!ast_tvzero(tv))
- {
+ if (!ast_tvzero(tv)) {
ast_localtime(&tv, &tm, NULL);
ast_strftime(buf, 80, DATE_FORMAT, &tm);
sprintf(dateField, "'%s'", buf);
- }
- else
- {
+ } else {
strcpy(dateField, "null");
}
}
@@ -319,12 +312,11 @@
char query[128];
/* Connect to M$SQL Server */
- if (!(login = tds_alloc_login()))
- {
+ if (!(login = tds_alloc_login())) {
ast_log(LOG_ERROR, "tds_alloc_login() failed.\n");
return -1;
}
-
+
tds_set_server(login, hostname);
tds_set_user(login, dbuser);
tds_set_passwd(login, password);
@@ -354,14 +346,12 @@
tds_set_parent(tds, NULL);
connection = tds_read_config_info(tds, login, context->locale);
- if (!connection)
- {
+ if (!connection) {
ast_log(LOG_ERROR, "tds_read_config() failed.\n");
goto connect_fail;
}
- if (tds_connect(tds, connection) == TDS_FAIL)
- {
+ if (tds_connect(tds, connection) == TDS_FAIL) {
ast_log(LOG_ERROR, "Failed to connect to MSSQL server.\n");
tds = NULL; /* freed by tds_connect() on error */
#if (defined(FREETDS_0_63) || defined(FREETDS_0_64))
@@ -438,7 +428,7 @@
ast_config_destroy(cfg);
return 0;
}
-
+
ptr = ast_variable_retrieve(cfg, "global", "hostname");
if (ptr) {
if (hostname)
More information about the asterisk-commits
mailing list