[PATCH 1/6] ftpd: Avoid NULL pointer checks before free()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Oct 5 13:43:42 UTC 2018
They are superfluous and just bloat the code.
Update #3530.
---
cpukit/ftpd/ftpd.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/cpukit/ftpd/ftpd.c b/cpukit/ftpd/ftpd.c
index 0d713c03e8..ccb2a93410 100644
--- a/cpukit/ftpd/ftpd.c
+++ b/cpukit/ftpd/ftpd.c
@@ -373,10 +373,8 @@ task_pool_done(int count)
int i;
for(i = 0; i < count; ++i)
rtems_task_delete(task_pool.info[i].tid);
- if(task_pool.info)
- free(task_pool.info);
- if(task_pool.queue)
- free(task_pool.queue);
+ free(task_pool.info);
+ free(task_pool.queue);
rtems_mutex_destroy(&task_pool.mutex);
rtems_counting_semaphore_destroy(&task_pool.sem);
task_pool.info = 0;
@@ -1740,10 +1738,8 @@ exec_command(FTPD_SessionInfo_t *info, char* cmd, char* args)
else if (!strcmp("USER", cmd))
{
sscanf(args, "%254s", fname);
- if (info->user)
- free(info->user);
- if (info->pass)
- free(info->pass);
+ free(info->user);
+ free(info->pass);
info->pass = NULL;
info->user = strdup(fname);
if (ftpd_config->login &&
@@ -1758,8 +1754,7 @@ exec_command(FTPD_SessionInfo_t *info, char* cmd, char* args)
else if (!strcmp("PASS", cmd))
{
sscanf(args, "%254s", fname);
- if (info->pass)
- free(info->pass);
+ free(info->pass);
info->pass = strdup(fname);
if (!info->user) {
send_reply(info, 332, "Need account to log in");
--
2.16.4
More information about the devel
mailing list