Skip to content

Fix sprintf warning mailbox.cc - #55

Closed
ghost wants to merge 4 commits into
nextfrom
unknown repository
Closed

ghost wants to merge 4 commits into
nextfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Nov 14, 2012

Copy link
Copy Markdown

rpc/mailbox/mailbox.cc: In member function ‘std::string raw_mailbox_t::address_t::human_readable() const’:
rpc/mailbox/mailbox.cc:33: error: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘long long unsigned int’

rpc/mailbox/mailbox.cc: In member function ‘std::string raw_mailbox_t::address_t::human_readable() const’:
rpc/mailbox/mailbox.cc:33: error: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘long long unsigned int’
@srh

srh commented Nov 14, 2012

Copy link
Copy Markdown
Contributor

What platform is this on?

@ghost

ghost commented Nov 14, 2012

Copy link
Copy Markdown
Author

Latest Debian.

CC rdb_protocol/btree.cc -o ../build/release/obj/rdb_protocol/btree.o

rdb_protocol/btree.cc: In function ‘void rdb_distribution_get(btree_slice_t*, int, const store_key_t&, transaction_t*, superblock_t*, distribution_read_response_t*)’:
rdb_protocol/btree.cc:415: error: no matching function for call to ‘max(int64_t, long unsigned int)’
make: *** [../build/release/obj/rdb_protocol/btree.o] Error 1
CC rdb_protocol/protocol.cc -o ../build/release/obj/rdb_protocol/protocol.o

In file included from ./serializer/log/data_block_manager.hpp:8,
                 from ./serializer/log/log_serializer.hpp:17,
                 from ./serializer/config.hpp:6,
                 from rdb_protocol/protocol.cc:22:
./containers/bitset.hpp:81: error: integer constant is too large for ‘long’ type
make: *** [../build/release/obj/rdb_protocol/protocol.o] Error 1
CC rdb_protocol/js.cc -o ../build/release/obj/rdb_protocol/js.o

rdb_protocol/js.cc: In member function ‘void js::compile_task_t::mkFuncSrc(scoped_array_t<char>*)’:
rdb_protocol/js.cc:251: error: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘int’
rdb_protocol/js.cc:251: error: format ‘%ld’ expects type ‘long int’, but argument 5 has type ‘ssize_t’
rdb_protocol/js.cc:251: error: format ‘%lu’ expects type ‘long unsigned int’, but argument 6 has type ‘int’
make: *** [../build/release/obj/rdb_protocol/js.o] Error 1
@ghost

ghost commented Nov 14, 2012

Copy link
Copy Markdown
Author

uname -a
Linux bajor 2.6.32-5-xen-amd64 #1 SMP Sun Sep 23 13:49:30 UTC 2012 x86_64 GNU/Linux

g++ --version
g++ (Debian 4.4.5-8) 4.4.5

@coffeemug

Copy link
Copy Markdown
Contributor

@gdonald -- thanks, we're working on the contributor agreement, it should be up very soon. We can review and accept the pull request then.

@coffeemug

Copy link
Copy Markdown
Contributor

@gdonald -- could you please fill out contributor agreement form: www.rethinkdb.com/community/cla/ You only have to do it once. Thanks for being patient!

@ghost ghost assigned srh Nov 15, 2012
@coffeemug

Copy link
Copy Markdown
Contributor

@srh - we got Greg's CLA. Could you review the pull request and merge it if you deem it sensible?

@srh

srh commented Nov 16, 2012

Copy link
Copy Markdown
Contributor

Hi @gdonald. Your uname -a says you're on a 64-bit system, but could it be that your compiler is trying to target a 32-bit architecture? Most notably, your change on line 252 of js.cc tries to print out the difference between two pointers with %d.

@ghost

ghost commented Nov 16, 2012

Copy link
Copy Markdown
Author

rdb_protocol/js.cc:251: error: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘int’
rdb_protocol/js.cc:251: error: format ‘%ld’ expects type ‘long int’, but argument 5 has type ‘ssize_t’
rdb_protocol/js.cc:251: error: format ‘%lu’ expects type ‘long unsigned int’, but argument 6 has type ‘int’

That compiler thinks those are int types.

@srh

srh commented Nov 16, 2012

Copy link
Copy Markdown
Contributor

None of these compilation errors happen for me on the latest 64-bit debian stable. Are you running testing or unstable?

Both size and endsz are declared as ssize_t in that function, so it doesn't make sense that the compiler would call one of them a ssize_t and the other an int. It's almost plausible if sizeof(int) == sizeof(ssize_t) -- either sizeof(int) == 8 for some reason or your compiler is targeting a 32-bit architecture.

@srh

srh commented Nov 16, 2012

Copy link
Copy Markdown
Contributor

@gdonald: It's currently not in next (it has to go through an internal code review process) but you might want to checkout e6085b3 or branch sam_55.

It makes some more portable fixes to the format string issues you faced, so that things still compile on the other platforms. It would be good to know if you can build with that.

@srh

srh commented Nov 16, 2012

Copy link
Copy Markdown
Contributor

The branch sam_55 has been merged into next. Also, code has been added to directly cause the build to fail immediately and with an error message if pointers are not 64 bits.

@srh srh closed this Nov 16, 2012
nviennot pushed a commit to NoBrainerORM/nobrainer that referenced this pull request Jan 10, 2014
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.

3 participants