Fix copyright lines
[folly.git] / folly / io / Cursor.cpp
index fe478403b4ab0e3fa8df61d35878d96702b2fc95..ff81a0c30a15ff794e6abafa57337f34714d8b4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2014-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 #include <folly/io/Cursor.h>
 
 #include <cstdio>
+
 #include <folly/ScopeGuard.h>
 
-namespace folly { namespace io {
+namespace folly {
+namespace io {
 
 void Appender::printf(const char* fmt, ...) {
   va_list ap;
@@ -43,28 +46,30 @@ void Appender::vprintf(const char* fmt, va_list ap) {
   if (ret < 0) {
     throw std::runtime_error("error formatting printf() data");
   }
+  auto len = size_t(ret);
   // vsnprintf() returns the number of characters that would be printed,
   // not including the terminating nul.
-  if (size_t(ret) < length()) {
+  if (len < length()) {
     // All of the data was successfully written.
-    append(ret);
+    append(len);
     return;
   }
 
   // There wasn't enough room for the data.
   // Allocate more room, and then retry.
-  ensure(ret + 1);
+  ensure(len + 1);
   ret = vsnprintf(reinterpret_cast<char*>(writableData()), length(),
                   fmt, apCopy);
   if (ret < 0) {
     throw std::runtime_error("error formatting printf() data");
   }
-  if (size_t(ret) >= length()) {
+  len = size_t(ret);
+  if (len >= length()) {
     // This shouldn't ever happen.
     throw std::runtime_error("unexpectedly out of buffer space on second "
                              "vsnprintf() attmept");
   }
-  append(ret);
+  append(len);
 }
-
-}}  // folly::io
+} // namespace io
+} // namespace folly