Re: The patch of glibc which allows the user to override the pfinet server

2008-08-26 Thread Da Zheng
[EMAIL PROTECTED] wrote: if (domain <= max_domain) - servers[domain] = server; + servers[domain] = server; I'm not sure about this, but I think it is usually better to avoid changing the indentation of code you haven't otherwise touched -- even if it was wrong before..

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-26 Thread Samuel Thibault
[EMAIL PROTECTED], le Mon 25 Aug 2008 21:59:02 +0200, a écrit : > On Fri, Aug 22, 2008 at 11:46:52AM +0200, Da Zheng wrote: > > [EMAIL PROTECTED] wrote: > >> On Tue, Aug 19, 2008 at 03:27:06PM +0200, zhengda wrote: > > >>> - socket_t server; > >>> + socket_t server = MACH_PORT_NULL; > >> > >> As

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-25 Thread olafBuddenhagen
hi, On Fri, Aug 22, 2008 at 11:46:52AM +0200, Da Zheng wrote: > [EMAIL PROTECTED] wrote: >> On Tue, Aug 19, 2008 at 03:27:06PM +0200, zhengda wrote: >>> - socket_t server; >>> + socket_t server = MACH_PORT_NULL; >> >> As I already said, this is unnecessary -- it will be assigned >> unconditiona

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-22 Thread Da Zheng
[EMAIL PROTECTED] wrote: Hi, On Tue, Aug 19, 2008 at 03:27:06PM +0200, zhengda wrote: - socket_t server; + socket_t server = MACH_PORT_NULL; As I already said, this is unnecessary -- it will be assigned unconditionally. It's necessary here. If __asprintf() returns -1, the funct

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-21 Thread olafBuddenhagen
Hi, On Tue, Aug 19, 2008 at 03:27:06PM +0200, zhengda wrote: > - socket_t server; > + socket_t server = MACH_PORT_NULL; As I already said, this is unnecessary -- it will be assigned unconditionally. > + if (__asprintf (&name, "%s/%d", sock_servs, domain) < 0) > + goto out; In

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-19 Thread zhengda
Samuel Thibault wrote: zhengda, le Sun 17 Aug 2008 13:40:59 +0200, a écrit : I wonder how I return ENOMEM? Does asprintf() write the errno itself? Yes. Should the function returns immediately after __asprintf() returns error? It has to clean its mess first of course. He

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-18 Thread olafBuddenhagen
Hi, On Sun, Aug 17, 2008 at 01:57:18PM +0200, zhengda wrote: > [EMAIL PROTECTED] wrote: >> It really depends on the context. In some cases -- if the pointer is >> dereferenced -- NULL will create an obvious failure, while some >> random uninitialized pointer might be harder to track down. >> >> I

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-17 Thread Samuel Thibault
zhengda, le Sun 17 Aug 2008 13:40:59 +0200, a écrit : > I wonder how I return ENOMEM? Does asprintf() write the errno itself? Yes. > Should the function returns immediately after __asprintf() returns error? It has to clean its mess first of course. Samuel

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-17 Thread Samuel Thibault
zhengda, le Sun 17 Aug 2008 13:57:18 +0200, a écrit : > My first C language teacher told me to initialize all local variables, > especially the pointers, That's probably some rule of the thumb for beginners, but we're not supposed to be beginners (hey, that's the C library! ;) ) Samuel

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-17 Thread zhengda
[EMAIL PROTECTED] wrote: It really depends on the context. In some cases -- if the pointer is dereferenced -- NULL will create an obvious failure, while some random uninitialized pointer might be harder to track down. In other cases -- if it's used as argument to realloc(), free() etc.; or if i

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-17 Thread zhengda
Samuel Thibault wrote: zhengda, le Fri 15 Aug 2008 20:05:53 +0200, a écrit : Samuel Thibault wrote: zhengda, le Fri 15 Aug 2008 19:05:49 +0200, a écrit : Samuel Thibault wrote: zhengda, le Fri 15 Aug 2008 18:27:00 +0200, a écrit : + if (__

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-16 Thread olafBuddenhagen
Hi, On Fri, Aug 15, 2008 at 06:27:00PM +0200, zhengda wrote: > [EMAIL PROTECTED] wrote: >>> But isn't it always right to initialize a local variable to reduce >>> the possibility of getting bugs? >> >> It won't avoid bugs; only either cover them up, or (less likely) >> expose them more clearly -

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-15 Thread Samuel Thibault
zhengda, le Fri 15 Aug 2008 20:05:53 +0200, a écrit : > Samuel Thibault wrote: > >zhengda, le Fri 15 Aug 2008 19:05:49 +0200, a écrit : > > > >>Samuel Thibault wrote: > >> > >>>zhengda, le Fri 15 Aug 2008 18:27:00 +0200, a écrit : > >>> > >>> > + if (__asprintf (&name, "SOCK_S

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-15 Thread zhengda
Samuel Thibault wrote: zhengda, le Fri 15 Aug 2008 19:05:49 +0200, a écrit : Samuel Thibault wrote: zhengda, le Fri 15 Aug 2008 18:27:00 +0200, a écrit : + if (__asprintf (&name, "SOCK_SERV_%d", domain) < 0) +__libc_fatal ("hurd: Can't get the socket server path\n");

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-15 Thread Samuel Thibault
zhengda, le Fri 15 Aug 2008 19:05:49 +0200, a écrit : > Samuel Thibault wrote: > >zhengda, le Fri 15 Aug 2008 18:27:00 +0200, a écrit : > > > >>+ if (__asprintf (&name, "SOCK_SERV_%d", domain) < 0) > >>+__libc_fatal ("hurd: Can't get the socket server path\n"); > >> > > > >Shouldn't

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-15 Thread zhengda
Samuel Thibault wrote: zhengda, le Fri 15 Aug 2008 18:27:00 +0200, a écrit : + if (__asprintf (&name, "SOCK_SERV_%d", domain) < 0) +__libc_fatal ("hurd: Can't get the socket server path\n"); Shouldn't we just return ENOMEM? In many parts of glibc, __libc_fatal() or assert(

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-15 Thread Samuel Thibault
zhengda, le Fri 15 Aug 2008 18:27:00 +0200, a écrit : > + if (__asprintf (&name, "SOCK_SERV_%d", domain) < 0) > +__libc_fatal ("hurd: Can't get the socket server path\n"); Shouldn't we just return ENOMEM? Samuel

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-15 Thread zhengda
[EMAIL PROTECTED] wrote: + char *name = NULL; No need to initialize this -- the asprintf() will overwrite it anyways. But isn't it always right to initialize a local variable to reduce the possibility of getting bugs? It won't avoid bugs; only either cover t

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-14 Thread olafBuddenhagen
Hi, On Wed, Aug 13, 2008 at 01:49:41PM +0200, zhengda wrote: > Neal H. Walfield wrote: >> Check if the result is != -1, not > 0, which has a different meaning. >> > + if (__asprintf (&name, "%s/%d", sock_servs, domain) > 0) > + np = name; >> > but it's still wrong

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-14 Thread olafBuddenhagen
Hi, On Wed, Aug 13, 2008 at 12:41:12PM +0200, zhengda wrote: > [EMAIL PROTECTED] wrote: >> On Tue, Aug 12, 2008 at 08:05:49PM +0200, zhengda wrote: >>> + char *name = NULL; >>> >> >> No need to initialize this -- the asprintf() will overwrite it anyways. >> > But isn't it always righ

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-13 Thread Samuel Thibault
zhengda, le Wed 13 Aug 2008 13:49:41 +0200, a écrit : > but it's still wrong that __asprintf returns 0 in my code, isn't it? That shall not happen. In such a case anyway, you'd still have to free it. Samuel

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-13 Thread zhengda
Neal H. Walfield wrote: At Wed, 13 Aug 2008 12:41:12 +0200, zhengda wrote: + if (__asprintf (&name, "SOCK_SERV_%d", domain) > 0) +{ + np = getenv (name); + __free (name); +} You need to check whether asprintf() returns an error code (-1),

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-13 Thread Neal H. Walfield
At Wed, 13 Aug 2008 12:41:12 +0200, zhengda wrote: > >> + if (__asprintf (&name, "SOCK_SERV_%d", domain) > 0) > >> +{ > >> + np = getenv (name); > >> + __free (name); > >> +} > >> > > > > You need to check whether asprintf() returns an error code (-1), me

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-13 Thread zhengda
[EMAIL PROTECTED] wrote: Hi, On Tue, Aug 12, 2008 at 08:05:49PM +0200, zhengda wrote: + char *name = NULL; No need to initialize this -- the asprintf() will overwrite it anyways. But isn't it always right to initialize a local variable to reduce the possibility of getting bu

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-13 Thread olafBuddenhagen
Hi, On Tue, Aug 12, 2008 at 08:05:49PM +0200, zhengda wrote: > + char *name = NULL; No need to initialize this -- the asprintf() will overwrite it anyways. > + if (__asprintf (&name, "SOCK_SERV_%d", domain) > 0) > +{ > + np = getenv (name); > + __free (name);

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-12 Thread zhengda
The new patch of glibc to override the default socket server: Needed for glibc-2_7-branch 2008-06-30 Zheng Da <[EMAIL PROTECTED]> * hurd/hurdsocks.c (_hurd_socket_server): Searches environment variables for the socket server insteading of using the default one. (SOCK_SERV_%d, SOCK_SER

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-12 Thread zhengda
Samuel Thibault wrote: zhengda, le Sun 10 Aug 2008 19:42:18 +0200, a écrit : Samuel Thibault wrote: if (domain > max_domain || servers[domain] == MACH_PORT_NULL) { char *name = NULL; char *np = NULL; if (__asprintf (&name, "SOCK_SERV_%d", domain) > 0) { np = geten

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-12 Thread Samuel Thibault
zhengda, le Sun 10 Aug 2008 19:42:18 +0200, a écrit : > Samuel Thibault wrote: > if (domain > max_domain || servers[domain] == MACH_PORT_NULL) > { > char *name = NULL; > char *np = NULL; > > if (__asprintf (&name, "SOCK_SERV_%d", domain) > 0) > { > np = getenv (name); >

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-10 Thread zhengda
Samuel Thibault wrote: zhengda, le Sun 10 Aug 2008 20:07:57 +0200, a écrit : Samuel Thibault wrote: zhengda, le Sun 10 Aug 2008 19:42:18 +0200, a écrit : But I don't understand why. Obviously, 'name' isn't double-freed. Mmm, maybe you have a glibc that is partly

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-10 Thread Samuel Thibault
zhengda, le Sun 10 Aug 2008 20:07:57 +0200, a écrit : > Samuel Thibault wrote: > >zhengda, le Sun 10 Aug 2008 19:42:18 +0200, a écrit : > > > >>But I don't understand why. Obviously, 'name' isn't double-freed. > >> > > > >Mmm, maybe you have a glibc that is partly compiled with debugging on >

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-10 Thread zhengda
Samuel Thibault wrote: zhengda, le Sun 10 Aug 2008 19:42:18 +0200, a écrit : But I don't understand why. Obviously, 'name' isn't double-freed. Mmm, maybe you have a glibc that is partly compiled with debugging on and partly compiled with debugging off? How can that happen? If so, w

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-10 Thread Samuel Thibault
zhengda, le Sun 10 Aug 2008 19:42:18 +0200, a écrit : > But I don't understand why. Obviously, 'name' isn't double-freed. Mmm, maybe you have a glibc that is partly compiled with debugging on and partly compiled with debugging off? Samuel

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-10 Thread zhengda
Samuel Thibault wrote: Gah. Then set from inside gdb: gdb --args /root/storage/glibc-2.7/build-tree/hurd-i386-libc/sunrpc/rpcgen -Y ../scripts -c rpcsvc/bootparam_prot.x -o /root/storage/glibc-2.7/build-tree/hurd-i386-libc/sunrpc/xbootparam_prot.T (gdb) set environment LD_LIBRARY_PATH=/root

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-10 Thread Samuel Thibault
zhengda, le Sun 10 Aug 2008 18:55:48 +0200, a écrit : > >LD_LIBRARY_PATH=/root/storage/glibc-2.7/build-tree/hurd-i386-libc gdb > >--args /root/storage/glibc-2.7/build-tree/hurd-i386-libc/sunrpc/rpcgen -Y > >../scripts -c rpcsvc/bootparam_prot.x -o > >/root/storage/glibc-2.7/build-tree/hurd-i386-

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-10 Thread zhengda
Samuel Thibault wrote: zhengda, le Sat 09 Aug 2008 13:59:19 +0200, a écrit : if (name) free (name); No need for an if here, free(NULL); is void already. OK When I build the glibc, I got the error as follow: CPP='gcc-4.2 -E -x c-header' /root/storage/glibc-2.7/build-

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-09 Thread Samuel Thibault
zhengda, le Sat 09 Aug 2008 13:59:19 +0200, a écrit : > if (name) >free (name); No need for an if here, free(NULL); is void already. > When I build the glibc, I got the error as follow: > > CPP='gcc-4.2 -E -x c-header' > /root/storage/glibc-2.7/build-tree/hurd-i386-libc/elf/ld.so.

Re: The patch of glibc which allows the user to override the pfinet server

2008-08-09 Thread zhengda
Samuel Thibault wrote: Hello, + char sock_serv_env_name[30]; To avoid a fixed-sized buffer you could use __asprintf. + name = (char *)malloc (len + 100); Use __asprintf here too. - servers[domain] = server; +servers[domain] = server;

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-10 Thread Samuel Thibault
Hello, > + char sock_serv_env_name[30]; To avoid a fixed-sized buffer you could use __asprintf. > + name = (char *)malloc (len + 100); Use __asprintf here too. > - servers[domain] = server; > +servers[domain] = server; Spurious hook, please try to minimize these. A

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-10 Thread olafBuddenhagen
Hi, On Wed, Jul 09, 2008 at 02:02:18PM +0200, zhengda wrote: > I also write a SHELL script "runwithpfinet" to set the environment > variables and run the command provided by the user. [...] > It works in most of cases. but it doesn't work with "ping" when the > user execute "runwithpfinet 1 ping

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-10 Thread olafBuddenhagen
Hi, On Tue, Jul 08, 2008 at 01:15:11AM +0200, zhengda wrote: > The patch is > http://www.assembla.com/spaces/VNetHurd/documents/aJidqKp6ur3z-Nab7jnrAJ/download/A%20patch%20of%20glibc Well, sending patches inline is generally a better idea... At least the whitespace in the diff is not mangled th

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-09 Thread zhengda
zhengda wrote: Neal H. Walfield wrote: If more network protocols are implemented, we have to provide more environment variables for the servers. Or you use an environment variable that is based on a stem and the protocol number. So instead of SOCK_INET_SERV_PATH, SOCK_SERV_%d_PATH. Perh

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-07 Thread zhengda
[EMAIL PROTECTED] wrote: Hi, On Wed, Jul 02, 2008 at 08:42:43PM +0200, zhengda wrote: The new version of the patch is below. Hm, what about dropping/replacing the "_PATH" bit, as discussed in the other subthread?... OK. I wonder if I can use __snprintf(). The code in the orig

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-04 Thread olafBuddenhagen
Hi, On Wed, Jul 02, 2008 at 08:42:43PM +0200, zhengda wrote: > The new version of the patch is below. Hm, what about dropping/replacing the "_PATH" bit, as discussed in the other subthread?... > I wonder if I can use __snprintf(). The code in the original glibc > doesn't use it. I'm not a glib

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-03 Thread olafBuddenhagen
Hi, On Mon, Jun 30, 2008 at 02:39:23PM +0200, zhengda wrote: > Kalle Olavi Niemitalo wrote: >> http://www.gnu.org/prep/standards/standards.html#GNU-Manuals >> >> # Please do not use the term ???pathname??? that is used in Unix # >> documentation; use ???file name??? (two words) instead. We use th

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-03 Thread olafBuddenhagen
Hi, On Mon, Jun 30, 2008 at 03:14:47PM +0200, zhengda wrote: > [EMAIL PROTECTED] wrote: >>> Do you mean the indentation here? It is caused by '-' and '+' in the >>> beginning of lines. >>> >> >> Ah, I see it now. That shouldn't happen, though. How did you generate >> the patch? >> > for

Re: The patch of glibc which allows the user to override the pfinet server

2008-07-02 Thread zhengda
Neal H. Walfield wrote: If more network protocols are implemented, we have to provide more environment variables for the servers. Or you use an environment variable that is based on a stem and the protocol number. So instead of SOCK_INET_SERV_PATH, SOCK_SERV_%d_PATH. Perhaps it is best t

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-30 Thread zhengda
[EMAIL PROTECTED] wrote: Do you mean the indentation here? It is caused by '-' and '+' in the beginning of lines. Ah, I see it now. That shouldn't happen, though. How did you generate the patch? for this case, I use diff -u glibc-2.7-old/hurd/hurdsock.c glibc-2.7/hurd/hurdsock.c Zhen

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-30 Thread zhengda
Kalle Olavi Niemitalo wrote: zhengda <[EMAIL PROTECTED]> writes: Anyway, I provide two more environment variables SOCK_INET_SERV_PATH and SOCK_LOCAL_SERV_PATH for the pfinet server and pflocal server, respectively. I try to make my code meet the GNU coding standard. http://www.gnu.org

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-28 Thread Kalle Olavi Niemitalo
zhengda <[EMAIL PROTECTED]> writes: > Anyway, I provide two more environment variables SOCK_INET_SERV_PATH > and SOCK_LOCAL_SERV_PATH for the pfinet server and pflocal server, > respectively. > I try to make my code meet the GNU coding standard. http://www.gnu.org/prep/standards/standards.html#GN

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-27 Thread olafBuddenhagen
Hi, On Thu, Jun 26, 2008 at 07:31:12PM +0200, zhengda wrote: > [EMAIL PROTECTED] wrote: >> If we want to override the TCP/IP stack, that doesn't mean we want to >> override the pipe server as well, or the other way round... >> > I think using the symbolic link to the default server is another

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-26 Thread Samuel Thibault
zhengda, le Thu 26 Jun 2008 19:31:12 +0200, a écrit : > >Hm... Something seems wrong with the indentation here -- but it looks as > >if it has been already wrong in the original code... Can you fix that > >please? > > > >Oh, and of course you still need a changelog entry. There is a section > >in t

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-26 Thread zhengda
[EMAIL PROTECTED] wrote: Hi, On Wed, Jun 25, 2008 at 04:44:51PM +0200, zhengda wrote: Neal H. Walfield wrote: Yes of course. If we want to override the TCP/IP stack, that doesn't mean we want to override the pipe server as well, or the other way round... I think using the symbolic link t

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-25 Thread olafBuddenhagen
Hi, On Wed, Jun 25, 2008 at 04:44:51PM +0200, zhengda wrote: > Neal H. Walfield wrote: >> This works in the case where you want to override all pf servers. >> This case is important. Also important is the ability to override a >> single pf server in a similar manner. > I wonder if it's really n

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-25 Thread Neal H. Walfield
At Wed, 25 Jun 2008 16:44:51 +0200, zhengda wrote: > I wonder if it's really necessary to override a single pf server. When porting pppd, I did this regularly; I used an alternative pfinet server but continued to use the default pipe server. I don't see why you think it would be normal to want to

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-25 Thread zhengda
Neal H. Walfield wrote: This works in the case where you want to override all pf servers. This case is important. Also important is the ability to override a single pf server in a similar manner. A couple comments on the code: please follow the GNU coding standards. Second, I assume that you le

Re: The patch of glibc which allows the user to override the pfinet server

2008-06-24 Thread Neal H. Walfield
This works in the case where you want to override all pf servers. This case is important. Also important is the ability to override a single pf server in a similar manner. A couple comments on the code: please follow the GNU coding standards. Second, I assume that you left the #if 0 in because yo

The patch of glibc which allows the user to override the pfinet server

2008-06-24 Thread zhengda
Hi, I modified the code of glibc, so the user can override the default pfinet server by using the environment variable. Here is the patch: --- glibc-2.7-old/hurd/hurdsock.c2008-06-21 01:38:30.04000 +0200 +++ glibc-2.7/hurd/hurdsock.c2008-06-21 01:45:28.34000 +0200 @@ -76,6 +76,3