[OPEN-ILS-DEV] non-portable code: strndup() in osrf-chat.c

Jeroen Ruigrok van der Werven asmodai at in-nomine.org
Mon Apr 30 15:37:51 EDT 2007


Hi gang,

I found the following non-portable code in OpenSRF/src/jserver/osrf_chat.c:

749	node->username = strndup((char*) ch, len)
755	node->resource = strndup((char*) ch, len);
773	char* key = strndup((char*) ch, len);

Only Linux and AIX seem to have this interface. As the Linux manual page says:

strdup() conforms to SVr4, 4.3BSD, POSIX.1-2001. strndup(), strdupa(), and
strndupa() are GNU extensions.

So I would advise against using this interface quite simply for the fact it
breaks builds on all other Unix systems.
Even if we autotool the entire tree it will not solve this non-portability
issue since you will simply have a config.h that says this function is not
supported on this platform, meaning you have to provide your own
implementation anyway.

-- 
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
Keep your face to the sun and you will never see the shadows...


More information about the Open-ils-dev mailing list