summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo.huerner@xse.de>2013-07-02 18:21:22 +0200
committerIngo Huerner <ingo.huerner@xse.de>2013-07-02 18:21:22 +0200
commitb3da08eaf50afa864a5bdaf8bac0238e1b0434c6 (patch)
tree7353dc18abd4554d6d4570c30e362ce03192bf03
parent77af38d0758c101048a39d5c456921bfd6e00e73 (diff)
downloadpersistence-client-library-b3da08eaf50afa864a5bdaf8bac0238e1b0434c6.tar.gz
Corrected minor findings after code review; Removed all printf
-rw-r--r--include/persistence_client_library.h7
-rw-r--r--include/persistence_client_library_key.h4
-rw-r--r--src/persistence_client_library.c3
-rw-r--r--src/persistence_client_library_backup_filelist.c6
-rw-r--r--src/persistence_client_library_custom_loader.c3
-rw-r--r--src/persistence_client_library_db_access.c5
-rw-r--r--src/persistence_client_library_dbus_service.c27
-rw-r--r--src/persistence_client_library_file.c24
-rw-r--r--src/persistence_client_library_itzam_errors.c3
-rw-r--r--src/persistence_client_library_key.c12
-rw-r--r--src/persistence_client_library_lc_interface.c2
-rw-r--r--src/persistence_client_library_pas_interface.c2
-rw-r--r--src/persistence_client_library_prct_access.c3
-rw-r--r--test/persistence_client_library_test.c14
14 files changed, 38 insertions, 77 deletions
diff --git a/include/persistence_client_library.h b/include/persistence_client_library.h
index 646215e..3327c2e 100644
--- a/include/persistence_client_library.h
+++ b/include/persistence_client_library.h
@@ -38,7 +38,7 @@ extern "C" {
* \{
*/
-#define PERSIST_API_INTERFACE_VERSION (0x01000000U)
+#define PERSIST_API_INTERFACE_VERSION (0x01010000U)
/** \} */
@@ -48,6 +48,11 @@ extern "C" {
* \{
*/
+
+#define PCL_SHUTDOWN_TYPE_FAST 2 /// Client registered for fast lifecycle shutdown
+#define PCL_SHUTDOWN_TYPE_NORMAL 1 /// Client registered for normal lifecycle shutdown
+
+
/**
* @brief initalize client library
*
diff --git a/include/persistence_client_library_key.h b/include/persistence_client_library_key.h
index e125bfa..bbd1c62 100644
--- a/include/persistence_client_library_key.h
+++ b/include/persistence_client_library_key.h
@@ -39,7 +39,7 @@ extern "C" {
* \{
*/
-#define PERSIST_KEYVALUEAPI_INTERFACE_VERSION (0x06000000U)
+#define PERSIST_KEYVALUEAPI_INTERFACE_VERSION (0x06010000U)
#include "persistence_client_library.h"
@@ -75,8 +75,6 @@ typedef struct _pclNotification_s
* \{
*/
-#define PCL_SHUTDOWN_TYPE_FAST 2 /// Client registered for fast lifecycle shutdown
-#define PCL_SHUTDOWN_TYPE_NORMAL 1 /// Client registered for normal lifecycle shutdown
/** \} */
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c
index 3fde82c..52168ba 100644
--- a/src/persistence_client_library.c
+++ b/src/persistence_client_library.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
+#include <dlfcn.h>
#include <dlt/dlt.h>
#include <dlt/dlt_common.h>
@@ -170,7 +171,7 @@ int pclDeinitLibrary(void)
// unload custom client libraries
for(i=0; i<PersCustomLib_LastEntry; i++)
{
- if(gPersCustomFuncs[i].custom_plugin_init != NULL)
+ if(gPersCustomFuncs[i].custom_plugin_deinit != NULL)
{
// deinitialize plugin
gPersCustomFuncs[i].custom_plugin_deinit();
diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c
index a193fb2..7a32e14 100644
--- a/src/persistence_client_library_backup_filelist.c
+++ b/src/persistence_client_library_backup_filelist.c
@@ -166,18 +166,14 @@ int readBlacklistConfigFile(const char* filename)
fd = open(filename, O_RDONLY);
if (fd == -1)
{
- printf("configReader::readConfigFile ==> Error file open: %s | error: %s \n", filename, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error file open"), DLT_STRING(filename), DLT_STRING(strerror(errno)) );
-
return -1;
}
// check for empty file
if(gConfigFileSize == 0)
{
- printf("configReader::readConfigFile ==> Error file size is 0: %s \n", filename);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error file size is 0:"), DLT_STRING(filename));
-
close(fd);
return -1;
}
@@ -189,7 +185,6 @@ int readBlacklistConfigFile(const char* filename)
{
gpConfigFileMap = 0;
close(fd);
- printf("configReader::readConfigFile ==> Error mapping the file: %s | error: %s \n", filename, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error mapping the file:"), DLT_STRING(filename), DLT_STRING(strerror(errno)) );
return -1;
@@ -241,7 +236,6 @@ int need_backup_key(unsigned int key)
free(item);
rval = -1;
- printf("need_backup_key ==> item or gRb_tree_bl is NULL\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("need_backup_key ==> item or gRb_tree_bl is NULL"));
}
diff --git a/src/persistence_client_library_custom_loader.c b/src/persistence_client_library_custom_loader.c
index 9a8bd7f..b12a131 100644
--- a/src/persistence_client_library_custom_loader.c
+++ b/src/persistence_client_library_custom_loader.c
@@ -246,7 +246,7 @@ int get_custom_libraries()
int load_custom_library(PersistenceCustomLibs_e customLib, Pers_custom_functs_s *customFuncts)
{
int rval = 1;
- char *error;
+ char *error = NULL;
if(customLib < PersCustomLib_LastEntry)
{
@@ -376,7 +376,6 @@ int load_all_custom_libraries()
rval = load_custom_library(i, &gPersCustomFuncs[i]);
if( rval < 0)
{
- // printf("load_all_custom_libraries - error loading library number [%d] \n", i);
break;
}
}
diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c
index 5875069..15ff7a6 100644
--- a/src/persistence_client_library_db_access.c
+++ b/src/persistence_client_library_db_access.c
@@ -171,7 +171,6 @@ int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned
|| PersistenceStorage_local == info->configKey.storage)
{
itzam_btree* btree = NULL;
- itzam_state state = ITZAM_FAILED;
KeyValuePair_s search;
btree = pers_db_open(info, dbPath);
@@ -337,7 +336,6 @@ int pers_db_get_key_size(char* dbPath, char* key, PersistenceInfo_s* info)
{
int keySize = 0;
itzam_btree* btree = NULL;
- itzam_state state = ITZAM_FAILED;
KeyValuePair_s search;
btree = pers_db_open(info, dbPath);
@@ -401,7 +399,6 @@ int pers_db_delete_key(char* dbPath, char* key, PersistenceInfo_s* info)
itzam_btree* btree = NULL;
KeyValuePair_s delete;
- //printf("delete_key_from_table_itzam => Path: \"%s\" | key: \"%s\" \n", dbPath, key);
btree = pers_db_open(info, dbPath);
if(btree != NULL)
{
@@ -576,13 +573,11 @@ int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* conte
}
else
{
- printf("pers_send_Notification_Signal ==> E R R O R C O N E C T I O N NULL!!\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_send_Notification_Signal ==> E R R O R C O N E C T I O N NULL!!"));
}
}
else
{
- printf("pers_send_Notification_Signal: ERROR \n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_send_Notification_Signal ==> ERROR dbus_message_append_args"));
rval = EPERS_NOTIFY_SIG;
}
diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c
index a6485d7..5176ba1 100644
--- a/src/persistence_client_library_dbus_service.c
+++ b/src/persistence_client_library_dbus_service.c
@@ -93,7 +93,7 @@ void sigHandler(int signo)
/* function to unregister ojbect path message handler */
static void unregisterMessageHandler(DBusConnection *connection, void *user_data)
{
- printf("unregisterObjectPath\n");
+ DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("unregisterObjectPath\n"));
}
/* catches messages not directed to any registered object path ("garbage collector") */
@@ -230,7 +230,7 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec
static void unregisterObjectPathFallback(DBusConnection *connection, void *user_data)
{
- printf("unregisterObjectPathFallback\n");
+ DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("unregisterObjectPathFallback\n"));
}
@@ -357,14 +357,14 @@ static dbus_bool_t addWatch(DBusWatch *watch, void *data)
static void removeWatch(DBusWatch *watch, void *data)
{
- printf("removeWatch called @0x%08x\n", (int)watch);
+ DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("removeWatch called "), DLT_INT( (int)watch) );
}
static void watchToggled(DBusWatch *watch, void *data)
{
- printf("watchToggled called @0x%08x\n", (int)watch);
+ DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("watchToggled called "), DLT_INT( (int)watch) );
}
@@ -394,20 +394,17 @@ static dbus_bool_t addTimeout(DBusTimeout *timeout, void *data)
}
else
{
- printf("timerfd_settime() failed %d '%s'\n", errno, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout => timerfd_settime() failed"), DLT_STRING(strerror(errno)) );
}
}
else
{
- printf("timerfd_create() failed %d '%s'\n", errno, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout => timerfd_create() failed"), DLT_STRING(strerror(errno)) );
}
}
}
else
{
- printf("cannot create another fd to be poll()'ed\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout => cannot create another fd to be poll()'ed"));
}
@@ -426,7 +423,6 @@ static void removeTimeout(DBusTimeout *timeout, void *data)
{
if (-1==close(gPollInfo.fds[i].fd))
{
- printf("removeTimeout => close() timerfd #%d failed %d '%s'\n", gPollInfo.fds[i].fd, errno, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("removeTimeout => close() timerfd"), DLT_STRING(strerror(errno)) );
}
@@ -450,14 +446,13 @@ static void timeoutToggled(DBusTimeout *timeout, void *data)
{
int i = gPollInfo.nfds;
while ((0<i--)&&(timeout!=gPollInfo.objects[i].timeout));
- fprintf(stderr, "timeoutToggled @%x %c %dms @%d [%d]\n", (int)timeout, dbus_timeout_get_enabled(timeout)?'x':'-', dbus_timeout_get_interval(timeout), i, gPollInfo.nfds);
+ DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("timeoutToggled") );
if (0<i)
{
const int interval = (TRUE==dbus_timeout_get_enabled(timeout))?dbus_timeout_get_interval(timeout):0;
const struct itimerspec its = { .it_value= {interval/1000, interval%1000} };
if (-1!=timerfd_settime(gPollInfo.fds[i].fd, 0, &its, NULL))
{
- printf("timeoutToggled => timerfd_settime() %d failed %d '%s'\n", interval, errno, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("timeoutToggled => timerfd_settime()"), DLT_STRING(strerror(errno)) );
}
}
@@ -481,17 +476,14 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
if (dbus_error_is_set(&err))
{
- printf("mainLoop => Connection Error (%s)\n", err.message);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => Connection Error:"), DLT_STRING(err.message) );
dbus_error_free(&err);
}
else if (NULL != conn)
{
dbus_connection_set_exit_on_disconnect (conn, FALSE);
- //printf("connected as '%s'\n", dbus_bus_get_unique_name(conn));
if (-1 == (gEfds = eventfd(0, 0)))
{
- printf("mainLoop => eventfd() failed w/ errno %d\n", errno);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => eventfd() failed w/ errno:"), DLT_INT(errno) );
}
else
@@ -514,7 +506,6 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
if( (TRUE!=dbus_connection_set_watch_functions(conn, addWatch, removeWatch, watchToggled, NULL, NULL))
|| (TRUE!=dbus_connection_set_timeout_functions(conn, addTimeout, removeTimeout, timeoutToggled, NULL, NULL)) )
{
- printf("mainLoop => dbus_connection_set_watch_functions() failed\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => dbus_connection_set_watch_functions() failed"));
}
else
@@ -531,7 +522,6 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
if (0>ret)
{
- printf("mainLoop => poll() failed w/ errno %d\n", errno);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => poll() failed w/ errno "), DLT_INT(errno) );
}
else if (0==ret)
@@ -547,23 +537,18 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
/* anything to do */
if (0!=gPollInfo.fds[i].revents)
{
- //fprintf(stderr, "\t[%d] revents 0x%04x\n", i, gPollInfo.fds[i].revents);
-
if (OT_TIMEOUT==gPollInfo.objects[i].objtype)
{
/* time-out occured */
unsigned long long nExpCount = 0;
if ((ssize_t)sizeof(nExpCount)!=read(gPollInfo.fds[i].fd, &nExpCount, sizeof(nExpCount)))
{
- printf("mainLoop => read failed!?\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => read failed"));
}
- printf("mainLoop => timeout %x #%d!\n", (int)gPollInfo.objects[i].timeout, (int)nExpCount);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => timeout"));
if (FALSE==dbus_timeout_handle(gPollInfo.objects[i].timeout))
{
- printf("mainLoop => dbus_timeout_handle() failed!?\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => dbus_timeout_handle() failed!?"));
}
bContinue = TRUE;
@@ -578,7 +563,6 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
while ((-1==(ret=read(gPollInfo.fds[i].fd, buf, 64)))&&(EINTR==errno));
if (0>ret)
{
- printf("mainLoop => read() failed w/ errno %d | %s\n", errno, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => read() failed"), DLT_STRING(strerror(errno)) );
}
else if (ret != -1)
@@ -595,7 +579,6 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
bContinue = FALSE;
break;
default:
- printf("command %d not handled!\n", buf[0]);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => command not handled"), DLT_INT(buf[0]) );
break;
}
diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c
index 92631a5..7b759f9 100644
--- a/src/persistence_client_library_file.c
+++ b/src/persistence_client_library_file.c
@@ -295,14 +295,12 @@ int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user
rval = remove(dbPath);
if(rval == -1)
{
- printf("pclFileRemove => remove ERROR: %s \n", strerror(errno) );
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileRemove => remove ERROR"), DLT_STRING(strerror(errno)) );
}
}
else
{
rval = shared_DB;
- printf("pclFileRemove ==> no valid database context or resource not a file\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileRemove ==> no valid database context or resource not a file"));
}
}
@@ -467,7 +465,6 @@ int pclCreateFile(const char* path)
}
else
{
- printf("pclCreateFile ==> no valid path to create: %s\n", path);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateFile ==> no valid path to create: "), DLT_STRING(path) );
}
@@ -493,15 +490,11 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
backupAvail = access(backupPath, F_OK);
csumAvail = access(csumPath, F_OK);
- //printf("pclVerifyConsistency => backup path: %s | backupAvail: %d \n", backupPath, backupAvail);
- //printf("pclVerifyConsistency => csum path: %s | csumAvail : %d \n", csumPath, csumAvail);
-
// *************************************************
// there is a backup file and a checksum
// *************************************************
if( (backupAvail == 0) && (csumAvail == 0) )
{
- //printf("pclVerifyConsistency => there is a backup file AND a checksum\n");
DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclVerifyConsistency => there is a backup file AND a checksum"));
// calculate checksum form backup file
fdBackup = open(backupPath, O_RDONLY);
@@ -561,7 +554,6 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
// *************************************************
else if(csumAvail == 0)
{
- //printf("verifyConsistency => there is ONLY a checksum file\n");
DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclVerifyConsistency => there is ONLY a checksum file"));
fdCsum = open(csumPath, O_RDONLY);
@@ -570,7 +562,6 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
readSize = read(fdCsum, csumBuf, ChecksumBufSize);
if(readSize <= 0)
{
- //printf("verifyConsistency ==> read checksum: invalid readSize\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclVerifyConsistency => read checksum: invalid readSize"));
}
close(fdCsum);
@@ -605,7 +596,6 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
// *************************************************
else if(backupAvail == 0)
{
- //printf("verifyConsistency => there is ONLY a backup file\n");
DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclVerifyConsistency => there is ONLY a backup file"));
// calculate checksum form backup file
@@ -647,7 +637,6 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha
// if we are in an inconsistent state: delete file, backup and checksum
if(handle == -1)
{
- //printf(" =====> remove\n");
remove(origPath);
remove(backupPath);
remove(csumPath);
@@ -671,7 +660,6 @@ int pclRecoverFromBackup(int backupFd, const char* original)
{
if(write(handle, buffer, readSize) != readSize)
{
- printf("pclRecoverFromBackup => couldn't write whole buffer\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclRecoverFromBackup => couldn't write whole buffer"));
break;
}
@@ -689,27 +677,23 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const
char buffer[RDRWBufferSize];
// create checksum file and and write checksum
- //printf(" pcl_create_backu => create checksum file: %s \n", csumPath);
csfd = open(csumPath, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
if(csfd != -1)
{
int csumSize = strlen(csumBuf);
if(write(csfd, csumBuf, csumSize) != csumSize)
{
- printf("pclCreateBackup: failed to write checksum to file\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => failed to write checksum to file"));
}
close(csfd);
}
else
{
- printf("pclCreateBackup => failed to create checksum file: %s | %s\n", csumPath, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => failed to create checksum file:"), DLT_STRING(strerror(errno)) );
}
// create backup file, user and group has read/write permission, others have read permission
- //printf(" pclFileOpen => create a backup for file: %s\n", dstPath);
dstFd = open(dstPath, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
if(dstFd != -1)
{
@@ -722,26 +706,24 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const
{
if(write(dstFd, buffer, readSize) != readSize)
{
- printf("pclCreateBackup => couldn't write whole buffer\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => couldn't write whole buffer"));
break;
}
}
if(readSize == -1)
- printf("pcl_create_backup => error copying file\n");
+ DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pcl_create_backup => error copying file"));
if((readSize = close(dstFd)) == -1)
- printf("pcl_create_backup => error closing fd\n");
+ DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pcl_create_backup => error closing fd"));
// set back to the position
lseek(srcfd, curPos, SEEK_SET);
}
else
{
- printf("pclCreateBackup => failed to open backup file: %s | %s \n", dstPath, strerror(errno));
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => failed to open backup file"),
- DLT_STRING(dstPath), DLT_STRING(strerror(errno)));
+ DLT_STRING(dstPath), DLT_STRING(strerror(errno)));
}
return readSize;
diff --git a/src/persistence_client_library_itzam_errors.c b/src/persistence_client_library_itzam_errors.c
index ba46cc2..843f675 100644
--- a/src/persistence_client_library_itzam_errors.c
+++ b/src/persistence_client_library_itzam_errors.c
@@ -73,6 +73,7 @@ Small changes to use in persistence
*/
#include "persistence_client_library_itzam_errors.h"
+#include "../include_protected/persistence_client_library_data_organization.h"
const char * ERROR_STRINGS [] =
@@ -140,5 +141,5 @@ const char * STATE_MESSAGES [] =
void error_handler(const char * function_name, itzam_error error)
{
- fprintf(stderr, "Itzam error in %s: %s\n", function_name, ERROR_STRINGS[error]);
+ DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("Itzam error in: "), DLT_STRING(function_name), DLT_STRING(ERROR_STRINGS[error]));
}
diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c
index dd9d16e..83a9efb 100644
--- a/src/persistence_client_library_key.c
+++ b/src/persistence_client_library_key.c
@@ -83,7 +83,7 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u
handle = get_persistence_handle_idx();
}
- if(handle < MaxPersHandle && handle != -1)
+ if((handle < MaxPersHandle) && (0 <= handle))
{
// remember data in handle array
strncpy(gKeyHandleArray[handle].dbPath, dbPath, DbPathMaxLen);
@@ -95,14 +95,12 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u
}
else
{
- printf("pclKeyHandleOpen: error - handleId out of bounds [%d]\n", handle);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - handleId out of bounds:"), DLT_INT(handle));
}
}
}
else
{
- printf("pclKeyHandleOpen: error - no database context or resource is not a key \n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - no database context or resource is not a key "));
}
}
@@ -146,10 +144,11 @@ int pclKeyHandleClose(int key_handle)
strncpy(gKeyHandleArray[key_handle].dbPath, "", DbPathMaxLen);
strncpy(gKeyHandleArray[key_handle].dbKey ,"", DbKeyMaxLen);
gKeyHandleArray[key_handle].info.configKey.storage = -1;
+ rval = 1;
}
else
{
- rval = -1;
+ rval = EPERS_MAXHANDLE;
}
}
@@ -296,7 +295,6 @@ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size
}
else
{
- printf("pclKeyHandleWriteData: error - buffer_size to big, limit is [%d] bytes\n", gMaxKeyValDataSize);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleWriteData: error - buffer_size to big, limit is [bytes]:"), DLT_INT(gMaxKeyValDataSize));
}
}
@@ -457,7 +455,6 @@ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int use
}
else
{
- printf("pclKeyReadData - error - no database context or resource is not a key\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyReadData - error - no database context or resource is not a key"));
}
}
@@ -520,14 +517,12 @@ int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int us
}
else
{
- printf("pclKeyWriteData: error - no database context or resource is not a key\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyWriteData - error - no database context or resource is not a key"));
}
}
else
{
data_size = EPERS_BUFLIMIT;
- printf("pclKeyWriteData: error - buffer_size to big, limit is [%d] bytes\n", gMaxKeyValDataSize);
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyWriteData: error - buffer_size to big, limit is [bytes]:"), DLT_INT(gMaxKeyValDataSize));
}
}
@@ -573,7 +568,6 @@ int pclKeyRegisterNotifyOnChange(unsigned int ldbid, const char* resource_id, un
}
else
{
- printf("pclKeyRegisterNotifyOnChange: error - resource is not a shared resource or resource is not a key\n");
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyRegisterNotifyOnChange: error - resource is not a shared resource or resource is not a key"));
rval = EPERS_RES_NO_KEY;
}
diff --git a/src/persistence_client_library_lc_interface.c b/src/persistence_client_library_lc_interface.c
index 987331e..7e1206e 100644
--- a/src/persistence_client_library_lc_interface.c
+++ b/src/persistence_client_library_lc_interface.c
@@ -329,7 +329,7 @@ void process_prepare_shutdown(unsigned char requestId, unsigned int status)
// unload custom client libraries
for(i=0; i<PersCustomLib_LastEntry; i++)
{
- if(gPersCustomFuncs[i].custom_plugin_init != NULL)
+ if(gPersCustomFuncs[i].custom_plugin_deinit != NULL)
{
// deinitialize plugin
gPersCustomFuncs[i].custom_plugin_deinit();
diff --git a/src/persistence_client_library_pas_interface.c b/src/persistence_client_library_pas_interface.c
index 2b6f000..b8d360e 100644
--- a/src/persistence_client_library_pas_interface.c
+++ b/src/persistence_client_library_pas_interface.c
@@ -66,7 +66,7 @@ int check_pas_request(unsigned int request, unsigned int requestID)
if(-1 == write(gEfds, &cmd, (sizeof(uint64_t))))
{
- printf("write failed w/ errno %d | %s\n", errno, strerror(errno));
+ DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("write failed w/ errno "), DLT_INT(errno), DLT_STRING(strerror(errno)));
rval = PasErrorStatus_FAIL;
}
else
diff --git a/src/persistence_client_library_prct_access.c b/src/persistence_client_library_prct_access.c
index 10c34da..f45d392 100644
--- a/src/persistence_client_library_prct_access.c
+++ b/src/persistence_client_library_prct_access.c
@@ -96,7 +96,7 @@ itzam_btree* get_resource_cfg_table(PersistenceRCT_e rct, int group)
snprintf(filename, DbPathMaxLen, gSharedWtPath, gAppId, group, gResTableCfg);
break;
default:
- printf("get_resource_cfg_table - error: no valid PersistenceRCT_e\n");
+ DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_resource_cfg_table - error: no valid PersistenceRCT_e"));
break;
}
@@ -141,7 +141,6 @@ int get_db_context(PersistenceInfo_s* dbContext, const char* resource_id, unsign
// check if resouce id is in write through table
if(itzam_true == itzam_btree_find(resource_table, resource_id, &search))
{
- //printf("get_db_context ==> data: %s\n", search.data);
memset(dbContext->configKey.reponsible, 0, MaxConfKeyLengthResp);
memset(dbContext->configKey.custom_name, 0, MaxConfKeyLengthCusName);
memset(dbContext->configKey.customID, 0, MaxRctLengthCustom_ID);
diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c
index 4ed33c9..d2d5a38 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -29,6 +29,8 @@
#include <dlt/dlt.h>
#include <dlt/dlt_common.h>
+#include "../include/persistence_client_library_file.h"
+#include "../include/persistence_client_library_key.h"
#include "../include/persistence_client_library.h"
@@ -612,7 +614,11 @@ START_TEST(test_DataFileRecovery)
pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
ret = pclFileClose(fd_RW);
+ if(ret == -1)
+
ret = pclFileClose(fd_RO);
+ if(ret == -1)
+
pclDeinitLibrary();
}
@@ -811,33 +817,37 @@ END_TEST
START_TEST(test_Plugin)
{
int ret = 0;
- char buffer[READ_SIZE];
+ unsigned char buffer[READ_SIZE];
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
pclInitLibrary(gTheAppId, shutdownReg);
ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
- //printf("B U F F E R - secure: %s\n", buffer);
+ fail_unless(ret != EPERS_NOT_INITIALIZED);
fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
+ fail_unless(ret != EPERS_NOT_INITIALIZED);
//printf("B U F F E R - early: %s\n", buffer);
fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
+ fail_unless(ret != EPERS_NOT_INITIALIZED);
//printf("B U F F E R - emergency: %s\n", buffer);
fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
+ fail_unless(ret != EPERS_NOT_INITIALIZED);
//printf("B U F F E R - hwinfo: %s\n", buffer);
fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
+ fail_unless(ret != EPERS_NOT_INITIALIZED);
//printf("B U F F E R - hwinfo: %s\n", buffer);
fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");