mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 17:39:53 +03:00
src/Mayaqua/Unix: resolve "unchecked return value", remove unused functions,
variables. Found by coverity, cppcheck [src/Mayaqua/Unix.c:2559]: (style) Unused variable: status [src/Mayaqua/Unix.c:181]: (style) Redundant condition: select!=NULL. 'select==NULL || (select!=NULL && (*select)(entry))' is equivalent to 'select==NULL || (*select)(entry)' [src/Mayaqua/Unix.c:1297]: (style) The function 'UnixDaemon' is never used. [src/Mayaqua/Unix.c:543]: (style) The function 'UnixGetDiskFreeW' is never used. [src/Mayaqua/Unix.c:834]: (style) The function 'UnixRestoreThreadPriority' is never used. [src/Mayaqua/Unix.c:816]: (style) The function 'UnixSetThreadPriorityHigh' is never used. [src/Mayaqua/Unix.c:825]: (style) The function 'UnixSetThreadPriorityIdle' is never used. [src/Mayaqua/Unix.c:807]: (style) The function 'UnixSetThreadPriorityLow' is never used. [src/Mayaqua/Unix.c:2805]: (style) The function 'UnixWaitProcess' is never used.
This commit is contained in:
parent
f3ff7e2743
commit
e0e4e8a4c8
@ -178,7 +178,7 @@ int local_scandir(const char *dir, struct dirent ***namelist,
|
|||||||
*namelist=NULL;
|
*namelist=NULL;
|
||||||
while ((entry=readdir(d)) != NULL)
|
while ((entry=readdir(d)) != NULL)
|
||||||
{
|
{
|
||||||
if (select == NULL || (select != NULL && (*select)(entry)))
|
if (select == NULL || (*select)(entry))
|
||||||
{
|
{
|
||||||
*namelist=(struct dirent **)realloc((void *)(*namelist),
|
*namelist=(struct dirent **)realloc((void *)(*namelist),
|
||||||
(size_t)((i+1)*sizeof(struct dirent *)));
|
(size_t)((i+1)*sizeof(struct dirent *)));
|
||||||
@ -516,7 +516,7 @@ void UnixInitSolarisSleep()
|
|||||||
char tmp[MAX_SIZE];
|
char tmp[MAX_SIZE];
|
||||||
|
|
||||||
UnixNewPipe(&solaris_sleep_p1, &solaris_sleep_p2);
|
UnixNewPipe(&solaris_sleep_p1, &solaris_sleep_p2);
|
||||||
read(solaris_sleep_p1, tmp, sizeof(tmp));
|
(void)read(solaris_sleep_p1, tmp, sizeof(tmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the Sleep for Solaris
|
// Release the Sleep for Solaris
|
||||||
@ -540,17 +540,6 @@ void UnixSolarisSleep(UINT msec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the free space of the disk
|
// Get the free space of the disk
|
||||||
bool UnixGetDiskFreeW(wchar_t *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size)
|
|
||||||
{
|
|
||||||
char *path_a = CopyUniToStr(path);
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
ret = UnixGetDiskFree(path_a, free_size, used_size, total_size);
|
|
||||||
|
|
||||||
Free(path_a);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
bool UnixGetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size)
|
bool UnixGetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size)
|
||||||
{
|
{
|
||||||
char tmp[MAX_PATH];
|
char tmp[MAX_PATH];
|
||||||
@ -803,42 +792,6 @@ void UnixSetThreadPriorityRealtime()
|
|||||||
pthread_setschedparam(pthread_self(), SCHED_RR, &p);
|
pthread_setschedparam(pthread_self(), SCHED_RR, &p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lower the priority of the thread
|
|
||||||
void UnixSetThreadPriorityLow()
|
|
||||||
{
|
|
||||||
struct sched_param p;
|
|
||||||
Zero(&p, sizeof(p));
|
|
||||||
p.sched_priority = 32;
|
|
||||||
pthread_setschedparam(pthread_self(), SCHED_OTHER, &p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Raise the priority of the thread
|
|
||||||
void UnixSetThreadPriorityHigh()
|
|
||||||
{
|
|
||||||
struct sched_param p;
|
|
||||||
Zero(&p, sizeof(p));
|
|
||||||
p.sched_priority = 127;
|
|
||||||
pthread_setschedparam(pthread_self(), SCHED_RR, &p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the priority of the thread to idle
|
|
||||||
void UnixSetThreadPriorityIdle()
|
|
||||||
{
|
|
||||||
struct sched_param p;
|
|
||||||
Zero(&p, sizeof(p));
|
|
||||||
p.sched_priority = 1;
|
|
||||||
pthread_setschedparam(pthread_self(), SCHED_OTHER, &p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore the priority of the thread to normal
|
|
||||||
void UnixRestoreThreadPriority()
|
|
||||||
{
|
|
||||||
struct sched_param p;
|
|
||||||
Zero(&p, sizeof(p));
|
|
||||||
p.sched_priority = 64;
|
|
||||||
pthread_setschedparam(pthread_self(), SCHED_OTHER, &p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the current directory
|
// Get the current directory
|
||||||
void UnixGetCurrentDir(char *dir, UINT size)
|
void UnixGetCurrentDir(char *dir, UINT size)
|
||||||
{
|
{
|
||||||
@ -899,7 +852,7 @@ void UnixFreeSingleInstance(void *data)
|
|||||||
lock.l_type = F_UNLCK;
|
lock.l_type = F_UNLCK;
|
||||||
lock.l_whence = SEEK_SET;
|
lock.l_whence = SEEK_SET;
|
||||||
|
|
||||||
fcntl(o->fd, F_SETLK, &lock);
|
(void)fcntl(o->fd, F_SETLK, &lock);
|
||||||
close(o->fd);
|
close(o->fd);
|
||||||
|
|
||||||
remove(o->FileName);
|
remove(o->FileName);
|
||||||
@ -947,7 +900,7 @@ void *UnixNewSingleInstance(char *instance_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fchmod(fd, mode);
|
fchmod(fd, mode);
|
||||||
chmod(name, mode);
|
(void)chmod(name, mode);
|
||||||
|
|
||||||
Zero(&lock, sizeof(lock));
|
Zero(&lock, sizeof(lock));
|
||||||
lock.l_type = F_WRLCK;
|
lock.l_type = F_WRLCK;
|
||||||
@ -1293,43 +1246,6 @@ bool UnixRun(char *filename, char *arg, bool hide, bool wait)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the daemon
|
|
||||||
void UnixDaemon(bool debug_mode)
|
|
||||||
{
|
|
||||||
UINT ret;
|
|
||||||
|
|
||||||
if (debug_mode)
|
|
||||||
{
|
|
||||||
// Debug mode
|
|
||||||
signal(SIGHUP, SIG_IGN);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = fork();
|
|
||||||
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
|
||||||
// Error
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (ret == 0)
|
|
||||||
{
|
|
||||||
// Create a new session for the child process
|
|
||||||
setsid();
|
|
||||||
|
|
||||||
// Close the standard I/O
|
|
||||||
UnixCloseIO();
|
|
||||||
|
|
||||||
// Mute the unwanted signal
|
|
||||||
signal(SIGHUP, SIG_IGN);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Terminate the parent process
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the standard I/O
|
// Close the standard I/O
|
||||||
void UnixCloseIO()
|
void UnixCloseIO()
|
||||||
{
|
{
|
||||||
@ -1826,7 +1742,7 @@ bool UnixInitThread(THREAD *t)
|
|||||||
{
|
{
|
||||||
// An error has occured
|
// An error has occured
|
||||||
t->pData = NULL;
|
t->pData = NULL;
|
||||||
Release(t->ref);
|
(void)Release(t->ref);
|
||||||
UnixMemoryFree(ut);
|
UnixMemoryFree(ut);
|
||||||
UnixMemoryFree(info);
|
UnixMemoryFree(info);
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
@ -2640,8 +2556,6 @@ void UnixStopService(char *name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int status;
|
|
||||||
|
|
||||||
// Stop the service
|
// Stop the service
|
||||||
UniPrint(_UU("UNIX_SVC_STOPPING"), svc_title);
|
UniPrint(_UU("UNIX_SVC_STOPPING"), svc_title);
|
||||||
|
|
||||||
@ -2802,10 +2716,6 @@ bool UnixWaitProcessEx(UINT pid, UINT timeout)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void UnixWaitProcess(UINT pid)
|
|
||||||
{
|
|
||||||
UnixWaitProcessEx(pid, INFINITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Description of how to start
|
// Description of how to start
|
||||||
void UnixUsage(char *name)
|
void UnixUsage(char *name)
|
||||||
|
@ -218,16 +218,11 @@ void UnixSetEnableKernelEspProcessing(bool b);
|
|||||||
|
|
||||||
void UnixDisableCoreDump();
|
void UnixDisableCoreDump();
|
||||||
void UnixSetThreadPriorityRealtime();
|
void UnixSetThreadPriorityRealtime();
|
||||||
void UnixSetThreadPriorityLow();
|
|
||||||
void UnixSetThreadPriorityHigh();
|
|
||||||
void UnixSetThreadPriorityIdle();
|
|
||||||
void UnixRestoreThreadPriority();
|
|
||||||
void UnixSetResourceLimit(UINT id, UINT64 value);
|
void UnixSetResourceLimit(UINT id, UINT64 value);
|
||||||
bool UnixIs64BitRlimSupported();
|
bool UnixIs64BitRlimSupported();
|
||||||
UINT64 UnixGetTick64();
|
UINT64 UnixGetTick64();
|
||||||
void UnixSigChldHandler(int sig);
|
void UnixSigChldHandler(int sig);
|
||||||
void UnixCloseIO();
|
void UnixCloseIO();
|
||||||
void UnixDaemon(bool debug_mode);
|
|
||||||
void UnixGetCurrentDir(char *dir, UINT size);
|
void UnixGetCurrentDir(char *dir, UINT size);
|
||||||
void UnixGetCurrentDirW(wchar_t *dir, UINT size);
|
void UnixGetCurrentDirW(wchar_t *dir, UINT size);
|
||||||
bool UnixCheckExecAccess(char *name);
|
bool UnixCheckExecAccess(char *name);
|
||||||
@ -236,7 +231,6 @@ DIRLIST *UnixEnumDirEx(char *dirname, COMPARE *compare);
|
|||||||
DIRLIST *UnixEnumDirExW(wchar_t *dirname, COMPARE *compare);
|
DIRLIST *UnixEnumDirExW(wchar_t *dirname, COMPARE *compare);
|
||||||
bool UnixGetDiskFreeMain(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
|
bool UnixGetDiskFreeMain(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
|
||||||
bool UnixGetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
|
bool UnixGetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
|
||||||
bool UnixGetDiskFreeW(wchar_t *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
|
|
||||||
void UnixInitSolarisSleep();
|
void UnixInitSolarisSleep();
|
||||||
void UnixFreeSolarisSleep();
|
void UnixFreeSolarisSleep();
|
||||||
void UnixSolarisSleep(UINT msec);
|
void UnixSolarisSleep(UINT msec);
|
||||||
@ -255,7 +249,6 @@ UINT UnixReadPidFile();
|
|||||||
UINT UnixReadCtlFile();
|
UINT UnixReadCtlFile();
|
||||||
bool UnixIsProcess(UINT pid);
|
bool UnixIsProcess(UINT pid);
|
||||||
bool UnixWaitProcessEx(UINT pid, UINT timeout);
|
bool UnixWaitProcessEx(UINT pid, UINT timeout);
|
||||||
void UnixWaitProcess(UINT pid);
|
|
||||||
void UnixDeletePidFile();
|
void UnixDeletePidFile();
|
||||||
void UnixDeleteCtlFile();
|
void UnixDeleteCtlFile();
|
||||||
void UnixStopThread(THREAD *t, void *param);
|
void UnixStopThread(THREAD *t, void *param);
|
||||||
|
Loading…
Reference in New Issue
Block a user