9front - general discussion about 9front
 help / color / mirror / Atom feed
From: cinap_lenrek@felloff.net
To: 9front@9front.org
Subject: Re: [9front] unofficial sdcard image for raspberry pi 4 testing
Date: Sat, 16 Nov 2019 02:08:36 +0100	[thread overview]
Message-ID: <121AFD953318E2873669556F35BF0C7C@felloff.net> (raw)
In-Reply-To: 7084F2A97B3ECD6C74D2C98C7671019C@hera.eonet.ne.jp

thats the way the kernel does exception handling.

basically, when error() is called, it jumps to the last invocation of
waserror(), and returns 1.

waserror() sets up the jumplabel. on first invocation, it returns 0, so
the print does not happen the first time.

but if some error condition happens, and someone calls error() then it
jumps right back to waserror(), and waserror returns with 1.

poperror() removes the jump label.

example:

if(waserror()){
	print("an error happend\n");
	return;
}

...

if(somevar)
	error("something went wrong");

...

print("everything went fine\n");

poperror();

will print
"an error happend"

once error() is called and somevar is non-zero.

but it somevar is zero, it prints

"everything went fine"

this is often used to cleanup in the error case. you'll find
code like:

x = allocatesomething()
if(waserror()){
	freesomething(x);
	nexterror();
}

...

dosomethingwith(x);

...

poperror();

when dosomethingwithx() calls error(), this will clean up. but in
normal case, it will complete fine and once finished, remove the
error label pushed by waserror() so the error handling can be
nested.

hope this explains it.

--
cinap


             reply	other threads:[~2019-11-16  1:08 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-16  1:08 cinap_lenrek [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-01-27  2:18 kokamoto
2019-12-05  5:19 kokamoto
2019-11-21  1:14 kokamoto
2020-05-31  8:51 ` Iruatã Souza
2020-06-01 23:07   ` kokamoto
2019-11-20  0:20 kokamoto
2019-11-21  0:23 ` hiro
2019-11-20  0:09 kokamoto
2019-11-18  9:45 umbraticus
2019-11-17 23:34 kokamoto
2019-11-17 23:37 ` Kurt H Maier
2019-11-17 18:33 cinap_lenrek
2020-06-20 11:39 ` Iruatã Souza
2019-11-17  6:23 kokamoto
2019-11-17  0:04 kokamoto
2019-11-17  0:02 kokamoto
2019-11-16 16:48 cinap_lenrek
2019-11-16 10:04 rgl
2019-11-16  9:29 kokamoto
2019-11-15  9:13 kokamoto
2019-11-15  6:58 rgl
2019-11-15  2:27 ori
2019-11-15  2:18 kokamoto
2019-11-15  0:21 kokamoto
2019-11-04  0:55 kokamoto
2019-10-21  4:19 kokamoto
2019-10-20  7:38 ori
2019-10-20  6:15 kokamoto
2019-10-20  0:37 cinap_lenrek
2019-10-20  9:13 ` Steve Simon
2019-10-20 13:48   ` hiro
2019-10-19 23:07 kokamoto
2019-10-19  0:13 kokamoto
2019-10-17 10:15 kokamoto
2019-10-16 23:29 kokamoto
2019-10-15  3:53 kokamoto
2019-09-30  0:31 kokamoto
2019-09-29  1:17 kokamoto
2019-09-29  4:27 ` Sean Hinchee
2019-09-29 20:43   ` hiro
2019-09-28  0:54 kokamoto
2019-09-28 18:48 ` Ethan Gardener
2019-09-28 19:43 ` Julius Schmidt
2019-09-28 23:35   ` hiro
2019-09-28  0:10 kokamoto
2019-09-28  1:24 ` Julius Schmidt
2019-09-28  7:43   ` hiro
2019-09-27  1:51 cinap_lenrek
2019-09-27  4:58 ` Roman Shaposhnik
2019-09-27  1:28 cinap_lenrek
2019-09-27  1:48 ` Roman Shaposhnik
2019-09-27  1:06 kokamoto
2019-09-27 10:22 ` Julius Schmidt
2019-09-26 14:35 cinap_lenrek
2019-09-26  9:58 kokamoto
2019-09-26 12:12 ` hiro
2019-09-26  3:50 kokamoto
2019-09-26  6:44 ` hiro
2019-09-26  0:04 kokamoto
2019-09-24 23:19 kokamoto
2019-09-24 22:45 cinap_lenrek
2019-09-24 21:51 kokamoto
2019-09-24 21:30 kokamoto
2019-09-24 21:22 kokamoto
2019-09-24 11:13 cinap_lenrek
2019-09-24  5:24 kokamoto
2019-09-23 17:24 cinap_lenrek
2019-09-23  1:44 cinap_lenrek
2019-09-23  2:00 ` Kenji Okamoto
2019-09-23  1:41 kokamoto
2019-08-23 20:16 cinap_lenrek
2019-08-21 14:35 cinap_lenrek

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=121AFD953318E2873669556F35BF0C7C@felloff.net \
    --to=cinap_lenrek@felloff.net \
    --cc=9front@9front.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;
as well as URLs for NNTP newsgroup(s).