Skip to content

Commit f9f2fb1

Browse files
committed
Fix implicit conversion warnings
1 parent 7d7b6e8 commit f9f2fb1

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

ext/mysql2/client.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ static VALUE rb_mysql_info(VALUE self) {
322322

323323
static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database, VALUE socket, VALUE flags) {
324324
struct nogvl_connect_args args;
325-
time_t start_time, end_time;
326-
unsigned int elapsed_time, connect_timeout;
325+
time_t start_time, end_time, elapsed_time, connect_timeout;
327326
VALUE rv;
328327
GET_CLIENT(self);
329328

@@ -1131,7 +1130,6 @@ static VALUE set_write_timeout(VALUE self, VALUE value) {
11311130
static VALUE set_charset_name(VALUE self, VALUE value) {
11321131
char *charset_name;
11331132
#ifdef HAVE_RUBY_ENCODING_H
1134-
size_t charset_name_len;
11351133
const struct mysql2_mysql_enc_name_to_rb_map *mysql2rb;
11361134
rb_encoding *enc;
11371135
VALUE rb_enc;
@@ -1141,8 +1139,7 @@ static VALUE set_charset_name(VALUE self, VALUE value) {
11411139
charset_name = RSTRING_PTR(value);
11421140

11431141
#ifdef HAVE_RUBY_ENCODING_H
1144-
charset_name_len = RSTRING_LEN(value);
1145-
mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
1142+
mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, (unsigned int)RSTRING_LEN(value));
11461143
if (mysql2rb == NULL || mysql2rb->rb_name == NULL) {
11471144
VALUE inspect = rb_inspect(value);
11481145
rb_raise(cMysql2Error, "Unsupported charset: '%s'", RSTRING_PTR(inspect));

ext/mysql2/mysql_enc_name_to_ruby.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ inline
4040
#endif
4141
#endif
4242
static unsigned int
43-
mysql2_mysql_enc_name_to_rb_hash (str, len)
43+
mysql2_mysql_enc_name_to_rb_hash(str, len)
4444
register const char *str;
45-
register unsigned int len;
45+
register const unsigned int len;
4646
{
4747
static const unsigned char asso_values[] =
4848
{
@@ -83,9 +83,9 @@ __attribute__ ((__gnu_inline__))
8383
#endif
8484
#endif
8585
const struct mysql2_mysql_enc_name_to_rb_map *
86-
mysql2_mysql_enc_name_to_rb (str, len)
86+
mysql2_mysql_enc_name_to_rb(str, len)
8787
register const char *str;
88-
register unsigned int len;
88+
register const unsigned int len;
8989
{
9090
enum
9191
{
@@ -154,9 +154,9 @@ mysql2_mysql_enc_name_to_rb (str, len)
154154

155155
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
156156
{
157-
register int key = mysql2_mysql_enc_name_to_rb_hash (str, len);
157+
register const unsigned int key = mysql2_mysql_enc_name_to_rb_hash(str, len);
158158

159-
if (key <= MAX_HASH_VALUE && key >= 0)
159+
if (key <= MAX_HASH_VALUE)
160160
{
161161
register const char *s = wordlist[key].name;
162162

ext/mysql2/result.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static VALUE mysql2_set_field_string_encoding(VALUE val, MYSQL_FIELD field, rb_e
220220
*/
221221
static unsigned int msec_char_to_uint(char *msec_char, size_t len)
222222
{
223-
int i;
223+
size_t i;
224224
for (i = 0; i < (len - 1); i++) {
225225
if (msec_char[i] == '\0') {
226226
msec_char[i] = '0';

0 commit comments

Comments
 (0)