summaryrefslogtreecommitdiff
path: root/cleopatre/application
diff options
context:
space:
mode:
authorBelkadi & Buret2011-06-30 15:12:50 +0200
committerBelkadi & Buret2011-06-30 15:16:39 +0200
commit4d9ef286cd338e20868d3212b6075fc7ccd7e5a6 (patch)
treeebefcff21b538660bf86ee8c47420c8ffc94d061 /cleopatre/application
parentd0b1b783db26da4f72366b157382ed9fe61c34b3 (diff)
cleo/app/libspid: check param validity, fix compilation warnings, refs #2449
Diffstat (limited to 'cleopatre/application')
-rw-r--r--cleopatre/application/libspid/src/system.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/cleopatre/application/libspid/src/system.c b/cleopatre/application/libspid/src/system.c
index aef91ed952..dcc40fb52c 100644
--- a/cleopatre/application/libspid/src/system.c
+++ b/cleopatre/application/libspid/src/system.c
@@ -37,11 +37,17 @@ typedef int file_lock_t;
* \return LIBSPID_SUCCESS, on success.
* LIBSPID_ERROR_NOT_FOUND, if the specified file doesn't exist and
* the create parameter was set to false.
+ * LIBSPID_ERROR_PARAM, on bad input parameters.
* LIBSPID_ERROR_SYSTEM, on error.
*/
static libspid_error_t
libspid_system_file_lock (const char *filename, libspid_boolean_t create, file_lock_t *lock)
{
+ if ((NULL == filename) || (NULL == lock))
+ {
+ return LIBSPID_ERROR_PARAM;
+ }
+
mode_t mode = S_IRUSR | S_IWUSR;
int flags = O_RDWR;
@@ -98,11 +104,17 @@ libspid_system_file_lock (const char *filename, libspid_boolean_t create, file_l
* Unlock a file.
* \param lock the lock obtained when locking the file.
* \return LIBSPID_SUCCES, on success.
+ * LIBSPID_ERROR_PARAM, on bad input parameters.
* LIBSPID_ERROR_SYSTEM, on error.
*/
static int
libspid_system_file_unlock (const file_lock_t *lock)
{
+ if (NULL == lock)
+ {
+ return LIBSPID_ERROR_PARAM;
+ }
+
int fd = *lock;
if (flock (fd, LOCK_UN) == -1)
@@ -538,7 +550,7 @@ libspid_system_file_update_register (pid_t rx_pid, const char *filename,
char key[LIBSPID_CONFIG_KEY_MAX_LEN] = {0};
unsigned int elt_number = LIBSPID_CONFIG_ELT_MAX_NB;
char buffer[LIBSPID_CONFIG_LINE_MAX_LEN] = {0};
- int i = 0;
+ unsigned int i = 0;
/* Check input parameters. */
if ((0 >= rx_pid)
@@ -641,7 +653,7 @@ libspid_system_file_update_unregister (pid_t rx_pid, const char *filename)
const char delimiter = *LIBSPID_SIGNAL_INFO_DELIMITER;
libspid_error_t ret = LIBSPID_SUCCESS;
libspid_boolean_t remove = LIBSPID_FALSE;
- int i = 0;
+ unsigned int i = 0;
/* Check input parameters. */
if ((0 >= rx_pid)
@@ -745,7 +757,7 @@ libspid_system_file_update_is_registered (pid_t rx_pid, const char *filename,
char *elt[LIBSPID_CONFIG_ELT_MAX_NB] = {NULL};
char buffer[LIBSPID_CONFIG_LINE_MAX_LEN] = {0};
char pid_str[8] = {0};
- int i = 0;
+ unsigned int i = 0;
/* Check input parameters. */
if ((0 >= rx_pid)
@@ -816,7 +828,7 @@ libspid_system_file_update_warn (pid_t tx_pid, const char *filename)
char *elt[LIBSPID_CONFIG_ELT_MAX_NB] = {NULL};
char buffer[LIBSPID_CONFIG_LINE_MAX_LEN] = {0};
pid_t rx_pid = 0;
- int i = 0;
+ unsigned int i = 0;
/* Check input parameters. */
if ((0 > tx_pid)