Skip to content

bsd-user style and reorg patches

[email protected] qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest48 patches 34 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/48bsd-user: whitespace changesbsd-user/bsdload.c+16 -160 replies
2/48bsd-user: whitespace changesbsd-user/elfload.c+163 -1630 replies
3/48bsd-user: whitespace changesbsd-user/main.c+20 -200 replies
4/48bsd-user: style tweak: keyword space (bsd-user/mmap.c+11 -110 replies
5/48bsd-user: style tweak: keyword space (bsd-user/qemu.h+2 -20 replies
6/48bsd-user: style tweak: keyword space (bsd-user/syscall.c+9 -90 replies
7/48bsd-user: style tweak: keyword space (bsd-user/uaccess.c+1 -10 replies
8/48bsd-user: style tweak: use C not C++ commentsbsd-user/elfload.c+2 -20 replies
9/48bsd-user: style tweak: use C not C++ commentsbsd-user/main.c+8 -80 replies
10/48bsd-user: Remove commented out codebsd-user/qemu.h+0 -41 reply
11/48bsd-user: style tweak: Remove #if 0'd codebsd-user/elfload.c+0 -121 reply
12/48bsd-user: style tweak: Remove #if 0'd codebsd-user/main.c+0 -1431 reply
13/48bsd-user: style tweak: Remove #if 0'd codebsd-user/strace.c+0 -81 reply
14/48bsd-user: style tweak: Remove #if 0'd codebsd-user/x86_64/target_syscall.h+0 -151 reply
15/48bsd-user: style tweak: return is not a function, eliminate ()bsd-user/bsdload.c+6 -71 reply
16/48bsd-user: style tweak: Put {} around all if/else/for statementsbsd-user/bsdload.c+7 -51 reply
17/48bsd-user: style tweak: Fix commentary issuesbsd-user/bsd-mman.h+26 -160 replies
18/48bsd-user: style tweak: Use preferred block commentsbsd-user/main.c+18 -100 replies
19/48bsd-user: style tweak: move extern to header filebsd-user/main.c bsd-user/qemu.h+2 -10 replies
20/48bsd-user: style tweak: use {} consistently in for / if / else statementsbsd-user/main.c+43 -230 replies
21/48bsd-user: style nits: return is not a functionbsd-user/elfload.c+1 -11 reply
22/48bsd-user: use qemu_strtoul in preference to strtolbsd-user/main.c+8 -41 reply
23/48bsd-user: introduce host_os.h for bsd-specific code and defaultsbsd-user/freebsd/host_os.h bsd-user/main.c bsd-user/netbsd/host_os.h +1 more+78 -10 replies
24/48bsd-user: create target_arch_cpu.hbsd-user/arm/target_arch_cpu.h bsd-user/i386/target_arch_cpu.h bsd-user/main.c +3 more+105 -00 replies
25/48bsd-user: move x86 (i386 and x86_64) cpu_loop to target_arch_cpu.hbsd-user/i386/target_arch_cpu.h bsd-user/main.c+179 -1741 reply
26/48bsd-user: move sparc cpu_loop into target_arch_cpu.h as target_cpu_loopbsd-user/main.c bsd-user/sparc/target_arch_cpu.h+266 -2711 reply
27/48bsd-user: style tweak: space pedantrybsd-user/elfload.c+11 -111 reply
28/48bsd-user: style tweak: commentsbsd-user/elfload.c+123 -931 reply
29/48bsd-user: style tweak: use {} correctlybsd-user/elfload.c+92 -551 reply
30/48bsd-user: style tweak: fix block commentsbsd-user/mmap.c+29 -221 reply
31/48bsd-user: style tweak: use {} for all if statements, format else correctlybsd-user/mmap.c+74 -381 reply
32/48bsd-user: style tweak: remove spacing after '*' and add after }bsd-user/qemu.h+9 -91 reply
33/48bsd-user: style tweak: Use preferred block commentsbsd-user/qemu.h+43 -311 reply
34/48bsd-user: style tweak: don't assign in if statementsbsd-user/qemu.h+4 -21 reply
35/48bsd-user: style tweak: use {} for all if statements, format else correctlybsd-user/qemu.h+13 -71 reply
36/48bsd-user: style tweak: Use preferred block commentsbsd-user/uaccess.c+8 -51 reply
37/48bsd-user: style tweak: don't assign in if statementsbsd-user/uaccess.c+4 -21 reply
38/48bsd-user: style tweak: use {} for all if statements, format else correctlybsd-user/uaccess.c+4 -21 reply
39/48bsd-user: style tweak: spaces around =, remove stray spacebsd-user/strace.c+2 -21 reply
40/48bsd-user: style tweak: Use preferred block commentsbsd-user/strace.c+4 -21 reply
41/48bsd-user: style tweak: don't assign in if statementsbsd-user/strace.c+2 -11 reply
42/48bsd-user: style tweak: spaces around operators and commasbsd-user/syscall.c+11 -111 reply
43/48bsd-user: style tweak: fold long linesbsd-user/syscall.c+25 -151 reply
44/48bsd-user: style tweak: use preferred block commentsbsd-user/syscall.c+13 -81 reply
45/48bsd-user: style tweak: Use preferred {} in if/else statements.bsd-user/syscall.c+78 -421 reply
46/48bsd-user: style tweak: Return is not a function call.bsd-user/syscall.c+1 -11 reply
47/48bsd-user: style tweak: don't assign in if statement.bsd-user/syscall.c+27 -131 reply
48/48bsd-user: put back a break; that had gone missing...bsd-user/syscall.c+1 -01 reply

Reviews trailers per patch

All 48 patches have a Reviewed-by or Acked-by.

PatchRichard Henderson
1/48R-b
2/48R-b
3/48R-b
4/48R-b
5/48R-b
6/48R-b
7/48R-b
8/48R-b
9/48R-b
10/48R-b
11/48R-b
12/48R-b
13/48R-b
14/48R-b
15/48R-b
16/48R-b
17/48R-b
18/48R-b
19/48R-b
20/48R-b
21/48R-b
22/48R-b
23/48R-b
24/48R-b
25/48R-b
26/48R-b
27/48R-b
28/48R-b
29/48R-b
30/48R-b
31/48R-b
32/48R-b
33/48R-b
34/48R-b
35/48R-b
36/48R-b
37/48R-b
38/48R-b
39/48R-b
40/48R-b
41/48R-b
42/48R-b
43/48R-b
44/48R-b
45/48R-b
46/48R-b
47/48R-b
48/48R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/48] bsd-user style and reorg patches

From: Warner Losh <[email protected]>

Version 2:

In version 2 I've fixed all the checkpatch.pl issues for all the files that I touched. Since files are changed incrementally, some of the individual changes may not pass checkpatch.pl due to pre-existing problems, but the cumulative diff passes with just warnings. I've folded the 'if 0 should just be lost' advice in the relevant hunks, as well as in a few places where things were commented out.

I've included all the reviews I've got so far, but since this is my first time with such a complex review here please let me know if I've missed following all the conventions somehow.

I had to tweak patches 025 and 026, which had been previously reviewed (adding static in 2 places to fix a warning). So I removed the Reviewed By: line from it. I hope that's the proper protocol here, but if not I'm keen on suggestions.

Version 1:

This series starts to cleanup bsd-user. The current checkpatch.pl output is on the order of 4500 lines long. These cleanups don't fix everything (there's still plenty of errors, even in some of the files the patches touch). I've tried to make things better in every case, but be advised that checkpatch.pl is unhappy with many of the files still in the first 15 commits. I do plan on addressing the issues in the future as I need to make real commits to those files. The changes were ones that were trivial to do with scripts that I had to do for main.c anyway. main.c is now completely clean. All the cleanup I've done myself, and at the end of this patch trail the output is only 3500 lines...

Next, I've started to reorg the bsd-user sources. There's really 4 BSDs in the wild (FreeBSD, NetBSD, OpenBSD and Dragonfly) that these could, in theory, target. In the bsd-user branch, we've broken the emulation of these apart. It largely preserves the other BSD's as is, and greatly expands FreeBSD so that we can do package builds in user-land emulation. The other BSDs have not been run-time tested, though the CI tooling builds some of them. It's my belief that in the current state, even an old-school cat(1) would fail, though I am to fix that at least for FreeBSD...

We've also added a number of other architectures than sparc and i386. Those additions, though, are dependent on other things not yet reshuffled and or merged, so they will be coming along in due time: mips (32 and 64 bit), arm, aarch64 and riscv willl come in due time. powerpc might, but it's in a frightful state. I'm open to other BSDs that wish to work along with me as well, though it may be best to wait until after future patch sets as much is still set to change. CHERI and related work may also happen, but that's still TBD.

In this installement, after the style stuff, I've created a target_arch_cpu.h. Here, all the functions related to the cpu loop and similar things are moved into there on a per-architecture basis to start to tame the number of #ifdefs in mail. Linux-user did a similar thing years after we had done it in the repo, and a number of different choices were made. Rather than redo all the work from the bsd-user repo, I'm recreating / rebasing it on a current qemu. Future patch series will address other aspects. Once they are complete, we can look, potentially, at any refactoring between linux-user and bsd-user. I very much explicitly want to push that to the end because otherwise I'm completely recreating a lot of the work on the bsd-user branch rather than just transitioning it forward to a newer qemu. This reorg was started by Stacey Son and I've redone it with the latest code. I've added his signoff (with his blanket permission) to those commits. Also, all of these commits pass checkpatch.pl

Please let me know what you think, and how I might structure future patches if there's ways I can do them better. I've switched to pull-requests with this series since it will be easier to keep track of, especially in the future.

Warner

P.S. This has no relevance to 6.0 at all: we're too late and this feature isn't fully integrated by this patch trail.

Warner Losh (48):
bsd-user: whitespace changes
bsd-user: whitespace changes
bsd-user: whitespace changes
bsd-user: style tweak: keyword space (
bsd-user: style tweak: keyword space (
bsd-user: style tweak: keyword space (
bsd-user: style tweak: keyword space (
bsd-user: style tweak: use C not C++ comments
bsd-user: style tweak: use C not C++ comments
bsd-user: Remove commented out code
bsd-user: style tweak: Remove #if 0'd code
bsd-user: style tweak: Remove #if 0'd code
bsd-user: style tweak: Remove #if 0'd code
bsd-user: style tweak: Remove #if 0'd code
bsd-user: style tweak: return is not a function, eliminate ()
bsd-user: style tweak: Put {} around all if/else/for statements
bsd-user: style tweak: Fix commentary issues
bsd-user: style tweak: Use preferred block comments
bsd-user: style tweak: move extern to header file
bsd-user: style tweak: use {} consistently in for / if / else
statements
bsd-user: style nits: return is not a function
bsd-user: use qemu_strtoul in preference to strtol
bsd-user: introduce host_os.h for bsd-specific code and defaults
bsd-user: create target_arch_cpu.h
bsd-user: move x86 (i386 and x86_64) cpu_loop to target_arch_cpu.h
bsd-user: move sparc cpu_loop into target_arch_cpu.h as
target_cpu_loop
bsd-user: style tweak: space pedantry
bsd-user: style tweak: comments
bsd-user: style tweak: use {} correctly
bsd-user: style tweak: fix block comments
bsd-user: style tweak: use {} for all if statements, format else
correctly
bsd-user: style tweak: remove spacing after '*' and add after }
bsd-user: style tweak: Use preferred block comments
bsd-user: style tweak: don't assign in if statements
bsd-user: style tweak: use {} for all if statements, format else
correctly
bsd-user: style tweak: Use preferred block comments
bsd-user: style tweak: don't assign in if statements
bsd-user: style tweak: use {} for all if statements, format else
correctly
bsd-user: style tweak: spaces around =, remove stray space
bsd-user: style tweak: Use preferred block comments
bsd-user: style tweak: don't assign in if statements
bsd-user: style tweak: spaces around operators and commas
bsd-user: style tweak: fold long lines
bsd-user: style tweak: use preferred block comments
bsd-user: style tweak: Use preferred {} in if/else statements.
bsd-user: style tweak: Return is not a function call.
bsd-user: style tweak: don't assign in if statement.
bsd-user: put back a break; that had gone missing...

 bsd-user/arm/target_arch_cpu.h     |  22 +
 bsd-user/bsd-mman.h                |  42 +-
 bsd-user/bsdload.c                 |  55 +--
 bsd-user/elfload.c                 | 677 ++++++++++++++++-------------
 bsd-user/freebsd/host_os.h         |  25 ++
 bsd-user/i386/target_arch_cpu.h    | 197 +++++++++
 bsd-user/main.c                    | 657 +++-------------------------
 bsd-user/mmap.c                    | 185 +++++---
 bsd-user/netbsd/host_os.h          |  25 ++
 bsd-user/openbsd/host_os.h         |  25 ++
 bsd-user/qemu.h                    | 128 +++---
 bsd-user/sparc/target_arch_cpu.h   | 287 ++++++++++++
 bsd-user/sparc64/target_arch_cpu.h |  19 +
 bsd-user/strace.c                  |  21 +-
 bsd-user/syscall.c                 | 222 ++++++----
 bsd-user/uaccess.c                 |  27 +-
 bsd-user/x86_64/target_arch_cpu.h  |  19 +
 bsd-user/x86_64/target_syscall.h   |  15 -
 18 files changed, 1449 insertions(+), 1199 deletions(-)
 create mode 100644 bsd-user/arm/target_arch_cpu.h
 create mode 100644 bsd-user/freebsd/host_os.h
 create mode 100644 bsd-user/i386/target_arch_cpu.h
 create mode 100644 bsd-user/netbsd/host_os.h
 create mode 100644 bsd-user/openbsd/host_os.h
 create mode 100644 bsd-user/sparc/target_arch_cpu.h
 create mode 100644 bsd-user/sparc64/target_arch_cpu.h
 create mode 100644 bsd-user/x86_64/target_arch_cpu.h
Signature · 1 line
2.22.1