From: Karel Zak <kzak@redhat.com>
To: util-linux@vger.kernel.org
Cc: Philipp Thomas <pth@suse.de>, Werner Fin <werner@suse.de>
Subject: Re: [util-linux] [PATCH 00/13] Initial import of sulogin
Date: Fri, 9 Nov 2012 09:45:40 +0100 [thread overview]
Message-ID: <20121109084540.GB26857@x2.net.home> (raw)
In-Reply-To: <20121109083845.GA26857@x2.net.home>
On Fri, Nov 09, 2012 at 09:38:45AM +0100, Karel Zak wrote:
> On Fri, Oct 12, 2012 at 04:07:57PM +0200, Dr. Werner Fink wrote:
> > +static
> > +#ifdef __GNUC__
> > +__attribute__((__nonnull__,__hot__))
> > +#endif
> > +void consalloc(char * name)
> > +{
> > + struct console *restrict tail;
> > +
> > + if (posix_memalign((void*)&tail, sizeof(void*), alignof(typeof(struct console))) != 0)
> > + perror("memory allocation");
>
> why not malloc() ?
>
> > +
> > + tail->next = (struct console*)0;
> > + tail->tty = name;
> > +
> > + tail->file = (FILE*)0;
> > + tail->flags = 0;
> > + tail->fd = -1;
> > + tail->id = concount++;
> > + tail->pid = 0;
> > + memset(&tail->tio, 0, sizeof(tail->tio));
> > + memcpy(&tail->cp, &initcp, sizeof(struct chardata));
> > +
> > + if (!consoles)
> > + consoles = tail;
> > + else
> > + consoles->next = tail;
> > +}
>
> It does not look like a list. It always update the same pointer
> consoles->next but not "consoles", so the result is list with only
> two items (first and the last item).
>
> If you want to create a list you have to always update two pointers
> (the "->next" and pointer to the first/last item).
Note that the right code is something like:
struct console *last;
[...]
for (last = consoles; last && last->next; last = last->next);
if (!last)
consoles = tail;
else
last->next = tail;
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2012-11-09 8:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-28 16:45 [PATCH 00/13] Initial import of sulogin Dave Reisner
2012-02-28 16:45 ` [PATCH 01/13] fstab.5: fix misspelling of deprecated Dave Reisner
2012-02-28 16:45 ` [PATCH 02/13] sulogin: initial import from sysvinit Dave Reisner
2012-02-28 18:45 ` Davidlohr Bueso
2012-02-28 16:45 ` [PATCH 03/13] sulogin.8: refactor manpage Dave Reisner
2012-02-28 16:45 ` [PATCH 04/13] sulogin: whitespace fixes Dave Reisner
2012-02-28 16:45 ` [PATCH 05/13] sulogin: replace older signal() with sigaction() Dave Reisner
2012-02-28 16:45 ` [PATCH 06/13] sulogin: remove CHECK_{DES,MD5} defines Dave Reisner
2012-02-28 16:45 ` [PATCH 07/13] sulogin: remove USE_ONELINE and SANE_TIO defines Dave Reisner
2012-02-28 16:45 ` [PATCH 08/13] sulogin: use size_t for iterator to avoid cast Dave Reisner
2012-02-28 16:45 ` [PATCH 09/13] sulogin: get rid of calls to /bin/sash Dave Reisner
2012-02-28 16:45 ` [PATCH 10/13] sulogin: use pathnames.h for file locations Dave Reisner
2012-02-28 16:45 ` [PATCH 11/13] sulogin: header/include cleanup Dave Reisner
2012-02-28 16:45 ` [PATCH 12/13] sulogin: use a more standard usage output Dave Reisner
2012-02-28 16:45 ` [PATCH 13/13] sulogin: add i18n strings Dave Reisner
2012-02-28 16:48 ` [PATCH 00/13] Initial import of sulogin Dave Reisner
2012-10-12 12:53 ` [util-linux] " Dr. Werner Fink
2012-10-12 13:23 ` Karel Zak
2012-10-12 14:07 ` Dr. Werner Fink
2012-11-09 8:38 ` Karel Zak
2012-11-09 8:45 ` Karel Zak [this message]
2012-11-09 12:09 ` Karel Zak
2012-11-30 15:57 ` Dr. Werner Fink
2012-12-04 12:12 ` Dr. Werner Fink
2012-03-12 14:20 ` sulogin merged into util-linux (Re: [PATCH 00/13] Initial import of sulogin) Karel Zak
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=20121109084540.GB26857@x2.net.home \
--to=kzak@redhat.com \
--cc=pth@suse.de \
--cc=util-linux@vger.kernel.org \
--cc=werner@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).