All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Peter Hüwe" <PeterHuewe@gmx.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: memcpy
Date: Wed, 26 Aug 2009 22:42:00 +0000	[thread overview]
Message-ID: <200908270042.00597.PeterHuewe@gmx.de> (raw)
In-Reply-To: <4A95B4B4.3020408@uiuc.edu>

Am Donnerstag 27 August 2009 00:18:28 schrieb Stoyan Gaydarov:
> I wanted to know what memcpy returned as a result, and if it
> needs/should be checked. There are several places in the kernel where i
> noticed it being used but i also saw a warning about the result not
> being used, so i wanted to know a little more about it.
>
> -Stoyan
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



Hi,

*memcpy is defined in .../lib/string.c  (+ some macros etc - use cscope to 
find more references) as

/**
 * memcpy - Copy one area of memory to another
 * @dest: Where to copy to
 * @src: Where to copy from
 * @count: The size of the area.
 *
 * You should not use this function to access IO space, use memcpy_toio()
 * or memcpy_fromio() instead.
 */
void *memcpy(void *dest, const void *src, size_t count)
{
    char *tmp = dest;
    const char *s = src;

    while (count--)
        *tmp++ = *s++;
    return dest;
}

You can see it just returns the destination address that you have passed to it
-> so I guess unless it is possible that you have already passed it a null 
pointer (which might horribly fail) it is not really necessary to check the 
result.


Peter


  reply	other threads:[~2009-08-26 22:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-26 22:18 memcpy Stoyan Gaydarov
2009-08-26 22:42 ` Peter Hüwe [this message]
2009-08-27 12:02 ` memcpy Bernd Petrovitsch
  -- strict thread matches above, loose matches on Subject: below --
2002-09-12  8:32 memcpy Carsten Langgaard
2002-09-19 13:31 ` memcpy Ralf Baechle
2001-03-12 15:14 memcpy Rama Krishna Mandava
2001-03-12 14:40 ` memcpy Francois Romieu

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=200908270042.00597.PeterHuewe@gmx.de \
    --to=peterhuewe@gmx.de \
    --cc=kernel-janitors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.