9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] tweak: add missing return to fix double close(…) on file descriptor…
@ 2021-10-06 13:51 igor
  0 siblings, 0 replies; only message in thread
From: igor @ 2021-10-06 13:51 UTC (permalink / raw)
  To: 9front; +Cc: igor

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

The below patch adds a missing return statement to avoid a double close() on a file
descriptor and printing of conflicting messages where one says `can't write...`
followed by a `wrote ...` message.

Plumb the following for more context:
∙ /sys/src/cmd/tweak.c:/^twrite
∙ /sys/src/cmd/tweak.c:1730,1739


<snip>
From: Igor Böhm <igor@9lab.org>
Date: Wed, 06 Oct 2021 13:37:39 +0000
Subject: [PATCH] tweak: add missing return to fix double close(…) on file descriptor…

… and avoid printing conflicting messages.
---
diff 6ebb8b9e357944cc29ae3fafc0900ee3e325ed39 f9a20f83ad671a6404c42cc2bdfd4c9b1abceabc
--- a/sys/src/cmd/tweak.c	Sun Oct  3 17:58:58 2021
+++ b/sys/src/cmd/tweak.c	Wed Oct  6 15:37:39 2021
@@ -1731,6 +1731,7 @@
 		if(writeimage(fd, t->b, 0)<0 || (t->s && writesubfont(fd, t->s)<0)){
 			close(fd);
 			mesg("can't write %s: %r", t->name);
+			return;
 		}
 	t->mod = 0;
 	close(fd);
</snap>

Cheers,
Igor

[-- Attachment #2: tweak-missing-return.patch --]
[-- Type: text/plain, Size: 593 bytes --]

From: Igor Böhm <igor@9lab.org>
Date: Wed, 06 Oct 2021 13:37:39 +0000
Subject: [PATCH] tweak: add missing return to fix double close(…) on file descriptor…

… and avoid printing conflicting messages.
---
diff 6ebb8b9e357944cc29ae3fafc0900ee3e325ed39 f9a20f83ad671a6404c42cc2bdfd4c9b1abceabc
--- a/sys/src/cmd/tweak.c	Sun Oct  3 17:58:58 2021
+++ b/sys/src/cmd/tweak.c	Wed Oct  6 15:37:39 2021
@@ -1731,6 +1731,7 @@
 		if(writeimage(fd, t->b, 0)<0 || (t->s && writesubfont(fd, t->s)<0)){
 			close(fd);
 			mesg("can't write %s: %r", t->name);
+			return;
 		}
 	t->mod = 0;
 	close(fd);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-06 13:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 13:51 [9front] [PATCH] tweak: add missing return to fix double close(…) on file descriptor… igor

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ https://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git