Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1288606

Re: [PATCH 1/4] list: introduce list_is_first()

From Christoph Hellwig <hch@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH 1/4] list: introduce list_is_first()
Date 2015-12-10 16:40 +0100
Message-ID <qEbu2-83j-29@gated-at.bofh.it> (permalink)
References <qEaeC-7jl-25@gated-at.bofh.it> <qEbaF-7V7-7@gated-at.bofh.it> <qEbkm-7Z2-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Dec 10, 2015 at 09:23:57AM -0600, Josh Poimboeuf wrote:
> Personally I would disagree.  Something like:
> 
>   if (list_is_first(&rq->queuelist, &nd->queue))
> 
> is much more readable to me than:
> 
>   if (rq->queuelist.prev == &nd->queue)
> 
> The first one takes no effort for me -- it's almost English.  While the
> second one takes me a few seconds (and some precious brain cycles) to
> decipher.
> 
> Maybe whether it's readable depends on how many years you've been
> looking at the pattern.  But IMHO we shouldn't make "having x # of years
> staring at kernel code" a prerequisite for being able to read kernel
> code.

I think understanding the list.h semantics is a requirement for writing
(or reading) non-trivial kernel code.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/4] list: introduce list_is_first() Geliang Tang <geliangtang@163.com> - 2015-12-10 15:30 +0100
  Re: [PATCH 1/4] list: introduce list_is_first() Jens Axboe <axboe@kernel.dk> - 2015-12-10 16:20 +0100
    Re: [PATCH 1/4] list: introduce list_is_first() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-12-10 16:30 +0100
      Re: [PATCH 1/4] list: introduce list_is_first() Christoph Hellwig <hch@infradead.org> - 2015-12-10 16:40 +0100
      Re: [PATCH 1/4] list: introduce list_is_first() Jens Axboe <axboe@kernel.dk> - 2015-12-10 16:40 +0100
        Re: [PATCH 1/4] list: introduce list_is_first() Jiri Kosina <jikos@kernel.org> - 2015-12-10 17:50 +0100

csiph-web