diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2011-05-03 10:10:59 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2011-05-03 10:10:59 -0400 |
commit | ff108a1414736fe057b4eada10f4a8c3dc32ac39 (patch) | |
tree | 942d28cad437dd20bf29cb60ad58ad4949b87c96 /src | |
parent | 91af8f14863a516ff9aa80b703d8a34583e6e107 (diff) | |
parent | 4957bf13b26a403271c9838a9b74b9f61682fa8e (diff) | |
download | duser-ff108a1414736fe057b4eada10f4a8c3dc32ac39.tar.gz |
Merge pull request #5 from extrarius/master.
Various code clean ups to solve potential problems
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.in | 1 | ||||
-rw-r--r-- | src/log.c | 2 | ||||
-rw-r--r-- | src/user.c | 21 |
3 files changed, 13 insertions, 11 deletions
diff --git a/src/Makefile.in b/src/Makefile.in index 15a1e3a..7f1b5d6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -189,7 +189,6 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -LIBCOMPAT_LDADDS = $(top_builddir)/compat/libdusercompat.a AM_CPPFLAGS = -I$(top_srcdir)/include duser_LDFLAGS = -L$(top_srcdir)/compat duser_SOURCES = duser.c \ @@ -43,7 +43,7 @@ int logcleanup() return status; } -int COM(const char* func, char *format, ...) +int COM(const char* func, const char *format, ...) { struct tm *logtm; time_t logtime = time(NULL); @@ -159,16 +159,16 @@ int user_del(record_t* rec) int bytes = 0; int bytes_total = 0; char buf[REGEX_MAX]; - char tmpfile[255]; - snprintf(tmpfile, sizeof(tmpfile), "/tmp/duser.%s.XXXXXX", basename(rec->file)); - if((fd = mkstemp(tmpfile)) < 0 || (tfp = fdopen(fd, "r+")) == NULL) + char _tmpfile[255]; + snprintf(_tmpfile, sizeof(_tmpfile), "/tmp/duser.%s.XXXXXX", basename(rec->file)); + if((fd = mkstemp(_tmpfile)) < 0 || (tfp = fdopen(fd, "r+")) == NULL) { if(fd != -1) { close(fd); - unlink(tmpfile); + unlink(_tmpfile); } - fprintf(stderr, "FATAL: %s: %s: %s\n", SELF, tmpfile, strerror(errno)); + fprintf(stderr, "FATAL: %s: %s: %s\n", SELF, _tmpfile, strerror(errno)); exit(1); } @@ -220,7 +220,10 @@ int user_del(record_t* rec) fclose(fp); close(fd); - unlink(tmpfile); + + /* unistd.h requires this be a (const char *) not (struct FILE * (*)(void)) */ + /* -- extrarius -- */ + unlink((const char *)tmpfile); if(bytes_total) return bytes_total; @@ -266,7 +269,7 @@ record_t* find_in_file(const char* filename, const char* needle) rptr->index = 0; rptr->match = 0; - int index = 0; + int _index = 0; FILE *fp; char *fname = strdup(filename); @@ -287,9 +290,9 @@ record_t* find_in_file(const char* filename, const char* needle) { snprintf(rptr->name, REGEX_MAX, "%s", cmp); rptr->match = 1; - rptr->index = index; + rptr->index = _index; } - index++; + _index++; processed.lines++; } |