Merge lp:~stewart/drizzle/cleanups-1 into lp:drizzle

Proposed by Stewart Smith
Status: Merged
Merged at revision: 2619
Proposed branch: lp:~stewart/drizzle/cleanups-1
Merge into: lp:drizzle
Diff against target: 243 lines (+15/-40)
14 files modified
client/drizzledump_drizzle.cc (+2/-2)
client/drizzledump_mysql.cc (+2/-2)
client/drizzletest.cc (+2/-2)
drizzled/internal/mf_format.cc (+1/-9)
drizzled/internal/my_sys.h (+0/-1)
drizzled/item/cmpfunc.h (+1/-4)
plugin/collation_dictionary/character_sets.cc (+1/-0)
plugin/collation_dictionary/collations.cc (+1/-0)
plugin/connection_id/connection_id.cc (+2/-2)
plugin/innobase/handler/ha_innodb.h (+1/-1)
plugin/json_server/sql_executor.cc (+1/-1)
plugin/myisam/ha_myisam.cc (+0/-14)
plugin/myisam/ha_myisam.h (+0/-1)
plugin/myisam/mi_open.cc (+1/-1)
To merge this branch: bzr merge lp:~stewart/drizzle/cleanups-1
Reviewer Review Type Date Requested Status
Drizzle Trunk Pending
Review via email: mp+147553@code.launchpad.net

Description of the change

First round of fixes from a coverity scan. Mostly pretty minor, and some dead code found.

To post a comment you must log in.
lp:~stewart/drizzle/cleanups-1 updated
2627. By Stewart Smith

data_file_name and index_file_name in ha_myisam were actually all just dead code

2628. By Stewart Smith

Fix the following Coverity warning in class COND_EQUAL

CID 973373 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
2. uninit_member: Non-static class member "max_members" is not initialized in this constructor nor in any functions that it calls.

2629. By Stewart Smith

