Re: How to use 'get_random_bytes'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Sven,

> >     int i;
> >     int *ip;
> >
> >     ip = &i;
> >     get_random_bytes(&i, sizeof i);
> >     get_random_bytes(ip, sizeof *ip);
> 
> Yes, this seems to make more sense. The only thing I'm a little bit
> unsure about is why 'get_random_bytes' is called twice. The first
> time it gets the address of 'i' and it's size which is int. The next
> time it gets 'ip' which is equal to the address of 'i' (ip=&i;) and
> should have the size of int, too (int *ip).

Often, examples of calling a function are given multiple times.  The
sequence as a whole doesn't make sense.  It is the different methods of
calling it which are being shown.

Given the confusion over passing an int instead of an int * I thought a
comparision of the two would be helpful.

You're completely correct in your understanding of those lines;  the
second call will trample the bytes returned by the first.

Cheers,


Ralph.

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux