← Back to team overview

maria-developers team mailing list archive

WebScaleSQL: Actually fix all the array bounds warnings


Hi Sergei and Alexey,

during our recent discussion re WebScaleSQL patches we agreed to review $subj:

All these warnings come from strings/decimal.c. I was able to reproduce them using
gcc-4.8.1, cmake -DBUILD_CONFIG=mysql_release (basically needs -Wall -O3).

I simplified this function to the following:
gcc -Wall -O3 -c dec.c -o dec.o

static const int powers10[2 + 1]= { 1, 10, 100 };

int remove_leading_zeroes(int decimals, int var)
  decimals%= 2;
  while (var < powers10[decimals--]) /* no-op */;
  return decimals;

The only allowed value for decimals is 1 and var must be > 0. Similar assertion
is enforced by original function.

So far I see nothing wrong with this code. I believe we should skip this patch,
but still we should probably do something about these warning. What's your take?


Follow ups