More printf portability fixes. Got caught out by some gcc'isms last
[tprouty/samba.git] / source / lib / util_file.c
index 90cb022f587769819f631297972bbc6c40334470..638a6ca3429161115b61dcddcdc3b2fb3ff05637 100644 (file)
@@ -362,7 +362,7 @@ char *file_pload(char *syscmd, size_t *size)
        while ((n = read(fd, buf, sizeof(buf))) > 0) {
                tp = Realloc(p, total + n + 1);
                if (!tp) {
-                       DEBUG(0,("file_pload: failed to exand buffer!\n"));
+                       DEBUG(0,("file_pload: failed to expand buffer!\n"));
                        close(fd);
                        SAFE_FREE(p);
                        return NULL;
@@ -372,6 +372,9 @@ char *file_pload(char *syscmd, size_t *size)
        }
        if (p) p[total] = 0;
 
+       /* FIXME: Perhaps ought to check that the command completed
+        * successfully (returned 0); if not the data may be
+        * truncated. */
        sys_pclose(fd);
 
        if (size) *size = total;
@@ -450,9 +453,10 @@ void *map_file(char *fname, size_t size)
 #endif
        if (!p) {
                p = file_load(fname, &s2);
-               if (!p || (s2 != 0 && s2 != size)) {
-                       DEBUG(1,("incorrect size for %s - got %d expected %d\n",
-                                fname, s2, size));
+               if (!p) return NULL;
+               if (s2 != size) {
+                       DEBUG(1,("incorrect size for %s - got %lu expected %lu\n",
+                                fname, (unsigned long)s2, (unsigned long)size));
                        if (p) free(p);
                        return NULL;
                }
@@ -589,7 +593,7 @@ BOOL file_save(const char *fname, void *packet, size_t length)
        if (fd == -1) {
                return False;
        }
-       if (write(fd, packet, length) != length) {
+       if (write(fd, packet, length) != (size_t)length) {
                return False;
        }
        close(fd);