From: Leon Romanovsky <leon@leon.nu>
To: Randi Botse <nightdecoder@gmail.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Problem with scatter/gather IO
Date: Wed, 13 Jul 2011 15:16:14 +0300 [thread overview]
Message-ID: <CALq1K=LLCLqE9k4QaqtDCxgPH8fniTPCssqDvSoOuOYT_j4Kag@mail.gmail.com> (raw)
In-Reply-To: <CAA6iF_6Y4VbHSKnNMYhAhTjf=ZoQZxwO+nqYPmV=R5=6c=KKiQ@mail.gmail.com>
On Wed, Jul 13, 2011 at 14:54, Randi Botse <nightdecoder@gmail.com> wrote:
>
> Hi,
>
> I will read/write file with readv() and writev(), I have problem to
> use that since the struct iovec will be a variable-length array, if i
> have code.
>
> struct foo {
> unsigned char data[100];
> unsigned char another_data[28];
> };
> unsigned len;
> ....
>
> /* calculate len */
> /* use len as array's member size */
> struct iovec iov[len];
> printf("len is: %i\n", len);
> readv(fd, iov, len);
>
> I got: BAD ADDRESS, and if I remove the printf() then I will get
> INVALID ARGUMENT. What the possible problem with that?
>
> Thanks,
> --
Did you try "man readv" ?
You didn't initialized iovec struct.
http://pubs.opengroup.org/onlinepubs/009695399/functions/readv.html
--
Leon Romanovsky | Independent Linux Consultant
www.leon.nu | leon@leon.nu
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-07-13 12:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-13 11:54 Problem with scatter/gather IO Randi Botse
2011-07-13 12:16 ` Leon Romanovsky [this message]
[not found] ` <CAA6iF_6CUa6ECMvnh9YehmxWYJzj23FEHZ4RJ5PtP-WdrrTr_A@mail.gmail.com>
2011-07-14 6:33 ` Fwd: " Randi Botse
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='CALq1K=LLCLqE9k4QaqtDCxgPH8fniTPCssqDvSoOuOYT_j4Kag@mail.gmail.com' \
--to=leon@leon.nu \
--cc=linux-c-programming@vger.kernel.org \
--cc=nightdecoder@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).