Fwd: [PATCH] Assorted cleanups for memcached for g++ and icc

7 views
Skip to first unread message

Steve Peters

unread,
Jul 6, 2008, 9:04:10 AM7/6/08
to memc...@googlegroups.com
The attached patch cleans up various coding issues with memcached.
None of these show up with the typical gcc build, but will if you turn
up warnings a bit, try compiling with an older compiler (for example
gcc 2.95) or one that likes stricter compliance to C++ style
standards. At a minumum, this patch gets memcached to compile and
pass all tests with g++ and icc. Based on the compile errors I've
seen with Perl, VC++ is probably much better off as well.

Some of the example fixes include:
* casting malloc, realloc(), calloc(), etc. calls to avoid errors
with C++ compilers and warnings with gcc with -Wc++-compat on.
* a few other assorted casting fixes
* removal of some unused variables
* replacing function prototypes with empty parameter lists with
(void). icc complains loudly about this.
* fixing a few declaration after statement errors. Compilers in C90
mode will error out on this.
* math with void pointer fixes. C++ compilers error on this usually.
* const'ing return types for two functions that always return constant char *'s
* assorted other fixes and cleanups

Please let me know if you have any questions or comments.

Thanks!

Steve Peters
st...@fisharerojo.org

memcached.diff

Steve Peters

unread,
Jul 14, 2008, 4:28:58 PM7/14/08
to memc...@googlegroups.com
This appears to have been warnocked. Any comments from those with
commit access?

Steve Peters

This appears to have been warnocked. Any comments from those with
commit access?

Steve Peters

Trond Norbye

unread,
Jul 14, 2008, 5:42:21 PM7/14/08
to memc...@googlegroups.com

On Jul 14, 2008, at 10:28 PM, Steve Peters wrote:

>> Some of the example fixes include:
>> * casting malloc, realloc(), calloc(), etc. calls to avoid errors
>> with C++ compilers and warnings with gcc with -Wc++-compat on.

Why do we want this? This is a C-project and assigning to/form a void
pointer is perfectly legal without a cast and this unneeded cast just
clutters the code.

Trond

Oleg Grenrus

unread,
Jul 16, 2008, 1:29:13 AM7/16/08
to memc...@googlegroups.com
icc is actually c++ compiler but compiles c-code much better then gcc?

--
Oleg Grenrus

Trond Norbye

unread,
Jul 16, 2008, 3:06:05 AM7/16/08
to memc...@googlegroups.com

On Jul 16, 2008, at 7:29 AM, Oleg Grenrus wrote:

>
> icc is actually c++ compiler but compiles c-code much better then gcc?

If it fails to accept assignment to/from a void pointer it does not
compile c-code better than gcc, because that is a perfectly legal
construct in C. (According to http://www.intel.com/cd/software/products/asmo-na/eng/284736.htm
(page 3) it claims to support C99, so _if_ icc really fails to
compile such constructs I guess that you should file a bug report on
the compiler.

Trond

Steve Peters

unread,
Jul 17, 2008, 4:46:30 PM7/17/08
to memc...@googlegroups.com
Some of the issues were discovered by other C compilers including C89
and C99 based compilers. I'll double check the issues at create a new
patch that deals exclusively with C related issues.

Steve

dormando

unread,
Jul 27, 2008, 8:06:30 PM7/27/08
to memc...@googlegroups.com
(forget if I responded to this yet?)

I agree with trond actually... we had a patch a long time ago which did
the opposite of this. I've also been significantly LART'ed for doing that
with my malloc calls under other projects. Don't think that's the best
direction for us.

-Dormando

dormando

unread,
Jul 27, 2008, 8:09:19 PM7/27/08
to memc...@googlegroups.com
This also brings in a larger discussion, I guess... or a short one for a
broader scope...

I really want to kill support for gcc 2.95 and below. Dealing with it
fuglifies the code a bit too much and it'd be really nice to be able to
stick with C99 standards.

There was one last holdout for gcc 2.95, and that was a freebsd 4.x user
who couldn't build under a newer gcc. Are you folks still out there and do
you still care? It's time to upgrade :\

-Dormando

Mike Panchenko

unread,
Jul 27, 2008, 8:23:35 PM7/27/08
to memc...@googlegroups.com
I don't know what version of gcc we're on, but I know Yahoo! still has tons of FreeBSD 4 machines. Would you guys like me to forward this to the appropriate person/group to verify if that would affect us?

Cheers.

Mike.

dormando

unread,
Jul 27, 2008, 8:39:11 PM7/27/08
to memc...@googlegroups.com
That would actually be helpful, thanks!

Brian Aker

unread,
Jul 27, 2008, 8:42:06 PM7/27/08
to memc...@googlegroups.com
Hi!

On Jul 27, 2008, at 5:23 PM, Mike Panchenko wrote:

> I don't know what version of gcc we're on, but I know Yahoo! still
> has tons of FreeBSD 4 machines. Would you guys like me to forward
> this to the appropriate person/group to verify if that would affect
> us?


I am worried about Yahoo when it comes to most of this conversation. I
do not have the impression that they use a very modern version of GCC,
and that is going to be an issue I suspect.

Cheers,
-Brian

--
_______________________________________________________
Brian "Krow" Aker, brian at tangent.org
Seattle, Washington
http://krow.net/ <-- Me
http://tangent.org/ <-- Software
_______________________________________________________
You can't grep a dead tree.

Mike Panchenko

unread,
Jul 27, 2008, 8:46:09 PM7/27/08
to memc...@googlegroups.com
That is why this discussion caught my eye :) I'll find out who maintains memcached for us and get them on here if they aren't already.

Mike.

Chris Goffinet

unread,
Jul 27, 2008, 9:45:26 PM7/27/08
to memc...@googlegroups.com
Brian

Yes we use BSD4 heavily at Yahoo. Though we have been pushing hard for
over a year now to get everyone on RHEL (gcc 3.4).The gcc we use on
BSD is 2.95

--
Chris Goffinet
MyBlogLog Senior Performance Engineer

Yahoo!
San Francisco, CA
United States

Chris Goffinet

unread,
Jul 27, 2008, 9:46:23 PM7/27/08
to memc...@googlegroups.com
Mike,

I maintain memcached at Yahoo ;-)


-- 
Chris Goffinet
MyBlogLog Senior Performance Engineer

Yahoo!
San Francisco, CA
United States

Chris Goffinet

unread,
Jul 27, 2008, 9:49:30 PM7/27/08
to memc...@googlegroups.com
Dormando:

I think its very safe to say its 'okay' to stop supporting GCC 2.95
(BSD4). At Yahoo we have phased out BSD4 (2.95) and are using BSD6
which has a gcc 3.4 compiler. We're good.

--
Chris Goffinet
MyBlogLog Senior Performance Engineer

Yahoo!
San Francisco, CA
United States

dormando

unread,
Jul 27, 2008, 11:37:42 PM7/27/08
to memc...@googlegroups.com
Huzzah, thanks!
Reply all
Reply to author
Forward
0 new messages