fixed snprintf.c for systems that have only some of the *printf() family of functions
authorAndrew Tridgell <tridge@samba.org>
Fri, 10 Oct 2003 05:40:32 +0000 (05:40 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 10 Oct 2003 05:40:32 +0000 (05:40 +0000)
cope with servers that return bogus (too large) values in max_xmit

cope with a couple more error conditions in RAW-SFILEINFO

better startup time heuristics in NBENCH

source/lib/snprintf.c
source/libcli/clireadwrite.c
source/torture/raw/setfileinfo.c
source/torture/torture.c

index 1eae2f09b9bc5a6bf6525fda7336230cc325b291..fd31870162d1ae223a9804426728cb8438ecca4f 100644 (file)
 #include <stdlib.h>
 #endif
 
+#ifndef VA_COPY
+#ifdef HAVE_VA_COPY
+#define VA_COPY(dest, src) __va_copy(dest, src)
+#else
+#define VA_COPY(dest, src) (dest) = (src)
+#endif
+#endif
+
+
 #if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
 /* only include stdio.h if we are not re-defining snprintf or vsnprintf */
 #include <stdio.h>
 #define SAFE_FREE(x) do { if ((x) != NULL) {free((x)); (x)=NULL;} } while(0)
 #endif
 
-#ifndef VA_COPY
-#ifdef HAVE_VA_COPY
-#define VA_COPY(dest, src) __va_copy(dest, src)
-#else
-#define VA_COPY(dest, src) (dest) = (src)
-#endif
-#endif
-
 static size_t dopr(char *buffer, size_t maxlen, const char *format, 
                   va_list args_in);
 static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
index e1d154b283ff98d6a7bab01d11f47734a07706ec..1e6c0fc064752849207e51a7cb401ea997747726 100644 (file)
@@ -42,6 +42,7 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
         * rounded down to a multiple of 1024.
         */
        readsize = (cli->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
+       if (readsize > 0xFFFF) readsize = 0xFFFF;
 
        while (total < size) {
                NTSTATUS status;
@@ -91,6 +92,9 @@ ssize_t cli_write(struct cli_state *cli,
                return 0;
        }
 
+       if (block > 0xFFFF) block = 0xFFFF;
+
+
        parms.writex.level = RAW_WRITE_WRITEX;
        parms.writex.in.fnum = fnum;
        parms.writex.in.wmode = write_mode;
@@ -133,6 +137,7 @@ ssize_t cli_smbwrite(struct cli_state *cli,
        
        do {
                size_t size = MIN(size1, cli->transport->negotiate.max_xmit - 48);
+               if (size > 0xFFFF) size = 0xFFFF;
                
                parms.write.in.fnum = fnum;
                parms.write.in.offset = offset;
index 0871d25bc5a5405e71a14833ebbab6adea34465c..9da75596c521c0726d7fa4eeba106b621e9a4b26 100644 (file)
@@ -143,7 +143,7 @@ BOOL torture_raw_sfileinfo(int dummy)
 
 #define CHECK_VALUE(call, stype, field, value) do { \
        CHECK1(call); \
-       if (NT_STATUS_IS_OK(status) && finfo2.stype.out.field != value) { \
+       if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && finfo2.stype.out.field != value) { \
                printf("(%d) %s - %s/%s should be 0x%x - 0x%x\n", __LINE__, \
                       call_name, #stype, #field, \
                       (uint_t)value, (uint_t)finfo2.stype.out.field); \
@@ -152,7 +152,7 @@ BOOL torture_raw_sfileinfo(int dummy)
 
 #define CHECK_TIME(call, stype, field, value) do { \
        CHECK1(call); \
-       if (NT_STATUS_IS_OK(status) && nt_time_to_unix(&finfo2.stype.out.field) != value) { \
+       if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && nt_time_to_unix(&finfo2.stype.out.field) != value) { \
                printf("(%d) %s - %s/%s should be 0x%x - 0x%x\n", __LINE__, \
                        call_name, #stype, #field, \
                        (uint_t)value, \
@@ -164,7 +164,7 @@ BOOL torture_raw_sfileinfo(int dummy)
 
 #define CHECK_STR(call, stype, field, value) do { \
        CHECK1(call); \
-       if (NT_STATUS_IS_OK(status) && strcmp(finfo2.stype.out.field, value) != 0) { \
+       if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && strcmp(finfo2.stype.out.field, value) != 0) { \
                printf("(%d) %s - %s/%s should be '%s' - '%s'\n", __LINE__, \
                        call_name, #stype, #field, \
                        value, \
index f54483ae455a3ef9e59c98d5482e12657f597a27..fe1bddcc2a4359f899b431483d38d7c808861e9d 100644 (file)
@@ -3763,7 +3763,7 @@ static double create_procs(BOOL (*fn)(int), BOOL *result)
        volatile BOOL *child_status_out;
        int synccount;
        int tries = 8;
-       double start_time_limit = 10 + (nprocs * 0.5);
+       double start_time_limit = 10 + (nprocs * 1.5);
 
        synccount = 0;
 
@@ -3808,7 +3808,7 @@ static double create_procs(BOOL (*fn)(int), BOOL *result)
 
                        child_status[i] = getpid();
 
-                       while (child_status[i] && end_timer() < start_time_limit) msleep(2);
+                       while (child_status[i] && end_timer() < start_time_limit) msleep(100);
 
                        if (child_status[i]) {
                                printf("Child %d failed to start!\n", i);