~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-04-17 01:38:47 UTC
  • mfrom: (1237.9.238 bad-staging)
  • Revision ID: osullivan.padraig@gmail.com-20100417013847-ibjioqsfbmf5yg4g
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
bool plugin::Client::store(const DRIZZLE_TIME *from)
29
29
{
30
 
  char buff[40];
31
 
  uint32_t length;
 
30
  const size_t buff_len= 40;
 
31
  char buff[buff_len];
 
32
  uint32_t length= 0;
32
33
  uint32_t day;
33
34
 
34
35
  switch (from->time_type)
35
36
  {
36
37
  case DRIZZLE_TIMESTAMP_DATETIME:
37
 
    length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
 
38
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
38
39
                    (int) from->year,
39
40
                    (int) from->month,
40
41
                    (int) from->day,
42
43
                    (int) from->minute,
43
44
                    (int) from->second);
44
45
    if (from->second_part)
45
 
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
 
46
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
46
47
    break;
47
48
 
48
49
  case DRIZZLE_TIMESTAMP_DATE:
49
 
    length= sprintf(buff, "%04d-%02d-%02d",
 
50
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
50
51
                    (int) from->year,
51
52
                    (int) from->month,
52
53
                    (int) from->day);
54
55
 
55
56
  case DRIZZLE_TIMESTAMP_TIME:
56
57
    day= (from->year || from->month) ? 0 : from->day;
57
 
    length= sprintf(buff, "%s%02ld:%02d:%02d",
 
58
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
58
59
                    from->neg ? "-" : "",
59
60
                    (long) day*24L+(long) from->hour,
60
61
                    (int) from->minute,
61
62
                    (int) from->second);
62
63
    if (from->second_part)
63
 
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
 
64
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
64
65
    break;
65
66
 
66
67
  case DRIZZLE_TIMESTAMP_NONE: