From: Wol's lists <antlists@youngman.org.uk>
To: Phil Turmel <philip@turmel.org>, mdraid <linux-raid@vger.kernel.org>
Subject: Re: [OT] C programming problem
Date: Wed, 7 Feb 2018 23:32:55 +0000 [thread overview]
Message-ID: <12c4cfa3-4131-0ecb-8277-4927ba89461d@youngman.org.uk> (raw)
In-Reply-To: <ab1b1454-8226-ceab-55c8-e105fd0b3ca6@turmel.org>
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
prev parent reply other threads:[~2018-02-07 23:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 19:46 [OT] C programming problem Wol's lists
2018-02-07 20:00 ` Linus Lüssing
2018-02-07 20:00 ` Michael Fritscher
2018-02-07 20:22 ` Wol's lists
2018-02-07 22:43 ` Phil Turmel
2018-02-07 23:32 ` Wol's lists [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=12c4cfa3-4131-0ecb-8277-4927ba89461d@youngman.org.uk \
--to=antlists@youngman.org.uk \
--cc=linux-raid@vger.kernel.org \
--cc=philip@turmel.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