On Sat, Nov 25, 2000 at 04:31:31PM -0500, Igor Khavkine wrote:
> >  
> >   sprintf(node_name, "%s/%d", _SERVERS_SOCKET, PF_INET);
> 
> Well, that's another segfault right there, you're trying to write
> to a wild pointer. Try:
> asprintf(&node_name, _SERVERS_SOCKET "%d", PF_INET);
> Actually you don't even have to use asprintf(), just allocate an array
> large enough to hold _SERVERS_SOCKET + largest integer. Too bad
> you can't embed a constant integer into a string at compile time.

Actually, you can at preprocessing time:

#define _GNU_SOURCE
#include <hurd/paths.h>
#include <sys/socket.h>

#define _SERVERS_SOCKET_SOME2(ARG) _SERVERS_SOCKET "/" #ARG
#define _SERVERS_SOCKET_SOME(ARG) _SERVERS_SOCKET_SOME2(ARG)
#define _SERVERS_SOCKET_PFINET _SERVERS_SOCKET_SOME(PF_INET)

main()
{
  printf(_SERVERS_SOCKET_PFINET);
}


(Or, more general, see libdiskfs/priv.h:

#define STRINGIFY(x) STRINGIFY_1(x)
#define STRINGIFY_1(x) #x

)

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org [EMAIL PROTECTED]
Marcus Brinkmann              GNU    http://www.gnu.org    [EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.marcus-brinkmann.de

_______________________________________________
Bug-hurd mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-hurd

Reply via email to