Skip to content

Commit

Permalink
cnxcc: minor changes
Browse files Browse the repository at this point in the history
* use [PKG|SHM]_MEM_ERROR
* use memset and avoid initialization per field
* init variables
* add cnxcc to lgtm build
* use localtime_r() for a safer multi-thread usage
* replaced deprecated STR_PARAM with PARAM_STR
* clean includes
* clang-format
  • Loading branch information
linuxmaniac committed Jun 4, 2020
1 parent be57be3 commit 396c732
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 141 deletions.
3 changes: 2 additions & 1 deletion .lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extraction:
- "libcurl4-openssl-dev"
- "libjansson-dev"
- "libhiredis-dev"
- "libevent-dev"
- "liblua5.1-0-dev"
- "libpcre3-dev"
- "libncurses5-dev"
Expand All @@ -24,6 +25,6 @@ extraction:
after_prepare:
- "export PKG_CONFIG_PATH=$LGTM_WORKSPACE/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
configure:
command: "make include_modules='app_lua app_python3 db_mysql db_postgres db_redis dialplan http_client jansson lcr ndb_redis presence presence_xml presence_dialoginfo pua pua_dialoginfo topos_redis uuid websocket xmlops' cfg"
command: "make include_modules='app_lua app_python3 cnxcc db_mysql db_postgres db_redis dialplan http_client jansson lcr ndb_redis presence presence_xml presence_dialoginfo pua pua_dialoginfo topos_redis uuid websocket xmlops' cfg"
index:
build_command: "make all"
4 changes: 1 addition & 3 deletions src/modules/cnxcc/cnxcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <time.h>
#include <string.h>

#include <stdlib.h>
#include <sys/time.h>

#include "cnxcc.h"

Expand Down
8 changes: 5 additions & 3 deletions src/modules/cnxcc/cnxcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef _CNXCC_H
#define _CNXCC_H

#include <time.h>

#include "../../core/str.h"

#define DATETIME_SIZE sizeof("0001-01-01 00:00:00")
Expand All @@ -37,12 +39,12 @@ static inline unsigned int get_current_timestamp()
static inline int timestamp2isodt(str *dest, unsigned int timestamp)
{
time_t tim;
struct tm *tmPtr;
struct tm tmPtr;

tim = timestamp;
tmPtr = localtime(&tim);
localtime_r(&tim, &tmPtr);

strftime(dest->s, DATETIME_SIZE, "%Y-%m-%d %H:%M:%S", tmPtr);
strftime(dest->s, DATETIME_SIZE, "%Y-%m-%d %H:%M:%S", &tmPtr);
dest->len = DATETIME_LENGTH;

return 0;
Expand Down

0 comments on commit 396c732

Please sign in to comment.