Skip to content

Commit 0dcb47c

Browse files
committed
change lex_string_eq to return what it says
the function xxx_eq(a,b) returns true if two elements are equal and false if they are not.
1 parent 479bd5a commit 0dcb47c

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

sql/lex_string.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@
2121
typedef struct st_mysql_const_lex_string LEX_CSTRING;
2222

2323
/* Functions to compare if two lex strings are equal */
24-
inline bool lex_string_cmp(CHARSET_INFO *charset,
25-
const LEX_CSTRING *a,
26-
const LEX_CSTRING *b)
24+
static inline bool lex_string_cmp(CHARSET_INFO *charset, const LEX_CSTRING *a,
25+
const LEX_CSTRING *b)
2726
{
2827
return my_strcasecmp(charset, a->str, b->str);
2928
}
3029

3130
/*
3231
Compare to LEX_CSTRING's and return 0 if equal
3332
*/
34-
inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
33+
static inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
3534
{
3635
return (a->length != b->length ||
3736
memcmp(a->str, b->str, a->length));
@@ -41,12 +40,11 @@ inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
4140
Compare if two LEX_CSTRING are equal. Assumption is that
4241
character set is ASCII (like for plugin names)
4342
*/
44-
inline bool lex_string_eq(const LEX_CSTRING *a,
45-
const LEX_CSTRING *b)
43+
static inline bool lex_string_eq(const LEX_CSTRING *a, const LEX_CSTRING *b)
4644
{
4745
if (a->length != b->length)
48-
return 1; /* Different */
49-
return strcasecmp(a->str, b->str) != 0;
46+
return 0; /* Different */
47+
return strcasecmp(a->str, b->str) == 0;
5048
}
5149

5250
#endif /* LEX_STRING_INCLUDED */

sql/sql_acl.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,10 +1482,10 @@ static const char *fix_plugin_ptr(const char *name)
14821482
*/
14831483
static bool fix_user_plugin_ptr(ACL_USER *user)
14841484
{
1485-
if (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0)
1485+
if (lex_string_eq(&user->plugin, &native_password_plugin_name))
14861486
user->plugin= native_password_plugin_name;
14871487
else
1488-
if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0)
1488+
if (lex_string_eq(&user->plugin, &old_password_plugin_name))
14891489
user->plugin= old_password_plugin_name;
14901490
else
14911491
return true;
@@ -1525,10 +1525,10 @@ static bool fix_lex_user(THD *thd, LEX_USER *user)
15251525
DBUG_ASSERT(user->plugin.length || !user->auth.length);
15261526
DBUG_ASSERT(!(user->plugin.length && (user->pwtext.length || user->pwhash.length)));
15271527

1528-
if (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0)
1528+
if (lex_string_eq(&user->plugin, &native_password_plugin_name))
15291529
check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH;
15301530
else
1531-
if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0)
1531+
if (lex_string_eq(&user->plugin, &old_password_plugin_name))
15321532
check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323;
15331533
else
15341534
if (user->plugin.length)
@@ -11213,7 +11213,7 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
1121311213
if (!is_role)
1121411214
{
1121511215
if (data->user->default_rolename.length &&
11216-
!lex_string_eq(&data->user->default_rolename, &role->user))
11216+
lex_string_eq(&data->user->default_rolename, &role->user))
1121711217
table->field[3]->store(STRING_WITH_LEN("YES"), cs);
1121811218
else
1121911219
table->field[3]->store(STRING_WITH_LEN("NO"), cs);
@@ -12825,8 +12825,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
1282512825
restarted and a server auth plugin will read the data that the client
1282612826
has just send. Cache them to return in the next server_mpvio_read_packet().
1282712827
*/
12828-
if (lex_string_eq(&mpvio->acl_user->plugin,
12829-
plugin_name(mpvio->plugin)) != 0)
12828+
if (!lex_string_eq(&mpvio->acl_user->plugin, plugin_name(mpvio->plugin)))
1283012829
{
1283112830
mpvio->cached_client_reply.pkt= passwd;
1283212831
mpvio->cached_client_reply.pkt_len= (uint)passwd_len;
@@ -13256,7 +13255,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
1325613255
{
1325713256
DBUG_ASSERT(mpvio.acl_user);
1325813257
DBUG_ASSERT(command == COM_CHANGE_USER ||
13259-
lex_string_eq(auth_plugin_name, &mpvio.acl_user->plugin));
13258+
!lex_string_eq(auth_plugin_name, &mpvio.acl_user->plugin));
1326013259
auth_plugin_name= &mpvio.acl_user->plugin;
1326113260
res= do_auth_once(thd, auth_plugin_name, &mpvio);
1326213261
}

sql/table.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,21 @@ TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
252252
if (is_infoschema_db(db))
253253
return TABLE_CATEGORY_INFORMATION;
254254

255-
if (lex_string_eq(&PERFORMANCE_SCHEMA_DB_NAME, db) == 0)
255+
if (lex_string_eq(&PERFORMANCE_SCHEMA_DB_NAME, db))
256256
return TABLE_CATEGORY_PERFORMANCE;
257257

258-
if (lex_string_eq(&MYSQL_SCHEMA_NAME, db) == 0)
258+
if (lex_string_eq(&MYSQL_SCHEMA_NAME, db))
259259
{
260260
if (is_system_table_name(name->str, name->length))
261261
return TABLE_CATEGORY_SYSTEM;
262262

263-
if (lex_string_eq(&GENERAL_LOG_NAME, name) == 0)
263+
if (lex_string_eq(&GENERAL_LOG_NAME, name))
264264
return TABLE_CATEGORY_LOG;
265265

266-
if (lex_string_eq(&SLOW_LOG_NAME, name) == 0)
266+
if (lex_string_eq(&SLOW_LOG_NAME, name))
267267
return TABLE_CATEGORY_LOG;
268268

269-
if (lex_string_eq(&TRANSACTION_REG_NAME, name) == 0)
269+
if (lex_string_eq(&TRANSACTION_REG_NAME, name))
270270
return TABLE_CATEGORY_LOG;
271271
}
272272

0 commit comments

Comments
 (0)