9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: EBo <ebo@sandien.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] read(2) problem on p9p?
Date: Fri, 13 Aug 2010 11:46:54 -0600	[thread overview]
Message-ID: <79d728670c7d6a03e9acc7fb3c756777@swcp.com> (raw)
In-Reply-To: <6c97cc385db794bd736f6ea0cd505989@plug.quanstro.net>



> you haven't explanined what the arguments to test do, but
> you appear to be mixing strcmp idioms.  i think you wish either
>
> 	test(strcmp(test_str, buf) == 0, 4, "check value\n");
>
> or
> 	test(!strcmp(test_str, buf), 4, "check value\n");

Right. Sorry...  The declaration for test is:

  void test(int bool, int space, ...);

where bool is the test case to prepend a pass/fail message in front of the
used defined message printed by vfprint.  Space is a pretty printing addon
that prints n spaces before the print message -- it makes it easier to
read.

The test you pointed out was a bad test.  Thanks for catching that!

The real problem was the test before it:

    ret = read(dtf, buf, strlen buf);
    test(strlen(tst_str)==ret,4, "read back from var\n");

Read actually correctly reads the file correctly (which the next test
verifies), but since I asked it to read 1K bytes when the message length is
only 39, read returns 0 instead of 39 and sets the file's offset to the end
of file as I would have expected.

I also should add if I did not before, this is on plan9port.


  EBo --




  reply	other threads:[~2010-08-13 17:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-13 16:54 EBo
2010-08-13 17:16 ` [9fans] " erik quanstrom
2010-08-13 17:46   ` EBo [this message]
2010-08-13 17:51 ` Skip Tavakkolian
2010-08-13 18:14   ` Russ Cox
2010-08-13 18:35     ` EBo
2010-08-13 18:46       ` Russ Cox
2010-08-13 19:03         ` EBo
2010-08-13 18:16   ` EBo
2010-08-13 18:58     ` erik quanstrom

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=79d728670c7d6a03e9acc7fb3c756777@swcp.com \
    --to=ebo@sandien.com \
    --cc=9fans@9fans.net \
    /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).