List:Commits« Previous MessageNext Message »
From:jack andrews Date:July 15 2009 5:27pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (jack:2949) Bug#45733
View as plain text  
#At file:///D:/repo/more-than-4-ndbd-bug45733/ based on revid:jack@stripped

 2949 jack andrews	2009-07-15
      Bug #45733  	Cluster with more than 4 storage node
        . fix for code review

    modified:
      storage/ndb/src/common/util/BaseString.cpp
      storage/ndb/src/common/util/basestring_vsnprintf.c
=== modified file 'storage/ndb/src/common/util/BaseString.cpp'
--- a/storage/ndb/src/common/util/BaseString.cpp	2009-07-15 07:52:30 +0000
+++ b/storage/ndb/src/common/util/BaseString.cpp	2009-07-15 17:26:07 +0000
@@ -623,14 +623,15 @@ TAPTEST(BaseString)
     //tests for Bug #45733 Cluster with more than 4 storage node 
     for(int i=0;i<20;i++) 
     {
-      OK(s2.assfmt("%*s",8,"Z"));
-      OK(s2.assfmt("%*s",511,"Z"));
-      OK(s2.assfmt("%*s",512,"Z"));
-      OK(s2.assfmt("%*s",513,"Z"));
-      OK(s2.assfmt("%*s",1023,"Z"));
-      OK(s2.assfmt("%*s",1024,"Z"));
-      OK(s2.assfmt("%*s",1025,"Z"));
-      OK(s2.assfmt("%*s",20*1024*1024,"Z"));
+#define BIG_ASSFMT_OK(X) do{long x=(X);OK(s2.assfmt("%*s",x,"Z").length() == x);}while(0)
+      BIG_ASSFMT_OK(8);
+      BIG_ASSFMT_OK(511);
+      BIG_ASSFMT_OK(512);
+      BIG_ASSFMT_OK(513);
+      BIG_ASSFMT_OK(1023);
+      BIG_ASSFMT_OK(1024);
+      BIG_ASSFMT_OK(1025);
+      BIG_ASSFMT_OK(20*1024*1024);
     }
 
     return 1; // OK

=== modified file 'storage/ndb/src/common/util/basestring_vsnprintf.c'
--- a/storage/ndb/src/common/util/basestring_vsnprintf.c	2009-07-15 07:52:30 +0000
+++ b/storage/ndb/src/common/util/basestring_vsnprintf.c	2009-07-15 17:26:07 +0000
@@ -35,13 +35,13 @@ basestring_snprintf(char *str, size_t si
   return(ret);
 }
 
-int
+static int
 vsnprintf_doubling(size_t size, const char *format, va_list ap)
 {
   char *buf = 0;
   int ret = -1;
 
-  while (ret < 0 || ret >= size)
+  while (ret < 0 || ret >= (int)size)
   {
     buf = realloc(buf, size*=2);
     ret = vsnprintf(buf, size, format, ap);
@@ -60,21 +60,21 @@ basestring_vsnprintf(char *str, size_t s
     char buf[1];
     return basestring_vsnprintf(buf, 1, format, ap);
   }
-  ret = IF_WIN(_vsnprintf,vsnprintf)(str, size, format, ap);
-  if (ret >= 0 && ret < size)
-    return ret;
-#ifdef _WIN32
-  if (errno == EINVAL)
-    return ret;
-  // otherwise, more than size chars are needed
-  return _vscprintf(format, ap);
-#endif
+  ret = IF_WIN(_vsnprintf,vsnprintf)(str, size, format, ap);
+  if (ret >= 0 && ret < (int)size)
+    return ret;
+#ifdef _WIN32
+  if (ret < 0 && errno == EINVAL)
+    return ret;
+  // otherwise, more than size chars are needed
+  return _vscprintf(format, ap);
+#endif
 #ifdef SNPRINTF_RETURN_TRUNC
   {
     char buf[512];
     ret = vsnprintf(buf, sizeof(buf), format, ap);
-    if (ret >= 0 && ret < size)
-      return ret;
+    if (ret >= 0 && ret < sizeof(buf))
+      return ret;
     ret = vsnprintf_doubling(sizeof(buf), format, ap);
   }
 #endif


Attachment: [text/bzr-bundle] bzr/jack@sun.com-20090715172607-2nyjnhnhlin5dhro.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (jack:2949) Bug#45733jack andrews15 Jul