@@ -141,7 +141,7 @@ class StringUtility {
141
141
142
142
static std::vector<std::string> Split (const std::string& s, const char delimiter) {
143
143
std::vector<std::string> res;
144
- int len = s.length ();
144
+ int len = static_cast < int >( s.length () );
145
145
146
146
std::string t = " " ;
147
147
for (int i = 0 ; i <= len; i++) {
@@ -184,7 +184,7 @@ class StringUtility {
184
184
const char * escape_character_set = " \\\"\'\?\a\b\f\n\r\t\v\0 " ;
185
185
186
186
const auto check = [&escape_character_set](char c) -> bool {
187
- auto p = escape_character_set;
187
+ const auto * p = escape_character_set;
188
188
while (*p) {
189
189
if (c == *p) {
190
190
return true ;
@@ -246,7 +246,7 @@ class FileUtility {
246
246
247
247
while (true ) {
248
248
size_t cur_pos = path.find (' /' , pos + 1 );
249
- pos = cur_pos;
249
+ pos = static_cast < int >( cur_pos) ;
250
250
251
251
if (cur_pos == std::string::npos) {
252
252
break ;
@@ -296,14 +296,14 @@ class FileUtility {
296
296
static void RewriteFile (const std::string& file_path, const std::string& content) {
297
297
std::ofstream file;
298
298
file.open (file_path, std::ofstream::out | std::ofstream::trunc);
299
- file.write (content.c_str (), content.length ());
299
+ file.write (content.c_str (), static_cast < long >( content.length () ));
300
300
file.close ();
301
301
}
302
302
303
303
static void AppendFile (const std::string& file_path, const std::string& content) {
304
304
std::ofstream file;
305
305
file.open (file_path, std::ofstream::out | std::ofstream::ate | std::ofstream::app);
306
- file.write (content.c_str (), content.length ());
306
+ file.write (content.c_str (), static_cast < long >( content.length () ));
307
307
file.close ();
308
308
}
309
309
@@ -322,13 +322,13 @@ class FileUtility {
322
322
int r = -1 ;
323
323
324
324
if (d) {
325
- struct dirent * p;
325
+ struct dirent * p = nullptr ;
326
326
327
327
r = 0 ;
328
328
while (!r && (p = readdir (d))) {
329
329
int r2 = -1 ;
330
- char * buf;
331
- size_t len;
330
+ char * buf = nullptr ;
331
+ size_t len = 0 ;
332
332
333
333
/* Skip the names "." and ".." as we don't want to recurse on them. */
334
334
if (!strcmp (p->d_name , " ." ) || !strcmp (p->d_name , " .." )) {
@@ -431,7 +431,7 @@ class Snapshot {
431
431
static T GenerateSnapshotInline (const T& t, const char * file_name, const int line_number) {
432
432
const auto content = StringUtility::ToString (t);
433
433
auto file_content = FileUtility::GetAllLines (file_name);
434
- auto & line_number_vec = getLineNumberVec (file_name, file_content.size ());
434
+ auto & line_number_vec = getLineNumberVec (file_name, static_cast < int >( file_content.size () ));
435
435
const auto actual_line_number = getActualLineNumber (line_number_vec, line_number);
436
436
437
437
auto match_range = getSnapshotInlineMatchRange (file_content[actual_line_number - 1 ]);
@@ -505,10 +505,10 @@ class Snapshot {
505
505
static std::pair<int , int > getSnapshotInlineMatchRange (const std::string& s) {
506
506
const std::string prefix = " SNAPSHOT_INLINE(" ;
507
507
508
- int len = s.length ();
509
- int prefix_len = prefix.length ();
508
+ int len = static_cast < int >( s.length () );
509
+ int prefix_len = static_cast < int >( prefix.length () );
510
510
511
- for (int i = prefix.length () - 1 ; i + 1 < len; i++) {
511
+ for (int i = static_cast < int >( prefix.length () ) - 1 ; i + 1 < len; i++) {
512
512
if (s.substr (i - prefix_len + 1 , prefix_len) == prefix) {
513
513
int l = 1 ;
514
514
for (int j = i + 1 ; j < len; j++) {
0 commit comments