Merge lp:~brianaker/libdrizzle/cleanup-api into lp:libdrizzle

Proposed by Brian Aker
Status: Merged
Approved by: Andrew Hutchings
Approved revision: no longer in the source branch.
Merged at revision: 99
Proposed branch: lp:~brianaker/libdrizzle/cleanup-api
Merge into: lp:libdrizzle
Diff against target: 361 lines (+43/-197)
10 files modified
libdrizzle-5.1/conn.h (+0/-10)
libdrizzle-5.1/query.h (+1/-7)
libdrizzle/conn.cc (+0/-10)
libdrizzle/drizzle_local.h (+5/-0)
libdrizzle/query.cc (+25/-5)
tests/unit/escape.c (+11/-8)
tests/unit/hex.c (+0/-65)
tests/unit/include.am (+0/-10)
tests/unit/passwd.c (+0/-77)
tests/unit/statement_char.c (+1/-5)
To merge this branch: bzr merge lp:~brianaker/libdrizzle/cleanup-api
Reviewer Review Type Date Requested Status
Drizzle Trunk Pending
Review via email: mp+145078@code.launchpad.net
To post a comment you must log in.
lp:~brianaker/libdrizzle/cleanup-api updated
99. By Drizzle Continuous Integration

Merge lp:~brianaker/libdrizzle/cleanup-api Build: jenkins-Libdrizzle-55

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdrizzle-5.1/conn.h'
2--- libdrizzle-5.1/conn.h 2013-01-27 00:09:17 +0000
3+++ libdrizzle-5.1/conn.h 2013-01-27 01:59:21 +0000
4@@ -105,16 +105,6 @@
5 const char *drizzle_error(const drizzle_st *con);
6
7 /**
8- * Value of errno in the case of a DRIZZLE_RETURN_ERRNO return value.
9- *
10- * @param[in] con Connection structure previously initialized with
11- * drizzle_create(), drizzle_clone(), or related functions.
12- * @return An errno value as defined in your system errno.h file.
13- */
14-DRIZZLE_API
15-int drizzle_errno(const drizzle_st *con);
16-
17-/**
18 * Get server defined error code for the last result read.
19 *
20 * @param[in] con Connection structure previously initialized with
21
22=== modified file 'libdrizzle-5.1/query.h'
23--- libdrizzle-5.1/query.h 2013-01-10 22:14:47 +0000
24+++ libdrizzle-5.1/query.h 2013-01-27 01:59:21 +0000
25@@ -79,13 +79,7 @@
26 */
27
28 DRIZZLE_API
29-ssize_t drizzle_escape_string(char *to, const size_t max_to_size, const char *from, const size_t from_size);
30-
31-DRIZZLE_API
32-bool drizzle_hex_string(char *to, const unsigned char *from, const size_t from_size);
33-
34-DRIZZLE_API
35-bool drizzle_mysql_password_hash(char *to, const char *from, const size_t from_size);
36+ssize_t drizzle_escape_string(drizzle_st *con, char **to, const char *from, const size_t from_size);
37
38 /** @} */
39
40
41=== modified file 'libdrizzle/conn.cc'
42--- libdrizzle/conn.cc 2013-01-26 23:31:43 +0000
43+++ libdrizzle/conn.cc 2013-01-27 01:59:21 +0000
44@@ -270,16 +270,6 @@
45 return (const char *)con->last_error;
46 }
47
48-int drizzle_errno(const drizzle_st *con)
49-{
50- if (con == NULL)
51- {
52- return 0;
53- }
54-
55- return con->last_errno;
56-}
57-
58 uint16_t drizzle_error_code(const drizzle_st *con)
59 {
60 if (con == NULL)
61
62=== modified file 'libdrizzle/drizzle_local.h'
63--- libdrizzle/drizzle_local.h 2013-01-26 23:44:28 +0000
64+++ libdrizzle/drizzle_local.h 2013-01-27 01:59:21 +0000
65@@ -115,6 +115,11 @@
66 }
67 }
68
69+bool drizzle_hex_string(char *to, const unsigned char *from, const size_t from_size);
70+
71+bool drizzle_mysql_password_hash(char *to, const char *from, const size_t from_size);
72+
73+
74 /**
75 * Log an error message, see drizzle_log() for argument details.
76 */
77
78=== modified file 'libdrizzle/query.cc'
79--- libdrizzle/query.cc 2013-01-10 22:14:47 +0000
80+++ libdrizzle/query.cc 2013-01-27 01:59:21 +0000
81@@ -56,14 +56,26 @@
82 (unsigned char *)query, size, size, ret_ptr);
83 }
84
85-ssize_t drizzle_escape_string(char *to, const size_t max_to_size, const char *from, const size_t from_size)
86+ssize_t drizzle_escape_string(drizzle_st *con, char **destination, const char *from, const size_t from_size)
87 {
88+ (void)con;
89 const char *end;
90
91- if (to == NULL || max_to_size == 0 || from == NULL || from_size == 0)
92- {
93- return -1;
94- }
95+ if (from == NULL || from_size == 0)
96+ {
97+ return -1;
98+ }
99+
100+ size_t max_to_size= from_size * 2;
101+ *destination= (char*) malloc(max_to_size);
102+
103+ if (destination == NULL)
104+ {
105+ return -1;
106+ }
107+
108+ char *to= *destination;
109+
110
111 ssize_t to_size= 0;
112 char newchar;
113@@ -104,7 +116,11 @@
114 if (newchar != '\0')
115 {
116 if ((size_t)to_size + 2 > max_to_size)
117+ {
118+ free(to);
119+ *destination= NULL;
120 return -1;
121+ }
122
123 *to++= '\\';
124 *to++= newchar;
125@@ -113,7 +129,11 @@
126 else
127 {
128 if ((size_t)to_size + 1 > max_to_size)
129+ {
130+ free(to);
131+ *destination= NULL;
132 return -1;
133+ }
134
135 *to++= *from;
136 }
137
138=== modified file 'tests/unit/escape.c'
139--- tests/unit/escape.c 2013-01-12 10:59:06 +0000
140+++ tests/unit/escape.c 2013-01-27 01:59:21 +0000
141@@ -46,19 +46,22 @@
142 int main(int argc, char* argv[])
143 {
144 const char* in= "escape \"this\"\n";
145- char out[255];
146- int out_len;
147
148 (void) argc;
149 (void) argv;
150
151 // Test for data too long
152- out_len= drizzle_escape_string(out, 2, in, strlen(in));
153- ASSERT_EQ(out_len, -1);
154-
155- out_len= drizzle_escape_string(out, 255, in, strlen(in));
156- ASSERT_EQ_(out_len, 17, "Bad hex length output %d", out_len);
157- ASSERT_EQ_(strcmp(out, "escape \\\"this\\\"\\n"), 0, "Bad hex data output");
158+ char *out;
159+ uint64_t out_len= drizzle_escape_string(NULL, &out, in, strlen(in));
160+ ASSERT_EQ_(17, out_len, "drizzle_escape_string(): %u != %u", 17, (unsigned int)(out_len));
161+
162+ free(out);
163+
164+ out_len= drizzle_escape_string(NULL, &out, in, strlen(in));
165+ ASSERT_EQ_(out_len, 17, "Bad hex length output %u", (unsigned int)(out_len));
166+ ASSERT_EQ_(0, strcmp(out, "escape \\\"this\\\"\\n"), "Bad hex data output");
167+
168+ free(out);
169
170 return EXIT_SUCCESS;
171 }
172
173=== removed file 'tests/unit/hex.c'
174--- tests/unit/hex.c 2013-01-12 10:59:06 +0000
175+++ tests/unit/hex.c 1970-01-01 00:00:00 +0000
176@@ -1,65 +0,0 @@
177-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
178- *
179- * Drizzle Client & Protocol Library
180- *
181- * Copyright (C) 2012 Drizzle Developer Group
182- * All rights reserved.
183- *
184- * Redistribution and use in source and binary forms, with or without
185- * modification, are permitted provided that the following conditions are
186- * met:
187- *
188- * * Redistributions of source code must retain the above copyright
189- * notice, this list of conditions and the following disclaimer.
190- *
191- * * Redistributions in binary form must reproduce the above
192- * copyright notice, this list of conditions and the following disclaimer
193- * in the documentation and/or other materials provided with the
194- * distribution.
195- *
196- * * The names of its contributors may not be used to endorse or
197- * promote products derived from this software without specific prior
198- * written permission.
199- *
200- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
201- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
202- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
203- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
205- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
206- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
207- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
208- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
209- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
210- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
211- *
212- */
213-
214-#include <yatl/lite.h>
215-
216-#include <libdrizzle-5.1/libdrizzle.h>
217-#include <stdio.h>
218-#include <string.h>
219-#include <stdlib.h>
220-#include <stdint.h>
221-
222-int main(int argc, char* argv[])
223-{
224- const unsigned char in[6]= {0x00, 0xFF, 0x7F, 0x80, 0xB9, 0xC0};
225- char out[255];
226- bool result;
227-
228- (void) argc;
229- (void) argv;
230-
231- // Test for bad usage
232- result= drizzle_hex_string(out, in, 0);
233- ASSERT_EQ_(false, result, "Bad usage of drizzle_hex_string()");
234-
235- result= drizzle_hex_string(out, in, sizeof(in));
236- ASSERT_EQ_(true, result, "Failed to get result");
237-
238- ASSERT_STREQ_("00FF7F80B9C0", out, "Bad result data from drizzle_hex_string()");
239-
240- return EXIT_SUCCESS;
241-}
242
243=== modified file 'tests/unit/include.am'
244--- tests/unit/include.am 2013-01-26 23:44:28 +0000
245+++ tests/unit/include.am 2013-01-27 01:59:21 +0000
246@@ -82,16 +82,6 @@
247 check_PROGRAMS+= tests/unit/connect_uds
248 noinst_PROGRAMS+= tests/unit/connect_uds
249
250-tests_unit_hex_SOURCES= tests/unit/hex.c
251-tests_unit_hex_LDADD= libdrizzle/libdrizzle.la
252-check_PROGRAMS+= tests/unit/hex
253-noinst_PROGRAMS+= tests/unit/hex
254-
255-tests_unit_passwd_SOURCES= tests/unit/passwd.c
256-tests_unit_passwd_LDADD= libdrizzle/libdrizzle.la
257-check_PROGRAMS+= tests/unit/passwd
258-noinst_PROGRAMS+= tests/unit/passwd
259-
260 tests_unit_unbuffered_query_SOURCES= tests/unit/unbuffered_query.c
261 tests_unit_unbuffered_query_LDADD= libdrizzle/libdrizzle.la
262 check_PROGRAMS+= tests/unit/unbuffered_query
263
264=== removed file 'tests/unit/passwd.c'
265--- tests/unit/passwd.c 2013-01-12 10:59:06 +0000
266+++ tests/unit/passwd.c 1970-01-01 00:00:00 +0000
267@@ -1,77 +0,0 @@
268-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
269- *
270- * Drizzle Client & Protocol Library
271- *
272- * Copyright (C) 2012 Drizzle Developer Group
273- * All rights reserved.
274- *
275- * Redistribution and use in source and binary forms, with or without
276- * modification, are permitted provided that the following conditions are
277- * met:
278- *
279- * * Redistributions of source code must retain the above copyright
280- * notice, this list of conditions and the following disclaimer.
281- *
282- * * Redistributions in binary form must reproduce the above
283- * copyright notice, this list of conditions and the following disclaimer
284- * in the documentation and/or other materials provided with the
285- * distribution.
286- *
287- * * The names of its contributors may not be used to endorse or
288- * promote products derived from this software without specific prior
289- * written permission.
290- *
291- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
293- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
294- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
295- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
296- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
297- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
298- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
299- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
300- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
301- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
302- *
303- */
304-
305-#include <yatl/lite.h>
306-
307-#include <libdrizzle-5.1/libdrizzle.h>
308-#include <stdio.h>
309-#include <string.h>
310-#include <stdlib.h>
311-#include <stdint.h>
312-#include <string.h>
313-
314-int main(int argc, char* argv[])
315-{
316- const char* in= "a nice passphrase";
317- char out[255];
318- bool result;
319-
320- (void) argc;
321- (void) argv;
322-
323- // Test for bad usage
324- result= drizzle_mysql_password_hash(out, in, 0);
325- if (result)
326- {
327- printf("Usage test failure\n");
328- return EXIT_FAILURE;
329- }
330-
331- result= drizzle_mysql_password_hash(out, in, strlen(in));
332- if (!result)
333- {
334- printf("Didn't get a result failure\n");
335- return EXIT_FAILURE;
336- }
337-
338- if (strcmp(out, "597B78D6E0366308739CEBB0E221B246F117E111") != 0)
339- {
340- printf("Password output didn't match\n");
341- return EXIT_FAILURE;
342- }
343- return EXIT_SUCCESS;
344-}
345
346=== modified file 'tests/unit/statement_char.c'
347--- tests/unit/statement_char.c 2013-01-12 13:40:18 +0000
348+++ tests/unit/statement_char.c 2013-01-27 01:59:21 +0000
349@@ -139,11 +139,7 @@
350 return EXIT_FAILURE;
351 }
352 ret = drizzle_stmt_close(stmt);
353- if (ret != DRIZZLE_RETURN_OK)
354- {
355- printf("Statement close failure ret: %d, err: %d, msg: %s\n", ret, drizzle_errno(con), drizzle_error(con));
356- return EXIT_FAILURE;
357- }
358+ ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "drizzle_stmt_close() %s", drizzle_error(con));
359
360 drizzle_query(con, "DROP TABLE libdrizzle.t1", 0, &ret);
361 ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "DROP TABLE libdrizzle.t1");

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: