Commit dd939d6f authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-15734 - calculation inside sizeof() warning

Reverted incorrect change introduced by 548d03d7.

As result is char**, third qsort() parameter must be sizeof(char*).
Not sizeof(result[0] + 2), which is same as sizeof(result[0]).
Not even sizeof(result[0]) + 2, which would cause invalid memory access.

Proper sorting is responsibility of logfilenamecompare() callback.
parent 78c1be8b
...@@ -667,12 +667,8 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp, int *n_lo ...@@ -667,12 +667,8 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp, int *n_lo
snprintf(fname, fnamelen, "%s/%s", directory, de->d_name); snprintf(fname, fnamelen, "%s/%s", directory, de->d_name);
result[n_results++] = fname; result[n_results++] = fname;
} }
// Return them in increasing order. Set width to allow for newer log file names ("xxx.tokulog13") // Return them in increasing order.
// which are one character longer than old log file names ("xxx.tokulog2"). The comparison function qsort(result, n_results, sizeof(result[0]), logfilenamecompare);
// won't look beyond the terminating NUL, so an extra character in the comparison string doesn't matter.
// Allow room for terminating NUL after "xxx.tokulog13" even if result[0] is of form "xxx.tokulog2."
int width = sizeof(result[0]+2);
qsort(result, n_results, width, logfilenamecompare);
*resultp = result; *resultp = result;
*n_logfiles = n_results; *n_logfiles = n_results;
result[n_results]=0; // make a trailing null result[n_results]=0; // make a trailing null
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment