From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: drow@false.org
Cc: eliz@gnu.org, sjackman@gmail.com, rearnsha@gcc.gnu.org,
gdb-patches@sources.redhat.com
Subject: Re: sim/arm/armos.c: IsTTY [PATCH]
Date: Sun, 18 Sep 2005 09:04:00 -0000 [thread overview]
Message-ID: <200509180903.j8I93fTo025933@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <20050918034432.GA6990@nevyn.them.org> (message from Daniel Jacobowitz on Sat, 17 Sep 2005 23:44:32 -0400)
> Date: Sat, 17 Sep 2005 23:44:32 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Sun, Sep 18, 2005 at 06:32:25AM +0300, Eli Zaretskii wrote:
> > > Date: Sat, 17 Sep 2005 18:37:28 -0400
> > > From: Daniel Jacobowitz <drow@false.org>
> > > Cc: Richard Earnshaw <rearnsha@gcc.gnu.org>, gdb-patches@sources.redhat.com
> > >
> > > Usage Note: Don't use FILENAME_MAX as the size of an array in which
> > > to store a file name! You can't possibly make an array that big! Use
> > > dynamic allocation (see section 3.2 Allocating Storage For Program
> > > Data) instead.
> >
> > That's a very strange advice, especially since there's gobs of code
> > out there that define arrays like that to store file names. What's
> > the value of FILENAME_MAX on those systems where a file name can have
> > unlimited length? Is it really larger than a typical stack
> > limitation?
>
> It's looks like it has since been toned down as a matter of
> practicality, but yes: I believe that at one point it was INT_MAX.
> I.E. Much Too Big.
>
> Ah, yes, Hurd throttles it to 1K in response to a limitation in their
> RPC mechanism. But the developers were making noise about unthrottling
> it again someday.
FWIW, the correct way to deal with these issues is to dynamically
allocate the buffer, making the buffer bigger if it fails because the
buffer is too small:
#ifndef _POSIX_PATH_MAX
#define _POSIX_PATH_MAX 256
#endif
size_t len = _POSIX_PATH_MAX;
char *buf = xmalloc(len);
while (foo(..., buf, len) == -1 && errno == ENAMETOOLONG)
{
len *= 2;
buf = xrealloc(buf, len);
}
I used _POSIX_PATH_MAX here, but you could probably just as well
hardcode a sensible value. Don't forget to free the buffer once
you're done with it ;-).
Mark
next prev parent reply other threads:[~2005-09-18 9:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-15 21:19 Shaun Jackman
2005-08-22 18:51 ` Shaun Jackman
2005-08-30 2:38 ` Daniel Jacobowitz
2005-09-06 16:22 ` Richard Earnshaw
2005-09-07 16:51 ` Shaun Jackman
2005-09-08 9:07 ` Richard Earnshaw
2005-09-08 19:28 ` Eli Zaretskii
2005-09-09 17:16 ` Shaun Jackman
2005-09-09 17:23 ` Shaun Jackman
2005-09-17 22:37 ` Daniel Jacobowitz
2005-09-17 23:32 ` Shaun Jackman
2005-09-18 1:14 ` Daniel Jacobowitz
2005-09-18 2:40 ` Shaun Jackman
2005-09-18 2:59 ` Daniel Jacobowitz
[not found] ` <20050918025653.GA4285@nevyn.them.org>
[not found] ` <7f45d93905091720161f61e995@mail.gmail.com>
[not found] ` <20050918033152.GA6546@nevyn.them.org>
2005-10-13 20:30 ` Shaun Jackman
2005-10-19 16:12 ` Shaun Jackman
2005-11-17 10:49 ` Daniel Jacobowitz
2005-11-17 15:54 ` Shaun Jackman
2005-09-18 3:32 ` Eli Zaretskii
2005-09-18 3:44 ` Daniel Jacobowitz
2005-09-18 9:04 ` Mark Kettenis [this message]
2005-09-18 19:13 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200509180903.j8I93fTo025933@elgar.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=drow@false.org \
--cc=eliz@gnu.org \
--cc=gdb-patches@sources.redhat.com \
--cc=rearnsha@gcc.gnu.org \
--cc=sjackman@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox