public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/5] Settings for Zed editor and minor fixups
@ 2026-08-21  5:03 David Gibson
  2026-08-21  5:03 ` [PATCH 1/5] clangd: Add _GNU_SOURCE to default clangd options David Gibson
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: David Gibson @ 2026-08-21  5:03 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev, Laurent Vivier; +Cc: David Gibson

I've been playing with the Zed editor again.  It's default settings
don't quite match passt's style, so add a config file to make it do
the right thing.  Also update some of the config for clangd to
suppress bogus warnings the way Zed invokes it.

Between them these also found a handful of minor but real code warts,
so fix those, too.

David Gibson (5):
  clangd: Add _GNU_SOURCE to default clangd options
  util: Eliminate a stray trailing whitespace
  util: Add missing O_CLOEXEC for !HAS_GETRANDOM path
  util, pasta: Remove some unneeded #includes
  Add Zed editor settings

 .clangd            | 2 +-
 .zed/settings.json | 4 ++++
 pasta.c            | 1 -
 util.c             | 7 ++-----
 4 files changed, 7 insertions(+), 7 deletions(-)
 create mode 100644 .zed/settings.json

-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] clangd: Add _GNU_SOURCE to default clangd options
  2026-08-21  5:03 [PATCH 0/5] Settings for Zed editor and minor fixups David Gibson
@ 2026-08-21  5:03 ` David Gibson
  2026-08-21  5:04 ` [PATCH 2/5] util: Eliminate a stray trailing whitespace David Gibson
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2026-08-21  5:03 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev, Laurent Vivier; +Cc: David Gibson

We always insert -D_GNU_SOURCE and -D_XOPEN_SOURCE=700 when compiling from
the Makefile, and we rely on it.  Without these listed in .clangd, clangd
will generate numerous spurious warnings.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 .clangd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.clangd b/.clangd
index 41bec92a..51baf737 100644
--- a/.clangd
+++ b/.clangd
@@ -1,3 +1,3 @@
 CompileFlags:
     # Don't try to interpret our headers as C++'
-    Add: [-xc, -Wall]
+    Add: [-xc, -Wall, -D_XOPEN_SOURCE=700, -D_GNU_SOURCE]
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/5] util: Eliminate a stray trailing whitespace
  2026-08-21  5:03 [PATCH 0/5] Settings for Zed editor and minor fixups David Gibson
  2026-08-21  5:03 ` [PATCH 1/5] clangd: Add _GNU_SOURCE to default clangd options David Gibson
@ 2026-08-21  5:04 ` David Gibson
  2026-08-21  5:04 ` [PATCH 3/5] util: Add missing O_CLOEXEC for !HAS_GETRANDOM path David Gibson
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2026-08-21  5:04 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev, Laurent Vivier; +Cc: David Gibson

We generally avoid trailing whitespace, but one slipped in.  Fix it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util.c b/util.c
index 28c32e43..500e8f55 100644
--- a/util.c
+++ b/util.c
@@ -1072,7 +1072,7 @@ void passt_exit(int status)
 	/* Make sure we don't leave any messages incomplete */
 	(void)fflush(stderr);
 	(void)fflush(stdout);
-	
+
 	_exit(status);
 }
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/5] util: Add missing O_CLOEXEC for !HAS_GETRANDOM path
  2026-08-21  5:03 [PATCH 0/5] Settings for Zed editor and minor fixups David Gibson
  2026-08-21  5:03 ` [PATCH 1/5] clangd: Add _GNU_SOURCE to default clangd options David Gibson
  2026-08-21  5:04 ` [PATCH 2/5] util: Eliminate a stray trailing whitespace David Gibson
