bkmgit commented on a change in pull request #11399:
URL: https://github.com/apache/arrow/pull/11399#discussion_r730567907



##########
File path: cpp/examples/parquet/parquet_stream_api/stream_reader_writer.cc
##########
@@ -136,12 +137,14 @@ struct TestData {
     return "Str #" + std::to_string(i);
   }
   static arrow::util::string_view GetStringView(const int i) {
-    string_ = "StringView #" + std::to_string(i);
+    int length = snprintf(string_, str_buff_size, "StringView #%d", i);
+    snprintf(string_, length + 1, "StringView #%d", i);
     return arrow::util::string_view(string_);

Review comment:
       ```cpp
   static std::string string
   ```
   is not recommended style. [Style 
guide|https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables]
 suggests using a C character array
   ```cpp
       static char string[100];
       int length = snprintf(string, str_buff_size, "StringView #%d", i);
      snprintf(string, length + 1, "StringView #%d", i);
      return arrow::util::string_view(string);
   ```
   otherwise would need to make an exception in linting.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to