supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Laurent Bercot <ska-supervision@skarnet.org>
To: supervision@list.skarnet.org
Subject: Re: runit: buffer_feed()
Date: Fri, 23 Jan 2009 18:06:00 +0100	[thread overview]
Message-ID: <20090123170600.GA12078@skarnet.org> (raw)
In-Reply-To: <4979DAC5.8090007@dbservice.com>

> byte_copy is a poor reimplementation of memcpy

 Wrong.
 byte_copy works when the source and destination overlap and dst < src.
 byte_copyr works when the source and destination overlap and dst > src.
 memcpy is NOT guaranteed to work when the source and destination overlap.

 If you want an optimized function that works in every case, try memmove.


> Also, it makes the executable smaller and faster, the project as a whole 
> faster to compile, the code easier to read etc.

 Your mileage may vary. I'm used to the byte_copy() interface. :)

 I'm not pretending your remarks are unfounded. The functions in byte.h
and buffer.h are very old DJB code, when he was rewriting the world and
its mother in order to be portable on alien computers pretending to be
half POSIX-compliant.
 I'm not aware of any modern architecture/libc combination where memmove()
doesn't work, so I *think* byte_copy and byte_copyr's naive implementations
can be safely replaced with memmove() (and that's what skalibs does by
default). I could be wrong, though, and be non-portable on a few archs.
 As for buffer.h, I disliked DJB's implementation and rewrote it entirely.
The API, however, is excellent.
 (If I'm not mistaken, buffer_feed() fills the buffer if it's empty (and
doesn't if it's not), and returns the number of bytes in the buffer.)

 What I'm saying is there's risk involved in patching software without
giving it a good deal of thought - especially software including DJB code,
which usually features a number of non-apparent, but important, design
decisions. If you go and wildly replace byte_copy with memcpy, you will
introduce bugs into the code. ;)

-- 
 Laurent


      reply	other threads:[~2009-01-23 17:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-23 13:06 Tomas Carnecky
2009-01-23 14:30 ` Charlie Brady
2009-01-23 14:57   ` Tomas Carnecky
2009-01-23 17:06     ` Laurent Bercot [this message]

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=20090123170600.GA12078@skarnet.org \
    --to=ska-supervision@skarnet.org \
    --cc=supervision@list.skarnet.org \
    /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).