@ 2026-08-21  5:04 ` David Gibson
  2026-08-21  5:04 ` [PATCH 4/5] util, pasta: Remove some unneeded #includes David Gibson
  2026-08-21  5:04 ` [PATCH 5/5] Add Zed editor settings David Gibson
  4 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2026-08-21  5:04 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev, Laurent Vivier; +Cc: David Gibson

It rarely matters, since we usually have getrandom(), but in case we don't
our open() of /dev/random was missing O_CLOEXEC, which can cause clang
warnings.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util.c b/util.c
index 500e8f55..df972a05 100644
--- a/util.c
+++ b/util.c
@@ -964,7 +964,7 @@ void raw_random(void *buf, size_t buflen)
 {
 	size_t random_read = 0;
 #ifndef HAS_GETRANDOM
-	int fd = open(DEV_RANDOM, O_RDONLY);
+	int fd = open(DEV_RANDOM, O_RDONLY | O_CLOEXEC);
 
 	if (fd < 0)
 		die_perror("Couldn't open %s", DEV_RANDOM);
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/5] util, pasta: Remove some unneeded #includes
  2026-08-21  5:03 [PATCH 0/5] Settings for Zed editor and minor fixups David Gibson
                   ` (2 preceding siblings ...)
  2026-08-21  5:04 ` [PATCH 3/5] util: Add missing O_CLOEXEC for !HAS_GETRANDOM path David Gibson
@ 2026-08-21  5:04 ` David Gibson
  2026-08-21  5:04 ` [PATCH 5/5] Add Zed editor settings David Gibson
  4 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2026-08-21  5:04 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev, Laurent Vivier; +Cc: David Gibson

Presumably these mattered at some point in the past, but no longer.  Found
by clangd as invoked by Zed editor.  Not sure why direct clang-tidy runs
didn't spot these.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 pasta.c | 1 -
 util.c  | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/pasta.c b/pasta.c
index 5aa56b78..247ebeda 100644
--- a/pasta.c
+++ b/pasta.c
@@ -46,7 +46,6 @@
 
 #include "util.h"
 #include "passt.h"
-#include "isolation.h"
 #include "netlink.h"
 #include "log.h"
 #include "epoll_ctl.h"
diff --git a/util.c b/util.c
index df972a05..99585d2c 100644
--- a/util.c
+++ b/util.c
@@ -30,11 +30,8 @@
 #include "util.h"
 #include "iov.h"
 #include "passt.h"
-#include "packet.h"
 #include "log.h"
 #include "pcap.h"
-#include "epoll_ctl.h"
-#include "pasta.h"
 #include "serialise.h"
 #ifdef HAS_GETRANDOM
 #include <sys/random.h>
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5/5] Add Zed editor settings
  2026-08-21  5:03 [PATCH 0/5] Settings for Zed editor and minor fixups David Gibson
                   ` (3 preceding siblings ...)
  2026-08-21  5:04 ` [PATCH 4/5] util, pasta: Remove some unneeded #includes David Gibson
@ 2026-08-21  5:04 ` David Gibson
  4 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2026-08-21  5:04 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev, Laurent Vivier; +Cc: David Gibson

I've been playing around with the Zed editor again.  Its default tab and
indent settings are a bit weird, and don't match passt's code style.  Add
a project config file to improve that.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 .zed/settings.json | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 .zed/settings.json

diff --git a/.zed/settings.json b/.zed/settings.json
new file mode 100644
index 00000000..87de0b4d
--- /dev/null
+++ b/.zed/settings.json
@@ -0,0 +1,4 @@
+{
+  "tab_size": 8,
+  "hard_tabs": true
+}
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-21  5:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21  5:03 [PATCH 0/5] Settings for Zed editor and minor fixups David Gibson
2026-08-21  5:03 ` [PATCH 1/5] clangd: Add _GNU_SOURCE to default clangd options David Gibson
2026-08-21  5:04 ` [PATCH 2/5] util: Eliminate a stray trailing whitespace David Gibson
2026-08-21  5:04 ` [PATCH 3/5] util: Add missing O_CLOEXEC for !HAS_GETRANDOM path David Gibson
2026-08-21  5:04 ` [PATCH 4/5] util, pasta: Remove some unneeded #includes David Gibson
2026-08-21  5:04 ` [PATCH 5/5] Add Zed editor settings David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).