Fix Coverity found bug in drizzletest.cc:
CID 973171 (#1 of 1): Out-of-bounds access (OVERRUN)
2. alloc_strlen: Allocating insufficient memory for the terminating null of the string.

This isn't exploitable, just test suite.

2630. By Stewart Smith

Attempt to fix CID 980643 (#1 of 1): Uninitialized pointer read (UNINIT)
6. uninit_use: Using uninitialized value "index".

Basically, false positive but we could make the code a bit more obvious
that the first run through we were going to allocate index.

2631. By Stewart Smith

Attempt to fix CID 980642 (#1 of 1): Uninitialized pointer read (UNINIT)
6. uninit_use: Using uninitialized value "index".

Basically try and make the code a bit more obvious that we do in fact
alloc index on first run through.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/drizzledump_drizzle.cc'
2--- client/drizzledump_drizzle.cc 2012-04-23 08:25:39 +0000
3+++ client/drizzledump_drizzle.cc 2013-02-16 03:55:26 +0000
4@@ -222,7 +222,7 @@
5 std::string query;
6 std::string lastKey;
7 bool firstIndex= true;
8- DrizzleDumpIndex *index;
9+ DrizzleDumpIndex *index= NULL;
10
11 if (verbose)
12 std::cerr << _("-- Retrieving indexes for ") << tableName << "..." << std::endl;
13@@ -241,7 +241,7 @@
14 while ((row= drizzle_row_next(result)))
15 {
16 std::string indexName(row[0]);
17- if (indexName.compare(lastKey) != 0)
18+ if (index == NULL || indexName.compare(lastKey) != 0)
19 {
20 if (!firstIndex)
21 indexes.push_back(index);
22
23=== modified file 'client/drizzledump_mysql.cc'
24--- client/drizzledump_mysql.cc 2012-04-23 08:25:39 +0000
25+++ client/drizzledump_mysql.cc 2013-02-16 03:55:26 +0000
26@@ -264,7 +264,7 @@
27 std::string query;
28 std::string lastKey;
29 bool firstIndex= true;
30- DrizzleDumpIndex *index;
31+ DrizzleDumpIndex *index= NULL;
32
33 if (verbose)
34 std::cerr << _("-- Retrieving indexes for ") << tableName << "..." << std::endl;
35@@ -280,7 +280,7 @@
36 while ((row= drizzle_row_next(result)))
37 {
38 std::string indexName(row[2]);
39- if (indexName.compare(lastKey) != 0)
40+ if (index == NULL || indexName.compare(lastKey) != 0)
41 {
42 if (strcmp(row[10], "FULLTEXT") == 0)
43 continue;
44
45=== modified file 'client/drizzletest.cc'
46--- client/drizzletest.cc 2013-01-08 12:08:04 +0000
47+++ client/drizzletest.cc 2013-02-16 03:55:26 +0000
48@@ -5129,7 +5129,7 @@
49
50 if (vm.count("tmpdir"))
51 {
52- strncpy(TMPDIR, vm["tmpdir"].as<string>().c_str(), sizeof(TMPDIR));
53+ strncpy(TMPDIR, vm["tmpdir"].as<string>().c_str(), sizeof(TMPDIR)-1);
54 }
55
56 if (vm.count("version"))
57@@ -5867,7 +5867,7 @@
58 char last_c = 0;
59 st_regex reg;
60
61- char* buf= new char[expr_len];
62+ char* buf= new char[expr_len+1];
63 char* expr_end= expr + expr_len;
64 char* p= expr;
65 char* buf_p= buf;
66
67=== modified file 'drizzled/internal/mf_format.cc'
68--- drizzled/internal/mf_format.cc 2011-03-28 05:22:04 +0000
69+++ drizzled/internal/mf_format.cc 2013-02-16 03:55:26 +0000
70@@ -119,8 +119,7 @@
71 {
72 struct stat stat_buff;
73 char rp_buff[PATH_MAX];
74- if ((!flag & MY_RESOLVE_SYMLINKS) ||
75- (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
76+ if ((!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
77 {
78 if (!realpath(to,rp_buff))
79 my_load_path(rp_buff, to, NULL);
80@@ -128,13 +127,6 @@
81 strcpy(to,rp_buff);
82 }
83 }
84- else if (flag & MY_RESOLVE_SYMLINKS)
85- {
86- strcpy(buff,to);
87- ssize_t sym_link_size= readlink(buff,to,FN_REFLEN-1);
88- if (sym_link_size >= 0)
89- to[sym_link_size]= '\0';
90- }
91 return(to);
92 } /* fn_format */
93
94
95=== modified file 'drizzled/internal/my_sys.h'
96--- drizzled/internal/my_sys.h 2011-10-24 13:51:13 +0000
97+++ drizzled/internal/my_sys.h 2013-02-16 03:55:26 +0000
98@@ -97,7 +97,6 @@
99 #define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
100 #define MY_REPLACE_EXT 2 /* replace extension with 'ext' */
101 #define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */
102-#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */
103 #define MY_RETURN_REAL_PATH 32 /* return full path for file */
104 #define MY_SAFE_PATH 64 /* Return NULL if too long path */
105 #define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
106
107=== modified file 'drizzled/item/cmpfunc.h'
108--- drizzled/item/cmpfunc.h 2013-01-20 11:22:10 +0000
109+++ drizzled/item/cmpfunc.h 2013-02-16 03:55:26 +0000
110@@ -1566,10 +1566,7 @@
111 COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
112 List<Item_equal> current_level; /* list of multiple equalities of
113 the current and level */
114- COND_EQUAL()
115- {
116- upper_levels= 0;
117- }
118+ COND_EQUAL() : max_members(0), upper_levels(NULL) {}
119 };
120
121 typedef List<Item_field>::iterator Item_equal_iterator;
122
123=== modified file 'plugin/collation_dictionary/character_sets.cc'
124--- plugin/collation_dictionary/character_sets.cc 2011-03-28 02:46:21 +0000
125+++ plugin/collation_dictionary/character_sets.cc 2013-02-16 03:55:26 +0000
126@@ -35,6 +35,7 @@
127
128 CharacterSetsTool::Generator::Generator(Field **arg) :
129 plugin::TableFunction::Generator(arg),
130+ character_set_iter(NULL),
131 is_char_primed(false)
132 {
133 }
134
135=== modified file 'plugin/collation_dictionary/collations.cc'
136--- plugin/collation_dictionary/collations.cc 2011-03-28 02:46:21 +0000
137+++ plugin/collation_dictionary/collations.cc 2013-02-16 03:55:26 +0000
138@@ -39,6 +39,7 @@
139
140 CollationsTool::Generator::Generator(Field **arg) :
141 CharacterSetsTool::Generator(arg),
142+ collation_iter(NULL),
143 is_collation_primed(false)
144 {
145 }
146
147=== modified file 'plugin/connection_id/connection_id.cc'
148--- plugin/connection_id/connection_id.cc 2012-01-15 20:54:59 +0000
149+++ plugin/connection_id/connection_id.cc 2013-02-16 03:55:26 +0000
150@@ -30,8 +30,8 @@
151 {
152 int64_t value;
153 public:
154- ConnectionIdFunction() :Item_int_func() {}
155-
156+ ConnectionIdFunction() :Item_int_func(), value(0) {}
157+
158 int64_t val_int()
159 {
160 assert(fixed == true);
161
162=== modified file 'plugin/innobase/handler/ha_innodb.h'
163--- plugin/innobase/handler/ha_innodb.h 2011-03-14 05:40:28 +0000
164+++ plugin/innobase/handler/ha_innodb.h 2013-02-16 03:55:26 +0000
165@@ -60,7 +60,7 @@
166 st_innobase_share(const char *arg) :
167 use_count(0)
168 {
169- strncpy(table_name, arg, FN_REFLEN);
170+ strncpy(table_name, arg, FN_REFLEN-1);
171 }
172
173 } INNOBASE_SHARE;
174
175=== modified file 'plugin/json_server/sql_executor.cc'
176--- plugin/json_server/sql_executor.cc 2012-06-27 13:19:14 +0000
177+++ plugin/json_server/sql_executor.cc 2013-02-16 03:55:26 +0000
178@@ -40,7 +40,7 @@
179 namespace json_server
180 {
181 SQLExecutor::SQLExecutor(const string &schema)
182- : _in_error_state(false)
183+ : _in_error_state(false), _err(EE_OK)
184 {
185 /* setup a Session object */
186 _session= Session::make_shared(plugin::Listen::getNullClient(), catalog::local());
187
188=== modified file 'plugin/myisam/ha_myisam.cc'
189--- plugin/myisam/ha_myisam.cc 2012-02-18 01:04:31 +0000
190+++ plugin/myisam/ha_myisam.cc 2013-02-16 03:55:26 +0000
191@@ -1198,7 +1198,6 @@
192 int ha_myisam::info(uint32_t flag)
193 {
194 MI_ISAMINFO misam_info;
195- char name_buff[FN_REFLEN];
196
197 (void) mi_status(file,&misam_info,flag);
198 if (flag & HA_STATUS_VARIABLE)
199@@ -1275,19 +1274,6 @@
200 sizeof(getTable()->key_info[0].rec_per_key)*share->key_parts);
201 assert(share->getType() != message::Table::STANDARD);
202
203- /*
204- Set data_file_name and index_file_name to point at the symlink value
205- if table is symlinked (Ie; Real name is not same as generated name)
206- */
207- data_file_name= index_file_name= 0;
208- internal::fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
209- MY_APPEND_EXT | MY_UNPACK_FILENAME);
210- if (strcmp(name_buff, misam_info.data_file_name))
211- data_file_name=misam_info.data_file_name;
212- internal::fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
213- MY_APPEND_EXT | MY_UNPACK_FILENAME);
214- if (strcmp(name_buff, misam_info.index_file_name))
215- index_file_name=misam_info.index_file_name;
216 }
217 if (flag & HA_STATUS_ERRKEY)
218 {
219
220=== modified file 'plugin/myisam/ha_myisam.h'
221--- plugin/myisam/ha_myisam.h 2011-03-14 05:40:28 +0000
222+++ plugin/myisam/ha_myisam.h 2013-02-16 03:55:26 +0000
223@@ -26,7 +26,6 @@
224 class ha_myisam: public drizzled::Cursor
225 {
226 MI_INFO *file;
227- char *data_file_name, *index_file_name;
228 bool can_enable_indexes;
229 bool is_ordered;
230 int repair(drizzled::Session *session, MI_CHECK &param, bool optimize);
231
232=== modified file 'plugin/myisam/mi_open.cc'
233--- plugin/myisam/mi_open.cc 2012-08-26 19:27:29 +0000
234+++ plugin/myisam/mi_open.cc 2013-02-16 03:55:26 +0000
235@@ -168,7 +168,7 @@
236 (void) strcpy(index_name, org_name);
237 *strrchr(org_name, '.')= '\0';
238 (void) internal::fn_format(data_name,org_name,"",MI_NAME_DEXT,
239- MY_APPEND_EXT|MY_UNPACK_FILENAME|MY_RESOLVE_SYMLINKS);
240+ MY_APPEND_EXT|MY_UNPACK_FILENAME);
241
242 info_length=mi_uint2korr(share->state.header.header_length);
243 base_pos=mi_uint2korr(share->state.header.base_pos);

Subscribers

People subscribed via source and target branches

to all changes: