Selaa lähdekoodia

- moved variable declaration at the beginning of the function
- replaced the c++ like comments with standard C one


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3004 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu 18 vuotta sitten
vanhempi
commit
0cdfaf602b
1 muutettua tiedostoa jossa 7 lisäystä ja 6 poistoa
  1. 7 6
      lib/srdb1/db_ut.c

+ 7 - 6
lib/srdb1/db_ut.c

@@ -125,14 +125,15 @@ inline int db_double2str(double _v, char* _s, int* _l)
  */
  */
 inline int db_str2time(const char* _s, time_t* _v)
 inline int db_str2time(const char* _s, time_t* _v)
 {
 {
+	struct tm time;
+
 	if ((!_s) || (!_v)) {
 	if ((!_s) || (!_v)) {
 		LM_ERR("Invalid parameter value\n");
 		LM_ERR("Invalid parameter value\n");
 		return -1;
 		return -1;
 	}
 	}
 
 
-	// Convert database time representation to time_t structure
-	struct tm time;
-	/* It is necessary to zero tm structure first */
+	/* Convert database time representation to time_t structure
+	   It is necessary to zero tm structure first */
 	memset(&time, '\0', sizeof(struct tm));
 	memset(&time, '\0', sizeof(struct tm));
 	if (strptime(_s, "%Y-%m-%d %H:%M:%S", &time) == NULL) {
 	if (strptime(_s, "%Y-%m-%d %H:%M:%S", &time) == NULL) {
 		LM_ERR("Error during time conversion\n");
 		LM_ERR("Error during time conversion\n");
@@ -156,6 +157,7 @@ inline int db_str2time(const char* _s, time_t* _v)
  */
  */
 inline int db_time2str(time_t _v, char* _s, int* _l)
 inline int db_time2str(time_t _v, char* _s, int* _l)
 {
 {
+	struct tm* t;
 	int l;
 	int l;
 
 
 	if ((!_s) || (!_l) || (*_l < 2)) {
 	if ((!_s) || (!_l) || (*_l < 2)) {
@@ -165,14 +167,13 @@ inline int db_time2str(time_t _v, char* _s, int* _l)
 
 
 	*_s++ = '\'';
 	*_s++ = '\'';
 
 
-	// Convert time_t structure to format accepted by the database
-	struct tm* t;
+	/* Convert time_t structure to format accepted by the database */
 	t = localtime(&_v);
 	t = localtime(&_v);
 	l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", t);
 	l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", t);
 
 
 	if (l == 0) {
 	if (l == 0) {
 		LM_ERR("Error during time conversion\n");
 		LM_ERR("Error during time conversion\n");
-		// the value of _s is now unspecified
+		/* the value of _s is now unspecified */
 		_s = NULL;
 		_s = NULL;
 		_l = 0;
 		_l = 0;
 		return -1;
 		return -1;