Re: [OT] C programming problem

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

 



On 07/02/18 22:43, Phil Turmel wrote:
Hi Wol,

Bug alert!

On 02/07/2018 02:46 PM, Wol's lists wrote:
void main()
{

     blocks = logdisks * mirrors * disks;
     array = (int *) malloc( sizeof(int) * blocks );
     memset( &array, 0, blocks * sizeof(int) );
               ^^^^^^

Your 'array' variable is already a pointer.  You should not have
another address-of operator in front of it.  You are overwriting
your pointer and a bunch of static memory right after it, not
zeroing the area pointed to by 'array'.

Thanks. Somebody else already pointed out the error, but he was rather more "teacher", didn't tell me what exactly it was, and let me find it for myself!

Stupid mistake, but as I said, my C-fu is rusted solid :-)

Anyways, I've now got it sorted - I'll probably be posting it to the list as an RFC very soon ...

Cheers,
Wol
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux