use buffers instead of realloc-ed string. makes code shorter.
[apps/madmutt.git] / dotlock.c
index 3f55d40..8f1f308 100644 (file)
--- a/dotlock.c
+++ b/dotlock.c
 #include <lib-lib/lib-lib.h>
 
 #include <sys/utsname.h>
-
-#ifndef _POSIX_PATH_MAX
-#include <posix1_lim.h>
-#endif
-
 #include "dotlock.h"
-#include "config.h"
 
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
@@ -74,7 +68,9 @@ static int dotlock_unlink (const char *);
 static int dotlock_lock (const char *);
 
 
-#define check_flags(a) if (a & DL_FL_ACTIONS) usage (argv[0])
+#define check_flags(a)                              \
+    if (a & (DL_FL_TRY|DL_FL_UNLOCK|DL_FL_UNLINK))  \
+       usage(argv[0])
 
 int main (int argc, char **argv)
 {
@@ -91,7 +87,7 @@ int main (int argc, char **argv)
   /* determine the system's host name */
 
   uname (&utsname);
-  if (!(Hostname = strdup (utsname.nodename)))  /* __MEM_CHECKED__ */
+  if (!(Hostname = strdup(utsname.nodename)))
     return DL_EX_ERROR;
   if ((p = strchr (Hostname, '.')))
     *p = '\0';
@@ -482,7 +478,7 @@ static int dotlock_lock (const char *frealpath)
 {
   char lockfile[_POSIX_PATH_MAX + LONG_STRING];
   char nfslockfile[_POSIX_PATH_MAX + LONG_STRING];
-  size_t prev_size = 0;
+  ssize_t prev_size = 0;
   int fd;
   int count = 0;
   int hard_count = 0;