public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* memcpy
@ 2009-08-26 22:18 Stoyan Gaydarov
  2009-08-26 22:42 ` memcpy Peter Hüwe
  2009-08-27 12:02 ` memcpy Bernd Petrovitsch
  0 siblings, 2 replies; 3+ messages in thread
From: Stoyan Gaydarov @ 2009-08-26 22:18 UTC (permalink / raw)
  To: kernel-janitors

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: memcpy
  2009-08-26 22:18 memcpy Stoyan Gaydarov
@ 2009-08-26 22:42 ` Peter Hüwe
  2009-08-27 12:02 ` memcpy Bernd Petrovitsch
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Hüwe @ 2009-08-26 22:42 UTC (permalink / raw)
  To: kernel-janitors

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: memcpy
  2009-08-26 22:18 memcpy Stoyan Gaydarov
  2009-08-26 22:42 ` memcpy Peter Hüwe
@ 2009-08-27 12:02 ` Bernd Petrovitsch
  1 sibling, 0 replies; 3+ messages in thread
From: Bernd Petrovitsch @ 2009-08-27 12:02 UTC (permalink / raw)
  To: kernel-janitors

On Mit, 2009-08-26 at 17:18 -0500, Stoyan Gaydarov wrote:
> 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 
It is IMHO agreed concensus that kernel-implementations of well-known
(and especially C-library) userspace functions have to behave the
same/similar.
Or they get another name if only to avoid confusion.

> 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.

Use the source, Luke.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-27 12:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 22:18 memcpy Stoyan Gaydarov
2009-08-26 22:42 ` memcpy Peter Hüwe
2009-08-27 12:02 ` memcpy Bernd Petrovitsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox