From 26780f3c132dc5af43324e9ade5c5dc25838d80f Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Wed, 18 Aug 2010 12:19:38 -0700 Subject: Bug 616500 - fix coverity Defect Type: Resource leaks issues CID 12094 - 12136 https://bugzilla.redhat.com/show_bug.cgi?id=616500 coverity ID 12135 Comment: Getting rid of unused functions fopen_l and fclose_l from lib/libadmin/util.c. --- lib/libadmin/util.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/lib/libadmin/util.c b/lib/libadmin/util.c index 1c6134d4..bbc6804b 100644 --- a/lib/libadmin/util.c +++ b/lib/libadmin/util.c @@ -81,54 +81,6 @@ char *get_flock_path(void) return result; } -/* Open a file with locking, close a file with unlocking. */ -FILE *fopen_l(char *path, char *mode) -{ - FILE *f = fopen(path, mode); - char *lockpath; - char *sn="admserv"; - char *flp=get_flock_path(); - - if(f == NULL) return NULL; - lockpath=(char *) MALLOC(strlen(sn)+strlen(flp)+16); - sprintf(lockpath, flp, sn); -#ifdef XP_UNIX - if( (lf=system_fopenRW(lockpath)) == SYS_ERROR_FD) - report_error(FILE_ERROR, lockpath, "Could not open file."); - if(system_flock(lf)==IO_ERROR) - report_error(FILE_ERROR, lockpath, "Could not lock file."); -#elif defined(XP_WIN32) - /* Using mutexes because if the CGI program dies, the mutex will be - * automatically released by the OS for another process to grab. - * Semaphores do not have this property; and if the CGI program crashes, - * the admin server would be effectively crippled. - */ - if ( (lf = CreateMutex(NULL, 0, lockpath)) == NULL) { - report_error(FILE_ERROR, lockpath, "Could not create admin mutex."); - } else { - if ( WaitForSingleObject(lf, 60*1000) == WAIT_FAILED) { - report_error(FILE_ERROR, lockpath, "Unable to obtain mutex after 60 seconds."); - } - } -#endif /* XP_UNIX */ - return f; -} - -void fclose_l(FILE *f) -{ - fclose(f); -#ifdef XP_UNIX - if(system_ulock(lf)==IO_ERROR) - report_error(FILE_ERROR, NULL, "Could not unlock lock file."); - system_fclose(lf); -#elif defined(XP_WIN32) - if (lf) { - ReleaseMutex(lf); - CloseHandle(lf); - } -#endif /* XP_UNIX */ -} - char *alert_word_wrap(char *str, int width, char *linefeed) { char *ans = NULL; -- cgit