Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libgearman/client.cc compilation errors #76

Closed
jwakely opened this issue Feb 17, 2017 · 7 comments
Closed

libgearman/client.cc compilation errors #76

jwakely opened this issue Feb 17, 2017 · 7 comments

Comments

@jwakely
Copy link

jwakely commented Feb 17, 2017

libgearman/client.cc: In function 'gearman_return_t gearman_client_add_server(gearman_client_st*, const char*, in_port_t)':
libgearman/client.cc:602:69: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if (gearman_connection_create(client->universal, host, port) == false)
                                                                     ^~~~~
libgearman/client.cc: In member function 'gearman_return_t Client::add_server(const char*, const char*)':
libgearman/client.cc:617:63: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   if (gearman_connection_create(universal, host, service_) == false)
                                                               ^~~~~
libgearman/client.cc: In function 'gearman_return_t gearman_client_job_status(gearman_client_st*, const char*, bool*, bool*, uint32_t*, uint32_t*)':
libgearman/client.cc:949:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if (is_known == false and is_running == false)
                     ^~~~~
libgearman/client.cc:949:45: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if (is_known == false and is_running == false)
                                             ^~~~~

Somebody is confused about the difference between pointers and booleans.

The first two are easy to fix (see #75) but the other one isn't so obvious. Is it supposed to be checking for null pointers?

 if (is_known == NULL and is_running == NULL)

or this, would would crash if they're null (and the checks a few lines above suggest they can be):

 if (*is_known == false and *is_running == false)

or maybe:

 if ((!is_known or *is_known == false) and (!is_running or *is_running == false))

or something else entirely.

Please advise, and I'll update the pull request.

@p-alik
Copy link
Collaborator

p-alik commented Feb 17, 2017

Thank you for reporting, @jwakely.

@p-alik
Copy link
Collaborator

p-alik commented Feb 17, 2017

Some TODO's with regard to the issue:

tests/protocol.cc:  ASSERT_TRUE(connection1= gearman_connection_create(universal, GEARMAN_DEFAULT_TCP_HOST, libtest::default_port()));
tests/protocol.cc:  ASSERT_TRUE(connection1= gearman_connection_create(universal, GEARMAN_DEFAULT_TCP_HOST, libtest::default_port()));
tests/protocol.cc:  ASSERT_TRUE(connection1= gearman_connection_create(universal, GEARMAN_DEFAULT_TCP_HOST, libtest::default_port()));
tests/libgearman-1.0/regression.cc:    ASSERT_TRUE(con_ptr= gearman_connection_create(universal, NULL, default_port()));
tests/libgearman-1.0/regression.cc:    ASSERT_TRUE(con_ptr= gearman_connection_create(universal, NULL, default_port()));
tests/libgearman-1.0/worker_test.cc:  ASSERT_TRUE(connection1= gearman_connection_create(universal, NULL, default_port()));
tests/libgearman-1.0/worker_test.cc:  ASSERT_TRUE(connection2= gearman_connection_create(universal, NULL, default_port()));

@p-alik p-alik closed this as completed Feb 17, 2017
@p-alik p-alik reopened this Feb 17, 2017
@SpamapS
Copy link
Member

SpamapS commented Feb 17, 2017

I'd like to get this one in and release 1.1.15 soon as there are other unreleased fixes in master. I don't have a lot of time to look at the issue, but I'd say one approach is to ensure there's adequate test coverage here, and make the most obvious change.

@esabol
Copy link
Collaborator

esabol commented Feb 20, 2017

I'm only a novice at reading the gearmand code, but, after looking it over, I think it should be:

   if (is_known == NULL and is_running == NULL)

p-alik added a commit to p-alik/gearmand that referenced this issue Feb 20, 2017
ISO C++ forbids comparison between pointer and integer
@p-alik
Copy link
Collaborator

p-alik commented Feb 20, 2017

@esabol, I'll test it twice to be on the safe side.

@esabol
Copy link
Collaborator

esabol commented Feb 22, 2017

Do those ASSERT_TRUE lines mentioned above result in compilation errors or warnings? If so, I think they could be fixed, like so:

ASSERT_TRUE(whatever) => ASSERT_TRUE((whatever) != NULL)

What do you think?

@p-alik
Copy link
Collaborator

p-alik commented Feb 22, 2017

actually none of them.
I guess ASSERT_TRUE should be replaced with a check for nullptr because gearman_connection_create is of type gearman_connection_st *.

p-alik added a commit to p-alik/gearmand that referenced this issue Mar 3, 2017
assert type of gearman_connection_create
@p-alik p-alik mentioned this issue Mar 3, 2017
p-alik added a commit to p-alik/gearmand that referenced this issue Mar 20, 2017
ISO C++ forbids comparison between pointer and integer
@p-alik p-alik closed this as completed May 9, 2017
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

No branches or pull requests

4 participants