Skip to content

Conversation

tamird
Copy link
Contributor

@tamird tamird commented Jun 8, 2015

Turns out there was a bug in how CFLAGS were being added in extconf; fixing it made '-Weverything' actually turn on, and a bunch of issues were revealed.

@tamird tamird mentioned this pull request Jun 8, 2015
@sodabrew
Copy link
Collaborator

sodabrew commented Jun 8, 2015

This fails to compile on OS X for me, due to a "Default label in switch which covers all enumeration values" warning. Even if we added a -Wno-error for that, I think -Weverything is too noisy to ship to end-users.

@tamird
Copy link
Contributor Author

tamird commented Jun 9, 2015

I kind of like having to explicitly list which warnings we do not comply with and the reasons we do not.

EDIT: Can you supply the exact error and its location?

@sodabrew
Copy link
Collaborator

sodabrew commented Jun 9, 2015

Two case blocks for MySQL return types in result.c:

ext/mysql2/result.c:298:7: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
ext/mysql2/result.c:706:9: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]

@tamird
Copy link
Contributor Author

tamird commented Jun 9, 2015

Oh, you must be compiling against a different version of the mysql header - on my system, those enumerations do not fully cover all values, so the warning is not issued. Which mysql are you compiling against?

@sodabrew
Copy link
Collaborator

sodabrew commented Jun 9, 2015

MySQL 5.5 -- of course we support compiling against a range of versions, so the default is an important fallback :)

Really my main concern is that all of the warning text cannot be printed to end users while they are compiling. There will be tons of tickets about how mysql2 doesn't compile cleanly, is it going to work? I haven't tried it but I'm nervous!?

@tamird
Copy link
Contributor Author

tamird commented Jun 9, 2015

Ah, turns out we can kill the warnings entirely with s/Wno-error=/Wno-/g. PTAL

@sodabrew
Copy link
Collaborator

sodabrew commented Jun 9, 2015

The next issue is thornier. There are a number of shortenings ala -Wshorten-64-to-32 and signedness conversion due to Ruby arrays being platform-signed-long in length[1] while MySQL result sets are an unsigned 64 on all platforms.

1 - http://rxr.whitequark.org/mri/source/include/ruby/ruby.h#927

ext/mysql2/result.c:749:35: error: comparison of integers of different signs: 'long' and 'unsigned int' [-Werror,-Wsign-compare]
  if (RARRAY_LEN(wrapper->fields) != wrapper->numberOfFields) {
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~
ext/mysql2/result.c:905:45: error: implicit conversion loses integer precision: 'my_ulonglong' (aka 'unsigned long long') to 'unsigned long' [-Werror,-Wshorten-64-to-32]
    wrapper->numberOfRows = wrapper->stmt ? mysql_stmt_num_rows(wrapper->stmt) : mysql_num_rows(wrapper->result);
                          ~                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ext/mysql2/result.c:905:82: error: implicit conversion loses integer precision: 'my_ulonglong' (aka 'unsigned long long') to 'unsigned long' [-Werror,-Wshorten-64-to-32]
    wrapper->numberOfRows = wrapper->stmt ? mysql_stmt_num_rows(wrapper->stmt) : mysql_num_rows(wrapper->result);
                          ~                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@tamird
Copy link
Contributor Author

tamird commented Jun 9, 2015

Neat. Where did you find a 32bit machine? :) PTAL

@sodabrew
Copy link
Collaborator

sodabrew commented Jun 9, 2015

Oddly, this is on my desktop Mac - it's 64-bit and compiled as such - so I'm confused, too! In result.h, numberOfRows is an unsigned long, which certainly should be 64-bit.

@tamird
Copy link
Contributor Author

tamird commented Jun 9, 2015

These failures look spurious, can you retry the build? I've changed numberOfRows and numberOfFields to both be my_ulonglong, so perhaps the error you saw is cleared?

@sodabrew sodabrew mentioned this pull request Jun 10, 2015
@sodabrew
Copy link
Collaborator

I think #629 satisfies most of the goals of this PR but with less ambitious compiler warnings. Let me know if there are items in this branch you would still hope to see land, or consider it resolved and close the PR.

@sodabrew sodabrew closed this Jul 14, 2015
@tamird tamird mentioned this pull request Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants