summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
m---------3rd-party/pico-fmt0
m---------3rd-party/pico-sdk0
-rw-r--r--CMakeLists.txt33
-rwxr-xr-xbuild-aux/lint-bin1
-rw-r--r--build-aux/measurestack/app_main.py12
-rw-r--r--build-aux/measurestack/app_plugins.py215
-rw-r--r--build-aux/measurestack/test_app_plugins.py379
-rw-r--r--cmd/sbc_harness/CMakeLists.txt6
-rw-r--r--cmd/sbc_harness/config/tusb_config.h45
-rw-r--r--cmd/sbc_harness/fs_harness_flash_bin.c16
-rw-r--r--cmd/sbc_harness/fs_harness_uptime_txt.c5
-rw-r--r--cmd/sbc_harness/main.c11
l---------cmd/sbc_harness/static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/printf.mit.txt1
-rw-r--r--cmd/sbc_harness/tusb_log.c13
-rw-r--r--lib9p/CMakeLists.txt1
-rw-r--r--lib9p/core.c189
-rw-r--r--lib9p/core_gen/c.py19
-rw-r--r--lib9p/core_gen/c_fmt_print.py (renamed from lib9p/core_gen/c_format.py)96
-rw-r--r--lib9p/core_gen/c_marshal.py7
-rw-r--r--lib9p/core_gen/c_validate.py20
-rw-r--r--lib9p/core_gen/h.py10
-rw-r--r--lib9p/core_generated.c5047
-rw-r--r--lib9p/core_include/lib9p/_core_generated.h100
-rw-r--r--lib9p/core_include/lib9p/core.h42
-rw-r--r--lib9p/core_tables.h6
-rw-r--r--lib9p/srv.c149
-rw-r--r--lib9p/tests/test_server/main.c40
-rw-r--r--libcr/coroutine.c33
-rw-r--r--libdhcp/dhcp_client.c29
-rw-r--r--libfmt/CMakeLists.txt15
-rw-r--r--libfmt/include/libfmt/fmt.h23
-rw-r--r--libfmt/libmisc.c73
-rw-r--r--libfmt/quote.c159
-rw-r--r--libhw_cr/rp2040_hwspi.c4
-rw-r--r--libhw_cr/w5500.c98
-rw-r--r--libhw_cr/w5500_ll.h37
-rw-r--r--libhw_generic/include/libhw/generic/net.h16
-rw-r--r--libhw_generic/net.c20
-rw-r--r--libmisc/CMakeLists.txt2
-rw-r--r--libmisc/assert.c10
-rw-r--r--libmisc/fmt.c225
-rw-r--r--libmisc/include/libmisc/_intercept.h17
-rw-r--r--libmisc/include/libmisc/fmt.h156
-rw-r--r--libmisc/include/libmisc/log.h19
-rw-r--r--libmisc/include/libmisc/macro.h107
-rw-r--r--libmisc/include/libmisc/obj.h27
-rw-r--r--libmisc/intercept.c20
-rw-r--r--libmisc/log.c20
-rw-r--r--libmisc/tests/test_assert.c70
-rw-r--r--libmisc/tests/test_fmt.c170
-rw-r--r--libmisc/tests/test_log.c79
-rw-r--r--libmisc/tests/test_macro.c128
-rw-r--r--libusb/usb_common.c4
54 files changed, 3702 insertions, 4325 deletions
diff --git a/.gitmodules b/.gitmodules
index 17dec29..8a4c874 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -6,6 +6,3 @@
[submodule "3rd-party/pico-sdk"]
path = 3rd-party/pico-sdk
url = https://github.com/LukeShu/pico-sdk
-[submodule "3rd-party/pico-fmt"]
- path = 3rd-party/pico-fmt
- url = https://github.com/LukeShu/pico-fmt
diff --git a/3rd-party/pico-fmt b/3rd-party/pico-fmt
deleted file mode 160000
-Subproject a69f6e22e9bf3da849b128d3a0ed3e77da5997d
diff --git a/3rd-party/pico-sdk b/3rd-party/pico-sdk
-Subproject c8a16c00453e4db4b771d7f1281391057c7477d
+Subproject bbad146d79b42081d85b76e44f136ff8d42f1a1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 659f530..5ce49ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,8 +14,6 @@ include("${PICO_SDK_PATH}/external/pico_sdk_import.cmake")
project(sbc_harness)
-add_subdirectory(3rd-party/pico-fmt/pico_fmt)
-add_subdirectory(3rd-party/pico-fmt/pico_printf)
pico_sdk_init()
if ((PICO_PLATFORM STREQUAL "host") AND (NOT PICO_NO_GC_SECTIONS))
@@ -36,7 +34,6 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" _upper_cmake_build_type)
string(REPLACE " " ";" _build_type_flags "${CMAKE_C_FLAGS_${_upper_cmake_build_type}}")
if ("-DNDEBUG" IN_LIST _build_type_flags)
add_compile_options(-Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable)
- target_compile_definitions(pico_printf INTERFACE PICO_PRINTF_ALWAYS_INCLUDED=1)
endif()
function(_suppress_tinyusb_warnings)
@@ -123,8 +120,36 @@ function(add_lib_test arg_libname arg_testname)
endif()
endfunction()
+function(_apply_matrix_helper _m_depth _m_assignments)
+ list(LENGTH _m_arg_matrix _m_dimensions)
+ math(EXPR _m_dimensions ${_m_dimensions}/2)
+ if("${_m_depth}" EQUAL "${_m_dimensions}")
+ cmake_language(CALL "${_m_arg_action}" "${_m_n}" "${_m_assignments}")
+ math(EXPR _m_n "${_m_n}+1")
+ set(_m_n "${_m_n}" PARENT_SCOPE)
+ else()
+ math(EXPR _m_ik "${_m_depth}*2")
+ list(GET _m_arg_matrix "${_m_ik}" _m_tmp_key)
+
+ math(EXPR _m_iv "${_m_ik}+1")
+ list(GET _m_arg_matrix "${_m_iv}" _m_tmp_vals)
+ string(REGEX REPLACE "^\\[(.*)\\]$" "\\1" _m_tmp_vals "${_m_tmp_vals}")
+
+ foreach(_m_tmp_val IN LISTS _m_tmp_vals)
+ math(EXPR _m_tmp_depth "${_m_depth}+1")
+ set(_m_tmp_assignments "${_m_assignments}")
+ list(APPEND _m_tmp_assignments "${_m_tmp_key}=${_m_tmp_val}")
+ _apply_matrix_helper("${_m_tmp_depth}" "${_m_tmp_assignments}")
+ set(_m_n "${_m_n}" PARENT_SCOPE)
+ endforeach()
+ endif()
+endfunction()
+function(apply_matrix _m_arg_action _m_arg_matrix)
+ set(_m_n 0)
+ _apply_matrix_helper(0 "")
+endfunction()
+
add_subdirectory(libmisc)
-add_subdirectory(libfmt)
add_subdirectory(libcr)
add_subdirectory(libcr_ipc)
add_subdirectory(libhw_generic)
diff --git a/build-aux/lint-bin b/build-aux/lint-bin
index 91f1612..19d3a3b 100755
--- a/build-aux/lint-bin
+++ b/build-aux/lint-bin
@@ -114,6 +114,7 @@ lint_func_blocklist() {
local blocklist=(
gpio_default_irq_handler
+ {,__wrap,weak_raw_,stdio_,_}{,v}{,sn}printf
)
while read -r func; do
diff --git a/build-aux/measurestack/app_main.py b/build-aux/measurestack/app_main.py
index f705876..4fdfd5c 100644
--- a/build-aux/measurestack/app_main.py
+++ b/build-aux/measurestack/app_main.py
@@ -28,7 +28,7 @@ def main(
# sbc-harness ####################################################
libmisc_plugin = app_plugins.LibMiscPlugin(arg_c_fnames)
- lib9p_plugin = app_plugins.Lib9PPlugin(arg_base_dir, arg_c_fnames, libmisc_plugin)
+ lib9p_plugin = app_plugins.Lib9PPlugin(arg_base_dir, arg_c_fnames)
def sbc_is_thread(name: QName) -> int:
if str(name).endswith("_cr") and name.base() != BaseName("lib9p_srv_read_cr"):
@@ -48,7 +48,6 @@ def main(
plugins += [
app_plugins.CmdPlugin(),
libmisc_plugin,
- app_plugins.PicoFmtPlugin(arg_pico_platform, lib9p_plugin.formatters),
app_plugins.LibHWPlugin(arg_pico_platform, libmisc_plugin),
app_plugins.LibCRPlugin(),
app_plugins.LibCRIPCPlugin(),
@@ -88,12 +87,13 @@ def main(
def misc_filter(name: QName) -> tuple[int, bool]:
if name in [
QName("__assert_msg_fail"),
- QName("__lm_printf"),
- QName("__lm_light_printf"),
- QName("fmt_vfctprintf"),
- QName("fmt_vsnprintf"),
]:
return 1, False
+ for prefix in ["fmt_print_", "_fmt_print_"]:
+ if str(name.base()).startswith(prefix):
+ return 1, False
+ if str(name.base()).endswith("_putb"):
+ return 1, False
return 0, False
extra_includes: list[BaseName] = []
diff --git a/build-aux/measurestack/app_plugins.py b/build-aux/measurestack/app_plugins.py
index e365f82..6fc81ec 100644
--- a/build-aux/measurestack/app_plugins.py
+++ b/build-aux/measurestack/app_plugins.py
@@ -19,7 +19,6 @@ __all__ = [
"LibCRIPCPlugin",
"Lib9PPlugin",
"LibMiscPlugin",
- "PicoFmtPlugin",
"PicoSDKPlugin",
"TinyUSBDevicePlugin",
"NewlibPlugin",
@@ -129,20 +128,7 @@ class LibMiscPlugin:
return None
def skipmodels(self) -> dict[BaseName, analyze.SkipModel]:
- return {
- BaseName("__assert_msg_fail"): analyze.SkipModel(
- {BaseName("__assert_msg_fail")}, self._skipmodel___assert_msg_fail
- ),
- }
-
- def _skipmodel___assert_msg_fail(
- self, chain: typing.Sequence[QName], node: Node, call: QName
- ) -> bool:
- if call.base() in [BaseName("__lm_printf"), BaseName("__lm_light_printf")]:
- return any(
- c.base() == BaseName("__assert_msg_fail") for c in reversed(chain)
- )
- return False
+ return {}
class LibHWPlugin:
@@ -268,35 +254,17 @@ class LibCRIPCPlugin:
class Lib9PPlugin:
- re_tmessage_handler = re.compile(
- r"^\s*\[LIB9P_TYP_T[^]]+\]\s*=\s*\(tmessage_handler\)\s*(?P<handler>\S+),\s*$"
- )
- re_lib9p_msg_entry = re.compile(r"^\s*_MSG_(?:[A-Z]+)\((?P<typ>\S+)\),$")
- re_lib9p_caller = re.compile(
- r"^lib9p_(?P<grp>[TR])msg_(?P<meth>validate|unmarshal|marshal)$"
- )
- re_lib9p_callee = re.compile(
- r"^(?P<meth>validate|unmarshal|marshal)_(?P<msg>(?P<grp>[TR]).*)$"
- )
+ re_lib9p_msg_entry = re.compile(r"^\s*_MSG\((?P<typ>\S+)\),$")
- tmessage_handlers: set[QName] | None
lib9p_msgs: set[str]
_CONFIG_9P_MAX_CONNS: int | None
_CONFIG_9P_MAX_REQS: int | None
- formatters: typing.Collection[BaseName]
def __init__(
self,
arg_base_dir: str,
arg_c_fnames: typing.Collection[str],
- libmisc_plugin: LibMiscPlugin,
) -> None:
- self.formatters = {
- x.base()
- for x in libmisc_plugin.objcalls["format"]
- if str(x.base()).startswith("lib9p_")
- }
-
# Find filenames #######################################################
def _is_config_h(fname: str) -> bool:
@@ -314,7 +282,7 @@ class Lib9PPlugin:
)
lib9p_generated_c_fname = util.get_zero_or_one(
- lambda fname: fname.endswith("lib9p/_core_generated.c"), arg_c_fnames
+ lambda fname: fname.endswith("lib9p/core_generated.c"), arg_c_fnames
)
# Read config ##########################################################
@@ -336,16 +304,6 @@ class Lib9PPlugin:
# Read sources #########################################################
- tmessage_handlers: set[QName] | None = None
- if lib9p_srv_c_fname:
- tmessage_handlers = set()
- with open(lib9p_srv_c_fname, "r", encoding="utf-8") as fh:
- for line in fh:
- line = line.rstrip()
- if m := self.re_tmessage_handler.fullmatch(line):
- tmessage_handlers.add(QName(m.group("handler")))
- self.tmessage_handlers = tmessage_handlers
-
lib9p_msgs: set[str] = set()
if lib9p_generated_c_fname:
with open(lib9p_generated_c_fname, "r", encoding="utf-8") as fh:
@@ -377,153 +335,37 @@ class Lib9PPlugin:
def extra_nodes(self) -> typing.Collection[Node]:
return []
- def indirect_callees(
- self, loc: str, line: str
- ) -> tuple[typing.Collection[QName], bool] | None:
- if "/3rd-party/" in loc:
- return None
- if (
- self.tmessage_handlers
- and "/srv.c:" in loc
- and "tmessage_handlers[typ](" in line
- ):
- # Functions for disabled protocol extensions will be missing.
- return self.tmessage_handlers, True
- if self.lib9p_msgs and "/9p.c:" in loc:
- for meth in ["validate", "unmarshal", "marshal"]:
- if line.startswith(f"tentry.{meth}("):
- # Functions for disabled protocol extensions will be missing.
- return [QName(f"{meth}_{msg}") for msg in self.lib9p_msgs], True
- return None
-
- def skipmodels(self) -> dict[BaseName, analyze.SkipModel]:
- ret: dict[BaseName, analyze.SkipModel] = {
- BaseName("_lib9p_validate"): analyze.SkipModel(
- 1,
- self._skipmodel__lib9p_validate_unmarshal_marshal,
- ),
- BaseName("_lib9p_unmarshal"): analyze.SkipModel(
- 1,
- self._skipmodel__lib9p_validate_unmarshal_marshal,
- ),
- BaseName("_lib9p_marshal"): analyze.SkipModel(
- 1,
- self._skipmodel__lib9p_validate_unmarshal_marshal,
- ),
- }
- return ret
-
- def _skipmodel__lib9p_validate_unmarshal_marshal(
- self, chain: typing.Sequence[QName], node: Node, call: QName
- ) -> bool:
- m_caller = self.re_lib9p_caller.fullmatch(str(chain[-1].base()))
- assert m_caller
-
- m_callee = self.re_lib9p_callee.fullmatch(str(call.base()))
- if not m_callee:
- return False
- return m_caller.group("grp") != m_callee.group("grp")
-
-
-class PicoFmtPlugin:
- known_fct: dict[BaseName, BaseName]
- wont_call_v: typing.Collection[BaseName]
-
- def __init__(
- self, arg_pico_platform: str, wont_call_v: typing.Collection[BaseName]
- ) -> None:
- self.known_fct = {
- # pico_fmt
- BaseName("fmt_vsnprintf"): BaseName("_out_buffer"),
- }
- match arg_pico_platform:
- case "rp2040":
- self.known_fct.update(
- {
- # pico_stdio
- BaseName("__wrap_vprintf"): BaseName("stdio_buffered_printer"),
- BaseName("stdio_vprintf"): BaseName("stdio_buffered_printer"),
- # libfmt
- BaseName("__lm_light_printf"): BaseName("libfmt_light_fct"),
- }
- )
- case "host":
- self.known_fct.update(
- {
- # libfmt
- BaseName("__lm_printf"): BaseName("libfmt_libc_fct"),
- BaseName("__lm_light_printf"): BaseName("libfmt_libc_fct"),
- }
- )
- self.wont_call_v = set([*self.known_fct.values(), *wont_call_v])
-
- def is_intrhandler(self, name: QName) -> bool:
- return False
-
- def init_array(self) -> typing.Collection[QName]:
- return []
-
- def extra_includes(self) -> typing.Collection[BaseName]:
- return []
-
- def extra_nodes(self) -> typing.Collection[Node]:
- return []
+ re_table_call = re.compile(
+ r"\s*_lib9p_(?P<meth>validate|unmarshal|marshal)\(.*(?P<grp>[RT])msg.*\);\s*"
+ )
+ re_print_call = re.compile(r".*lib9p_table_msg.*\.print\(.*")
def indirect_callees(
self, loc: str, line: str
) -> tuple[typing.Collection[QName], bool] | None:
- if "/3rd-party/pico-fmt/" not in loc:
+ if "/3rd-party/" in loc:
return None
- if "/printf.c:" in loc:
- m = util.re_call_other.fullmatch(line)
- call: str | None = m.group("func") if m else None
- if "->fct" in line:
- return [x.as_qname() for x in self.known_fct.values()], False
- if "specifier_table" in line:
+ if self.lib9p_msgs and "lib9p/core.c:" in loc:
+ if m := self.re_table_call.fullmatch(line):
+ meth = m.group("meth")
+ grp = m.group("grp")
+ # Functions for disabled protocol extensions will be missing.
return [
- # pico-fmt
- QName("conv_sint"),
- QName("conv_uint"),
- # QName("conv_double"),
- QName("conv_char"),
- QName("conv_str"),
- QName("conv_ptr"),
- QName("conv_pct"),
- # libfmt
- QName("libfmt_conv_formatter"),
- QName("libfmt_conv_quote"),
- ], False
+ QName(f"{meth}_{msg}")
+ for msg in self.lib9p_msgs
+ if msg.startswith(grp)
+ ], True
+ if self.re_print_call.fullmatch(line):
+ # Functions for disabled protocol extensions will be missing.
+ return [QName(f"fmt_print_{msg}") for msg in self.lib9p_msgs], True
+ if "lib9p/srv.c:" in loc:
+ if "srv->msglog(" in line:
+ # Actual ROMs shouldn't set this, and so will be missing on rp2040 builds.
+ return [QName("log_msg")], True
return None
def skipmodels(self) -> dict[BaseName, analyze.SkipModel]:
- ret: dict[BaseName, analyze.SkipModel] = {
- BaseName("fmt_state_putchar"): analyze.SkipModel(
- self.known_fct.keys(), self._skipmodel_fmt_state_putchar
- ),
- BaseName("_vfctprintf"): analyze.SkipModel(
- self.wont_call_v, self._skipmodel__vfctprintf
- ),
- }
- return ret
-
- def _skipmodel_fmt_state_putchar(
- self, chain: typing.Sequence[QName], node: Node, call: QName
- ) -> bool:
- if call.base() in self.known_fct.values():
- fct: BaseName | None = None
- for pcall in reversed(chain):
- if pcall.base() in self.known_fct:
- fct = self.known_fct[pcall.base()]
- return call.base() != fct
- return True
- return False
-
- def _skipmodel__vfctprintf(
- self, chain: typing.Sequence[QName], node: Node, call: QName
- ) -> bool:
- if call.base() == BaseName("libfmt_conv_formatter"):
- return any(c.base() in self.wont_call_v for c in chain)
- return False
+ return {}
class PicoSDKPlugin:
@@ -604,6 +446,8 @@ class PicoSDKPlugin:
return [QName("rom_func_lookup(ROM_FUNC_FLASH_RANGE_ERASE)")], False
case "flash_flush_cache_func":
return [QName("rom_func_lookup(ROM_FUNC_FLASH_FLUSH_CACHE)")], False
+ case "flash_range_program_func":
+ return [QName("rom_func_lookup(ROM_FUNC_FLASH_RANGE_PROGRAM)")], False
case "rom_table_lookup":
return [QName("rom_hword_as_ptr(BOOTROM_TABLE_LOOKUP_OFFSET)")], False
if "/flash.c:" in loc and "boot2_copyout" in line:
@@ -941,10 +785,7 @@ class LibGCCPlugin:
return False
def init_array(self) -> typing.Collection[QName]:
- return [
- QName("libfmt_install_formatter"),
- QName("libfmt_install_quote"),
- ]
+ return []
def extra_includes(self) -> typing.Collection[BaseName]:
return []
diff --git a/build-aux/measurestack/test_app_plugins.py b/build-aux/measurestack/test_app_plugins.py
deleted file mode 100644
index da8be65..0000000
--- a/build-aux/measurestack/test_app_plugins.py
+++ /dev/null
@@ -1,379 +0,0 @@
-# build-aux/measurestack/test_app_plugins.py - Tests for app_plugins.py
-#
-# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
-# SPDX-License-Identifier: AGPL-3.0-or-later
-
-# pylint: disable=unused-variable
-
-import typing
-
-from . import analyze, app_plugins, testutil, util
-from .analyze import BaseName, Node, QName, SkipModel
-
-
-def test_assert_msg_fail() -> None:
- # 1 2 3 4 5 6 7 <= call_depth
- # - main()
- # - __assert_msg_fail() *
- # - __lm_light_printf()
- # - fmt_vfctprintf()
- # - stdio_putchar()
- # - __assert_msg_fail() **
- # - __lm_abort()
- # - stdio_flush() (inconsequential)
- # - __lm_abort() (inconsequential)
- max_call_depth = 7
- exp = [
- "main",
- "__assert_msg_fail",
- "__lm_light_printf",
- "fmt_vfctprintf",
- "stdio_putchar",
- "__assert_msg_fail",
- "__lm_abort",
- ]
- graph: typing.Sequence[tuple[str, typing.Collection[str]]] = [
- # main.c
- ("main", {"__assert_msg_fail"}),
- # assert.c
- ("__assert_msg_fail", {"__lm_light_printf", "__lm_abort"}),
- # intercept.c / libfmt/libmisc.c
- ("__lm_abort", {}),
- ("__lm_light_printf", {"fmt_vfctprintf", "stdio_flush"}),
- ("stdio_flush", {}),
- ("stdio_putchar", {"__assert_msg_fail"}),
- # printf.c
- ("fmt_vfctprintf", {"stdio_putchar"}),
- ]
- graph_plugin = testutil.GraphProviderPlugin(max_call_depth, graph)
-
- class SkipPlugin(testutil.NopPlugin):
- def skipmodels(self) -> dict[BaseName, SkipModel]:
- models = app_plugins.LibMiscPlugin(arg_c_fnames=[]).skipmodels()
- assert BaseName("__assert_msg_fail") in models
- orig_model = models[BaseName("__assert_msg_fail")]
-
- def wrapped_model_fn(
- chain: typing.Sequence[QName], node: Node, call: QName
- ) -> bool:
- dbgstr = (
- ("=>".join(str(c) for c in [*chain, node.funcname]))
- + "=?=>"
- + str(call)
- )
- assert dbgstr in [
- "__assert_msg_fail=?=>__lm_light_printf",
- "__assert_msg_fail=?=>__lm_abort",
- "__assert_msg_fail=>__lm_light_printf=>fmt_vfctprintf=>stdio_putchar=>__assert_msg_fail=?=>__lm_light_printf",
- "__assert_msg_fail=>__lm_light_printf=>fmt_vfctprintf=>stdio_putchar=>__assert_msg_fail=?=>__lm_abort",
- ]
- return orig_model.fn(chain, node, call)
-
- models[BaseName("__assert_msg_fail")] = SkipModel(
- orig_model.nchain, wrapped_model_fn
- )
- return models
-
- def test_filter(name: QName) -> tuple[int, bool]:
- if name.base() == BaseName("main"):
- return 1, True
- return 0, False
-
- result = analyze.analyze(
- ci_fnames=[],
- app_func_filters={
- "Main": test_filter,
- },
- app=util.PluginApplication(
- testutil.nop_location_xform, [graph_plugin, SkipPlugin()]
- ),
- cfg_max_call_depth=max_call_depth,
- )
-
- graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("main")].nstatic, exp)
-
-
-def test_fct() -> None:
- # 1. | a + | b + | c + |*
- # 2. | fmt_vsnprintf + | vprintf + | __lm_light_printf + |*
- # 3. | fmt_vfctprintf + | fmt_vfctprintf + | fmt_vfctprintf + |
- # 4. | fmt_state_putchar + | fmt_state_putchar + | fmt_state_putchar + |
- # 5. | _out_buffer + | stdio_buffered_printer + | libfmt_light_fct + |*
- # 6. | | __assert_msg_fail + | __assert_msg_fail + |
- # 7. | | a. __lm_light_printf + | a. __lm_light_printf + |
- # 8. | | a. fmt_vfctprintf + | a. fmt_vfctprintf + |
- # 9. | | a. fmt_state_putchar + | a. fmt_state_putchar + |
- # 10. | | a. libfmt_light_fct + | a. libfmt_light_fct + |
- # 11. | | a. __assert_msg_fail + | a. __assert_msg_fail + |
- # 12. | | a. __lm_abort + | a. __lm_abort + |
- # 7. | | b. __lm_abort | b. __lm_abort |
- max_call_depth = 12
- exp_a = ["a", "fmt_vsnprintf", "fmt_vfctprintf", "fmt_state_putchar", "_out_buffer"]
- exp_b = [
- "b",
- "__wrap_vprintf",
- "fmt_vfctprintf",
- "fmt_state_putchar",
- "stdio_buffered_printer",
- "__assert_msg_fail",
- "__lm_light_printf",
- "fmt_vfctprintf",
- "fmt_state_putchar",
- "libfmt_light_fct",
- "__assert_msg_fail",
- "__lm_abort",
- ]
- exp_c = [
- "c",
- "__lm_light_printf",
- "fmt_vfctprintf",
- "fmt_state_putchar",
- "libfmt_light_fct",
- "__assert_msg_fail",
- "__lm_light_printf",
- "fmt_vfctprintf",
- "fmt_state_putchar",
- "libfmt_light_fct",
- "__assert_msg_fail",
- "__lm_abort",
- ]
- graph: typing.Sequence[tuple[str, typing.Collection[str]]] = [
- # main.c
- ("a", {"fmt_vsnprintf"}), # _out_buffer
- ("b", {"vprintf"}), # stdio_buffered_printer
- ("c", {"__lm_light_printf"}), # libfmt_light_printf
- # wrappers
- ("fmt_vsnprintf", {"fmt_vfctprintf"}),
- ("__wrap_vprintf", {"fmt_vfctprintf"}),
- ("__lm_light_printf", {"fmt_vfctprintf"}),
- # printf.c
- ("fmt_vfctprintf", {"fmt_state_putchar"}),
- (
- "fmt_state_putchar",
- {"_out_buffer", "stdio_buffered_printer", "libfmt_light_fct"},
- ),
- # fcts
- ("_out_buffer", {}),
- ("stdio_buffered_printer", {"__assert_msg_fail"}),
- ("libfmt_light_fct", {"__assert_msg_fail"}),
- # assert.c
- ("__assert_msg_fail", {"__lm_light_printf", "__lm_abort"}),
- # intercept.c / libfmt/libmisc.c
- ("__lm_abort", {}),
- ]
- graph_plugin = testutil.GraphProviderPlugin(max_call_depth, graph)
-
- plugins: list[util.Plugin] = [
- graph_plugin,
- app_plugins.LibMiscPlugin(arg_c_fnames=[]),
- # fmt_vsnprintf => fct=_out_buffer
- # if rp2040:
- # __wrap_vprintf => fct=stdio_buffered_printer
- # stdio_vprintf => fct=stdio_buffered_printer
- # __lm_light_printf => fct=libfmt_light_fct
- # if host:
- # __lm_printf => fct=libfmt_libc_fct
- # __lm_light_printf => fct=libfmt_libc_fct
- app_plugins.PicoFmtPlugin("rp2040", []),
- ]
-
- def test_filter(name: QName) -> tuple[int, bool]:
- if str(name.base()) in ["a", "b", "c"]:
- return 1, True
- return 0, False
-
- result = analyze.analyze(
- ci_fnames=[],
- app_func_filters={
- "Main": test_filter,
- },
- app=util.PluginApplication(testutil.nop_location_xform, plugins),
- cfg_max_call_depth=max_call_depth,
- )
-
- graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("a")].nstatic, exp_a)
- graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("b")].nstatic, exp_b)
- graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("c")].nstatic, exp_c)
-
-
-def test_assert_formatter() -> None:
- # _________________________________________________________
- # | |
- # | |
- # | main |
- # | | |
- # | _ __wrap_vprintf |
- # | / \ | _______________ |
- # | | fmt_vfctprintf / \ |
- # | | \ fmt_state_printf | |
- # | | \____ ____/ | |
- # | | \ / | |
- # | | _vfctprintf | |
- # | | ____/ \____ ^ |
- # | | / ?<---snip | |
- # | | conv_builtin \ | |
- # | | | libfmt_conv_formatter | |
- # | | | | | |
- # | ^ \ lib9p_msg_Rread_format | |
- # | | \ _____________/ | \______/ |
- # | | \ / \ |
- # | | fmt_state_putchar \ |
- # | | ?<-?<--------snip | |
- # | | / \_________ | |
- # | | / \ | |
- # | | stdio_buffered_printer \ | |
- # | | \ libfmt_light_fct | |
- # | | \ | / |
- # | | \_______ | ________/ |
- # | | \ | / |
- # | | __assert_msg_fail |
- # | | ___/ \____ |
- # | | snip--->? \ |
- # | | / \ |
- # | | __lm_light_printf \ |
- # | \____________/ __lm_abort |
- # | |
- # |_________________________________________________________|
- #
- graph: typing.Sequence[tuple[str, typing.Collection[str]]] = [
- ("main", {"vprintf"}),
- ("__wrap_vprintf", {"fmt_vfctprintf"}),
- ("fmt_vfctprintf", {"_vfctprintf"}),
- ("fmt_state_printf", {"_vfctprintf"}),
- ("_vfctprintf", {"conv_builtin", "libfmt_conv_formatter"}),
- ("conv_builtin", {"fmt_state_putchar"}),
- ("libfmt_conv_formatter", {"lib9p_msg_Rread_format"}),
- (
- "lib9p_msg_Rread_format",
- {"fmt_state_putchar", "__assert_msg_fail", "fmt_state_printf"},
- ),
- ("fmt_state_putchar", {"stdio_buffered_printer", "libfmt_light_fct"}),
- ("stdio_buffered_printer", {"__assert_msg_fail"}),
- ("libfmt_light_fct", {"__assert_msg_fail"}),
- ("__assert_msg_fail", {"__lm_light_printf", "__lm_abort"}),
- ("__lm_light_printf", {"fmt_vfctprintf"}),
- ("__lm_abort", {}),
- ]
-
- # fct-determining wrappers have their callees marked with "|":
- #
- # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <= call_depth
- # - main() ; +
- # - __wrap__vprintf() ; +
- # |- fmt_vfctprintf() ; +
- # | - _vfctprintf() ; +
- # | - conv_builtin() ;
- # | - fmt_state_putchar() ;
- # | - stdio_buffered_printer() ;
- # | - __assert_msg_fail() ;
- # | - __lm_light_printf() ;
- # | |- fmt_vfctprintf() ;
- # | | - _vfctprintf() ;
- # | | - conv_builtin() ;
- # | | - fmt_state_putchar() ;
- # | | - stdio_buffered_printer() ; skip (wrong fct)
- # | | - libfmt_light_fct() ;
- # | | - __assert_msg_fail() ;
- # | | - __lm_light_printf() ; skip (nested __assert_msg_fail)
- # | | - __lm_abort() ;
- # | | - libfmt_conv_formatter() ; skip (fct won't use %v)
- # | - __lm_abort() ;
- # | - libfmt_light_fct() ; skip (wrong fct)
- # | - libfmt_conv_formatter() ; +
- # | - lib9p_msg_Rread_format() ; +
- # | - fmt_state_putchar() ;
- # | - stdio_buffered_printer() ;
- # | - __assert_msg_fail() ;
- # | - __lm_light_printf() ;
- # | |- fmt_vfctprintf() ;
- # | | - _vfctprintf() ;
- # | | - conv_builtin() ;
- # | | - fmt_state_putchar() ;
- # | | - stdio_buffered_printer() ; skip (wrong fct)
- # | | - libfmt_light_fct() ;
- # | | - __assert_msg_fail() ;
- # | | - __lm_light_printf() ; skip (neseted __assert_msg_fail)
- # | | - __lm_abort() ;
- # | | - libfmt_conv_formatter() ; skip (fct won't use %v)
- # | - __lm_abort() ;
- # | - libfmt_light_fct() ; skip (wrong fct)
- # | - __assert_msg_fail() ;
- # | - __lm_light_printf() ;
- # | |- fmt_vfctprintf() ;
- # | | - _vfctprintf() ;
- # | | - conv_builtin() ;
- # | | - fmt_state_putchar() ;
- # | | - stdio_buffered_printer() ; skip (wrong fct)
- # | | - libfmt_light_fct() ;
- # | | - __assert_msg_fail() ;
- # | | - __lm_light_printf() ; skip (nested__assert_msg_fail)
- # | | - __lm_abort() ;
- # | | - libfmt_conv_formatter() ; skip (formatter won't use %v)
- # | - __lm_abort() ;
- # | - fmt_state_printf() ; +
- # | - _vfctprintf() ; +
- # | - conv_builtin() ; +
- # | - fmt_state_putchar() ; +
- # | - stdio_buffered_printer() ; +
- # | - __assert_msg_fail() ; +
- # | - __lm_light_printf() ; +
- # | |- fmt_vfctprintf() ; +
- # | | - _vfctprintf() ; +
- # | | - conv_builtin() ; +
- # | | - fmt_state_putchar() ; +
- # | | - stdio_buffered_printer() ; skip (wrong fct)
- # | | - libfmt_light_fct() ; +
- # | | - __assert_msg_fail() ; +
- # | | - __lm_light_printf() ; skip (neseted __assert_msg_fail)
- # | | - __lm_abort() ; +
- # | | - libfmt_conv_formatter() ; skip (fct won't use %v)
- # | - __lm_abort() ;
- # | - libfmt_light_fct() ; skip (wrong fct)
- # | - libfmt_conv_formatter() ; skip (formatter won't use %v)
- max_call_depth = 20
- exp = [
- "main",
- "__wrap_vprintf",
- "fmt_vfctprintf",
- "_vfctprintf",
- "libfmt_conv_formatter",
- "lib9p_msg_Rread_format",
- "fmt_state_printf",
- "_vfctprintf",
- "conv_builtin",
- "fmt_state_putchar",
- "stdio_buffered_printer",
- "__assert_msg_fail",
- "__lm_light_printf",
- "fmt_vfctprintf",
- "_vfctprintf",
- "conv_builtin",
- "fmt_state_putchar",
- "libfmt_light_fct",
- "__assert_msg_fail",
- "__lm_abort",
- ]
-
- graph_plugin = testutil.GraphProviderPlugin(max_call_depth, graph)
-
- plugins: list[util.Plugin] = [
- graph_plugin,
- app_plugins.LibMiscPlugin(arg_c_fnames=[]),
- app_plugins.PicoFmtPlugin("rp2040", [BaseName("lib9p_msg_Rread_format")]),
- ]
-
- def test_filter(name: QName) -> tuple[int, bool]:
- if name.base() == BaseName("main"):
- return 1, True
- return 0, False
-
- result = analyze.analyze(
- ci_fnames=[],
- app_func_filters={
- "Main": test_filter,
- },
- app=util.PluginApplication(testutil.nop_location_xform, plugins),
- cfg_max_call_depth=max_call_depth,
- )
-
- graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("main")].nstatic, exp)
diff --git a/cmd/sbc_harness/CMakeLists.txt b/cmd/sbc_harness/CMakeLists.txt
index 878e151..0e904ab 100644
--- a/cmd/sbc_harness/CMakeLists.txt
+++ b/cmd/sbc_harness/CMakeLists.txt
@@ -26,16 +26,13 @@ target_link_libraries(sbc_harness_objs
hardware_watchdog
libmisc
- libfmt
libusb
libdhcp
libhw_cr
lib9p_srv
lib9p_util
)
-pico_minimize_runtime(sbc_harness_objs
- INCLUDE PRINTF PRINTF_MINIMAL PRINTF_LONG_LONG PRINTF_PTRDIFF_T
-)
+pico_minimize_runtime(sbc_harness_objs)
target_compile_definitions(sbc_harness_objs PRIVATE
#PICO_USE_FASTEST_SUPPORTED_CLOCK=1
@@ -75,7 +72,6 @@ target_embed_sources(sbc_harness_objs sbc_harness static.h
static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/dhcp.bsd3-mit.txt
static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/newlib.txt
static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/pico-sdk.bsd3.txt
- static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/printf.mit.txt
static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/tinyusb.mit.txt
static/Documentation/harness_rom_bin.txt
static/Documentation/harness_flash_bin.txt
diff --git a/cmd/sbc_harness/config/tusb_config.h b/cmd/sbc_harness/config/tusb_config.h
index 5240311..2c7c02a 100644
--- a/cmd/sbc_harness/config/tusb_config.h
+++ b/cmd/sbc_harness/config/tusb_config.h
@@ -31,40 +31,31 @@
#ifndef _TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_
+#include <stdint.h> /* for uint{n}_t */
+
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------
-// Override the default definition of TU_ASSERT() to use our logging
+// Override the default TU_MESS_FAILED() and tu_print_*() to use our logging
//--------------------------------------------------------------------
-// "magically" select between the 1-arg and 2-args variants, inject a
-// stringified version of `_cond`.
-//
-// Note: Use GNU-C `, ##__VA_ARGS__`, not standard C `__VA_OPT__(,)
-// __VA_ARGS__`; because __VA_OPT__ doesn't handle present-but-empty
-// arguments the way that we need.
-#define TU_ASSERT(_cond, ...) \
- _GET_3RD_ARG(_cond, ##__VA_ARGS__, \
- _LIBMISC_TU_ASSERT_2ARGS, _LIBMISC_TU_ASSERT_1ARGS, _dummy) \
- (_cond, #_cond, ##__VA_ARGS__)
-
-#define _LIBMISC_TU_ASSERT_1ARGS(_cond, _cond_str) \
- _LIBMISC_TU_ASSERT_2ARGS(_cond, _cond_str, false)
-
-#define _LIBMISC_TU_ASSERT_2ARGS(_cond, _cond_str, _ret) \
- do { \
- if ( !(_cond) ) { \
- _libmisc_tu_mess_failed(_cond_str, \
- __FILE__, __LINE__, __func__); \
- TU_BREAKPOINT(); \
- return _ret; \
- } \
- } while (0)
-
-void _libmisc_tu_mess_failed(const char *expr,
- const char *file, unsigned int line, const char *func);
+#define TU_MESS_FAILED(_cond_str) _libmisc_tu_mess_failed(_cond_str, __FILE__, __LINE__, __func__)
+#define tu_print_str _libmisc_tu_print_str
+#define tu_print_byte _libmisc_tu_print_byte
+#define tu_print_base10 _libmisc_tu_print_base10
+#define tu_print_base16 _libmisc_tu_print_base16
+#define tu_print_base16_u8 _libmisc_tu_print_base16_u8
+#define tu_print_base16_u16 _libmisc_tu_print_base16_u16
+
+void _libmisc_tu_mess_failed(const char *expr, const char *file, unsigned int line, const char *func);
+void _libmisc_tu_print_str(const char *);
+void _libmisc_tu_print_byte(uint8_t);
+void _libmisc_tu_print_base10(unsigned long);
+void _libmisc_tu_print_base16(unsigned long);
+void _libmisc_tu_print_base16_u8(uint8_t);
+void _libmisc_tu_print_base16_u16(uint16_t);
//--------------------------------------------------------------------
// Configuration: common
diff --git a/cmd/sbc_harness/fs_harness_flash_bin.c b/cmd/sbc_harness/fs_harness_flash_bin.c
index f353ddd..3c3fa16 100644
--- a/cmd/sbc_harness/fs_harness_flash_bin.c
+++ b/cmd/sbc_harness/fs_harness_flash_bin.c
@@ -41,7 +41,7 @@ static_assert(DATA_HSIZE % FLASH_SECTOR_SIZE == 0);
[[noreturn]] static void __no_inline_not_in_flash_func(ab_flash_finalize)(uint8_t *buf) {
assert(buf);
- log_infof("copying upper flash to lower flash...");
+ log_infoln("copying upper flash to lower flash...");
cr_save_and_disable_interrupts();
@@ -53,7 +53,7 @@ static_assert(DATA_HSIZE % FLASH_SECTOR_SIZE == 0);
flash_range_program(off, buf, FLASH_SECTOR_SIZE);
}
- log_infof("rebooting...");
+ log_infoln("rebooting...");
watchdog_reboot(0, 0, 300);
@@ -71,7 +71,7 @@ static void ab_flash_initialize_zero(uint8_t *buf) {
memset(buf, 0, FLASH_SECTOR_SIZE);
- log_infof("zeroing upper flash...");
+ log_infoln("zeroing upper flash...");
for (size_t off = DATA_HSIZE; off < DATA_SIZE; off += FLASH_SECTOR_SIZE) {
if (memcmp(buf, DATA_START+off, FLASH_SECTOR_SIZE) == 0)
continue;
@@ -84,7 +84,7 @@ static void ab_flash_initialize_zero(uint8_t *buf) {
flash_range_program(off, buf, FLASH_SECTOR_SIZE);
cr_restore_interrupts(saved);
}
- log_debugf("... zeroed");
+ log_debugln("... zeroed");
}
/**
@@ -95,7 +95,7 @@ static void ab_flash_initialize_zero(uint8_t *buf) {
static void ab_flash_initialize(uint8_t *buf) {
assert(buf);
- log_infof("initializing upper flash...");
+ log_infoln("initializing upper flash...");
for (size_t off = 0; off < DATA_HSIZE; off += FLASH_SECTOR_SIZE) {
memcpy(buf, DATA_START+off, FLASH_SECTOR_SIZE);
if (memcmp(buf, DATA_START+DATA_HSIZE+off, FLASH_SECTOR_SIZE) == 0)
@@ -105,7 +105,7 @@ static void ab_flash_initialize(uint8_t *buf) {
flash_range_program(DATA_HSIZE+off, buf, FLASH_SECTOR_SIZE);
cr_restore_interrupts(saved);
}
- log_debugf("... initialized");
+ log_debugln("... initialized");
}
/**
@@ -123,14 +123,14 @@ static void ab_flash_write_sector(size_t pos, uint8_t *dat) {
pos += DATA_HSIZE;
- log_infof("write flash sector @ %zu...", pos);
+ log_infoln("write flash sector @ %zu...", pos);
if (memcmp(dat, DATA_START+pos, FLASH_SECTOR_SIZE) != 0) {
bool saved = cr_save_and_disable_interrupts();
flash_range_erase(pos, FLASH_SECTOR_SIZE);
flash_range_program(pos, dat, FLASH_SECTOR_SIZE);
cr_restore_interrupts(saved);
}
- log_debugf("... written");
+ log_debugln("... written");
}
/* srv_file *******************************************************************/
diff --git a/cmd/sbc_harness/fs_harness_uptime_txt.c b/cmd/sbc_harness/fs_harness_uptime_txt.c
index f7b755f..97246ea 100644
--- a/cmd/sbc_harness/fs_harness_uptime_txt.c
+++ b/cmd/sbc_harness/fs_harness_uptime_txt.c
@@ -4,11 +4,10 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-#include <stdio.h> /* for snprintf() */
-
#include <libhw/generic/alarmclock.h>
#include <util9p/static.h>
#include <libmisc/alloc.h> /* for heap_alloc(), free() */
+#include <libmisc/fmt.h> /* for fmt_snprint() */
#include "fs_harness_uptime_txt.h"
@@ -120,7 +119,7 @@ static void uptime_fio_pread(struct uptime_fio *self, struct lib9p_srv_ctx *ctx,
if (byte_offset == 0 || self->buf_len == 0) {
uint64_t now = LO_CALL(bootclock, get_time_ns);
- self->buf_len = snprintf(self->buf, sizeof(self->buf), "%"PRIu64"ns\n", now);
+ self->buf_len = fmt_snprint(self->buf, sizeof(self->buf), now, "ns\n");
}
if (byte_offset > (uint64_t)self->buf_len) {
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c
index de9751b..143bae0 100644
--- a/cmd/sbc_harness/main.c
+++ b/cmd/sbc_harness/main.c
@@ -61,7 +61,7 @@ enum { PATH_BASE = __COUNTER__ };
__VA_OPT__(,) __VA_ARGS__ \
}))
-struct lib9p_srv_file root =
+static struct lib9p_srv_file root =
STATIC_DIR("",
STATIC_DIR("Documentation",
STATIC_FILE("YOUR_RIGHTS_AND_OBLIGATIONS.md",
@@ -80,9 +80,6 @@ struct lib9p_srv_file root =
STATIC_FILE("pico-sdk.bsd3.txt",
.data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_pico_sdk_bsd3_txt_start,
.data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_pico_sdk_bsd3_txt_end),
- STATIC_FILE("printf.mit.txt",
- .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_printf_mit_txt_start,
- .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_printf_mit_txt_end),
STATIC_FILE("tinyusb.mit.txt",
.data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_tinyusb_mit_txt_start,
.data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_tinyusb_mit_txt_end),
@@ -132,7 +129,7 @@ static COROUTINE hello_world_cr(void *_chan) {
for (size_t i = 0;; i = (i+1) % strlen(msg)) {
int result = usb_keyboard_rpc_send_req(chan, (uint32_t)msg[i]);
if (result < 1) {
- log_errorf("error sending rune U+%d", (uint32_t)msg[i]);
+ log_errorln("error sending rune U+", msg[i]);
break;
}
}
@@ -176,7 +173,7 @@ static COROUTINE write9p_cr(void *) {
cr_end();
}
-const char *const hexdig = "0123456789ABCDEF";
+static const char *const hexdig = "0123456789ABCDEF";
static_assert(_CONFIG_9P_MAX_REQS <= 16);
COROUTINE init_cr(void *) {
@@ -249,7 +246,7 @@ int main() {
bootclock = rp2040_hwtimer(0);
stdio_uart_init();
/* char *hdr = "=" * (80-strlen("info : MAIN: ")); */
- log_infof("===================================================================");
+ log_infoln("===================================================================");
coroutine_add("init", init_cr, NULL);
coroutine_main();
assert_notreached("all coroutines exited");
diff --git a/cmd/sbc_harness/static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/printf.mit.txt b/cmd/sbc_harness/static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/printf.mit.txt
deleted file mode 120000
index 5a6e342..0000000
--- a/cmd/sbc_harness/static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/printf.mit.txt
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../3rd-party/pico-sdk/src/rp2_common/pico_printf/LICENSE \ No newline at end of file
diff --git a/cmd/sbc_harness/tusb_log.c b/cmd/sbc_harness/tusb_log.c
index fe2c688..09fe755 100644
--- a/cmd/sbc_harness/tusb_log.c
+++ b/cmd/sbc_harness/tusb_log.c
@@ -7,9 +7,16 @@
#define LOG_NAME TINY_USB
#include <libmisc/log.h>
+#include "tusb_config.h"
+
void _libmisc_tu_mess_failed(const char *expr,
const char *file, unsigned int line, const char *func) {
- log_errorf("%s:%u:%s(): assertion \"%s\" failed",
- file, line, func,
- expr);
+ log_errorln(file, ":", line, ":", func, "(): assertion ", (qstr, expr), " failed");
}
+
+void _libmisc_tu_print_str(const char *x) { fmt_print_str(_log_dest, x); }
+void _libmisc_tu_print_byte(uint8_t x) { fmt_print_byte(_log_dest, x); }
+void _libmisc_tu_print_base10(unsigned long x) { fmt_print_base10(_log_dest, x); }
+void _libmisc_tu_print_base16(unsigned long x) { fmt_print(_log_dest, "0x", (base16, x)); }
+void _libmisc_tu_print_base16_u8(uint8_t x) { fmt_print_base16_u8_(_log_dest, x); }
+void _libmisc_tu_print_base16_u16(uint16_t x) { fmt_print_base16_u16_(_log_dest, x); }
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt
index cff07ad..2a2f858 100644
--- a/lib9p/CMakeLists.txt
+++ b/lib9p/CMakeLists.txt
@@ -10,7 +10,6 @@ target_sources(lib9p_core INTERFACE
core_generated.c
)
target_link_libraries(lib9p_core INTERFACE
- libfmt
libhw_generic
libmisc
)
diff --git a/lib9p/core.c b/lib9p/core.c
index c777741..464b31d 100644
--- a/lib9p/core.c
+++ b/lib9p/core.c
@@ -7,7 +7,6 @@
#include <stdarg.h> /* for va_* */
#include <string.h> /* for strlen(), strnlen(), strncpy(), memcmp(), memset() */
-#include <libfmt/fmt.h> /* for fmt_vsnprintf() */
#include <libmisc/assert.h> /* for assert() */
#include <libmisc/endian.h> /* for uint32le_decode() */
#include <libmisc/log.h> /* for const_byte_str() */
@@ -62,46 +61,6 @@ bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) {
return ctx->err_msg[0];
}
-int _lib9p_error(struct lib9p_ctx *ctx,
-#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
- lib9p_errno_t linux_errno,
-#endif
- char const *msg) {
- if (lib9p_ctx_has_error(ctx))
- return -1;
- strncpy(ctx->err_msg, msg, sizeof(ctx->err_msg));
- ctx->err_msg[sizeof(ctx->err_msg)-1] = '\0';
-
-#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
- ctx->err_num = linux_errno;
-#endif
-
- return -1;
-}
-
-int _lib9p_errorf(struct lib9p_ctx *ctx,
-#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
- lib9p_errno_t linux_errno,
-#endif
- char const *fmt, ...) {
- int n;
- va_list args;
-
- if (lib9p_ctx_has_error(ctx))
- return -1;
- va_start(args, fmt);
- n = fmt_vsnprintf(ctx->err_msg, sizeof(ctx->err_msg), fmt, args);
- va_end(args);
- if ((size_t)(n+1) < sizeof(ctx->err_msg))
- memset(&ctx->err_msg[n+1], 0, sizeof(ctx->err_msg)-(n+1));
-
-#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
- ctx->err_num = linux_errno;
-#endif
-
- return -1;
-}
-
/* bounds checks **************************************************************/
static inline void assert_ver(enum lib9p_version ver) {
@@ -141,112 +100,94 @@ const char *lib9p_msgtype_str(enum lib9p_version ver, enum lib9p_msg_type typ) {
return _lib9p_table_msg[ver][typ].name ?: const_byte_str(typ);
}
-lo_interface fmt_formatter lo_box_lib9p_msg_as_fmt_formatter(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body) {
- assert(ctx);
- assert_ver(ctx->version);
- assert_typ(typ);
- assert(_lib9p_table_msg[ctx->version][typ].box_as_fmt_formatter);
- return _lib9p_table_msg[ctx->version][typ].box_as_fmt_formatter(body);
-}
-
/* main message functions *****************************************************/
-static
-ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit,
- const char *xxx_errmsg,
- const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0x80],
- struct lib9p_ctx *ctx, uint8_t *net_bytes) {
- assert_ver(ctx->version);
- /* Inspect the first 5 bytes ourselves. */
- uint32_t net_size = uint32le_decode(net_bytes);
- if (net_size < 5)
- return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is impossibly short");
- uint8_t typ = net_bytes[4];
- if (typ % 2 != xxx_low_typ_bit)
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "%s: message_type=%s", xxx_errmsg,
- lib9p_msgtype_str(ctx->version, typ));
- struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2];
- if (!tentry.validate)
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "unknown message type: %s (protocol_version=%s)",
- lib9p_msgtype_str(ctx->version, typ), lib9p_version_str(ctx->version));
-
- /* Now use the message-type-specific tentry to process the whole thing. */
- return tentry.validate(ctx, net_size, net_bytes);
-}
+void fmt_print_lib9p_msg(lo_interface fmt_dest w, struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body) {
+ assert(ctx);
+ assert_ver(ctx->version);
+ assert_typ(typ);
+ assert(_lib9p_table_msg[ctx->version][typ].print);
+ _lib9p_table_msg[ctx->version][typ].print(w, ctx, body);
+}
+
+#define _lib9p_validate(LOW_TYP_BIT, ERRMSG, TABLE) do { \
+ assert_ver(ctx->version); \
+ /* Inspect the first 5 bytes ourselves. */ \
+ uint32_t net_size = uint32le_decode(net_bytes); \
+ if (net_size < 5) \
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is impossibly short"); \
+ uint8_t typ = net_bytes[4]; \
+ if (typ % 2 != LOW_TYP_BIT) \
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, ERRMSG ": message_type=", lib9p_msgtype_str(ctx->version, typ)); \
+ struct _lib9p_recv_tentry tentry = TABLE[ctx->version][typ/2]; \
+ if (!tentry.validate) \
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "unknown message type: ", lib9p_msgtype_str(ctx->version, typ), \
+ " (protocol_version=", lib9p_version_str(ctx->version), ")"); \
+ \
+ /* Now use the message-type-specific tentry to process the whole thing. */ \
+ return tentry.validate(ctx, net_size, net_bytes); \
+} while (0)
ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) {
- return _lib9p_validate(0, "expected a T-message but got an R-message", _lib9p_table_Tmsg_recv,
- ctx, net_bytes);
+ _lib9p_validate(0, "expected a T-message but got an R-message", _lib9p_table_Tmsg_recv);
}
ssize_t lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) {
- return _lib9p_validate(1, "expected an R-message but got a T-message", _lib9p_table_Rmsg_recv,
- ctx, net_bytes);
+ _lib9p_validate(1, "expected an R-message but got a T-message", _lib9p_table_Rmsg_recv);
}
-static
-void _lib9p_unmarshal(const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0x80],
- struct lib9p_ctx *ctx, uint8_t *net_bytes,
- enum lib9p_msg_type *ret_typ, void *ret_body) {
- assert_ver(ctx->version);
- enum lib9p_msg_type typ = net_bytes[4];
- *ret_typ = typ;
- struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2];
- assert(tentry.unmarshal);
-
- tentry.unmarshal(ctx, net_bytes, ret_body);
-}
+#define _lib9p_unmarshal(TABLE) do { \
+ assert_ver(ctx->version); \
+ enum lib9p_msg_type typ = net_bytes[4]; \
+ *ret_typ = typ; \
+ struct _lib9p_recv_tentry tentry = TABLE[ctx->version][typ/2]; \
+ assert(tentry.unmarshal); \
+ \
+ tentry.unmarshal(ctx, net_bytes, ret_body); \
+} while (0)
void lib9p_Tmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
enum lib9p_msg_type *ret_typ, void *ret_body) {
- _lib9p_unmarshal(_lib9p_table_Tmsg_recv,
- ctx, net_bytes, ret_typ, ret_body);
+ _lib9p_unmarshal(_lib9p_table_Tmsg_recv);
}
void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
enum lib9p_msg_type *ret_typ, void *ret_body) {
- _lib9p_unmarshal(_lib9p_table_Rmsg_recv,
- ctx, net_bytes, ret_typ, ret_body);
-}
-
-static
-bool _lib9p_marshal(const struct _lib9p_send_tentry xxx_table[LIB9P_VER_NUM][0x80],
- struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
- size_t *ret_iov_cnt, struct iovec *ret_iov, uint8_t *ret_copied) {
- assert_ver(ctx->version);
- assert_typ(typ);
- struct _marshal_ret ret = {
- .net_iov_cnt = 1,
- .net_iov = ret_iov,
- .net_copied_size = 0,
- .net_copied = ret_copied,
- };
- struct _lib9p_send_tentry tentry = xxx_table[ctx->version][typ/2];
- assert(tentry.marshal);
-
- bool ret_erred = tentry.marshal(ctx, body, &ret);
- if (ret_iov[ret.net_iov_cnt-1].iov_len == 0)
- ret.net_iov_cnt--;
- *ret_iov_cnt = ret.net_iov_cnt;
- return ret_erred;
-}
+ _lib9p_unmarshal(_lib9p_table_Rmsg_recv);
+}
+
+#define _lib9p_marshal(LOW_TYP_BIT, TABLE) do { \
+ assert_ver(ctx->version); \
+ assert(typ % 2 == LOW_TYP_BIT); \
+ assert_typ(typ); \
+ \
+ memset(ret, 0, sizeof(*ret)); \
+ \
+ struct _marshal_ret _ret = { \
+ .net_iov_cnt = 1, \
+ .net_iov = ret->iov, \
+ .net_copied_size = 0, \
+ .net_copied = ret->copied, \
+ }; \
+ struct _lib9p_send_tentry tentry = TABLE[ctx->version][typ/2]; \
+ assert(tentry.marshal); \
+ \
+ bool ret_erred = tentry.marshal(ctx, body, &_ret); \
+ if (_ret.net_iov[_ret.net_iov_cnt-1].iov_len == 0) \
+ _ret.net_iov_cnt--; \
+ \
+ ret->iov_cnt = _ret.net_iov_cnt; \
+ return ret_erred; \
+} while (0)
bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
struct lib9p_Tmsg_send_buf *ret) {
- assert(typ % 2 == 0);
- memset(ret, 0, sizeof(*ret));
- return _lib9p_marshal(_lib9p_table_Tmsg_send,
- ctx, typ, body,
- &ret->iov_cnt, ret->iov, ret->copied);
+ _lib9p_marshal(0, _lib9p_table_Tmsg_send);
}
bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
struct lib9p_Rmsg_send_buf *ret) {
- assert(typ % 2 == 1);
- memset(ret, 0, sizeof(*ret));
- return _lib9p_marshal(_lib9p_table_Rmsg_send,
- ctx, typ, body,
- &ret->iov_cnt, ret->iov, ret->copied);
+ _lib9p_marshal(1, _lib9p_table_Rmsg_send);
}
/* `struct lib9p_stat` helpers ************************************************/
diff --git a/lib9p/core_gen/c.py b/lib9p/core_gen/c.py
index 393766b..60ceb70 100644
--- a/lib9p/core_gen/c.py
+++ b/lib9p/core_gen/c.py
@@ -7,7 +7,7 @@ import sys
import idl
-from . import c9util, c_format, c_marshal, c_unmarshal, c_validate, cutil
+from . import c9util, c_fmt_print, c_marshal, c_unmarshal, c_validate, cutil
# This strives to be "general-purpose" in that it just acts on the
# *.9p inputs; but (unfortunately?) there are a few special-cases in
@@ -35,15 +35,6 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
#include "core_tables.h"
#include "core_utf8.h"
"""
- # libmisc/obj.h vtables ####################################################
- ret += """
-/* libmisc/obj.h vtables ******************************************************/
-"""
- for typ in typs:
- ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions))
- ret += f"LO_IMPLEMENTATION_C(fmt_formatter, {c9util.typename(typ)}, {c9util.basename(typ)}, static);\n"
- ret += cutil.ifdef_pop(0)
-
# utilities ################################################################
ret += """
/* utilities ******************************************************************/
@@ -111,8 +102,8 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
# marshal_* ################################################################
ret += c_marshal.gen_c_marshal(versions, typs)
- # *_format #################################################################
- ret += c_format.gen_c_format(versions, typs)
+ # fmt_print_* ##############################################################
+ ret += c_fmt_print.gen_c_fmt_print(versions, typs)
# tables.h #################################################################
ret += """
@@ -156,8 +147,8 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
ret += "\n"
ret += cutil.macro(
f"#define _MSG(typ) [{c9util.Ident('TYP_')}##typ] = {{\n"
- f"\t\t.name = #typ,\n"
- f"\t\t.box_as_fmt_formatter = (_box_as_fmt_formatter_fn_t)lo_box_{c9util.ident('msg_')}##typ##_as_fmt_formatter,\n"
+ f"\t\t.name = #typ,\n"
+ f"\t\t.print = (_print_fn_t)fmt_print_##typ,\n"
f"\t}}\n"
)
ret += msg_table("_msg_tentry", "_table_msg", "_MSG", (0, 0x100, 1))
diff --git a/lib9p/core_gen/c_format.py b/lib9p/core_gen/c_fmt_print.py
index c633fbb..eaacddb 100644
--- a/lib9p/core_gen/c_format.py
+++ b/lib9p/core_gen/c_fmt_print.py
@@ -1,4 +1,4 @@
-# lib9p/core_gen/c_format.py - Generate C pretty-print functions
+# lib9p/core_gen/c_fmt_print.py - Generate C pretty-print functions
#
# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
@@ -6,14 +6,14 @@
import idl
-from . import c9util, cutil
+from . import c9util, cutil, idlutil
# This strives to be "general-purpose" in that it just acts on the
# *.9p inputs; but (unfortunately?) there are a few special-cases in
# this script, marked with "SPECIAL".
# pylint: disable=unused-variable
-__all__ = ["gen_c_format"]
+__all__ = ["gen_c_fmt_print"]
def bf_numname(typ: idl.Bitfield, num: idl.BitNum, base: str) -> str:
@@ -21,46 +21,34 @@ def bf_numname(typ: idl.Bitfield, num: idl.BitNum, base: str) -> str:
return c9util.Ident(c9util.add_prefix(prefix, base))
-def ext_printf(line: str) -> str:
- assert line.startswith("\t")
- assert line.endswith("\n")
- # It sucks that %v trips -Wformat and -Wformat-extra-args
- # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47781
- ret = "#pragma GCC diagnostic push\n"
- ret += '#pragma GCC diagnostic ignored "-Wformat"\n'
- ret += '#pragma GCC diagnostic ignored "-Wformat-extra-args"\n'
- ret += line
- ret += "#pragma GCC diagnostic pop\n"
- return ret
-
-
-def gen_c_format(versions: set[str], typs: list[idl.UserType]) -> str:
+def gen_c_fmt_print(versions: set[str], typs: list[idl.UserType]) -> str:
ret = """
-/* *_format *******************************************************************/
+/* fmt_print_* ****************************************************************/
"""
- for typ in typs:
+ for typ in idlutil.topo_sorted(typs):
ret += "\n"
ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions))
- ret += f"static void {c9util.basename(typ)}_format({c9util.typename(typ)} *self, struct fmt_state *state) {{\n"
+ storage = "" if typ.typname == "stat" else "static " # SPECIAL (stat is public)
+ ret += f"[[maybe_unused]] {storage}void fmt_print_{typ.typname}(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, {c9util.typename(typ)} *self) {{\n"
match typ:
case idl.Number():
if typ.vals:
ret += "\tswitch (*self) {\n"
for name in typ.vals:
ret += f"\tcase {c9util.Ident(c9util.add_prefix(f'{typ.typname}_'.upper(), name))}:\n"
- ret += f'\t\tfmt_state_puts(state, "{name}");\n'
+ ret += f'\t\tfmt_print_str(w, "{name}");\n'
ret += "\t\tbreak;\n"
ret += "\tdefault:\n"
- ret += f'\t\tfmt_state_printf(state, "%"PRIu{typ.static_size*8}, *self);\n'
+ ret += "\t\tfmt_print_base10(w, *self);\n"
ret += "\t}\n"
else:
- ret += f'\t\tfmt_state_printf(state, "%"PRIu{typ.static_size*8}, *self);\n'
+ ret += "\t\tfmt_print_base10(w, *self);\n"
case idl.Bitfield():
val = "*self"
if typ.typname == "dm": # SPECIAL (pretty file permissions)
val = f"(*self & ~(({c9util.typename(typ)})0777))"
ret += "\tbool empty = true;\n"
- ret += "\tfmt_state_putchar(state, '(');\n"
+ ret += "\tfmt_print_byte(w, '(');\n"
nums: set[str] = set()
for bit in reversed(typ.bits):
@@ -72,8 +60,8 @@ def gen_c_format(versions: set[str], typs: list[idl.UserType]) -> str:
bitname = bit.bitname
ret += f"\tif ({val} & (UINT{typ.static_size*8}_C(1)<<{bit.num})) {{\n"
ret += "\t\tif (!empty)\n"
- ret += "\t\t\tfmt_state_putchar(state, '|');\n"
- ret += f'\t\tfmt_state_puts(state, "{bitname}");\n'
+ ret += "\t\t\tfmt_print_byte(w, '|');\n"
+ ret += f'\t\tfmt_print_str(w, "{bitname}");\n'
ret += "\t\tempty = false;\n"
ret += "\t}\n"
case idl.BitNum():
@@ -86,34 +74,32 @@ def gen_c_format(versions: set[str], typs: list[idl.UserType]) -> str:
f"{bit.cat.numname}_".upper(), name
)
ret += "\t\tif (!empty)\n"
- ret += "\t\t\tfmt_state_putchar(state, '|');\n"
- ret += f'\t\tfmt_state_puts(state, "{bitname}");\n'
+ ret += "\t\t\tfmt_print_byte(w, '|');\n"
+ ret += f'\t\tfmt_print_str(w, "{bitname}");\n'
ret += "\t\tempty = false;\n"
ret += "\t\tbreak;\n"
ret += "\tdefault:\n"
ret += "\t\tif (!empty)\n"
- ret += "\t\t\tfmt_state_putchar(state, '|');\n"
- ret += f'\t\tfmt_state_printf(state, "%"PRIu{typ.static_size*8}, {val} & {bf_numname(typ, bit.cat, 'MASK')});\n'
+ ret += "\t\t\tfmt_print_byte(w, '|');\n"
+ ret += f"\t\tfmt_print_base10(w, {val} & {bf_numname(typ, bit.cat, 'MASK')});\n"
ret += "\t\tempty = false;\n"
ret += "\t}\n"
nums.add(bit.cat.numname)
if typ.typname == "dm": # SPECIAL (pretty file permissions)
ret += "\tif (!empty)\n"
- ret += "\t\tfmt_state_putchar(state, '|');\n"
- ret += f'\tfmt_state_printf(state, "%#04"PRIo{typ.static_size*8}, *self & 0777);\n'
+ ret += "\t\tfmt_print_byte(w, '|');\n"
+ ret += "\tfmt_print(w, (rjust, 4, '0', (base8, *self & 0777)));\n"
else:
ret += "\tif (empty)\n"
- ret += "\t\tfmt_state_putchar(state, '0');\n"
- ret += "\tfmt_state_putchar(state, ')');\n"
+ ret += "\t\tfmt_print_byte(w, '0');\n"
+ ret += "\tfmt_print_byte(w, ')');\n"
case idl.Struct(typname="s"): # SPECIAL (string)
- ret += ext_printf(
- '\tfmt_state_printf(state, "%.*q", self->len, self->utf8);\n'
- )
+ ret += "\tfmt_print_qmem(w, self->utf8, self->len);\n"
case idl.Struct(): # and idl.Message():
if isinstance(typ, idl.Message):
- ret += f'\tfmt_state_puts(state, "{typ.typname} {{");\n'
+ ret += f'\tfmt_print_str(w, "{typ.typname} {{");\n'
else:
- ret += "\tfmt_state_putchar(state, '{');\n"
+ ret += "\tfmt_print_byte(w, '{');\n"
for member in typ.members:
if member.val:
continue
@@ -127,35 +113,33 @@ def gen_c_format(versions: set[str], typs: list[idl.UserType]) -> str:
cnt_typ = c9util.typename(member.cnt.typ)
if member.typ.static_size == 1: # SPECIAL (data)
ret += f"\tif (is_valid_utf8_without_nul((uint8_t *)self->{member.membname}, (size_t){cnt_str})) {{\n"
- ret += ext_printf(
- f'\t\tfmt_state_printf(state, " {member.membname}=%.*q%s",\n'
- f"\t\t\t(int)({cnt_str} < 50 ? {cnt_str} : 50),\n"
- f"\t\t\t(char *)self->{member.membname},\n"
- f'\t\t\t{cnt_str} < 50 ? "" : "...");\n'
- )
+ ret += f'\t\tfmt_print_str(w, " {member.membname}=");\n'
+ ret += f"\t\tfmt_print_qmem(w, self->{member.membname}, {cnt_str} < 50 ? {cnt_str} : 50);\n"
+ ret += f"\t\tif ({cnt_str} > 50)\n"
+ ret += '\t\t\tfmt_print_str(w, "...");\n'
ret += "\t} else {\n"
- ret += f'\t\tfmt_state_puts(state, " {member.membname}=<bytedata>");\n'
+ ret += f'\t\tfmt_print_str(w, " {member.membname}=<bytedata>");\n'
ret += "\t}\n"
continue
- ret += f'\tfmt_state_puts(state, " {member.membname}=[");\n'
+ ret += f'\tfmt_print_str(w, " {member.membname}=[");\n'
ret += f"\tfor ({cnt_typ} i = 0; i < {cnt_str}; i++) {{\n"
ret += "\t\tif (i)\n"
- ret += "\t\t\tfmt_state_putchar(state, ',');\n"
- ret += "\t\tfmt_state_putchar(state, ' ');\n"
+ ret += "\t\t\tfmt_print_byte(w, ',');\n"
+ ret += "\t\tfmt_print_byte(w, ' ');\n"
if isinstance(member.typ, idl.Primitive):
- ret += f'\t\tfmt_state_printf(state, "%"PRIu{member.typ.static_size*8}, self->{member.membname}[i]);\n'
+ ret += f"\t\tfmt_print_base10(w, self->{member.membname}[i]);\n"
else:
- ret += f"\t\t{c9util.basename(member.typ)}_format(&self->{member.membname}[i], state);\n"
+ ret += f"\t\tfmt_print_{member.typ.typname}(w, ctx, &self->{member.membname}[i]);\n"
ret += "\t}\n"
- ret += '\tfmt_state_puts(state, " ]");\n'
+ ret += '\tfmt_print_str(w, " ]");\n'
else:
- ret += f'\tfmt_state_puts(state, " {member.membname}=");\n'
+ ret += f'\tfmt_print_str(w, " {member.membname}=");\n'
if isinstance(member.typ, idl.Primitive):
- ret += f'\tfmt_state_printf(state, "%"PRIu{member.typ.static_size*8}, self->{member.membname});\n'
+ ret += f"\tfmt_print_base10(w, self->{member.membname});\n"
else:
- ret += f"\t{c9util.basename(member.typ)}_format(&self->{member.membname}, state);\n"
+ ret += f"\tfmt_print_{member.typ.typname}(w, ctx, &self->{member.membname});\n"
ret += cutil.ifdef_pop(1)
- ret += '\tfmt_state_puts(state, " }");\n'
+ ret += '\tfmt_print_str(w, " }");\n'
ret += "}\n"
ret += cutil.ifdef_pop(0)
diff --git a/lib9p/core_gen/c_marshal.py b/lib9p/core_gen/c_marshal.py
index 322e1ef..bddf55f 100644
--- a/lib9p/core_gen/c_marshal.py
+++ b/lib9p/core_gen/c_marshal.py
@@ -381,10 +381,9 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str:
else:
ret += "\tif (needed_size > ctx->max_msg_size) {\n"
if isinstance(typ, idl.Message): # SPECIAL (disable for stat)
- ret += f'\t\tlib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_ERANGE")}, "%s message too large to marshal into %s limit (%"PRIu{szbits}" > %"PRIu32")",\n'
- ret += f'\t\t\t"{typ.typname}",\n'
- ret += f'\t\t\tctx->version ? "negotiated" : "{'client' if typ.msgid % 2 == 0 else 'server'}",\n'
- ret += "\t\t\tneeded_size, ctx->max_msg_size);\n"
+ ret += f'\t\tlib9p_error(ctx, {c9util.IDENT("ERRNO_L_ERANGE")}, "{typ.typname} message too large to marshal into ",\n'
+ ret += f'\t\t\tctx->version ? "negotiated" : "{'client' if typ.msgid % 2 == 0 else 'server'}", " limit",\n'
+ ret += '\t\t\t" (", needed_size, " > ", ctx->max_msg_size, ")");\n'
ret += "\t\treturn true;\n"
ret += "\t}\n"
diff --git a/lib9p/core_gen/c_validate.py b/lib9p/core_gen/c_validate.py
index 3073ed0..9c55d8d 100644
--- a/lib9p/core_gen/c_validate.py
+++ b/lib9p/core_gen/c_validate.py
@@ -59,7 +59,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
"\t\t * that. */\n"
f'\t\treturn lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message is too short for content");\n'
"\tif (net_offset > net_size)\n"
- f'\t\treturn lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__);\n'
+ f'\t\treturn lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message is too short for content (", net_offset, " > ", net_size, ")");\n'
)
ret += cutil.macro(
"#define VALIDATE_NET_UTF8(n)\n"
@@ -190,11 +190,10 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
for tok in child.val.tokens
):
nbits = 32
- act = f"(uint{nbits}_t)GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
- exp = f"(uint{nbits}_t)({c9util.idl_expr(child.val, lookup_sym)})"
+ act = f"GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
+ exp = f"{c9util.idl_expr(child.val, lookup_sym)}"
ret += f"{'\t'*indent_lvl()}if ({act} != {exp})\n"
- ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "{path} value is wrong: actual: %"PRIu{nbits}" != correct:%"PRIu{nbits},\n'
- ret += f"{'\t'*(indent_lvl()+2)}{act}, {exp});\n"
+ ret += f'{"\t"*(indent_lvl()+1)}return lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "{path} value is wrong: actual:", (base10, {act}), " != correct:", (base10, {exp}));\n'
if child.max:
incr_flush()
assert child.typ.static_size
@@ -205,19 +204,18 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
for tok in child.max.tokens
):
nbits = 32
- act = f"(uint{nbits}_t)GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
- exp = f"(uint{nbits}_t)({c9util.idl_expr(child.max, lookup_sym)})"
+ act = f"GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
+ exp = f"{c9util.idl_expr(child.max, lookup_sym)}"
ret += f"{'\t'*indent_lvl()}if ({act} > {exp})\n"
- ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "{path} value is too large: %"PRIu{nbits}" > %"PRIu{nbits},\n'
- ret += f"{'\t'*(indent_lvl()+2)}{act}, {exp});\n"
+ ret += f'{"\t"*(indent_lvl()+1)}return lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "{path} value is too large: ", (base10, {act}), " > ", (base10, {exp}));\n'
if isinstance(child.typ, idl.Bitfield):
incr_flush()
nbytes = child.typ.static_size
nbits = nbytes * 8
act = f"GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
ret += f"{'\t'*indent_lvl()}if ({act} & ~{child.typ.typname}_masks[ctx->version])\n"
- ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "unknown bits in {child.typ.typname} bitfield: %#0{nbytes*2}"PRIx{nbits},\n'
- ret += f"{'\t'*(indent_lvl()+2)}{act} & ~{child.typ.typname}_masks[ctx->version]);\n"
+ ret += f'{"\t"*(indent_lvl()+1)}return lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "unknown bits in {child.typ.typname} bitfield: ",\n'
+ ret += f"{'\t'*(indent_lvl()+2)}(base16_u{nbits}_, {act} & ~{child.typ.typname}_masks[ctx->version]));\n"
def handle(
path: idlutil.Path,
diff --git a/lib9p/core_gen/h.py b/lib9p/core_gen/h.py
index 3c857c1..acf8415 100644
--- a/lib9p/core_gen/h.py
+++ b/lib9p/core_gen/h.py
@@ -163,12 +163,7 @@ def gen_h(versions: set[str], typs: list[idl.UserType]) -> str:
\t#error Do not include <lib9p/_core_generated.h> directly; include <lib9p/core.h> instead
#endif
-#include <stdint.h> /* for uint{{n}}_t types */
-
-#include <libfmt/fmt.h> /* for fmt_formatter */
-#include <libhw/generic/io.h> /* for struct iovec */
"""
-
id2typ: dict[int, idl.Message] = {}
for msg in [msg for msg in typs if isinstance(msg, idl.Message)]:
id2typ[msg.msgid] = msg
@@ -214,7 +209,6 @@ enum {c9util.ident('version')} {{
ret += cutil.ifdef_pop(0)
ret += f"\t{c9util.ver_enum('NUM')},\n"
ret += "};\n"
- ret += f"LO_IMPLEMENTATION_H(fmt_formatter, enum {c9util.ident('version')}, {c9util.ident('version')});\n"
ret += """
/* enum msg_type **************************************************************/
@@ -230,7 +224,6 @@ enum {c9util.ident('version')} {{
ret += f"\t{c9util.Ident(f'TYP_{msg.typname:<{namewidth}}')} = {msg.msgid},\n"
ret += cutil.ifdef_pop(0)
ret += "};\n"
- ret += f"LO_IMPLEMENTATION_H(fmt_formatter, enum {c9util.ident('msg_type')}, {c9util.ident('msg_type')});\n"
ret += """
/* payload types **************************************************************/
@@ -371,7 +364,6 @@ enum {c9util.ident('version')} {{
def gen_number(typ: idl.Number) -> str:
ret = f"typedef {c9util.typename(typ.prim)} {c9util.typename(typ)};\n"
- ret += f"LO_IMPLEMENTATION_H(fmt_formatter, {c9util.typename(typ)}, {c9util.basename(typ)});\n"
def lookup_sym(sym: str) -> str:
assert False
@@ -390,7 +382,6 @@ def gen_number(typ: idl.Number) -> str:
def gen_bitfield(typ: idl.Bitfield) -> str:
ret = f"typedef {c9util.typename(typ.prim)} {c9util.typename(typ)};\n"
- ret += f"LO_IMPLEMENTATION_H(fmt_formatter, {c9util.typename(typ)}, {c9util.basename(typ)});\n"
def lookup_sym(sym: str) -> str:
assert False
@@ -538,5 +529,4 @@ def gen_struct(typ: idl.Struct) -> str: # and idl.Message
ret += f"\t{c9util.typename(member.typ, member):<{typewidth}} {'*' if member.cnt else ' '}{member.membname};\n"
ret += cutil.ifdef_pop(1)
ret += "};\n"
- ret += f"LO_IMPLEMENTATION_H(fmt_formatter, {c9util.typename(typ)}, {c9util.basename(typ)});\n"
return ret
diff --git a/lib9p/core_generated.c b/lib9p/core_generated.c
index 2532d12..81ace7d 100644
--- a/lib9p/core_generated.c
+++ b/lib9p/core_generated.c
@@ -12,132 +12,6 @@
#include "core_tables.h"
#include "core_utf8.h"
-/* libmisc/obj.h vtables ******************************************************/
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_tag_t, lib9p_tag, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_fid_t, lib9p_fid, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_s, lib9p_s, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_dm_t, lib9p_dm, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_qt_t, lib9p_qt, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_qid, lib9p_qid, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_stat, lib9p_stat, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_o_t, lib9p_o, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tversion, lib9p_msg_Tversion, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rauth, lib9p_msg_Rauth, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rerror, lib9p_msg_Rerror, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tflush, lib9p_msg_Tflush, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rflush, lib9p_msg_Rflush, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Twalk, lib9p_msg_Twalk, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rwalk, lib9p_msg_Rwalk, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Topen, lib9p_msg_Topen, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Ropen, lib9p_msg_Ropen, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tcreate, lib9p_msg_Tcreate, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rcreate, lib9p_msg_Rcreate, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tread, lib9p_msg_Tread, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rread, lib9p_msg_Rread, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Twrite, lib9p_msg_Twrite, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rwrite, lib9p_msg_Rwrite, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tclunk, lib9p_msg_Tclunk, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rclunk, lib9p_msg_Rclunk, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tremove, lib9p_msg_Tremove, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rremove, lib9p_msg_Rremove, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tstat, lib9p_msg_Tstat, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rstat, lib9p_msg_Rstat, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rwstat, lib9p_msg_Rwstat, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_p9p
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Topenfd, lib9p_msg_Topenfd, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Ropenfd, lib9p_msg_Ropenfd, static);
-#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
-#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_nuid_t, lib9p_nuid, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_errno_t, lib9p_errno, static);
-#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_L
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_super_magic_t, lib9p_super_magic, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lo_t, lib9p_lo, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_dt_t, lib9p_dt, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_mode_t, lib9p_mode, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_b4_t, lib9p_b4, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_getattr_t, lib9p_getattr, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_setattr_t, lib9p_setattr, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lock_type_t, lib9p_lock_type, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lock_flags_t, lib9p_lock_flags, static);
-LO_IMPLEMENTATION_C(fmt_formatter, lib9p_lock_status_t, lib9p_lock_status, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlerror, lib9p_msg_Rlerror, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tstatfs, lib9p_msg_Tstatfs, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rstatfs, lib9p_msg_Rstatfs, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlopen, lib9p_msg_Tlopen, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlopen, lib9p_msg_Rlopen, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlcreate, lib9p_msg_Tlcreate, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlcreate, lib9p_msg_Rlcreate, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsymlink, lib9p_msg_Tsymlink, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsymlink, lib9p_msg_Rsymlink, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tmknod, lib9p_msg_Tmknod, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rmknod, lib9p_msg_Rmknod, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Trename, lib9p_msg_Trename, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rrename, lib9p_msg_Rrename, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Treadlink, lib9p_msg_Treadlink, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rreadlink, lib9p_msg_Rreadlink, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tgetattr, lib9p_msg_Tgetattr, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rgetattr, lib9p_msg_Rgetattr, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsetattr, lib9p_msg_Tsetattr, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsetattr, lib9p_msg_Rsetattr, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Txattrwalk, lib9p_msg_Txattrwalk, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rxattrwalk, lib9p_msg_Rxattrwalk, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Txattrcreate, lib9p_msg_Txattrcreate, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rxattrcreate, lib9p_msg_Rxattrcreate, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Treaddir, lib9p_msg_Treaddir, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rreaddir, lib9p_msg_Rreaddir, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tfsync, lib9p_msg_Tfsync, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rfsync, lib9p_msg_Rfsync, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlock, lib9p_msg_Tlock, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlock, lib9p_msg_Rlock, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tgetlock, lib9p_msg_Tgetlock, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rgetlock, lib9p_msg_Rgetlock, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tlink, lib9p_msg_Tlink, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rlink, lib9p_msg_Rlink, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tmkdir, lib9p_msg_Tmkdir, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rmkdir, lib9p_msg_Rmkdir, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Trenameat, lib9p_msg_Trenameat, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rrenameat, lib9p_msg_Rrenameat, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tunlinkat, lib9p_msg_Tunlinkat, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Runlinkat, lib9p_msg_Runlinkat, static);
-#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsession, lib9p_msg_Tsession, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsession, lib9p_msg_Rsession, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tsread, lib9p_msg_Tsread, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rsread, lib9p_msg_Rsread, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tswrite, lib9p_msg_Tswrite, static);
-LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite, static);
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-
/* utilities ******************************************************************/
#if CONFIG_9P_ENABLE_9P2000
#define _is_ver_9P2000(v) (v == LIB9P_VER_9P2000)
@@ -355,7 +229,7 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = {
* that. */ \
return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content"); \
if (net_offset > net_size) \
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content (", net_offset, " > ", net_size, ")");
#define VALIDATE_NET_UTF8(n) \
{ \
size_t len = n; \
@@ -387,8 +261,8 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *
uint32_t offsetof_qid_type = net_offset + 8;
VALIDATE_NET_BYTES(21);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
@@ -406,12 +280,11 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof__stat_size) != (uint32_t)(offsetof_end - offsetof_fstype))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "stat->_stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof__stat_size), (uint32_t)(offsetof_end - offsetof_fstype));
+ if (GET_U32LE(offsetof__stat_size) != offsetof_end - offsetof_fstype)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "stat->_stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof__stat_size)), " != correct:", (base10, offsetof_end - offsetof_fstype));
if (GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version]));
if (ret_net_size)
*ret_net_size = net_offset;
return (ssize_t)host_size;
@@ -427,12 +300,10 @@ static ssize_t validate_Tversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8
VALIDATE_NET_BYTES(13);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(100))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(100));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 100)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 100));
return (ssize_t)host_size;
}
@@ -444,12 +315,10 @@ static ssize_t validate_Rversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8
VALIDATE_NET_BYTES(13);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(101))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(101));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 101)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 101));
return (ssize_t)host_size;
}
@@ -470,12 +339,10 @@ static ssize_t validate_Tauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(102))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(102));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 102)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 102));
return (ssize_t)host_size;
}
@@ -487,15 +354,13 @@ static ssize_t validate_Rauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_aqid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(103))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(103));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 103)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 103));
return (ssize_t)host_size;
}
@@ -514,12 +379,10 @@ static ssize_t validate_Tattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(104))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(104));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 104)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 104));
return (ssize_t)host_size;
}
@@ -531,15 +394,13 @@ static ssize_t validate_Rattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(105))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(105));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 105)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 105));
return (ssize_t)host_size;
}
@@ -558,12 +419,10 @@ static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(107))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(107));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 107)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 107));
return (ssize_t)host_size;
}
@@ -576,12 +435,10 @@ static ssize_t validate_Tflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 9;
VALIDATE_NET_BYTES(9);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(108))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(108));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 108)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 108));
return (ssize_t)host_size;
}
@@ -592,12 +449,10 @@ static ssize_t validate_Rflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(109))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(109));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 109)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 109));
return (ssize_t)host_size;
}
@@ -614,15 +469,12 @@ static ssize_t validate_Twalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_UTF8(LAST_U16LE());
}
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(110))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(110));
- if ((uint16_t)GET_U16LE(offsetof_nwname) > (uint16_t)(16))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->nwname value is too large: %"PRIu16" > %"PRIu16,
- (uint16_t)GET_U16LE(offsetof_nwname), (uint16_t)(16));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 110)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 110));
+ if (GET_U16LE(offsetof_nwname) > 16)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->nwname value is too large: ", (base10, GET_U16LE(offsetof_nwname)), " > ", (base10, 16));
return (ssize_t)host_size;
}
@@ -638,19 +490,16 @@ static ssize_t validate_Rwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_wqid_type = net_offset + 0;
VALIDATE_NET_BYTES(13);
if (GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]));
}
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(111))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(111));
- if ((uint16_t)GET_U16LE(offsetof_nwqid) > (uint16_t)(16))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->nwqid value is too large: %"PRIu16" > %"PRIu16,
- (uint16_t)GET_U16LE(offsetof_nwqid), (uint16_t)(16));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 111)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 111));
+ if (GET_U16LE(offsetof_nwqid) > 16)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->nwqid value is too large: ", (base10, GET_U16LE(offsetof_nwqid)), " > ", (base10, 16));
return (ssize_t)host_size;
}
@@ -664,15 +513,13 @@ static ssize_t validate_Topen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_mode = net_offset + 11;
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(112))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(112));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 112)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 112));
if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -684,16 +531,14 @@ static ssize_t validate_Ropen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(113))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(113));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 113)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 113));
return (ssize_t)host_size;
}
@@ -708,18 +553,16 @@ static ssize_t validate_Tcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_mode = net_offset + 4;
uint32_t offsetof_end = net_offset + 5;
VALIDATE_NET_BYTES(5);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(114))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(114));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 114)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 114));
if (GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]));
if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -731,16 +574,14 @@ static ssize_t validate_Rcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(115))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(115));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 115)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 115));
return (ssize_t)host_size;
}
@@ -755,18 +596,14 @@ static ssize_t validate_Tread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_count = net_offset + 19;
uint32_t offsetof_end = net_offset + 23;
VALIDATE_NET_BYTES(23);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(116))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(116));
- if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->offset value is too large: %"PRIu64" > %"PRIu64,
- (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX));
- if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->count value is too large: %"PRIu32" > %"PRIu32,
- (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 116)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 116));
+ if (GET_U64LE(offsetof_offset) > INT64_MAX)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX));
+ if (GET_U32LE(offsetof_count) > INT32_MAX)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
return (ssize_t)host_size;
}
@@ -779,15 +616,12 @@ static ssize_t validate_Rread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_BYTES(11);
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(117))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(117));
- if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->count value is too large: %"PRIu32" > %"PRIu32,
- (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 117)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 117));
+ if (GET_U32LE(offsetof_count) > INT32_MAX)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
return (ssize_t)host_size;
}
@@ -801,18 +635,14 @@ static ssize_t validate_Twrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_BYTES(23);
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(118))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(118));
- if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->offset value is too large: %"PRIu64" > %"PRIu64,
- (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX));
- if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->count value is too large: %"PRIu32" > %"PRIu32,
- (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 118)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 118));
+ if (GET_U64LE(offsetof_offset) > INT64_MAX)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX));
+ if (GET_U32LE(offsetof_count) > INT32_MAX)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
return (ssize_t)host_size;
}
@@ -824,15 +654,12 @@ static ssize_t validate_Rwrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_count = net_offset + 7;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(119))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(119));
- if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->count value is too large: %"PRIu32" > %"PRIu32,
- (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 119)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 119));
+ if (GET_U32LE(offsetof_count) > INT32_MAX)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
return (ssize_t)host_size;
}
@@ -843,12 +670,10 @@ static ssize_t validate_Tclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(120))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(120));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 120)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 120));
return (ssize_t)host_size;
}
@@ -859,12 +684,10 @@ static ssize_t validate_Rclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(121))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(121));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 121)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 121));
return (ssize_t)host_size;
}
@@ -875,12 +698,10 @@ static ssize_t validate_Tremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(122))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(122));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 122)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 122));
return (ssize_t)host_size;
}
@@ -891,12 +712,10 @@ static ssize_t validate_Rremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(123))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(123));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 123)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 123));
return (ssize_t)host_size;
}
@@ -909,12 +728,10 @@ static ssize_t validate_Tstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(124))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(124));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 124)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 124));
return (ssize_t)host_size;
}
@@ -930,8 +747,8 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_stat_qid_type = net_offset + 17;
VALIDATE_NET_BYTES(30);
if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_stat_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
@@ -949,22 +766,18 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_stat_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->stat._stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_stat__stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_fstype));
+ if (GET_U32LE(offsetof_stat__stat_size) != offsetof_stat_end - offsetof_stat_fstype)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype));
if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(125))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(125));
- if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 125)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 125));
+ if (GET_U32LE(offsetof_nstat) != offsetof_end - offsetof_stat)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat));
return (ssize_t)host_size;
}
@@ -980,8 +793,8 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_stat_qid_type = net_offset + 21;
VALIDATE_NET_BYTES(34);
if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_stat_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
@@ -999,22 +812,18 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_stat_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->stat._stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_stat__stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_fstype));
+ if (GET_U32LE(offsetof_stat__stat_size) != offsetof_stat_end - offsetof_stat_fstype)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype));
if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(126))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(126));
- if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 126)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 126));
+ if (GET_U32LE(offsetof_nstat) != offsetof_end - offsetof_stat)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat));
return (ssize_t)host_size;
}
@@ -1025,12 +834,10 @@ static ssize_t validate_Rwstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(127))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(127));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 127)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 127));
return (ssize_t)host_size;
}
@@ -1044,15 +851,13 @@ static ssize_t validate_Topenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_mode = net_offset + 11;
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(98))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(98));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 98)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 98));
if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1064,16 +869,14 @@ static ssize_t validate_Ropenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 8;
VALIDATE_NET_BYTES(8);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(99))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(99));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 99)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 99));
return (ssize_t)host_size;
}
@@ -1086,12 +889,10 @@ static ssize_t validate_Rlerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(7))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(7));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 7)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 7));
return (ssize_t)host_size;
}
@@ -1102,12 +903,10 @@ static ssize_t validate_Tstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(8))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(8));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 8)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 8));
return (ssize_t)host_size;
}
@@ -1118,12 +917,10 @@ static ssize_t validate_Rstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 67;
VALIDATE_NET_BYTES(67);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(9))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(9));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 9)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 9));
return (ssize_t)host_size;
}
@@ -1135,15 +932,13 @@ static ssize_t validate_Tlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_flags = net_offset + 11;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(12))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(12));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 12)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 12));
if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1155,16 +950,14 @@ static ssize_t validate_Rlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(13))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(13));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 13)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 13));
return (ssize_t)host_size;
}
@@ -1179,18 +972,16 @@ static ssize_t validate_Tlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_mode = net_offset + 4;
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(14))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(14));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 14)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 14));
if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1202,16 +993,14 @@ static ssize_t validate_Rlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(15))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(15));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 15)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 15));
return (ssize_t)host_size;
}
@@ -1226,12 +1015,10 @@ static ssize_t validate_Tsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(16))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(16));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 16)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 16));
return (ssize_t)host_size;
}
@@ -1243,15 +1030,13 @@ static ssize_t validate_Rsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(17))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(17));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 17)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 17));
return (ssize_t)host_size;
}
@@ -1265,15 +1050,13 @@ static ssize_t validate_Tmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_mode = net_offset + 0;
uint32_t offsetof_end = net_offset + 16;
VALIDATE_NET_BYTES(16);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(18))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(18));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 18)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 18));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1285,15 +1068,13 @@ static ssize_t validate_Rmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(19))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(19));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 19)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 19));
return (ssize_t)host_size;
}
@@ -1305,12 +1086,10 @@ static ssize_t validate_Trename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
VALIDATE_NET_BYTES(17);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(20))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(20));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 20)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 20));
return (ssize_t)host_size;
}
@@ -1321,12 +1100,10 @@ static ssize_t validate_Rrename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(21))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(21));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 21)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 21));
return (ssize_t)host_size;
}
@@ -1337,12 +1114,10 @@ static ssize_t validate_Treadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(22))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(22));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 22)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 22));
return (ssize_t)host_size;
}
@@ -1354,12 +1129,10 @@ static ssize_t validate_Rreadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint
VALIDATE_NET_BYTES(9);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(23))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(23));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 23)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 23));
return (ssize_t)host_size;
}
@@ -1371,15 +1144,13 @@ static ssize_t validate_Tgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_request_mask = net_offset + 11;
uint32_t offsetof_end = net_offset + 19;
VALIDATE_NET_BYTES(19);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(24))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(24));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 24)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 24));
if (GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64,
- GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: ",
+ (base16_u64_, GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1392,23 +1163,21 @@ static ssize_t validate_Rgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_qid_type = net_offset + 15;
VALIDATE_NET_BYTES(28);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_mode = net_offset + 0;
uint32_t offsetof_end = net_offset + 132;
VALIDATE_NET_BYTES(132);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(25))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(25));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 25)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 25));
if (GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64,
- GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: ",
+ (base16_u64_, GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1421,18 +1190,16 @@ static ssize_t validate_Tsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_mode = net_offset + 15;
uint32_t offsetof_end = net_offset + 67;
VALIDATE_NET_BYTES(67);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(26))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(26));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 26)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 26));
if (GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in setattr bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in setattr bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1443,12 +1210,10 @@ static ssize_t validate_Rsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(27))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(27));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 27)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 27));
return (ssize_t)host_size;
}
@@ -1460,12 +1225,10 @@ static ssize_t validate_Txattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uin
VALIDATE_NET_BYTES(17);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(30))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(30));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 30)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 30));
return (ssize_t)host_size;
}
@@ -1476,12 +1239,10 @@ static ssize_t validate_Rxattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uin
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(31))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(31));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 31)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 31));
return (ssize_t)host_size;
}
@@ -1494,12 +1255,10 @@ static ssize_t validate_Txattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, u
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(32))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(32));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 32)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 32));
return (ssize_t)host_size;
}
@@ -1510,12 +1269,10 @@ static ssize_t validate_Rxattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, u
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(33))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(33));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 33)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 33));
return (ssize_t)host_size;
}
@@ -1526,12 +1283,10 @@ static ssize_t validate_Treaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 23;
VALIDATE_NET_BYTES(23);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(40))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(40));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 40)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 40));
return (ssize_t)host_size;
}
@@ -1543,12 +1298,10 @@ static ssize_t validate_Rreaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8
VALIDATE_NET_BYTES(11);
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(41))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(41));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 41)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 41));
return (ssize_t)host_size;
}
@@ -1559,12 +1312,10 @@ static ssize_t validate_Tfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(50))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(50));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 50)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 50));
return (ssize_t)host_size;
}
@@ -1575,12 +1326,10 @@ static ssize_t validate_Rfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(51))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(51));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 51)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 51));
return (ssize_t)host_size;
}
@@ -1593,15 +1342,13 @@ static ssize_t validate_Tlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_BYTES(38);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(52))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(52));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 52)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 52));
if (GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lock_flags bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lock_flags bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1612,12 +1359,10 @@ static ssize_t validate_Rlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 8;
VALIDATE_NET_BYTES(8);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(53))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(53));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 53)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 53));
return (ssize_t)host_size;
}
@@ -1629,12 +1374,10 @@ static ssize_t validate_Tgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8
VALIDATE_NET_BYTES(34);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(54))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(54));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 54)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 54));
return (ssize_t)host_size;
}
@@ -1646,12 +1389,10 @@ static ssize_t validate_Rgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8
VALIDATE_NET_BYTES(30);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(55))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(55));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 55)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 55));
return (ssize_t)host_size;
}
@@ -1663,12 +1404,10 @@ static ssize_t validate_Tlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_BYTES(17);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(70))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(70));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 70)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 70));
return (ssize_t)host_size;
}
@@ -1679,12 +1418,10 @@ static ssize_t validate_Rlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(71))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(71));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 71)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 71));
return (ssize_t)host_size;
}
@@ -1698,15 +1435,13 @@ static ssize_t validate_Tmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_mode = net_offset + 0;
uint32_t offsetof_end = net_offset + 8;
VALIDATE_NET_BYTES(8);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(72))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(72));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 72)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 72));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
return (ssize_t)host_size;
}
@@ -1718,15 +1453,13 @@ static ssize_t validate_Rmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(73))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(73));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 73)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 73));
return (ssize_t)host_size;
}
@@ -1740,12 +1473,10 @@ static ssize_t validate_Trenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint
VALIDATE_NET_BYTES(6);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(74))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(74));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 74)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 74));
return (ssize_t)host_size;
}
@@ -1756,12 +1487,10 @@ static ssize_t validate_Rrenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(75))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(75));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 75)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 75));
return (ssize_t)host_size;
}
@@ -1774,12 +1503,10 @@ static ssize_t validate_Tunlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(76))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(76));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 76)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 76));
return (ssize_t)host_size;
}
@@ -1790,12 +1517,10 @@ static ssize_t validate_Runlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(77))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(77));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 77)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 77));
return (ssize_t)host_size;
}
@@ -1808,12 +1533,10 @@ static ssize_t validate_Tsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(150))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(150));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 150)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 150));
return (ssize_t)host_size;
}
@@ -1824,12 +1547,10 @@ static ssize_t validate_Rsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(151))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(151));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 151)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 151));
return (ssize_t)host_size;
}
@@ -1845,12 +1566,10 @@ static ssize_t validate_Tsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_UTF8(LAST_U16LE());
}
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(152))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(152));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 152)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 152));
return (ssize_t)host_size;
}
@@ -1862,12 +1581,10 @@ static ssize_t validate_Rsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_BYTES(11);
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(153))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(153));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 153)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 153));
return (ssize_t)host_size;
}
@@ -1885,12 +1602,10 @@ static ssize_t validate_Tswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
VALIDATE_NET_BYTES(4);
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(154))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(154));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 154)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 154));
return (ssize_t)host_size;
}
@@ -1901,12 +1616,10 @@ static ssize_t validate_Rswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
- if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size));
- if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(155))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8,
- (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(155));
+ if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ if (GET_U8LE(offsetof_typ) != 155)
+ return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 155));
return (ssize_t)host_size;
}
#endif /* CONFIG_9P_ENABLE_9P2000_e */
@@ -3057,10 +2770,9 @@ static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _
static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *val, struct _marshal_ret *ret) {
uint32_t needed_size = 13 + val->version.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tversion",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tversion message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3077,10 +2789,9 @@ static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *v
static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *val, struct _marshal_ret *ret) {
uint32_t needed_size = 13 + val->version.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rversion",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rversion message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3104,10 +2815,9 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tauth",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tauth message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3131,10 +2841,9 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st
static bool marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rauth",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rauth message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3156,10 +2865,9 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tattach",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tattach message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3184,10 +2892,9 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val
static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rattach",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rattach message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3211,10 +2918,9 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val,
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rerror",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rerror message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3237,10 +2943,9 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val,
static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tflush",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tflush message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3255,10 +2960,9 @@ static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val,
static bool marshal_Rflush(struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rflush",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rflush message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3275,10 +2979,9 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st
needed_size += 2 + val->wname[i].len;
}
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Twalk",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Twalk message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3299,10 +3002,9 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st
static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9 + (val->nwqid)*13;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rwalk",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rwalk message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3324,10 +3026,9 @@ static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, st
static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 12;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Topen",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Topen message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3343,10 +3044,9 @@ static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, st
static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Ropen",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Ropen message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3364,10 +3064,9 @@ static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, st
static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 18 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tcreate",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tcreate message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3386,10 +3085,9 @@ static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val
static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rcreate",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rcreate message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3409,10 +3107,9 @@ static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val
static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, struct _marshal_ret *ret) {
uint32_t needed_size = 23;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tread",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tread message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3429,10 +3126,9 @@ static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, st
static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11 + val->count;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rread",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rread message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3448,10 +3144,9 @@ static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, st
static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val, struct _marshal_ret *ret) {
uint32_t needed_size = 23 + val->count;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Twrite",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Twrite message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3469,10 +3164,9 @@ static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val,
static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rwrite",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rwrite message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3487,10 +3181,9 @@ static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val,
static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tclunk",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tclunk message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3505,10 +3198,9 @@ static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val,
static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rclunk",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rclunk message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3522,10 +3214,9 @@ static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val,
static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tremove",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tremove message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3540,10 +3231,9 @@ static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val
static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rremove",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rremove message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3559,10 +3249,9 @@ static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val
static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tstat",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tstat message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3582,10 +3271,9 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rstat",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rstat message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3640,10 +3328,9 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val,
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Twstat",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Twstat message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3694,10 +3381,9 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val,
static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rwstat",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rwstat message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3713,10 +3399,9 @@ static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val,
static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val, struct _marshal_ret *ret) {
uint32_t needed_size = 12;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Topenfd",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Topenfd message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3732,10 +3417,9 @@ static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val
static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val, struct _marshal_ret *ret) {
uint32_t needed_size = 28;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Ropenfd",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Ropenfd message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3756,10 +3440,9 @@ static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val
static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rlerror",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlerror message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3774,10 +3457,9 @@ static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val
static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tstatfs",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tstatfs message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3792,10 +3474,9 @@ static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val
static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val, struct _marshal_ret *ret) {
uint32_t needed_size = 67;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rstatfs",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rstatfs message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3818,10 +3499,9 @@ static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val
static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tlopen",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlopen message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3837,10 +3517,9 @@ static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val,
static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rlopen",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlopen message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3858,10 +3537,9 @@ static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val,
static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 25 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tlcreate",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlcreate message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3881,10 +3559,9 @@ static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *v
static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rlcreate",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlcreate message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3902,10 +3579,9 @@ static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *v
static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 19 + val->name.len + val->symtgt.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tsymlink",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsymlink message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3925,10 +3601,9 @@ static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *v
static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rsymlink",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsymlink message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3945,10 +3620,9 @@ static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *v
static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val, struct _marshal_ret *ret) {
uint32_t needed_size = 29 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tmknod",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tmknod message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3969,10 +3643,9 @@ static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val,
static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rmknod",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rmknod message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -3989,10 +3662,9 @@ static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val,
static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Trename",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Trename message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4010,10 +3682,9 @@ static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val
static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rrename",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rrename message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4027,10 +3698,9 @@ static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val
static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Treadlink",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Treadlink message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4045,10 +3715,9 @@ static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink
static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9 + val->target.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rreadlink",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rreadlink message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4064,10 +3733,9 @@ static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink
static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 19;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tgetattr",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tgetattr message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4083,10 +3751,9 @@ static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *v
static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 160;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rgetattr",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rgetattr message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4122,10 +3789,9 @@ static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *v
static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 67;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tsetattr",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsetattr message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4149,10 +3815,9 @@ static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *v
static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rsetattr",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsetattr message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4166,10 +3831,9 @@ static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *v
static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwalk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Txattrwalk",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Txattrwalk message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4187,10 +3851,9 @@ static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwal
static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwalk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rxattrwalk",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rxattrwalk message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4205,10 +3868,9 @@ static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwal
static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 25 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Txattrcreate",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Txattrcreate message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4227,10 +3889,9 @@ static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrc
static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rxattrcreate",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rxattrcreate message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4244,10 +3905,9 @@ static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrc
static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *val, struct _marshal_ret *ret) {
uint32_t needed_size = 23;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Treaddir",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Treaddir message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4264,10 +3924,9 @@ static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *v
static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *val, struct _marshal_ret *ret) {
uint64_t needed_size = 11 + val->count;
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")",
- "Rreaddir",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rreaddir message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
@@ -4283,10 +3942,9 @@ static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *v
static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tfsync",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tfsync message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4302,10 +3960,9 @@ static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val,
static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rfsync",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rfsync message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4319,10 +3976,9 @@ static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val,
static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 38 + val->client_id.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tlock",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlock message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4344,10 +4000,9 @@ static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, st
static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 8;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rlock",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlock message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4362,10 +4017,9 @@ static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, st
static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 34 + val->client_id.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tgetlock",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tgetlock message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4386,10 +4040,9 @@ static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *v
static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 30 + val->client_id.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rgetlock",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rgetlock message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4409,10 +4062,9 @@ static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *v
static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tlink",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tlink message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4430,10 +4082,9 @@ static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, st
static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rlink",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rlink message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4447,10 +4098,9 @@ static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, st
static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val, struct _marshal_ret *ret) {
uint32_t needed_size = 21 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tmkdir",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tmkdir message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4469,10 +4119,9 @@ static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val,
static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rmkdir",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rmkdir message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4489,10 +4138,9 @@ static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val,
static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 19 + val->oldname.len + val->newname.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Trenameat",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Trenameat message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4512,10 +4160,9 @@ static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat
static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rrenameat",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rrenameat message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4529,10 +4176,9 @@ static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat
static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tunlinkat",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tunlinkat message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4550,10 +4196,9 @@ static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat
static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Runlinkat",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Runlinkat message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4569,10 +4214,9 @@ static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat
static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Tsession",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsession message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4587,10 +4231,9 @@ static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *v
static bool marshal_Rsession(struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rsession",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsession message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4607,10 +4250,9 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val,
needed_size += 2 + val->wname[i].len;
}
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")",
- "Tsread",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tsread message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
@@ -4630,10 +4272,9 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val,
static bool marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val, struct _marshal_ret *ret) {
uint64_t needed_size = 11 + val->count;
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")",
- "Rsread",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rsread message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
@@ -4652,10 +4293,9 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val
needed_size += 2 + val->wname[i].len;
}
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")",
- "Tswrite",
- ctx->version ? "negotiated" : "client",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Tswrite message too large to marshal into ",
+ ctx->version ? "negotiated" : "client", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
@@ -4677,10 +4317,9 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val
static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")",
- "Rswrite",
- ctx->version ? "negotiated" : "server",
- needed_size, ctx->max_msg_size);
+ lib9p_error(ctx, LIB9P_ERRNO_L_ERANGE, "Rswrite message too large to marshal into ",
+ ctx->version ? "negotiated" : "server", " limit",
+ " (", needed_size, " > ", ctx->max_msg_size, ")");
return true;
}
uint32_t offsetof_end = needed_size;
@@ -4693,3158 +4332,3152 @@ static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val
}
#endif /* CONFIG_9P_ENABLE_9P2000_e */
-/* *_format *******************************************************************/
+/* fmt_print_* ****************************************************************/
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static void lib9p_tag_format(lib9p_tag_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_tag(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_tag_t *self) {
switch (*self) {
case LIB9P_TAG_NOTAG:
- fmt_state_puts(state, "NOTAG");
+ fmt_print_str(w, "NOTAG");
break;
default:
- fmt_state_printf(state, "%"PRIu16, *self);
+ fmt_print_base10(w, *self);
}
}
-static void lib9p_fid_format(lib9p_fid_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_fid(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_fid_t *self) {
switch (*self) {
case LIB9P_FID_NOFID:
- fmt_state_puts(state, "NOFID");
+ fmt_print_str(w, "NOFID");
break;
default:
- fmt_state_printf(state, "%"PRIu32, *self);
+ fmt_print_base10(w, *self);
}
}
-static void lib9p_s_format(struct lib9p_s *self, struct fmt_state *state) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- fmt_state_printf(state, "%.*q", self->len, self->utf8);
-#pragma GCC diagnostic pop
-}
-
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static void lib9p_dm_format(lib9p_dm_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_dm(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_dm_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<31)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "DIR");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "DIR");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<30)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "APPEND");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "APPEND");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<29)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "EXCL");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "EXCL");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<28)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "_PLAN9_MOUNT");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "_PLAN9_MOUNT");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<27)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "AUTH");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "AUTH");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<26)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "TMP");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "TMP");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<25)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<25");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<25");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<24)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<24");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<24");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<23)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "DEVICE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "DEVICE");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<22)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<22");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<22");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<21)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PIPE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PIPE");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<20)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "SOCKET");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "SOCKET");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<19)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "SETUID");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "SETUID");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<18)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "SETGID");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "SETGID");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<17)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<17");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<17");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<16)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<16");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<16");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<15)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<15");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<15");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<14)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<14");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<14");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<13)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<13");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<13");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<12)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<12");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<12");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<11)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<11");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<11");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<10)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<10");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<10");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<9)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<9");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<9");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<8)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "OWNER_R");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "OWNER_R");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "OWNER_W");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "OWNER_W");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "OWNER_X");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "OWNER_X");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "GROUP_R");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "GROUP_R");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "GROUP_W");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "GROUP_W");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "GROUP_X");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "GROUP_X");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "OTHER_R");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "OTHER_R");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<1)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "OTHER_W");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "OTHER_W");
empty = false;
}
if ((*self & ~((lib9p_dm_t)0777)) & (UINT32_C(1)<<0)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "OTHER_X");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "OTHER_X");
empty = false;
}
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_printf(state, "%#04"PRIo32, *self & 0777);
- fmt_state_putchar(state, ')');
+ fmt_print_byte(w, '|');
+ fmt_print(w, (rjust, 4, '0', (base8, *self & 0777)));
+ fmt_print_byte(w, ')');
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static void lib9p_qt_format(lib9p_qt_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_qt(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_qt_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if (*self & (UINT8_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "DIR");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "DIR");
empty = false;
}
if (*self & (UINT8_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "APPEND");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "APPEND");
empty = false;
}
if (*self & (UINT8_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "EXCL");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "EXCL");
empty = false;
}
if (*self & (UINT8_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "_PLAN9_MOUNT");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "_PLAN9_MOUNT");
empty = false;
}
if (*self & (UINT8_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "AUTH");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "AUTH");
empty = false;
}
if (*self & (UINT8_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "TMP");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "TMP");
empty = false;
}
if (*self & (UINT8_C(1)<<1)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "SYMLINK");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "SYMLINK");
empty = false;
}
if (*self & (UINT8_C(1)<<0)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<0");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<0");
empty = false;
}
if (empty)
- fmt_state_putchar(state, '0');
- fmt_state_putchar(state, ')');
-}
-
-static void lib9p_qid_format(struct lib9p_qid *self, struct fmt_state *state) {
- fmt_state_putchar(state, '{');
- fmt_state_puts(state, " type=");
- lib9p_qt_format(&self->type, state);
- fmt_state_puts(state, " vers=");
- fmt_state_printf(state, "%"PRIu32, self->vers);
- fmt_state_puts(state, " path=");
- fmt_state_printf(state, "%"PRIu64, self->path);
- fmt_state_puts(state, " }");
+ fmt_print_byte(w, '0');
+ fmt_print_byte(w, ')');
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static void lib9p_stat_format(struct lib9p_stat *self, struct fmt_state *state) {
- fmt_state_putchar(state, '{');
- fmt_state_puts(state, " fstype=");
- fmt_state_printf(state, "%"PRIu16, self->fstype);
- fmt_state_puts(state, " fsdev=");
- fmt_state_printf(state, "%"PRIu32, self->fsdev);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " mode=");
- lib9p_dm_format(&self->mode, state);
- fmt_state_puts(state, " atime=");
- fmt_state_printf(state, "%"PRIu32, self->atime);
- fmt_state_puts(state, " mtime=");
- fmt_state_printf(state, "%"PRIu32, self->mtime);
- fmt_state_puts(state, " length=");
- fmt_state_printf(state, "%"PRIu64, self->length);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " owner_uname=");
- lib9p_s_format(&self->owner_uname, state);
- fmt_state_puts(state, " owner_gname=");
- lib9p_s_format(&self->owner_gname, state);
- fmt_state_puts(state, " last_modifier_uname=");
- lib9p_s_format(&self->last_modifier_uname, state);
-#if CONFIG_9P_ENABLE_9P2000_u
- fmt_state_puts(state, " extension=");
- lib9p_s_format(&self->extension, state);
- fmt_state_puts(state, " owner_unum=");
- lib9p_nuid_format(&self->owner_unum, state);
- fmt_state_puts(state, " owner_gnum=");
- lib9p_nuid_format(&self->owner_gnum, state);
- fmt_state_puts(state, " last_modifier_unum=");
- lib9p_nuid_format(&self->last_modifier_unum, state);
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_o_format(lib9p_o_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_o(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_o_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if (*self & (UINT8_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<7");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<7");
empty = false;
}
if (*self & (UINT8_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "RCLOSE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "RCLOSE");
empty = false;
}
if (*self & (UINT8_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "CEXEC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "CEXEC");
empty = false;
}
if (*self & (UINT8_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "TRUNC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "TRUNC");
empty = false;
}
if (*self & (UINT8_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<3");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<3");
empty = false;
}
if (*self & (UINT8_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<2");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<2");
empty = false;
}
switch (*self & LIB9P_O_MODE_MASK) {
case LIB9P_O_MODE_READ:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_READ");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_READ");
empty = false;
break;
case LIB9P_O_MODE_WRITE:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_WRITE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_WRITE");
empty = false;
break;
case LIB9P_O_MODE_RDWR:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_RDWR");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_RDWR");
empty = false;
break;
case LIB9P_O_MODE_EXEC:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_EXEC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_EXEC");
empty = false;
break;
default:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_printf(state, "%"PRIu8, *self & LIB9P_O_MODE_MASK);
+ fmt_print_byte(w, '|');
+ fmt_print_base10(w, *self & LIB9P_O_MODE_MASK);
empty = false;
}
if (empty)
- fmt_state_putchar(state, '0');
- fmt_state_putchar(state, ')');
+ fmt_print_byte(w, '0');
+ fmt_print_byte(w, ')');
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static void lib9p_msg_Tversion_format(struct lib9p_msg_Tversion *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tversion {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " max_msg_size=");
- fmt_state_printf(state, "%"PRIu32, self->max_msg_size);
- fmt_state_puts(state, " version=");
- lib9p_s_format(&self->version, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rversion_format(struct lib9p_msg_Rversion *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rversion {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " max_msg_size=");
- fmt_state_printf(state, "%"PRIu32, self->max_msg_size);
- fmt_state_puts(state, " version=");
- lib9p_s_format(&self->version, state);
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static void lib9p_msg_Tauth_format(struct lib9p_msg_Tauth *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tauth {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " afid=");
- lib9p_fid_format(&self->afid, state);
- fmt_state_puts(state, " uname=");
- lib9p_s_format(&self->uname, state);
- fmt_state_puts(state, " aname=");
- lib9p_s_format(&self->aname, state);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
- fmt_state_puts(state, " unum=");
- lib9p_nuid_format(&self->unum, state);
-#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rauth_format(struct lib9p_msg_Rauth *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rauth {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " aqid=");
- lib9p_qid_format(&self->aqid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tattach_format(struct lib9p_msg_Tattach *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tattach {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " afid=");
- lib9p_fid_format(&self->afid, state);
- fmt_state_puts(state, " uname=");
- lib9p_s_format(&self->uname, state);
- fmt_state_puts(state, " aname=");
- lib9p_s_format(&self->aname, state);
-#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
- fmt_state_puts(state, " unum=");
- lib9p_nuid_format(&self->unum, state);
-#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rattach_format(struct lib9p_msg_Rattach *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rattach {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static void lib9p_msg_Rerror_format(struct lib9p_msg_Rerror *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rerror {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " errstr=");
- lib9p_s_format(&self->errstr, state);
-#if CONFIG_9P_ENABLE_9P2000_u
- fmt_state_puts(state, " errnum=");
- lib9p_errno_format(&self->errnum, state);
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static void lib9p_msg_Tflush_format(struct lib9p_msg_Tflush *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tflush {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " oldtag=");
- fmt_state_printf(state, "%"PRIu16, self->oldtag);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rflush_format(struct lib9p_msg_Rflush *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rflush {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Twalk_format(struct lib9p_msg_Twalk *self, struct fmt_state *state) {
- fmt_state_puts(state, "Twalk {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " newfid=");
- lib9p_fid_format(&self->newfid, state);
- fmt_state_puts(state, " nwname=");
- fmt_state_printf(state, "%"PRIu16, self->nwname);
- fmt_state_puts(state, " wname=[");
- for (uint16_t i = 0; i < self->nwname; i++) {
- if (i)
- fmt_state_putchar(state, ',');
- fmt_state_putchar(state, ' ');
- lib9p_s_format(&self->wname[i], state);
- }
- fmt_state_puts(state, " ]");
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rwalk_format(struct lib9p_msg_Rwalk *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rwalk {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " nwqid=");
- fmt_state_printf(state, "%"PRIu16, self->nwqid);
- fmt_state_puts(state, " wqid=[");
- for (uint16_t i = 0; i < self->nwqid; i++) {
- if (i)
- fmt_state_putchar(state, ',');
- fmt_state_putchar(state, ' ');
- lib9p_qid_format(&self->wqid[i], state);
- }
- fmt_state_puts(state, " ]");
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static void lib9p_msg_Topen_format(struct lib9p_msg_Topen *self, struct fmt_state *state) {
- fmt_state_puts(state, "Topen {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " mode=");
- lib9p_o_format(&self->mode, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Ropen_format(struct lib9p_msg_Ropen *self, struct fmt_state *state) {
- fmt_state_puts(state, "Ropen {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " iounit=");
- fmt_state_printf(state, "%"PRIu32, self->iounit);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tcreate_format(struct lib9p_msg_Tcreate *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tcreate {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " perm=");
- lib9p_dm_format(&self->perm, state);
- fmt_state_puts(state, " mode=");
- lib9p_o_format(&self->mode, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rcreate_format(struct lib9p_msg_Rcreate *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rcreate {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " iounit=");
- fmt_state_printf(state, "%"PRIu32, self->iounit);
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static void lib9p_msg_Tread_format(struct lib9p_msg_Tread *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tread {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " offset=");
- fmt_state_printf(state, "%"PRIu64, self->offset);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rread_format(struct lib9p_msg_Rread *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rread {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
- if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- fmt_state_printf(state, " data=%.*q%s",
- (int)(self->count < 50 ? self->count : 50),
- (char *)self->data,
- self->count < 50 ? "" : "...");
-#pragma GCC diagnostic pop
- } else {
- fmt_state_puts(state, " data=<bytedata>");
- }
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Twrite_format(struct lib9p_msg_Twrite *self, struct fmt_state *state) {
- fmt_state_puts(state, "Twrite {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " offset=");
- fmt_state_printf(state, "%"PRIu64, self->offset);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
- if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- fmt_state_printf(state, " data=%.*q%s",
- (int)(self->count < 50 ? self->count : 50),
- (char *)self->data,
- self->count < 50 ? "" : "...");
-#pragma GCC diagnostic pop
- } else {
- fmt_state_puts(state, " data=<bytedata>");
- }
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rwrite_format(struct lib9p_msg_Rwrite *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rwrite {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tclunk_format(struct lib9p_msg_Tclunk *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tclunk {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rclunk_format(struct lib9p_msg_Rclunk *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rclunk {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tremove_format(struct lib9p_msg_Tremove *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tremove {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rremove_format(struct lib9p_msg_Rremove *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rremove {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static void lib9p_msg_Tstat_format(struct lib9p_msg_Tstat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tstat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rstat_format(struct lib9p_msg_Rstat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rstat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " stat=");
- lib9p_stat_format(&self->stat, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Twstat_format(struct lib9p_msg_Twstat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Twstat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " stat=");
- lib9p_stat_format(&self->stat, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rwstat_format(struct lib9p_msg_Rwstat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rwstat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_p9p
-static void lib9p_msg_Topenfd_format(struct lib9p_msg_Topenfd *self, struct fmt_state *state) {
- fmt_state_puts(state, "Topenfd {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " mode=");
- lib9p_o_format(&self->mode, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Ropenfd_format(struct lib9p_msg_Ropenfd *self, struct fmt_state *state) {
- fmt_state_puts(state, "Ropenfd {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " iounit=");
- fmt_state_printf(state, "%"PRIu32, self->iounit);
- fmt_state_puts(state, " unixfd=");
- fmt_state_printf(state, "%"PRIu32, self->unixfd);
- fmt_state_puts(state, " }");
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
-#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
-static void lib9p_nuid_format(lib9p_nuid_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_nuid(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_nuid_t *self) {
switch (*self) {
case LIB9P_NUID_NONUID:
- fmt_state_puts(state, "NONUID");
+ fmt_print_str(w, "NONUID");
break;
default:
- fmt_state_printf(state, "%"PRIu32, *self);
+ fmt_print_base10(w, *self);
}
}
-static void lib9p_errno_format(lib9p_errno_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_errno(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_errno_t *self) {
switch (*self) {
case LIB9P_ERRNO_NOERROR:
- fmt_state_puts(state, "NOERROR");
+ fmt_print_str(w, "NOERROR");
break;
case LIB9P_ERRNO_L_EPERM:
- fmt_state_puts(state, "L_EPERM");
+ fmt_print_str(w, "L_EPERM");
break;
case LIB9P_ERRNO_L_ENOENT:
- fmt_state_puts(state, "L_ENOENT");
+ fmt_print_str(w, "L_ENOENT");
break;
case LIB9P_ERRNO_L_ESRCH:
- fmt_state_puts(state, "L_ESRCH");
+ fmt_print_str(w, "L_ESRCH");
break;
case LIB9P_ERRNO_L_EINTR:
- fmt_state_puts(state, "L_EINTR");
+ fmt_print_str(w, "L_EINTR");
break;
case LIB9P_ERRNO_L_EIO:
- fmt_state_puts(state, "L_EIO");
+ fmt_print_str(w, "L_EIO");
break;
case LIB9P_ERRNO_L_ENXIO:
- fmt_state_puts(state, "L_ENXIO");
+ fmt_print_str(w, "L_ENXIO");
break;
case LIB9P_ERRNO_L_E2BIG:
- fmt_state_puts(state, "L_E2BIG");
+ fmt_print_str(w, "L_E2BIG");
break;
case LIB9P_ERRNO_L_ENOEXEC:
- fmt_state_puts(state, "L_ENOEXEC");
+ fmt_print_str(w, "L_ENOEXEC");
break;
case LIB9P_ERRNO_L_EBADF:
- fmt_state_puts(state, "L_EBADF");
+ fmt_print_str(w, "L_EBADF");
break;
case LIB9P_ERRNO_L_ECHILD:
- fmt_state_puts(state, "L_ECHILD");
+ fmt_print_str(w, "L_ECHILD");
break;
case LIB9P_ERRNO_L_EAGAIN:
- fmt_state_puts(state, "L_EAGAIN");
+ fmt_print_str(w, "L_EAGAIN");
break;
case LIB9P_ERRNO_L_ENOMEM:
- fmt_state_puts(state, "L_ENOMEM");
+ fmt_print_str(w, "L_ENOMEM");
break;
case LIB9P_ERRNO_L_EACCES:
- fmt_state_puts(state, "L_EACCES");
+ fmt_print_str(w, "L_EACCES");
break;
case LIB9P_ERRNO_L_EFAULT:
- fmt_state_puts(state, "L_EFAULT");
+ fmt_print_str(w, "L_EFAULT");
break;
case LIB9P_ERRNO_L_ENOTBLK:
- fmt_state_puts(state, "L_ENOTBLK");
+ fmt_print_str(w, "L_ENOTBLK");
break;
case LIB9P_ERRNO_L_EBUSY:
- fmt_state_puts(state, "L_EBUSY");
+ fmt_print_str(w, "L_EBUSY");
break;
case LIB9P_ERRNO_L_EEXIST:
- fmt_state_puts(state, "L_EEXIST");
+ fmt_print_str(w, "L_EEXIST");
break;
case LIB9P_ERRNO_L_EXDEV:
- fmt_state_puts(state, "L_EXDEV");
+ fmt_print_str(w, "L_EXDEV");
break;
case LIB9P_ERRNO_L_ENODEV:
- fmt_state_puts(state, "L_ENODEV");
+ fmt_print_str(w, "L_ENODEV");
break;
case LIB9P_ERRNO_L_ENOTDIR:
- fmt_state_puts(state, "L_ENOTDIR");
+ fmt_print_str(w, "L_ENOTDIR");
break;
case LIB9P_ERRNO_L_EISDIR:
- fmt_state_puts(state, "L_EISDIR");
+ fmt_print_str(w, "L_EISDIR");
break;
case LIB9P_ERRNO_L_EINVAL:
- fmt_state_puts(state, "L_EINVAL");
+ fmt_print_str(w, "L_EINVAL");
break;
case LIB9P_ERRNO_L_ENFILE:
- fmt_state_puts(state, "L_ENFILE");
+ fmt_print_str(w, "L_ENFILE");
break;
case LIB9P_ERRNO_L_EMFILE:
- fmt_state_puts(state, "L_EMFILE");
+ fmt_print_str(w, "L_EMFILE");
break;
case LIB9P_ERRNO_L_ENOTTY:
- fmt_state_puts(state, "L_ENOTTY");
+ fmt_print_str(w, "L_ENOTTY");
break;
case LIB9P_ERRNO_L_ETXTBSY:
- fmt_state_puts(state, "L_ETXTBSY");
+ fmt_print_str(w, "L_ETXTBSY");
break;
case LIB9P_ERRNO_L_EFBIG:
- fmt_state_puts(state, "L_EFBIG");
+ fmt_print_str(w, "L_EFBIG");
break;
case LIB9P_ERRNO_L_ENOSPC:
- fmt_state_puts(state, "L_ENOSPC");
+ fmt_print_str(w, "L_ENOSPC");
break;
case LIB9P_ERRNO_L_ESPIPE:
- fmt_state_puts(state, "L_ESPIPE");
+ fmt_print_str(w, "L_ESPIPE");
break;
case LIB9P_ERRNO_L_EROFS:
- fmt_state_puts(state, "L_EROFS");
+ fmt_print_str(w, "L_EROFS");
break;
case LIB9P_ERRNO_L_EMLINK:
- fmt_state_puts(state, "L_EMLINK");
+ fmt_print_str(w, "L_EMLINK");
break;
case LIB9P_ERRNO_L_EPIPE:
- fmt_state_puts(state, "L_EPIPE");
+ fmt_print_str(w, "L_EPIPE");
break;
case LIB9P_ERRNO_L_EDOM:
- fmt_state_puts(state, "L_EDOM");
+ fmt_print_str(w, "L_EDOM");
break;
case LIB9P_ERRNO_L_ERANGE:
- fmt_state_puts(state, "L_ERANGE");
+ fmt_print_str(w, "L_ERANGE");
break;
case LIB9P_ERRNO_L_EDEADLK:
- fmt_state_puts(state, "L_EDEADLK");
+ fmt_print_str(w, "L_EDEADLK");
break;
case LIB9P_ERRNO_L_ENAMETOOLONG:
- fmt_state_puts(state, "L_ENAMETOOLONG");
+ fmt_print_str(w, "L_ENAMETOOLONG");
break;
case LIB9P_ERRNO_L_ENOLCK:
- fmt_state_puts(state, "L_ENOLCK");
+ fmt_print_str(w, "L_ENOLCK");
break;
case LIB9P_ERRNO_L_ENOSYS:
- fmt_state_puts(state, "L_ENOSYS");
+ fmt_print_str(w, "L_ENOSYS");
break;
case LIB9P_ERRNO_L_ENOTEMPTY:
- fmt_state_puts(state, "L_ENOTEMPTY");
+ fmt_print_str(w, "L_ENOTEMPTY");
break;
case LIB9P_ERRNO_L_ELOOP:
- fmt_state_puts(state, "L_ELOOP");
+ fmt_print_str(w, "L_ELOOP");
break;
case LIB9P_ERRNO_L_ENOMSG:
- fmt_state_puts(state, "L_ENOMSG");
+ fmt_print_str(w, "L_ENOMSG");
break;
case LIB9P_ERRNO_L_EIDRM:
- fmt_state_puts(state, "L_EIDRM");
+ fmt_print_str(w, "L_EIDRM");
break;
case LIB9P_ERRNO_L_ECHRNG:
- fmt_state_puts(state, "L_ECHRNG");
+ fmt_print_str(w, "L_ECHRNG");
break;
case LIB9P_ERRNO_L_EL2NSYNC:
- fmt_state_puts(state, "L_EL2NSYNC");
+ fmt_print_str(w, "L_EL2NSYNC");
break;
case LIB9P_ERRNO_L_EL3HLT:
- fmt_state_puts(state, "L_EL3HLT");
+ fmt_print_str(w, "L_EL3HLT");
break;
case LIB9P_ERRNO_L_EL3RST:
- fmt_state_puts(state, "L_EL3RST");
+ fmt_print_str(w, "L_EL3RST");
break;
case LIB9P_ERRNO_L_ELNRNG:
- fmt_state_puts(state, "L_ELNRNG");
+ fmt_print_str(w, "L_ELNRNG");
break;
case LIB9P_ERRNO_L_EUNATCH:
- fmt_state_puts(state, "L_EUNATCH");
+ fmt_print_str(w, "L_EUNATCH");
break;
case LIB9P_ERRNO_L_ENOCSI:
- fmt_state_puts(state, "L_ENOCSI");
+ fmt_print_str(w, "L_ENOCSI");
break;
case LIB9P_ERRNO_L_EL2HLT:
- fmt_state_puts(state, "L_EL2HLT");
+ fmt_print_str(w, "L_EL2HLT");
break;
case LIB9P_ERRNO_L_EBADE:
- fmt_state_puts(state, "L_EBADE");
+ fmt_print_str(w, "L_EBADE");
break;
case LIB9P_ERRNO_L_EBADR:
- fmt_state_puts(state, "L_EBADR");
+ fmt_print_str(w, "L_EBADR");
break;
case LIB9P_ERRNO_L_EXFULL:
- fmt_state_puts(state, "L_EXFULL");
+ fmt_print_str(w, "L_EXFULL");
break;
case LIB9P_ERRNO_L_ENOANO:
- fmt_state_puts(state, "L_ENOANO");
+ fmt_print_str(w, "L_ENOANO");
break;
case LIB9P_ERRNO_L_EBADRQC:
- fmt_state_puts(state, "L_EBADRQC");
+ fmt_print_str(w, "L_EBADRQC");
break;
case LIB9P_ERRNO_L_EBADSLT:
- fmt_state_puts(state, "L_EBADSLT");
+ fmt_print_str(w, "L_EBADSLT");
break;
case LIB9P_ERRNO_L_EBFONT:
- fmt_state_puts(state, "L_EBFONT");
+ fmt_print_str(w, "L_EBFONT");
break;
case LIB9P_ERRNO_L_ENOSTR:
- fmt_state_puts(state, "L_ENOSTR");
+ fmt_print_str(w, "L_ENOSTR");
break;
case LIB9P_ERRNO_L_ENODATA:
- fmt_state_puts(state, "L_ENODATA");
+ fmt_print_str(w, "L_ENODATA");
break;
case LIB9P_ERRNO_L_ETIME:
- fmt_state_puts(state, "L_ETIME");
+ fmt_print_str(w, "L_ETIME");
break;
case LIB9P_ERRNO_L_ENOSR:
- fmt_state_puts(state, "L_ENOSR");
+ fmt_print_str(w, "L_ENOSR");
break;
case LIB9P_ERRNO_L_ENONET:
- fmt_state_puts(state, "L_ENONET");
+ fmt_print_str(w, "L_ENONET");
break;
case LIB9P_ERRNO_L_ENOPKG:
- fmt_state_puts(state, "L_ENOPKG");
+ fmt_print_str(w, "L_ENOPKG");
break;
case LIB9P_ERRNO_L_EREMOTE:
- fmt_state_puts(state, "L_EREMOTE");
+ fmt_print_str(w, "L_EREMOTE");
break;
case LIB9P_ERRNO_L_ENOLINK:
- fmt_state_puts(state, "L_ENOLINK");
+ fmt_print_str(w, "L_ENOLINK");
break;
case LIB9P_ERRNO_L_EADV:
- fmt_state_puts(state, "L_EADV");
+ fmt_print_str(w, "L_EADV");
break;
case LIB9P_ERRNO_L_ESRMNT:
- fmt_state_puts(state, "L_ESRMNT");
+ fmt_print_str(w, "L_ESRMNT");
break;
case LIB9P_ERRNO_L_ECOMM:
- fmt_state_puts(state, "L_ECOMM");
+ fmt_print_str(w, "L_ECOMM");
break;
case LIB9P_ERRNO_L_EPROTO:
- fmt_state_puts(state, "L_EPROTO");
+ fmt_print_str(w, "L_EPROTO");
break;
case LIB9P_ERRNO_L_EMULTIHOP:
- fmt_state_puts(state, "L_EMULTIHOP");
+ fmt_print_str(w, "L_EMULTIHOP");
break;
case LIB9P_ERRNO_L_EDOTDOT:
- fmt_state_puts(state, "L_EDOTDOT");
+ fmt_print_str(w, "L_EDOTDOT");
break;
case LIB9P_ERRNO_L_EBADMSG:
- fmt_state_puts(state, "L_EBADMSG");
+ fmt_print_str(w, "L_EBADMSG");
break;
case LIB9P_ERRNO_L_EOVERFLOW:
- fmt_state_puts(state, "L_EOVERFLOW");
+ fmt_print_str(w, "L_EOVERFLOW");
break;
case LIB9P_ERRNO_L_ENOTUNIQ:
- fmt_state_puts(state, "L_ENOTUNIQ");
+ fmt_print_str(w, "L_ENOTUNIQ");
break;
case LIB9P_ERRNO_L_EBADFD:
- fmt_state_puts(state, "L_EBADFD");
+ fmt_print_str(w, "L_EBADFD");
break;
case LIB9P_ERRNO_L_EREMCHG:
- fmt_state_puts(state, "L_EREMCHG");
+ fmt_print_str(w, "L_EREMCHG");
break;
case LIB9P_ERRNO_L_ELIBACC:
- fmt_state_puts(state, "L_ELIBACC");
+ fmt_print_str(w, "L_ELIBACC");
break;
case LIB9P_ERRNO_L_ELIBBAD:
- fmt_state_puts(state, "L_ELIBBAD");
+ fmt_print_str(w, "L_ELIBBAD");
break;
case LIB9P_ERRNO_L_ELIBSCN:
- fmt_state_puts(state, "L_ELIBSCN");
+ fmt_print_str(w, "L_ELIBSCN");
break;
case LIB9P_ERRNO_L_ELIBMAX:
- fmt_state_puts(state, "L_ELIBMAX");
+ fmt_print_str(w, "L_ELIBMAX");
break;
case LIB9P_ERRNO_L_ELIBEXEC:
- fmt_state_puts(state, "L_ELIBEXEC");
+ fmt_print_str(w, "L_ELIBEXEC");
break;
case LIB9P_ERRNO_L_EILSEQ:
- fmt_state_puts(state, "L_EILSEQ");
+ fmt_print_str(w, "L_EILSEQ");
break;
case LIB9P_ERRNO_L_ERESTART:
- fmt_state_puts(state, "L_ERESTART");
+ fmt_print_str(w, "L_ERESTART");
break;
case LIB9P_ERRNO_L_ESTRPIPE:
- fmt_state_puts(state, "L_ESTRPIPE");
+ fmt_print_str(w, "L_ESTRPIPE");
break;
case LIB9P_ERRNO_L_EUSERS:
- fmt_state_puts(state, "L_EUSERS");
+ fmt_print_str(w, "L_EUSERS");
break;
case LIB9P_ERRNO_L_ENOTSOCK:
- fmt_state_puts(state, "L_ENOTSOCK");
+ fmt_print_str(w, "L_ENOTSOCK");
break;
case LIB9P_ERRNO_L_EDESTADDRREQ:
- fmt_state_puts(state, "L_EDESTADDRREQ");
+ fmt_print_str(w, "L_EDESTADDRREQ");
break;
case LIB9P_ERRNO_L_EMSGSIZE:
- fmt_state_puts(state, "L_EMSGSIZE");
+ fmt_print_str(w, "L_EMSGSIZE");
break;
case LIB9P_ERRNO_L_EPROTOTYPE:
- fmt_state_puts(state, "L_EPROTOTYPE");
+ fmt_print_str(w, "L_EPROTOTYPE");
break;
case LIB9P_ERRNO_L_ENOPROTOOPT:
- fmt_state_puts(state, "L_ENOPROTOOPT");
+ fmt_print_str(w, "L_ENOPROTOOPT");
break;
case LIB9P_ERRNO_L_EPROTONOSUPPORT:
- fmt_state_puts(state, "L_EPROTONOSUPPORT");
+ fmt_print_str(w, "L_EPROTONOSUPPORT");
break;
case LIB9P_ERRNO_L_ESOCKTNOSUPPORT:
- fmt_state_puts(state, "L_ESOCKTNOSUPPORT");
+ fmt_print_str(w, "L_ESOCKTNOSUPPORT");
break;
case LIB9P_ERRNO_L_EOPNOTSUPP:
- fmt_state_puts(state, "L_EOPNOTSUPP");
+ fmt_print_str(w, "L_EOPNOTSUPP");
break;
case LIB9P_ERRNO_L_EPFNOSUPPORT:
- fmt_state_puts(state, "L_EPFNOSUPPORT");
+ fmt_print_str(w, "L_EPFNOSUPPORT");
break;
case LIB9P_ERRNO_L_EAFNOSUPPORT:
- fmt_state_puts(state, "L_EAFNOSUPPORT");
+ fmt_print_str(w, "L_EAFNOSUPPORT");
break;
case LIB9P_ERRNO_L_EADDRINUSE:
- fmt_state_puts(state, "L_EADDRINUSE");
+ fmt_print_str(w, "L_EADDRINUSE");
break;
case LIB9P_ERRNO_L_EADDRNOTAVAIL:
- fmt_state_puts(state, "L_EADDRNOTAVAIL");
+ fmt_print_str(w, "L_EADDRNOTAVAIL");
break;
case LIB9P_ERRNO_L_ENETDOWN:
- fmt_state_puts(state, "L_ENETDOWN");
+ fmt_print_str(w, "L_ENETDOWN");
break;
case LIB9P_ERRNO_L_ENETUNREACH:
- fmt_state_puts(state, "L_ENETUNREACH");
+ fmt_print_str(w, "L_ENETUNREACH");
break;
case LIB9P_ERRNO_L_ENETRESET:
- fmt_state_puts(state, "L_ENETRESET");
+ fmt_print_str(w, "L_ENETRESET");
break;
case LIB9P_ERRNO_L_ECONNABORTED:
- fmt_state_puts(state, "L_ECONNABORTED");
+ fmt_print_str(w, "L_ECONNABORTED");
break;
case LIB9P_ERRNO_L_ECONNRESET:
- fmt_state_puts(state, "L_ECONNRESET");
+ fmt_print_str(w, "L_ECONNRESET");
break;
case LIB9P_ERRNO_L_ENOBUFS:
- fmt_state_puts(state, "L_ENOBUFS");
+ fmt_print_str(w, "L_ENOBUFS");
break;
case LIB9P_ERRNO_L_EISCONN:
- fmt_state_puts(state, "L_EISCONN");
+ fmt_print_str(w, "L_EISCONN");
break;
case LIB9P_ERRNO_L_ENOTCONN:
- fmt_state_puts(state, "L_ENOTCONN");
+ fmt_print_str(w, "L_ENOTCONN");
break;
case LIB9P_ERRNO_L_ESHUTDOWN:
- fmt_state_puts(state, "L_ESHUTDOWN");
+ fmt_print_str(w, "L_ESHUTDOWN");
break;
case LIB9P_ERRNO_L_ETOOMANYREFS:
- fmt_state_puts(state, "L_ETOOMANYREFS");
+ fmt_print_str(w, "L_ETOOMANYREFS");
break;
case LIB9P_ERRNO_L_ETIMEDOUT:
- fmt_state_puts(state, "L_ETIMEDOUT");
+ fmt_print_str(w, "L_ETIMEDOUT");
break;
case LIB9P_ERRNO_L_ECONNREFUSED:
- fmt_state_puts(state, "L_ECONNREFUSED");
+ fmt_print_str(w, "L_ECONNREFUSED");
break;
case LIB9P_ERRNO_L_EHOSTDOWN:
- fmt_state_puts(state, "L_EHOSTDOWN");
+ fmt_print_str(w, "L_EHOSTDOWN");
break;
case LIB9P_ERRNO_L_EHOSTUNREACH:
- fmt_state_puts(state, "L_EHOSTUNREACH");
+ fmt_print_str(w, "L_EHOSTUNREACH");
break;
case LIB9P_ERRNO_L_EALREADY:
- fmt_state_puts(state, "L_EALREADY");
+ fmt_print_str(w, "L_EALREADY");
break;
case LIB9P_ERRNO_L_EINPROGRESS:
- fmt_state_puts(state, "L_EINPROGRESS");
+ fmt_print_str(w, "L_EINPROGRESS");
break;
case LIB9P_ERRNO_L_ESTALE:
- fmt_state_puts(state, "L_ESTALE");
+ fmt_print_str(w, "L_ESTALE");
break;
case LIB9P_ERRNO_L_EUCLEAN:
- fmt_state_puts(state, "L_EUCLEAN");
+ fmt_print_str(w, "L_EUCLEAN");
break;
case LIB9P_ERRNO_L_ENOTNAM:
- fmt_state_puts(state, "L_ENOTNAM");
+ fmt_print_str(w, "L_ENOTNAM");
break;
case LIB9P_ERRNO_L_ENAVAIL:
- fmt_state_puts(state, "L_ENAVAIL");
+ fmt_print_str(w, "L_ENAVAIL");
break;
case LIB9P_ERRNO_L_EISNAM:
- fmt_state_puts(state, "L_EISNAM");
+ fmt_print_str(w, "L_EISNAM");
break;
case LIB9P_ERRNO_L_EREMOTEIO:
- fmt_state_puts(state, "L_EREMOTEIO");
+ fmt_print_str(w, "L_EREMOTEIO");
break;
case LIB9P_ERRNO_L_EDQUOT:
- fmt_state_puts(state, "L_EDQUOT");
+ fmt_print_str(w, "L_EDQUOT");
break;
case LIB9P_ERRNO_L_ENOMEDIUM:
- fmt_state_puts(state, "L_ENOMEDIUM");
+ fmt_print_str(w, "L_ENOMEDIUM");
break;
case LIB9P_ERRNO_L_EMEDIUMTYPE:
- fmt_state_puts(state, "L_EMEDIUMTYPE");
+ fmt_print_str(w, "L_EMEDIUMTYPE");
break;
case LIB9P_ERRNO_L_ECANCELED:
- fmt_state_puts(state, "L_ECANCELED");
+ fmt_print_str(w, "L_ECANCELED");
break;
case LIB9P_ERRNO_L_ENOKEY:
- fmt_state_puts(state, "L_ENOKEY");
+ fmt_print_str(w, "L_ENOKEY");
break;
case LIB9P_ERRNO_L_EKEYEXPIRED:
- fmt_state_puts(state, "L_EKEYEXPIRED");
+ fmt_print_str(w, "L_EKEYEXPIRED");
break;
case LIB9P_ERRNO_L_EKEYREVOKED:
- fmt_state_puts(state, "L_EKEYREVOKED");
+ fmt_print_str(w, "L_EKEYREVOKED");
break;
case LIB9P_ERRNO_L_EKEYREJECTED:
- fmt_state_puts(state, "L_EKEYREJECTED");
+ fmt_print_str(w, "L_EKEYREJECTED");
break;
case LIB9P_ERRNO_L_EOWNERDEAD:
- fmt_state_puts(state, "L_EOWNERDEAD");
+ fmt_print_str(w, "L_EOWNERDEAD");
break;
case LIB9P_ERRNO_L_ENOTRECOVERABLE:
- fmt_state_puts(state, "L_ENOTRECOVERABLE");
+ fmt_print_str(w, "L_ENOTRECOVERABLE");
break;
case LIB9P_ERRNO_L_ERFKILL:
- fmt_state_puts(state, "L_ERFKILL");
+ fmt_print_str(w, "L_ERFKILL");
break;
case LIB9P_ERRNO_L_EHWPOISON:
- fmt_state_puts(state, "L_EHWPOISON");
+ fmt_print_str(w, "L_EHWPOISON");
break;
default:
- fmt_state_printf(state, "%"PRIu32, *self);
+ fmt_print_base10(w, *self);
}
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
-static void lib9p_super_magic_format(lib9p_super_magic_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_super_magic(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_super_magic_t *self) {
switch (*self) {
case LIB9P_SUPER_MAGIC_V9FS_MAGIC:
- fmt_state_puts(state, "V9FS_MAGIC");
+ fmt_print_str(w, "V9FS_MAGIC");
break;
default:
- fmt_state_printf(state, "%"PRIu32, *self);
+ fmt_print_base10(w, *self);
}
}
-static void lib9p_lo_format(lib9p_lo_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_lo(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lo_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if (*self & (UINT32_C(1)<<31)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<31");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<31");
empty = false;
}
if (*self & (UINT32_C(1)<<30)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<30");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<30");
empty = false;
}
if (*self & (UINT32_C(1)<<29)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<29");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<29");
empty = false;
}
if (*self & (UINT32_C(1)<<28)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<28");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<28");
empty = false;
}
if (*self & (UINT32_C(1)<<27)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<27");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<27");
empty = false;
}
if (*self & (UINT32_C(1)<<26)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<26");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<26");
empty = false;
}
if (*self & (UINT32_C(1)<<25)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<25");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<25");
empty = false;
}
if (*self & (UINT32_C(1)<<24)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<24");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<24");
empty = false;
}
if (*self & (UINT32_C(1)<<23)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<23");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<23");
empty = false;
}
if (*self & (UINT32_C(1)<<22)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<22");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<22");
empty = false;
}
if (*self & (UINT32_C(1)<<21)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<21");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<21");
empty = false;
}
if (*self & (UINT32_C(1)<<20)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "SYNC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "SYNC");
empty = false;
}
if (*self & (UINT32_C(1)<<19)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "CLOEXEC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "CLOEXEC");
empty = false;
}
if (*self & (UINT32_C(1)<<18)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "NOATIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "NOATIME");
empty = false;
}
if (*self & (UINT32_C(1)<<17)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "NOFOLLOW");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "NOFOLLOW");
empty = false;
}
if (*self & (UINT32_C(1)<<16)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "DIRECTORY");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "DIRECTORY");
empty = false;
}
if (*self & (UINT32_C(1)<<15)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "LARGEFILE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "LARGEFILE");
empty = false;
}
if (*self & (UINT32_C(1)<<14)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "DIRECT");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "DIRECT");
empty = false;
}
if (*self & (UINT32_C(1)<<13)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "BSD_FASYNC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "BSD_FASYNC");
empty = false;
}
if (*self & (UINT32_C(1)<<12)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "DSYNC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "DSYNC");
empty = false;
}
if (*self & (UINT32_C(1)<<11)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "NONBLOCK");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "NONBLOCK");
empty = false;
}
if (*self & (UINT32_C(1)<<10)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "APPEND");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "APPEND");
empty = false;
}
if (*self & (UINT32_C(1)<<9)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "TRUNC");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "TRUNC");
empty = false;
}
if (*self & (UINT32_C(1)<<8)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "NOCTTY");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "NOCTTY");
empty = false;
}
if (*self & (UINT32_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "EXCL");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "EXCL");
empty = false;
}
if (*self & (UINT32_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "CREATE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "CREATE");
empty = false;
}
if (*self & (UINT32_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<5");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<5");
empty = false;
}
if (*self & (UINT32_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<4");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<4");
empty = false;
}
if (*self & (UINT32_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<3");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<3");
empty = false;
}
if (*self & (UINT32_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<2");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<2");
empty = false;
}
switch (*self & LIB9P_LO_MODE_MASK) {
case LIB9P_LO_MODE_RDONLY:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_RDONLY");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_RDONLY");
empty = false;
break;
case LIB9P_LO_MODE_WRONLY:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_WRONLY");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_WRONLY");
empty = false;
break;
case LIB9P_LO_MODE_RDWR:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_RDWR");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_RDWR");
empty = false;
break;
case LIB9P_LO_MODE_NOACCESS:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE_NOACCESS");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE_NOACCESS");
empty = false;
break;
default:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_printf(state, "%"PRIu32, *self & LIB9P_LO_MODE_MASK);
+ fmt_print_byte(w, '|');
+ fmt_print_base10(w, *self & LIB9P_LO_MODE_MASK);
empty = false;
}
if (empty)
- fmt_state_putchar(state, '0');
- fmt_state_putchar(state, ')');
+ fmt_print_byte(w, '0');
+ fmt_print_byte(w, ')');
}
-static void lib9p_dt_format(lib9p_dt_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_dt(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_dt_t *self) {
switch (*self) {
case LIB9P_DT_UNKNOWN:
- fmt_state_puts(state, "UNKNOWN");
+ fmt_print_str(w, "UNKNOWN");
break;
case LIB9P_DT_PIPE:
- fmt_state_puts(state, "PIPE");
+ fmt_print_str(w, "PIPE");
break;
case LIB9P_DT_CHAR_DEV:
- fmt_state_puts(state, "CHAR_DEV");
+ fmt_print_str(w, "CHAR_DEV");
break;
case LIB9P_DT_DIRECTORY:
- fmt_state_puts(state, "DIRECTORY");
+ fmt_print_str(w, "DIRECTORY");
break;
case LIB9P_DT_BLOCK_DEV:
- fmt_state_puts(state, "BLOCK_DEV");
+ fmt_print_str(w, "BLOCK_DEV");
break;
case LIB9P_DT_REGULAR:
- fmt_state_puts(state, "REGULAR");
+ fmt_print_str(w, "REGULAR");
break;
case LIB9P_DT_SYMLINK:
- fmt_state_puts(state, "SYMLINK");
+ fmt_print_str(w, "SYMLINK");
break;
case LIB9P_DT_SOCKET:
- fmt_state_puts(state, "SOCKET");
+ fmt_print_str(w, "SOCKET");
break;
case _LIB9P_DT_WHITEOUT:
- fmt_state_puts(state, "_WHITEOUT");
+ fmt_print_str(w, "_WHITEOUT");
break;
default:
- fmt_state_printf(state, "%"PRIu8, *self);
+ fmt_print_base10(w, *self);
}
}
-static void lib9p_mode_format(lib9p_mode_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_mode(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_mode_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if (*self & (UINT32_C(1)<<31)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<31");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<31");
empty = false;
}
if (*self & (UINT32_C(1)<<30)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<30");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<30");
empty = false;
}
if (*self & (UINT32_C(1)<<29)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<29");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<29");
empty = false;
}
if (*self & (UINT32_C(1)<<28)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<28");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<28");
empty = false;
}
if (*self & (UINT32_C(1)<<27)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<27");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<27");
empty = false;
}
if (*self & (UINT32_C(1)<<26)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<26");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<26");
empty = false;
}
if (*self & (UINT32_C(1)<<25)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<25");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<25");
empty = false;
}
if (*self & (UINT32_C(1)<<24)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<24");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<24");
empty = false;
}
if (*self & (UINT32_C(1)<<23)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<23");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<23");
empty = false;
}
if (*self & (UINT32_C(1)<<22)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<22");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<22");
empty = false;
}
if (*self & (UINT32_C(1)<<21)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<21");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<21");
empty = false;
}
if (*self & (UINT32_C(1)<<20)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<20");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<20");
empty = false;
}
if (*self & (UINT32_C(1)<<19)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<19");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<19");
empty = false;
}
if (*self & (UINT32_C(1)<<18)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<18");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<18");
empty = false;
}
if (*self & (UINT32_C(1)<<17)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<17");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<17");
empty = false;
}
if (*self & (UINT32_C(1)<<16)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<16");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<16");
empty = false;
}
switch (*self & LIB9P_MODE_FMT_MASK) {
case LIB9P_MODE_FMT_PIPE:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "FMT_PIPE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "FMT_PIPE");
empty = false;
break;
case LIB9P_MODE_FMT_CHAR_DEV:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "FMT_CHAR_DEV");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "FMT_CHAR_DEV");
empty = false;
break;
case LIB9P_MODE_FMT_DIRECTORY:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "FMT_DIRECTORY");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "FMT_DIRECTORY");
empty = false;
break;
case LIB9P_MODE_FMT_BLOCK_DEV:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "FMT_BLOCK_DEV");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "FMT_BLOCK_DEV");
empty = false;
break;
case LIB9P_MODE_FMT_REGULAR:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "FMT_REGULAR");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "FMT_REGULAR");
empty = false;
break;
case LIB9P_MODE_FMT_SYMLINK:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "FMT_SYMLINK");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "FMT_SYMLINK");
empty = false;
break;
case LIB9P_MODE_FMT_SOCKET:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "FMT_SOCKET");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "FMT_SOCKET");
empty = false;
break;
default:
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_printf(state, "%"PRIu32, *self & LIB9P_MODE_FMT_MASK);
+ fmt_print_byte(w, '|');
+ fmt_print_base10(w, *self & LIB9P_MODE_FMT_MASK);
empty = false;
}
if (*self & (UINT32_C(1)<<11)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_SETGROUP");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_SETGROUP");
empty = false;
}
if (*self & (UINT32_C(1)<<10)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_SETUSER");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_SETUSER");
empty = false;
}
if (*self & (UINT32_C(1)<<9)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_STICKY");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_STICKY");
empty = false;
}
if (*self & (UINT32_C(1)<<8)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_OWNER_R");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_OWNER_R");
empty = false;
}
if (*self & (UINT32_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_OWNER_W");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_OWNER_W");
empty = false;
}
if (*self & (UINT32_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_OWNER_X");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_OWNER_X");
empty = false;
}
if (*self & (UINT32_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_GROUP_R");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_GROUP_R");
empty = false;
}
if (*self & (UINT32_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_GROUP_W");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_GROUP_W");
empty = false;
}
if (*self & (UINT32_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_GROUP_X");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_GROUP_X");
empty = false;
}
if (*self & (UINT32_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_OTHER_R");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_OTHER_R");
empty = false;
}
if (*self & (UINT32_C(1)<<1)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_OTHER_W");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_OTHER_W");
empty = false;
}
if (*self & (UINT32_C(1)<<0)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "PERM_OTHER_X");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "PERM_OTHER_X");
empty = false;
}
if (empty)
- fmt_state_putchar(state, '0');
- fmt_state_putchar(state, ')');
+ fmt_print_byte(w, '0');
+ fmt_print_byte(w, ')');
}
-static void lib9p_b4_format(lib9p_b4_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_b4(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_b4_t *self) {
switch (*self) {
case LIB9P_B4_FALSE:
- fmt_state_puts(state, "FALSE");
+ fmt_print_str(w, "FALSE");
break;
case LIB9P_B4_TRUE:
- fmt_state_puts(state, "TRUE");
+ fmt_print_str(w, "TRUE");
break;
default:
- fmt_state_printf(state, "%"PRIu32, *self);
+ fmt_print_base10(w, *self);
}
}
-static void lib9p_getattr_format(lib9p_getattr_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_getattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_getattr_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if (*self & (UINT64_C(1)<<63)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<63");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<63");
empty = false;
}
if (*self & (UINT64_C(1)<<62)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<62");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<62");
empty = false;
}
if (*self & (UINT64_C(1)<<61)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<61");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<61");
empty = false;
}
if (*self & (UINT64_C(1)<<60)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<60");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<60");
empty = false;
}
if (*self & (UINT64_C(1)<<59)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<59");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<59");
empty = false;
}
if (*self & (UINT64_C(1)<<58)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<58");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<58");
empty = false;
}
if (*self & (UINT64_C(1)<<57)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<57");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<57");
empty = false;
}
if (*self & (UINT64_C(1)<<56)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<56");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<56");
empty = false;
}
if (*self & (UINT64_C(1)<<55)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<55");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<55");
empty = false;
}
if (*self & (UINT64_C(1)<<54)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<54");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<54");
empty = false;
}
if (*self & (UINT64_C(1)<<53)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<53");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<53");
empty = false;
}
if (*self & (UINT64_C(1)<<52)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<52");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<52");
empty = false;
}
if (*self & (UINT64_C(1)<<51)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<51");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<51");
empty = false;
}
if (*self & (UINT64_C(1)<<50)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<50");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<50");
empty = false;
}
if (*self & (UINT64_C(1)<<49)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<49");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<49");
empty = false;
}
if (*self & (UINT64_C(1)<<48)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<48");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<48");
empty = false;
}
if (*self & (UINT64_C(1)<<47)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<47");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<47");
empty = false;
}
if (*self & (UINT64_C(1)<<46)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<46");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<46");
empty = false;
}
if (*self & (UINT64_C(1)<<45)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<45");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<45");
empty = false;
}
if (*self & (UINT64_C(1)<<44)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<44");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<44");
empty = false;
}
if (*self & (UINT64_C(1)<<43)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<43");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<43");
empty = false;
}
if (*self & (UINT64_C(1)<<42)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<42");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<42");
empty = false;
}
if (*self & (UINT64_C(1)<<41)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<41");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<41");
empty = false;
}
if (*self & (UINT64_C(1)<<40)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<40");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<40");
empty = false;
}
if (*self & (UINT64_C(1)<<39)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<39");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<39");
empty = false;
}
if (*self & (UINT64_C(1)<<38)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<38");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<38");
empty = false;
}
if (*self & (UINT64_C(1)<<37)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<37");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<37");
empty = false;
}
if (*self & (UINT64_C(1)<<36)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<36");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<36");
empty = false;
}
if (*self & (UINT64_C(1)<<35)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<35");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<35");
empty = false;
}
if (*self & (UINT64_C(1)<<34)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<34");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<34");
empty = false;
}
if (*self & (UINT64_C(1)<<33)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<33");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<33");
empty = false;
}
if (*self & (UINT64_C(1)<<32)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<32");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<32");
empty = false;
}
if (*self & (UINT64_C(1)<<31)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<31");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<31");
empty = false;
}
if (*self & (UINT64_C(1)<<30)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<30");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<30");
empty = false;
}
if (*self & (UINT64_C(1)<<29)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<29");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<29");
empty = false;
}
if (*self & (UINT64_C(1)<<28)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<28");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<28");
empty = false;
}
if (*self & (UINT64_C(1)<<27)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<27");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<27");
empty = false;
}
if (*self & (UINT64_C(1)<<26)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<26");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<26");
empty = false;
}
if (*self & (UINT64_C(1)<<25)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<25");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<25");
empty = false;
}
if (*self & (UINT64_C(1)<<24)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<24");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<24");
empty = false;
}
if (*self & (UINT64_C(1)<<23)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<23");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<23");
empty = false;
}
if (*self & (UINT64_C(1)<<22)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<22");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<22");
empty = false;
}
if (*self & (UINT64_C(1)<<21)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<21");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<21");
empty = false;
}
if (*self & (UINT64_C(1)<<20)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<20");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<20");
empty = false;
}
if (*self & (UINT64_C(1)<<19)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<19");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<19");
empty = false;
}
if (*self & (UINT64_C(1)<<18)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<18");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<18");
empty = false;
}
if (*self & (UINT64_C(1)<<17)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<17");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<17");
empty = false;
}
if (*self & (UINT64_C(1)<<16)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<16");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<16");
empty = false;
}
if (*self & (UINT64_C(1)<<15)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<15");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<15");
empty = false;
}
if (*self & (UINT64_C(1)<<14)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<14");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<14");
empty = false;
}
if (*self & (UINT64_C(1)<<13)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "DATA_VERSION");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "DATA_VERSION");
empty = false;
}
if (*self & (UINT64_C(1)<<12)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "GEN");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "GEN");
empty = false;
}
if (*self & (UINT64_C(1)<<11)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "BTIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "BTIME");
empty = false;
}
if (*self & (UINT64_C(1)<<10)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "BLOCKS");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "BLOCKS");
empty = false;
}
if (*self & (UINT64_C(1)<<9)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "SIZE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "SIZE");
empty = false;
}
if (*self & (UINT64_C(1)<<8)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "INO");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "INO");
empty = false;
}
if (*self & (UINT64_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "CTIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "CTIME");
empty = false;
}
if (*self & (UINT64_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MTIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MTIME");
empty = false;
}
if (*self & (UINT64_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "ATIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "ATIME");
empty = false;
}
if (*self & (UINT64_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "RDEV");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "RDEV");
empty = false;
}
if (*self & (UINT64_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "GID");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "GID");
empty = false;
}
if (*self & (UINT64_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "UID");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "UID");
empty = false;
}
if (*self & (UINT64_C(1)<<1)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "NLINK");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "NLINK");
empty = false;
}
if (*self & (UINT64_C(1)<<0)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE");
empty = false;
}
if (empty)
- fmt_state_putchar(state, '0');
- fmt_state_putchar(state, ')');
+ fmt_print_byte(w, '0');
+ fmt_print_byte(w, ')');
}
-static void lib9p_setattr_format(lib9p_setattr_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_setattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_setattr_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if (*self & (UINT32_C(1)<<31)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<31");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<31");
empty = false;
}
if (*self & (UINT32_C(1)<<30)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<30");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<30");
empty = false;
}
if (*self & (UINT32_C(1)<<29)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<29");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<29");
empty = false;
}
if (*self & (UINT32_C(1)<<28)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<28");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<28");
empty = false;
}
if (*self & (UINT32_C(1)<<27)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<27");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<27");
empty = false;
}
if (*self & (UINT32_C(1)<<26)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<26");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<26");
empty = false;
}
if (*self & (UINT32_C(1)<<25)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<25");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<25");
empty = false;
}
if (*self & (UINT32_C(1)<<24)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<24");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<24");
empty = false;
}
if (*self & (UINT32_C(1)<<23)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<23");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<23");
empty = false;
}
if (*self & (UINT32_C(1)<<22)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<22");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<22");
empty = false;
}
if (*self & (UINT32_C(1)<<21)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<21");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<21");
empty = false;
}
if (*self & (UINT32_C(1)<<20)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<20");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<20");
empty = false;
}
if (*self & (UINT32_C(1)<<19)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<19");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<19");
empty = false;
}
if (*self & (UINT32_C(1)<<18)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<18");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<18");
empty = false;
}
if (*self & (UINT32_C(1)<<17)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<17");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<17");
empty = false;
}
if (*self & (UINT32_C(1)<<16)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<16");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<16");
empty = false;
}
if (*self & (UINT32_C(1)<<15)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<15");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<15");
empty = false;
}
if (*self & (UINT32_C(1)<<14)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<14");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<14");
empty = false;
}
if (*self & (UINT32_C(1)<<13)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<13");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<13");
empty = false;
}
if (*self & (UINT32_C(1)<<12)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<12");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<12");
empty = false;
}
if (*self & (UINT32_C(1)<<11)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<11");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<11");
empty = false;
}
if (*self & (UINT32_C(1)<<10)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<10");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<10");
empty = false;
}
if (*self & (UINT32_C(1)<<9)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<9");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<9");
empty = false;
}
if (*self & (UINT32_C(1)<<8)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MTIME_SET");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MTIME_SET");
empty = false;
}
if (*self & (UINT32_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "ATIME_SET");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "ATIME_SET");
empty = false;
}
if (*self & (UINT32_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "CTIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "CTIME");
empty = false;
}
if (*self & (UINT32_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MTIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MTIME");
empty = false;
}
if (*self & (UINT32_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "ATIME");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "ATIME");
empty = false;
}
if (*self & (UINT32_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "SIZE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "SIZE");
empty = false;
}
if (*self & (UINT32_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "GID");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "GID");
empty = false;
}
if (*self & (UINT32_C(1)<<1)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "UID");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "UID");
empty = false;
}
if (*self & (UINT32_C(1)<<0)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "MODE");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "MODE");
empty = false;
}
if (empty)
- fmt_state_putchar(state, '0');
- fmt_state_putchar(state, ')');
+ fmt_print_byte(w, '0');
+ fmt_print_byte(w, ')');
}
-static void lib9p_lock_type_format(lib9p_lock_type_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_lock_type(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lock_type_t *self) {
switch (*self) {
case LIB9P_LOCK_TYPE_RDLCK:
- fmt_state_puts(state, "RDLCK");
+ fmt_print_str(w, "RDLCK");
break;
case LIB9P_LOCK_TYPE_WRLCK:
- fmt_state_puts(state, "WRLCK");
+ fmt_print_str(w, "WRLCK");
break;
case LIB9P_LOCK_TYPE_UNLCK:
- fmt_state_puts(state, "UNLCK");
+ fmt_print_str(w, "UNLCK");
break;
default:
- fmt_state_printf(state, "%"PRIu8, *self);
+ fmt_print_base10(w, *self);
}
}
-static void lib9p_lock_flags_format(lib9p_lock_flags_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_lock_flags(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lock_flags_t *self) {
bool empty = true;
- fmt_state_putchar(state, '(');
+ fmt_print_byte(w, '(');
if (*self & (UINT32_C(1)<<31)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<31");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<31");
empty = false;
}
if (*self & (UINT32_C(1)<<30)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<30");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<30");
empty = false;
}
if (*self & (UINT32_C(1)<<29)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<29");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<29");
empty = false;
}
if (*self & (UINT32_C(1)<<28)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<28");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<28");
empty = false;
}
if (*self & (UINT32_C(1)<<27)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<27");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<27");
empty = false;
}
if (*self & (UINT32_C(1)<<26)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<26");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<26");
empty = false;
}
if (*self & (UINT32_C(1)<<25)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<25");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<25");
empty = false;
}
if (*self & (UINT32_C(1)<<24)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<24");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<24");
empty = false;
}
if (*self & (UINT32_C(1)<<23)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<23");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<23");
empty = false;
}
if (*self & (UINT32_C(1)<<22)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<22");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<22");
empty = false;
}
if (*self & (UINT32_C(1)<<21)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<21");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<21");
empty = false;
}
if (*self & (UINT32_C(1)<<20)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<20");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<20");
empty = false;
}
if (*self & (UINT32_C(1)<<19)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<19");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<19");
empty = false;
}
if (*self & (UINT32_C(1)<<18)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<18");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<18");
empty = false;
}
if (*self & (UINT32_C(1)<<17)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<17");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<17");
empty = false;
}
if (*self & (UINT32_C(1)<<16)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<16");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<16");
empty = false;
}
if (*self & (UINT32_C(1)<<15)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<15");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<15");
empty = false;
}
if (*self & (UINT32_C(1)<<14)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<14");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<14");
empty = false;
}
if (*self & (UINT32_C(1)<<13)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<13");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<13");
empty = false;
}
if (*self & (UINT32_C(1)<<12)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<12");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<12");
empty = false;
}
if (*self & (UINT32_C(1)<<11)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<11");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<11");
empty = false;
}
if (*self & (UINT32_C(1)<<10)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<10");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<10");
empty = false;
}
if (*self & (UINT32_C(1)<<9)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<9");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<9");
empty = false;
}
if (*self & (UINT32_C(1)<<8)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<8");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<8");
empty = false;
}
if (*self & (UINT32_C(1)<<7)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<7");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<7");
empty = false;
}
if (*self & (UINT32_C(1)<<6)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<6");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<6");
empty = false;
}
if (*self & (UINT32_C(1)<<5)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<5");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<5");
empty = false;
}
if (*self & (UINT32_C(1)<<4)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<4");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<4");
empty = false;
}
if (*self & (UINT32_C(1)<<3)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<3");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<3");
empty = false;
}
if (*self & (UINT32_C(1)<<2)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "1<<2");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "1<<2");
empty = false;
}
if (*self & (UINT32_C(1)<<1)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "RECLAIM");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "RECLAIM");
empty = false;
}
if (*self & (UINT32_C(1)<<0)) {
if (!empty)
- fmt_state_putchar(state, '|');
- fmt_state_puts(state, "BLOCK");
+ fmt_print_byte(w, '|');
+ fmt_print_str(w, "BLOCK");
empty = false;
}
if (empty)
- fmt_state_putchar(state, '0');
- fmt_state_putchar(state, ')');
+ fmt_print_byte(w, '0');
+ fmt_print_byte(w, ')');
}
-static void lib9p_lock_status_format(lib9p_lock_status_t *self, struct fmt_state *state) {
+[[maybe_unused]] static void fmt_print_lock_status(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, lib9p_lock_status_t *self) {
switch (*self) {
case LIB9P_LOCK_STATUS_SUCCESS:
- fmt_state_puts(state, "SUCCESS");
+ fmt_print_str(w, "SUCCESS");
break;
case LIB9P_LOCK_STATUS_BLOCKED:
- fmt_state_puts(state, "BLOCKED");
+ fmt_print_str(w, "BLOCKED");
break;
case LIB9P_LOCK_STATUS_ERROR:
- fmt_state_puts(state, "ERROR");
+ fmt_print_str(w, "ERROR");
break;
case LIB9P_LOCK_STATUS_GRACE:
- fmt_state_puts(state, "GRACE");
+ fmt_print_str(w, "GRACE");
break;
default:
- fmt_state_printf(state, "%"PRIu8, *self);
- }
-}
-
-static void lib9p_msg_Rlerror_format(struct lib9p_msg_Rlerror *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rlerror {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " errnum=");
- lib9p_errno_format(&self->errnum, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tstatfs_format(struct lib9p_msg_Tstatfs *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tstatfs {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rstatfs_format(struct lib9p_msg_Rstatfs *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rstatfs {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " type=");
- lib9p_super_magic_format(&self->type, state);
- fmt_state_puts(state, " bsize=");
- fmt_state_printf(state, "%"PRIu32, self->bsize);
- fmt_state_puts(state, " blocks=");
- fmt_state_printf(state, "%"PRIu64, self->blocks);
- fmt_state_puts(state, " bfree=");
- fmt_state_printf(state, "%"PRIu64, self->bfree);
- fmt_state_puts(state, " bavail=");
- fmt_state_printf(state, "%"PRIu64, self->bavail);
- fmt_state_puts(state, " files=");
- fmt_state_printf(state, "%"PRIu64, self->files);
- fmt_state_puts(state, " ffree=");
- fmt_state_printf(state, "%"PRIu64, self->ffree);
- fmt_state_puts(state, " fsid=");
- fmt_state_printf(state, "%"PRIu64, self->fsid);
- fmt_state_puts(state, " namelen=");
- fmt_state_printf(state, "%"PRIu32, self->namelen);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tlopen_format(struct lib9p_msg_Tlopen *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tlopen {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " flags=");
- lib9p_lo_format(&self->flags, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rlopen_format(struct lib9p_msg_Rlopen *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rlopen {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " iounit=");
- fmt_state_printf(state, "%"PRIu32, self->iounit);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tlcreate_format(struct lib9p_msg_Tlcreate *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tlcreate {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " flags=");
- lib9p_lo_format(&self->flags, state);
- fmt_state_puts(state, " mode=");
- lib9p_mode_format(&self->mode, state);
- fmt_state_puts(state, " gid=");
- lib9p_nuid_format(&self->gid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rlcreate_format(struct lib9p_msg_Rlcreate *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rlcreate {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " iounit=");
- fmt_state_printf(state, "%"PRIu32, self->iounit);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tsymlink_format(struct lib9p_msg_Tsymlink *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tsymlink {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " symtgt=");
- lib9p_s_format(&self->symtgt, state);
- fmt_state_puts(state, " gid=");
- lib9p_nuid_format(&self->gid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rsymlink_format(struct lib9p_msg_Rsymlink *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rsymlink {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tmknod_format(struct lib9p_msg_Tmknod *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tmknod {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " dfid=");
- lib9p_fid_format(&self->dfid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " mode=");
- lib9p_mode_format(&self->mode, state);
- fmt_state_puts(state, " major=");
- fmt_state_printf(state, "%"PRIu32, self->major);
- fmt_state_puts(state, " minor=");
- fmt_state_printf(state, "%"PRIu32, self->minor);
- fmt_state_puts(state, " gid=");
- lib9p_nuid_format(&self->gid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rmknod_format(struct lib9p_msg_Rmknod *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rmknod {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Trename_format(struct lib9p_msg_Trename *self, struct fmt_state *state) {
- fmt_state_puts(state, "Trename {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " dfid=");
- lib9p_fid_format(&self->dfid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rrename_format(struct lib9p_msg_Rrename *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rrename {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Treadlink_format(struct lib9p_msg_Treadlink *self, struct fmt_state *state) {
- fmt_state_puts(state, "Treadlink {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rreadlink_format(struct lib9p_msg_Rreadlink *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rreadlink {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " target=");
- lib9p_s_format(&self->target, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tgetattr_format(struct lib9p_msg_Tgetattr *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tgetattr {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " request_mask=");
- lib9p_getattr_format(&self->request_mask, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rgetattr_format(struct lib9p_msg_Rgetattr *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rgetattr {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " valid=");
- lib9p_getattr_format(&self->valid, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " mode=");
- lib9p_mode_format(&self->mode, state);
- fmt_state_puts(state, " uid=");
- lib9p_nuid_format(&self->uid, state);
- fmt_state_puts(state, " gid=");
- lib9p_nuid_format(&self->gid, state);
- fmt_state_puts(state, " nlink=");
- fmt_state_printf(state, "%"PRIu64, self->nlink);
- fmt_state_puts(state, " rdev=");
- fmt_state_printf(state, "%"PRIu64, self->rdev);
- fmt_state_puts(state, " filesize=");
- fmt_state_printf(state, "%"PRIu64, self->filesize);
- fmt_state_puts(state, " blksize=");
- fmt_state_printf(state, "%"PRIu64, self->blksize);
- fmt_state_puts(state, " blocks=");
- fmt_state_printf(state, "%"PRIu64, self->blocks);
- fmt_state_puts(state, " atime_sec=");
- fmt_state_printf(state, "%"PRIu64, self->atime_sec);
- fmt_state_puts(state, " atime_nsec=");
- fmt_state_printf(state, "%"PRIu64, self->atime_nsec);
- fmt_state_puts(state, " mtime_sec=");
- fmt_state_printf(state, "%"PRIu64, self->mtime_sec);
- fmt_state_puts(state, " mtime_nsec=");
- fmt_state_printf(state, "%"PRIu64, self->mtime_nsec);
- fmt_state_puts(state, " ctime_sec=");
- fmt_state_printf(state, "%"PRIu64, self->ctime_sec);
- fmt_state_puts(state, " ctime_nsec=");
- fmt_state_printf(state, "%"PRIu64, self->ctime_nsec);
- fmt_state_puts(state, " btime_sec=");
- fmt_state_printf(state, "%"PRIu64, self->btime_sec);
- fmt_state_puts(state, " btime_nsec=");
- fmt_state_printf(state, "%"PRIu64, self->btime_nsec);
- fmt_state_puts(state, " gen=");
- fmt_state_printf(state, "%"PRIu64, self->gen);
- fmt_state_puts(state, " data_version=");
- fmt_state_printf(state, "%"PRIu64, self->data_version);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tsetattr_format(struct lib9p_msg_Tsetattr *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tsetattr {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " valid=");
- lib9p_setattr_format(&self->valid, state);
- fmt_state_puts(state, " mode=");
- lib9p_mode_format(&self->mode, state);
- fmt_state_puts(state, " uid=");
- lib9p_nuid_format(&self->uid, state);
- fmt_state_puts(state, " gid=");
- lib9p_nuid_format(&self->gid, state);
- fmt_state_puts(state, " filesize=");
- fmt_state_printf(state, "%"PRIu64, self->filesize);
- fmt_state_puts(state, " atime_sec=");
- fmt_state_printf(state, "%"PRIu64, self->atime_sec);
- fmt_state_puts(state, " atime_nsec=");
- fmt_state_printf(state, "%"PRIu64, self->atime_nsec);
- fmt_state_puts(state, " mtime_sec=");
- fmt_state_printf(state, "%"PRIu64, self->mtime_sec);
- fmt_state_puts(state, " mtime_nsec=");
- fmt_state_printf(state, "%"PRIu64, self->mtime_nsec);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rsetattr_format(struct lib9p_msg_Rsetattr *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rsetattr {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Txattrwalk_format(struct lib9p_msg_Txattrwalk *self, struct fmt_state *state) {
- fmt_state_puts(state, "Txattrwalk {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " newfid=");
- lib9p_fid_format(&self->newfid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rxattrwalk_format(struct lib9p_msg_Rxattrwalk *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rxattrwalk {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " attr_size=");
- fmt_state_printf(state, "%"PRIu64, self->attr_size);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Txattrcreate_format(struct lib9p_msg_Txattrcreate *self, struct fmt_state *state) {
- fmt_state_puts(state, "Txattrcreate {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " attr_size=");
- fmt_state_printf(state, "%"PRIu64, self->attr_size);
- fmt_state_puts(state, " flags=");
- fmt_state_printf(state, "%"PRIu32, self->flags);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rxattrcreate_format(struct lib9p_msg_Rxattrcreate *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rxattrcreate {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Treaddir_format(struct lib9p_msg_Treaddir *self, struct fmt_state *state) {
- fmt_state_puts(state, "Treaddir {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " offset=");
- fmt_state_printf(state, "%"PRIu64, self->offset);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rreaddir_format(struct lib9p_msg_Rreaddir *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rreaddir {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
+ fmt_print_base10(w, *self);
+ }
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
+[[maybe_unused]] static void fmt_print_s(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_s *self) {
+ fmt_print_qmem(w, self->utf8, self->len);
+}
+
+[[maybe_unused]] static void fmt_print_qid(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_qid *self) {
+ fmt_print_byte(w, '{');
+ fmt_print_str(w, " type=");
+ fmt_print_qt(w, ctx, &self->type);
+ fmt_print_str(w, " vers=");
+ fmt_print_base10(w, self->vers);
+ fmt_print_str(w, " path=");
+ fmt_print_base10(w, self->path);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Tflush(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *self) {
+ fmt_print_str(w, "Tflush {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " oldtag=");
+ fmt_print_base10(w, self->oldtag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rflush(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *self) {
+ fmt_print_str(w, "Rflush {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Topen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Topen *self) {
+ fmt_print_str(w, "Topen {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " mode=");
+ fmt_print_o(w, ctx, &self->mode);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Tread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tread *self) {
+ fmt_print_str(w, "Tread {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " offset=");
+ fmt_print_base10(w, self->offset);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rread *self) {
+ fmt_print_str(w, "Rread {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
+ if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
+ fmt_print_str(w, " data=");
+ fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50);
+ if (self->count > 50)
+ fmt_print_str(w, "...");
+ } else {
+ fmt_print_str(w, " data=<bytedata>");
+ }
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Twrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *self) {
+ fmt_print_str(w, "Twrite {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " offset=");
+ fmt_print_base10(w, self->offset);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
+ if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
+ fmt_print_str(w, " data=");
+ fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50);
+ if (self->count > 50)
+ fmt_print_str(w, "...");
+ } else {
+ fmt_print_str(w, " data=<bytedata>");
+ }
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rwrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *self) {
+ fmt_print_str(w, "Rwrite {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tclunk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *self) {
+ fmt_print_str(w, "Tclunk {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rclunk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *self) {
+ fmt_print_str(w, "Rclunk {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tremove(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *self) {
+ fmt_print_str(w, "Tremove {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rremove(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *self) {
+ fmt_print_str(w, "Rremove {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Tstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *self) {
+ fmt_print_str(w, "Tstat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rwstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *self) {
+ fmt_print_str(w, "Rwstat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_p9p
+[[maybe_unused]] static void fmt_print_Topenfd(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *self) {
+ fmt_print_str(w, "Topenfd {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " mode=");
+ fmt_print_o(w, ctx, &self->mode);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
+#if CONFIG_9P_ENABLE_9P2000_L
+[[maybe_unused]] static void fmt_print_Rlerror(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *self) {
+ fmt_print_str(w, "Rlerror {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " errnum=");
+ fmt_print_errno(w, ctx, &self->errnum);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tstatfs(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *self) {
+ fmt_print_str(w, "Tstatfs {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rstatfs(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *self) {
+ fmt_print_str(w, "Rstatfs {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " type=");
+ fmt_print_super_magic(w, ctx, &self->type);
+ fmt_print_str(w, " bsize=");
+ fmt_print_base10(w, self->bsize);
+ fmt_print_str(w, " blocks=");
+ fmt_print_base10(w, self->blocks);
+ fmt_print_str(w, " bfree=");
+ fmt_print_base10(w, self->bfree);
+ fmt_print_str(w, " bavail=");
+ fmt_print_base10(w, self->bavail);
+ fmt_print_str(w, " files=");
+ fmt_print_base10(w, self->files);
+ fmt_print_str(w, " ffree=");
+ fmt_print_base10(w, self->ffree);
+ fmt_print_str(w, " fsid=");
+ fmt_print_base10(w, self->fsid);
+ fmt_print_str(w, " namelen=");
+ fmt_print_base10(w, self->namelen);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tlopen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *self) {
+ fmt_print_str(w, "Tlopen {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " flags=");
+ fmt_print_lo(w, ctx, &self->flags);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rrename(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *self) {
+ fmt_print_str(w, "Rrename {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Treadlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *self) {
+ fmt_print_str(w, "Treadlink {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tgetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *self) {
+ fmt_print_str(w, "Tgetattr {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " request_mask=");
+ fmt_print_getattr(w, ctx, &self->request_mask);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tsetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *self) {
+ fmt_print_str(w, "Tsetattr {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " valid=");
+ fmt_print_setattr(w, ctx, &self->valid);
+ fmt_print_str(w, " mode=");
+ fmt_print_mode(w, ctx, &self->mode);
+ fmt_print_str(w, " uid=");
+ fmt_print_nuid(w, ctx, &self->uid);
+ fmt_print_str(w, " gid=");
+ fmt_print_nuid(w, ctx, &self->gid);
+ fmt_print_str(w, " filesize=");
+ fmt_print_base10(w, self->filesize);
+ fmt_print_str(w, " atime_sec=");
+ fmt_print_base10(w, self->atime_sec);
+ fmt_print_str(w, " atime_nsec=");
+ fmt_print_base10(w, self->atime_nsec);
+ fmt_print_str(w, " mtime_sec=");
+ fmt_print_base10(w, self->mtime_sec);
+ fmt_print_str(w, " mtime_nsec=");
+ fmt_print_base10(w, self->mtime_nsec);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rsetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *self) {
+ fmt_print_str(w, "Rsetattr {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rxattrwalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwalk *self) {
+ fmt_print_str(w, "Rxattrwalk {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " attr_size=");
+ fmt_print_base10(w, self->attr_size);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rxattrcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrcreate *self) {
+ fmt_print_str(w, "Rxattrcreate {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Treaddir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *self) {
+ fmt_print_str(w, "Treaddir {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " offset=");
+ fmt_print_base10(w, self->offset);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rreaddir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *self) {
+ fmt_print_str(w, "Rreaddir {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- fmt_state_printf(state, " data=%.*q%s",
- (int)(self->count < 50 ? self->count : 50),
- (char *)self->data,
- self->count < 50 ? "" : "...");
-#pragma GCC diagnostic pop
+ fmt_print_str(w, " data=");
+ fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50);
+ if (self->count > 50)
+ fmt_print_str(w, "...");
} else {
- fmt_state_puts(state, " data=<bytedata>");
- }
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tfsync_format(struct lib9p_msg_Tfsync *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tfsync {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " datasync=");
- lib9p_b4_format(&self->datasync, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rfsync_format(struct lib9p_msg_Rfsync *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rfsync {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tlock_format(struct lib9p_msg_Tlock *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tlock {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " type=");
- lib9p_lock_type_format(&self->type, state);
- fmt_state_puts(state, " flags=");
- lib9p_lock_flags_format(&self->flags, state);
- fmt_state_puts(state, " start=");
- fmt_state_printf(state, "%"PRIu64, self->start);
- fmt_state_puts(state, " length=");
- fmt_state_printf(state, "%"PRIu64, self->length);
- fmt_state_puts(state, " proc_id=");
- fmt_state_printf(state, "%"PRIu32, self->proc_id);
- fmt_state_puts(state, " client_id=");
- lib9p_s_format(&self->client_id, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rlock_format(struct lib9p_msg_Rlock *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rlock {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " status=");
- lib9p_lock_status_format(&self->status, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tgetlock_format(struct lib9p_msg_Tgetlock *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tgetlock {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " type=");
- lib9p_lock_type_format(&self->type, state);
- fmt_state_puts(state, " start=");
- fmt_state_printf(state, "%"PRIu64, self->start);
- fmt_state_puts(state, " length=");
- fmt_state_printf(state, "%"PRIu64, self->length);
- fmt_state_puts(state, " proc_id=");
- fmt_state_printf(state, "%"PRIu32, self->proc_id);
- fmt_state_puts(state, " client_id=");
- lib9p_s_format(&self->client_id, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rgetlock_format(struct lib9p_msg_Rgetlock *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rgetlock {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " type=");
- lib9p_lock_type_format(&self->type, state);
- fmt_state_puts(state, " start=");
- fmt_state_printf(state, "%"PRIu64, self->start);
- fmt_state_puts(state, " length=");
- fmt_state_printf(state, "%"PRIu64, self->length);
- fmt_state_puts(state, " proc_id=");
- fmt_state_printf(state, "%"PRIu32, self->proc_id);
- fmt_state_puts(state, " client_id=");
- lib9p_s_format(&self->client_id, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tlink_format(struct lib9p_msg_Tlink *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tlink {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " dfid=");
- lib9p_fid_format(&self->dfid, state);
- fmt_state_puts(state, " fid=");
- lib9p_fid_format(&self->fid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rlink_format(struct lib9p_msg_Rlink *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rlink {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tmkdir_format(struct lib9p_msg_Tmkdir *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tmkdir {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " dfid=");
- lib9p_fid_format(&self->dfid, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " mode=");
- lib9p_mode_format(&self->mode, state);
- fmt_state_puts(state, " gid=");
- lib9p_nuid_format(&self->gid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rmkdir_format(struct lib9p_msg_Rmkdir *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rmkdir {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " qid=");
- lib9p_qid_format(&self->qid, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Trenameat_format(struct lib9p_msg_Trenameat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Trenameat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " olddirfid=");
- lib9p_fid_format(&self->olddirfid, state);
- fmt_state_puts(state, " oldname=");
- lib9p_s_format(&self->oldname, state);
- fmt_state_puts(state, " newdirfid=");
- lib9p_fid_format(&self->newdirfid, state);
- fmt_state_puts(state, " newname=");
- lib9p_s_format(&self->newname, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rrenameat_format(struct lib9p_msg_Rrenameat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rrenameat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tunlinkat_format(struct lib9p_msg_Tunlinkat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tunlinkat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " dirfd=");
- lib9p_fid_format(&self->dirfd, state);
- fmt_state_puts(state, " name=");
- lib9p_s_format(&self->name, state);
- fmt_state_puts(state, " flags=");
- fmt_state_printf(state, "%"PRIu32, self->flags);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Runlinkat_format(struct lib9p_msg_Runlinkat *self, struct fmt_state *state) {
- fmt_state_puts(state, "Runlinkat {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
+ fmt_print_str(w, " data=<bytedata>");
+ }
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tfsync(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *self) {
+ fmt_print_str(w, "Tfsync {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " datasync=");
+ fmt_print_b4(w, ctx, &self->datasync);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rfsync(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *self) {
+ fmt_print_str(w, "Rfsync {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *self) {
+ fmt_print_str(w, "Rlock {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " status=");
+ fmt_print_lock_status(w, ctx, &self->status);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *self) {
+ fmt_print_str(w, "Rlink {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rrenameat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat *self) {
+ fmt_print_str(w, "Rrenameat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Runlinkat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat *self) {
+ fmt_print_str(w, "Runlinkat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
-static void lib9p_msg_Tsession_format(struct lib9p_msg_Tsession *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tsession {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " key=");
- fmt_state_printf(state, "%"PRIu64, self->key);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Rsession_format(struct lib9p_msg_Rsession *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rsession {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " }");
-}
-
-static void lib9p_msg_Tsread_format(struct lib9p_msg_Tsread *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tsread {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- fmt_state_printf(state, "%"PRIu32, self->fid);
- fmt_state_puts(state, " nwname=");
- fmt_state_printf(state, "%"PRIu16, self->nwname);
- fmt_state_puts(state, " wname=[");
+[[maybe_unused]] static void fmt_print_Tsession(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *self) {
+ fmt_print_str(w, "Tsession {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " key=");
+ fmt_print_base10(w, self->key);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rsession(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *self) {
+ fmt_print_str(w, "Rsession {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rsread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *self) {
+ fmt_print_str(w, "Rsread {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
+ if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
+ fmt_print_str(w, " data=");
+ fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50);
+ if (self->count > 50)
+ fmt_print_str(w, "...");
+ } else {
+ fmt_print_str(w, " data=<bytedata>");
+ }
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rswrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *self) {
+ fmt_print_str(w, "Rswrite {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] void fmt_print_stat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_stat *self) {
+ fmt_print_byte(w, '{');
+ fmt_print_str(w, " fstype=");
+ fmt_print_base10(w, self->fstype);
+ fmt_print_str(w, " fsdev=");
+ fmt_print_base10(w, self->fsdev);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " mode=");
+ fmt_print_dm(w, ctx, &self->mode);
+ fmt_print_str(w, " atime=");
+ fmt_print_base10(w, self->atime);
+ fmt_print_str(w, " mtime=");
+ fmt_print_base10(w, self->mtime);
+ fmt_print_str(w, " length=");
+ fmt_print_base10(w, self->length);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " owner_uname=");
+ fmt_print_s(w, ctx, &self->owner_uname);
+ fmt_print_str(w, " owner_gname=");
+ fmt_print_s(w, ctx, &self->owner_gname);
+ fmt_print_str(w, " last_modifier_uname=");
+ fmt_print_s(w, ctx, &self->last_modifier_uname);
+#if CONFIG_9P_ENABLE_9P2000_u
+ fmt_print_str(w, " extension=");
+ fmt_print_s(w, ctx, &self->extension);
+ fmt_print_str(w, " owner_unum=");
+ fmt_print_nuid(w, ctx, &self->owner_unum);
+ fmt_print_str(w, " owner_gnum=");
+ fmt_print_nuid(w, ctx, &self->owner_gnum);
+ fmt_print_str(w, " last_modifier_unum=");
+ fmt_print_nuid(w, ctx, &self->last_modifier_unum);
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
+[[maybe_unused]] static void fmt_print_Tversion(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *self) {
+ fmt_print_str(w, "Tversion {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " max_msg_size=");
+ fmt_print_base10(w, self->max_msg_size);
+ fmt_print_str(w, " version=");
+ fmt_print_s(w, ctx, &self->version);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rversion(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *self) {
+ fmt_print_str(w, "Rversion {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " max_msg_size=");
+ fmt_print_base10(w, self->max_msg_size);
+ fmt_print_str(w, " version=");
+ fmt_print_s(w, ctx, &self->version);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Tauth(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *self) {
+ fmt_print_str(w, "Tauth {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " afid=");
+ fmt_print_fid(w, ctx, &self->afid);
+ fmt_print_str(w, " uname=");
+ fmt_print_s(w, ctx, &self->uname);
+ fmt_print_str(w, " aname=");
+ fmt_print_s(w, ctx, &self->aname);
+#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
+ fmt_print_str(w, " unum=");
+ fmt_print_nuid(w, ctx, &self->unum);
+#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rauth(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *self) {
+ fmt_print_str(w, "Rauth {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " aqid=");
+ fmt_print_qid(w, ctx, &self->aqid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tattach(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *self) {
+ fmt_print_str(w, "Tattach {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " afid=");
+ fmt_print_fid(w, ctx, &self->afid);
+ fmt_print_str(w, " uname=");
+ fmt_print_s(w, ctx, &self->uname);
+ fmt_print_str(w, " aname=");
+ fmt_print_s(w, ctx, &self->aname);
+#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
+ fmt_print_str(w, " unum=");
+ fmt_print_nuid(w, ctx, &self->unum);
+#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rattach(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *self) {
+ fmt_print_str(w, "Rattach {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
+[[maybe_unused]] static void fmt_print_Rerror(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *self) {
+ fmt_print_str(w, "Rerror {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " errstr=");
+ fmt_print_s(w, ctx, &self->errstr);
+#if CONFIG_9P_ENABLE_9P2000_u
+ fmt_print_str(w, " errnum=");
+ fmt_print_errno(w, ctx, &self->errnum);
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Twalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *self) {
+ fmt_print_str(w, "Twalk {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " newfid=");
+ fmt_print_fid(w, ctx, &self->newfid);
+ fmt_print_str(w, " nwname=");
+ fmt_print_base10(w, self->nwname);
+ fmt_print_str(w, " wname=[");
for (uint16_t i = 0; i < self->nwname; i++) {
if (i)
- fmt_state_putchar(state, ',');
- fmt_state_putchar(state, ' ');
- lib9p_s_format(&self->wname[i], state);
+ fmt_print_byte(w, ',');
+ fmt_print_byte(w, ' ');
+ fmt_print_s(w, ctx, &self->wname[i]);
}
- fmt_state_puts(state, " ]");
- fmt_state_puts(state, " }");
+ fmt_print_str(w, " ]");
+ fmt_print_str(w, " }");
}
-static void lib9p_msg_Rsread_format(struct lib9p_msg_Rsread *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rsread {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
- if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- fmt_state_printf(state, " data=%.*q%s",
- (int)(self->count < 50 ? self->count : 50),
- (char *)self->data,
- self->count < 50 ? "" : "...");
-#pragma GCC diagnostic pop
- } else {
- fmt_state_puts(state, " data=<bytedata>");
+[[maybe_unused]] static void fmt_print_Rwalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *self) {
+ fmt_print_str(w, "Rwalk {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " nwqid=");
+ fmt_print_base10(w, self->nwqid);
+ fmt_print_str(w, " wqid=[");
+ for (uint16_t i = 0; i < self->nwqid; i++) {
+ if (i)
+ fmt_print_byte(w, ',');
+ fmt_print_byte(w, ' ');
+ fmt_print_qid(w, ctx, &self->wqid[i]);
}
- fmt_state_puts(state, " }");
+ fmt_print_str(w, " ]");
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Ropen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *self) {
+ fmt_print_str(w, "Ropen {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " iounit=");
+ fmt_print_base10(w, self->iounit);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *self) {
+ fmt_print_str(w, "Tcreate {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " perm=");
+ fmt_print_dm(w, ctx, &self->perm);
+ fmt_print_str(w, " mode=");
+ fmt_print_o(w, ctx, &self->mode);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *self) {
+ fmt_print_str(w, "Rcreate {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " iounit=");
+ fmt_print_base10(w, self->iounit);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_p9p
+[[maybe_unused]] static void fmt_print_Ropenfd(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *self) {
+ fmt_print_str(w, "Ropenfd {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " iounit=");
+ fmt_print_base10(w, self->iounit);
+ fmt_print_str(w, " unixfd=");
+ fmt_print_base10(w, self->unixfd);
+ fmt_print_str(w, " }");
}
-static void lib9p_msg_Tswrite_format(struct lib9p_msg_Tswrite *self, struct fmt_state *state) {
- fmt_state_puts(state, "Tswrite {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " fid=");
- fmt_state_printf(state, "%"PRIu32, self->fid);
- fmt_state_puts(state, " nwname=");
- fmt_state_printf(state, "%"PRIu16, self->nwname);
- fmt_state_puts(state, " wname=[");
+#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
+#if CONFIG_9P_ENABLE_9P2000_L
+[[maybe_unused]] static void fmt_print_Rlopen(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *self) {
+ fmt_print_str(w, "Rlopen {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " iounit=");
+ fmt_print_base10(w, self->iounit);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tlcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *self) {
+ fmt_print_str(w, "Tlcreate {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " flags=");
+ fmt_print_lo(w, ctx, &self->flags);
+ fmt_print_str(w, " mode=");
+ fmt_print_mode(w, ctx, &self->mode);
+ fmt_print_str(w, " gid=");
+ fmt_print_nuid(w, ctx, &self->gid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rlcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *self) {
+ fmt_print_str(w, "Rlcreate {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " iounit=");
+ fmt_print_base10(w, self->iounit);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tsymlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *self) {
+ fmt_print_str(w, "Tsymlink {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " symtgt=");
+ fmt_print_s(w, ctx, &self->symtgt);
+ fmt_print_str(w, " gid=");
+ fmt_print_nuid(w, ctx, &self->gid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rsymlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *self) {
+ fmt_print_str(w, "Rsymlink {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tmknod(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *self) {
+ fmt_print_str(w, "Tmknod {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " dfid=");
+ fmt_print_fid(w, ctx, &self->dfid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " mode=");
+ fmt_print_mode(w, ctx, &self->mode);
+ fmt_print_str(w, " major=");
+ fmt_print_base10(w, self->major);
+ fmt_print_str(w, " minor=");
+ fmt_print_base10(w, self->minor);
+ fmt_print_str(w, " gid=");
+ fmt_print_nuid(w, ctx, &self->gid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rmknod(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *self) {
+ fmt_print_str(w, "Rmknod {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Trename(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Trename *self) {
+ fmt_print_str(w, "Trename {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " dfid=");
+ fmt_print_fid(w, ctx, &self->dfid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rreadlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink *self) {
+ fmt_print_str(w, "Rreadlink {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " target=");
+ fmt_print_s(w, ctx, &self->target);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rgetattr(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *self) {
+ fmt_print_str(w, "Rgetattr {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " valid=");
+ fmt_print_getattr(w, ctx, &self->valid);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " mode=");
+ fmt_print_mode(w, ctx, &self->mode);
+ fmt_print_str(w, " uid=");
+ fmt_print_nuid(w, ctx, &self->uid);
+ fmt_print_str(w, " gid=");
+ fmt_print_nuid(w, ctx, &self->gid);
+ fmt_print_str(w, " nlink=");
+ fmt_print_base10(w, self->nlink);
+ fmt_print_str(w, " rdev=");
+ fmt_print_base10(w, self->rdev);
+ fmt_print_str(w, " filesize=");
+ fmt_print_base10(w, self->filesize);
+ fmt_print_str(w, " blksize=");
+ fmt_print_base10(w, self->blksize);
+ fmt_print_str(w, " blocks=");
+ fmt_print_base10(w, self->blocks);
+ fmt_print_str(w, " atime_sec=");
+ fmt_print_base10(w, self->atime_sec);
+ fmt_print_str(w, " atime_nsec=");
+ fmt_print_base10(w, self->atime_nsec);
+ fmt_print_str(w, " mtime_sec=");
+ fmt_print_base10(w, self->mtime_sec);
+ fmt_print_str(w, " mtime_nsec=");
+ fmt_print_base10(w, self->mtime_nsec);
+ fmt_print_str(w, " ctime_sec=");
+ fmt_print_base10(w, self->ctime_sec);
+ fmt_print_str(w, " ctime_nsec=");
+ fmt_print_base10(w, self->ctime_nsec);
+ fmt_print_str(w, " btime_sec=");
+ fmt_print_base10(w, self->btime_sec);
+ fmt_print_str(w, " btime_nsec=");
+ fmt_print_base10(w, self->btime_nsec);
+ fmt_print_str(w, " gen=");
+ fmt_print_base10(w, self->gen);
+ fmt_print_str(w, " data_version=");
+ fmt_print_base10(w, self->data_version);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Txattrwalk(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwalk *self) {
+ fmt_print_str(w, "Txattrwalk {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " newfid=");
+ fmt_print_fid(w, ctx, &self->newfid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Txattrcreate(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Txattrcreate *self) {
+ fmt_print_str(w, "Txattrcreate {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " attr_size=");
+ fmt_print_base10(w, self->attr_size);
+ fmt_print_str(w, " flags=");
+ fmt_print_base10(w, self->flags);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *self) {
+ fmt_print_str(w, "Tlock {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " type=");
+ fmt_print_lock_type(w, ctx, &self->type);
+ fmt_print_str(w, " flags=");
+ fmt_print_lock_flags(w, ctx, &self->flags);
+ fmt_print_str(w, " start=");
+ fmt_print_base10(w, self->start);
+ fmt_print_str(w, " length=");
+ fmt_print_base10(w, self->length);
+ fmt_print_str(w, " proc_id=");
+ fmt_print_base10(w, self->proc_id);
+ fmt_print_str(w, " client_id=");
+ fmt_print_s(w, ctx, &self->client_id);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tgetlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *self) {
+ fmt_print_str(w, "Tgetlock {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " type=");
+ fmt_print_lock_type(w, ctx, &self->type);
+ fmt_print_str(w, " start=");
+ fmt_print_base10(w, self->start);
+ fmt_print_str(w, " length=");
+ fmt_print_base10(w, self->length);
+ fmt_print_str(w, " proc_id=");
+ fmt_print_base10(w, self->proc_id);
+ fmt_print_str(w, " client_id=");
+ fmt_print_s(w, ctx, &self->client_id);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rgetlock(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *self) {
+ fmt_print_str(w, "Rgetlock {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " type=");
+ fmt_print_lock_type(w, ctx, &self->type);
+ fmt_print_str(w, " start=");
+ fmt_print_base10(w, self->start);
+ fmt_print_str(w, " length=");
+ fmt_print_base10(w, self->length);
+ fmt_print_str(w, " proc_id=");
+ fmt_print_base10(w, self->proc_id);
+ fmt_print_str(w, " client_id=");
+ fmt_print_s(w, ctx, &self->client_id);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tlink(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *self) {
+ fmt_print_str(w, "Tlink {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " dfid=");
+ fmt_print_fid(w, ctx, &self->dfid);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tmkdir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *self) {
+ fmt_print_str(w, "Tmkdir {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " dfid=");
+ fmt_print_fid(w, ctx, &self->dfid);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " mode=");
+ fmt_print_mode(w, ctx, &self->mode);
+ fmt_print_str(w, " gid=");
+ fmt_print_nuid(w, ctx, &self->gid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Rmkdir(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *self) {
+ fmt_print_str(w, "Rmkdir {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " qid=");
+ fmt_print_qid(w, ctx, &self->qid);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Trenameat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat *self) {
+ fmt_print_str(w, "Trenameat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " olddirfid=");
+ fmt_print_fid(w, ctx, &self->olddirfid);
+ fmt_print_str(w, " oldname=");
+ fmt_print_s(w, ctx, &self->oldname);
+ fmt_print_str(w, " newdirfid=");
+ fmt_print_fid(w, ctx, &self->newdirfid);
+ fmt_print_str(w, " newname=");
+ fmt_print_s(w, ctx, &self->newname);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tunlinkat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat *self) {
+ fmt_print_str(w, "Tunlinkat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " dirfd=");
+ fmt_print_fid(w, ctx, &self->dirfd);
+ fmt_print_str(w, " name=");
+ fmt_print_s(w, ctx, &self->name);
+ fmt_print_str(w, " flags=");
+ fmt_print_base10(w, self->flags);
+ fmt_print_str(w, " }");
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+[[maybe_unused]] static void fmt_print_Tsread(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *self) {
+ fmt_print_str(w, "Tsread {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_base10(w, self->fid);
+ fmt_print_str(w, " nwname=");
+ fmt_print_base10(w, self->nwname);
+ fmt_print_str(w, " wname=[");
+ for (uint16_t i = 0; i < self->nwname; i++) {
+ if (i)
+ fmt_print_byte(w, ',');
+ fmt_print_byte(w, ' ');
+ fmt_print_s(w, ctx, &self->wname[i]);
+ }
+ fmt_print_str(w, " ]");
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Tswrite(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *self) {
+ fmt_print_str(w, "Tswrite {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_base10(w, self->fid);
+ fmt_print_str(w, " nwname=");
+ fmt_print_base10(w, self->nwname);
+ fmt_print_str(w, " wname=[");
for (uint16_t i = 0; i < self->nwname; i++) {
if (i)
- fmt_state_putchar(state, ',');
- fmt_state_putchar(state, ' ');
- lib9p_s_format(&self->wname[i], state);
+ fmt_print_byte(w, ',');
+ fmt_print_byte(w, ' ');
+ fmt_print_s(w, ctx, &self->wname[i]);
}
- fmt_state_puts(state, " ]");
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
+ fmt_print_str(w, " ]");
+ fmt_print_str(w, " count=");
+ fmt_print_base10(w, self->count);
if (is_valid_utf8_without_nul((uint8_t *)self->data, (size_t)self->count)) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- fmt_state_printf(state, " data=%.*q%s",
- (int)(self->count < 50 ? self->count : 50),
- (char *)self->data,
- self->count < 50 ? "" : "...");
-#pragma GCC diagnostic pop
+ fmt_print_str(w, " data=");
+ fmt_print_qmem(w, self->data, self->count < 50 ? self->count : 50);
+ if (self->count > 50)
+ fmt_print_str(w, "...");
} else {
- fmt_state_puts(state, " data=<bytedata>");
+ fmt_print_str(w, " data=<bytedata>");
}
- fmt_state_puts(state, " }");
+ fmt_print_str(w, " }");
}
-static void lib9p_msg_Rswrite_format(struct lib9p_msg_Rswrite *self, struct fmt_state *state) {
- fmt_state_puts(state, "Rswrite {");
- fmt_state_puts(state, " tag=");
- lib9p_tag_format(&self->tag, state);
- fmt_state_puts(state, " count=");
- fmt_state_printf(state, "%"PRIu32, self->count);
- fmt_state_puts(state, " }");
-}
#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+[[maybe_unused]] static void fmt_print_Rstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *self) {
+ fmt_print_str(w, "Rstat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " stat=");
+ fmt_print_stat(w, ctx, &self->stat);
+ fmt_print_str(w, " }");
+}
+
+[[maybe_unused]] static void fmt_print_Twstat(lo_interface fmt_dest w, [[maybe_unused]] struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *self) {
+ fmt_print_str(w, "Twstat {");
+ fmt_print_str(w, " tag=");
+ fmt_print_tag(w, ctx, &self->tag);
+ fmt_print_str(w, " fid=");
+ fmt_print_fid(w, ctx, &self->fid);
+ fmt_print_str(w, " stat=");
+ fmt_print_stat(w, ctx, &self->stat);
+ fmt_print_str(w, " }");
+}
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
/* tables.h *******************************************************************/
@@ -7869,9 +7502,9 @@ const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM] = {
#endif /* CONFIG_9P_ENABLE_uninitialized */
};
-#define _MSG(typ) [LIB9P_TYP_##typ] = { \
- .name = #typ, \
- .box_as_fmt_formatter = (_box_as_fmt_formatter_fn_t)lo_box_lib9p_msg_##typ##_as_fmt_formatter, \
+#define _MSG(typ) [LIB9P_TYP_##typ] = { \
+ .name = #typ, \
+ .print = (_print_fn_t)fmt_print_##typ, \
}
const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = {
#if CONFIG_9P_ENABLE_9P2000
diff --git a/lib9p/core_include/lib9p/_core_generated.h b/lib9p/core_include/lib9p/_core_generated.h
index 9e6366f..5b9a67d 100644
--- a/lib9p/core_include/lib9p/_core_generated.h
+++ b/lib9p/core_include/lib9p/_core_generated.h
@@ -4,10 +4,6 @@
#error Do not include <lib9p/_core_generated.h> directly; include <lib9p/core.h> instead
#endif
-#include <stdint.h> /* for uint{n}_t types */
-
-#include <libfmt/fmt.h> /* for fmt_formatter */
-#include <libhw/generic/io.h> /* for struct iovec */
/* config *********************************************************************/
@@ -67,7 +63,6 @@ enum lib9p_version {
#endif /* CONFIG_9P_ENABLE_9P2000_u */
LIB9P_VER_NUM,
};
-LO_IMPLEMENTATION_H(fmt_formatter, enum lib9p_version, lib9p_version);
/* enum msg_type **************************************************************/
@@ -167,26 +162,22 @@ enum lib9p_msg_type { /* uint8_t */
LIB9P_TYP_Rswrite = 155,
#endif /* CONFIG_9P_ENABLE_9P2000_e */
};
-LO_IMPLEMENTATION_H(fmt_formatter, enum lib9p_msg_type, lib9p_msg_type);
/* payload types **************************************************************/
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
/* size = 2 ; max_iov = 1 ; max_copy = 2 */
typedef uint16_t lib9p_tag_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_tag_t, lib9p_tag);
#define LIB9P_TAG_NOTAG ((lib9p_tag_t)(UINT16_MAX))
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_fid_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_fid_t, lib9p_fid);
#define LIB9P_FID_NOFID ((lib9p_fid_t)(UINT32_MAX))
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_dm_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dm_t, lib9p_dm);
/* bits */
#define LIB9P_DM_DIR ((lib9p_dm_t)(UINT32_C(1)<<31))
#define LIB9P_DM_APPEND ((lib9p_dm_t)(UINT32_C(1)<<30))
@@ -231,7 +222,6 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dm_t, lib9p_dm);
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_qt_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_qt_t, lib9p_qt);
/* bits */
#define LIB9P_QT_DIR ((lib9p_qt_t)(UINT8_C(1)<<7))
#define LIB9P_QT_APPEND ((lib9p_qt_t)(UINT8_C(1)<<6))
@@ -250,7 +240,6 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_qt_t, lib9p_qt);
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_o_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_o_t, lib9p_o);
/* bits */
#define _LIB9P_O_UNUSED_7 ((lib9p_o_t)(UINT8_C(1)<<7))
#define LIB9P_O_RCLOSE ((lib9p_o_t)(UINT8_C(1)<<6))
@@ -273,12 +262,10 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_o_t, lib9p_o);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_nuid_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_nuid_t, lib9p_nuid);
#define LIB9P_NUID_NONUID ((lib9p_nuid_t)(UINT32_MAX))
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_errno_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_errno_t, lib9p_errno);
#define LIB9P_ERRNO_NOERROR ((lib9p_errno_t)(0))
#define LIB9P_ERRNO_L_EPERM ((lib9p_errno_t)(1))
#define LIB9P_ERRNO_L_ENOENT ((lib9p_errno_t)(2))
@@ -416,12 +403,10 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_errno_t, lib9p_errno);
#if CONFIG_9P_ENABLE_9P2000_L
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_super_magic_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_super_magic_t, lib9p_super_magic);
#define LIB9P_SUPER_MAGIC_V9FS_MAGIC ((lib9p_super_magic_t)(16914839))
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_lo_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lo_t, lib9p_lo);
/* bits */
#define _LIB9P_LO_UNUSED_31 ((lib9p_lo_t)(UINT32_C(1)<<31))
#define _LIB9P_LO_UNUSED_30 ((lib9p_lo_t)(UINT32_C(1)<<30))
@@ -466,7 +451,6 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lo_t, lib9p_lo);
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_dt_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dt_t, lib9p_dt);
#define LIB9P_DT_UNKNOWN ((lib9p_dt_t)(0))
#define LIB9P_DT_PIPE ((lib9p_dt_t)(1))
#define LIB9P_DT_CHAR_DEV ((lib9p_dt_t)(2))
@@ -479,7 +463,6 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dt_t, lib9p_dt);
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_mode_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_mode_t, lib9p_mode);
/* bits */
#define _LIB9P_MODE_UNUSED_31 ((lib9p_mode_t)(UINT32_C(1)<<31))
#define _LIB9P_MODE_UNUSED_30 ((lib9p_mode_t)(UINT32_C(1)<<30))
@@ -527,13 +510,11 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_mode_t, lib9p_mode);
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_b4_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_b4_t, lib9p_b4);
#define LIB9P_B4_FALSE ((lib9p_b4_t)(0))
#define LIB9P_B4_TRUE ((lib9p_b4_t)(1))
/* size = 8 ; max_iov = 1 ; max_copy = 8 */
typedef uint64_t lib9p_getattr_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_getattr_t, lib9p_getattr);
/* bits */
#define _LIB9P_GETATTR_UNUSED_63 ((lib9p_getattr_t)(UINT64_C(1)<<63))
#define _LIB9P_GETATTR_UNUSED_62 ((lib9p_getattr_t)(UINT64_C(1)<<62))
@@ -605,7 +586,6 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_getattr_t, lib9p_getattr);
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_setattr_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_setattr_t, lib9p_setattr);
/* bits */
#define _LIB9P_SETATTR_UNUSED_31 ((lib9p_setattr_t)(UINT32_C(1)<<31))
#define _LIB9P_SETATTR_UNUSED_30 ((lib9p_setattr_t)(UINT32_C(1)<<30))
@@ -642,14 +622,12 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_setattr_t, lib9p_setattr);
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_lock_type_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lock_type_t, lib9p_lock_type);
#define LIB9P_LOCK_TYPE_RDLCK ((lib9p_lock_type_t)(0))
#define LIB9P_LOCK_TYPE_WRLCK ((lib9p_lock_type_t)(1))
#define LIB9P_LOCK_TYPE_UNLCK ((lib9p_lock_type_t)(2))
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_lock_flags_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lock_flags_t, lib9p_lock_flags);
/* bits */
#define _LIB9P_LOCK_FLAGS_UNUSED_31 ((lib9p_lock_flags_t)(UINT32_C(1)<<31))
#define _LIB9P_LOCK_FLAGS_UNUSED_30 ((lib9p_lock_flags_t)(UINT32_C(1)<<30))
@@ -686,7 +664,6 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lock_flags_t, lib9p_lock_flags);
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_lock_status_t;
-LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lock_status_t, lib9p_lock_status);
#define LIB9P_LOCK_STATUS_SUCCESS ((lib9p_lock_status_t)(0))
#define LIB9P_LOCK_STATUS_BLOCKED ((lib9p_lock_status_t)(1))
#define LIB9P_LOCK_STATUS_ERROR ((lib9p_lock_status_t)(2))
@@ -699,7 +676,6 @@ struct lib9p_s {
uint16_t len;
[[gnu::nonstring]] char *utf8;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_s, lib9p_s);
/* size = 13 ; max_iov = 1 ; max_copy = 13 */
struct lib9p_qid {
@@ -707,7 +683,6 @@ struct lib9p_qid {
uint32_t vers;
uint64_t path;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_qid, lib9p_qid);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -716,13 +691,11 @@ struct lib9p_msg_Tflush {
lib9p_tag_t tag;
uint16_t oldtag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tflush, lib9p_msg_Tflush);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rflush {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rflush, lib9p_msg_Rflush);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -732,7 +705,6 @@ struct lib9p_msg_Topen {
lib9p_fid_t fid;
lib9p_o_t mode;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Topen, lib9p_msg_Topen);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -743,7 +715,6 @@ struct lib9p_msg_Tread {
uint64_t offset;
uint32_t count;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tread, lib9p_msg_Tread);
/* min_size = 11 ; exp_size = 8,203 ; max_size = 2,147,483,658 ; max_iov = 2 ; max_copy = 11 */
struct lib9p_msg_Rread {
@@ -751,7 +722,6 @@ struct lib9p_msg_Rread {
uint32_t count;
[[gnu::nonstring]] char *data;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rread, lib9p_msg_Rread);
/* min_size = 23 ; exp_size = 8,215 ; max_size = 2,147,483,670 ; max_iov = 2 ; max_copy = 23 */
struct lib9p_msg_Twrite {
@@ -761,40 +731,34 @@ struct lib9p_msg_Twrite {
uint32_t count;
[[gnu::nonstring]] char *data;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twrite, lib9p_msg_Twrite);
/* size = 11 ; max_iov = 1 ; max_copy = 11 */
struct lib9p_msg_Rwrite {
lib9p_tag_t tag;
uint32_t count;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rwrite, lib9p_msg_Rwrite);
/* size = 11 ; max_iov = 1 ; max_copy = 11 */
struct lib9p_msg_Tclunk {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tclunk, lib9p_msg_Tclunk);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rclunk {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rclunk, lib9p_msg_Rclunk);
/* size = 11 ; max_iov = 1 ; max_copy = 11 */
struct lib9p_msg_Tremove {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tremove, lib9p_msg_Tremove);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rremove {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rremove, lib9p_msg_Rremove);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -803,13 +767,11 @@ struct lib9p_msg_Tstat {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tstat, lib9p_msg_Tstat);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rwstat {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rwstat, lib9p_msg_Rwstat);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_p9p
@@ -819,7 +781,6 @@ struct lib9p_msg_Topenfd {
lib9p_fid_t fid;
lib9p_o_t mode;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Topenfd, lib9p_msg_Topenfd);
#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
#if CONFIG_9P_ENABLE_9P2000_L
@@ -828,14 +789,12 @@ struct lib9p_msg_Rlerror {
lib9p_tag_t tag;
lib9p_errno_t errnum;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlerror, lib9p_msg_Rlerror);
/* size = 11 ; max_iov = 1 ; max_copy = 11 */
struct lib9p_msg_Tstatfs {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tstatfs, lib9p_msg_Tstatfs);
/* size = 67 ; max_iov = 1 ; max_copy = 67 */
struct lib9p_msg_Rstatfs {
@@ -850,7 +809,6 @@ struct lib9p_msg_Rstatfs {
uint64_t fsid;
uint32_t namelen;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rstatfs, lib9p_msg_Rstatfs);
/* size = 15 ; max_iov = 1 ; max_copy = 15 */
struct lib9p_msg_Tlopen {
@@ -858,20 +816,17 @@ struct lib9p_msg_Tlopen {
lib9p_fid_t fid;
lib9p_lo_t flags;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlopen, lib9p_msg_Tlopen);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rrename {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rrename, lib9p_msg_Rrename);
/* size = 11 ; max_iov = 1 ; max_copy = 11 */
struct lib9p_msg_Treadlink {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Treadlink, lib9p_msg_Treadlink);
/* size = 19 ; max_iov = 1 ; max_copy = 19 */
struct lib9p_msg_Tgetattr {
@@ -879,7 +834,6 @@ struct lib9p_msg_Tgetattr {
lib9p_fid_t fid;
lib9p_getattr_t request_mask;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tgetattr, lib9p_msg_Tgetattr);
/* size = 67 ; max_iov = 1 ; max_copy = 67 */
struct lib9p_msg_Tsetattr {
@@ -895,26 +849,22 @@ struct lib9p_msg_Tsetattr {
uint64_t mtime_sec;
uint64_t mtime_nsec;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsetattr, lib9p_msg_Tsetattr);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rsetattr {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rsetattr, lib9p_msg_Rsetattr);
/* size = 15 ; max_iov = 1 ; max_copy = 15 */
struct lib9p_msg_Rxattrwalk {
lib9p_tag_t tag;
uint64_t attr_size;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rxattrwalk, lib9p_msg_Rxattrwalk);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rxattrcreate {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rxattrcreate, lib9p_msg_Rxattrcreate);
/* size = 23 ; max_iov = 1 ; max_copy = 23 */
struct lib9p_msg_Treaddir {
@@ -923,7 +873,6 @@ struct lib9p_msg_Treaddir {
uint64_t offset;
uint32_t count;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Treaddir, lib9p_msg_Treaddir);
/* min_size = 11 ; exp_size = 8,203 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) ; max_iov = 2 ; max_copy = 11 */
struct lib9p_msg_Rreaddir {
@@ -931,7 +880,6 @@ struct lib9p_msg_Rreaddir {
uint32_t count;
[[gnu::nonstring]] char *data;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rreaddir, lib9p_msg_Rreaddir);
/* size = 15 ; max_iov = 1 ; max_copy = 15 */
struct lib9p_msg_Tfsync {
@@ -939,38 +887,32 @@ struct lib9p_msg_Tfsync {
lib9p_fid_t fid;
lib9p_b4_t datasync;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tfsync, lib9p_msg_Tfsync);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rfsync {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rfsync, lib9p_msg_Rfsync);
/* size = 8 ; max_iov = 1 ; max_copy = 8 */
struct lib9p_msg_Rlock {
lib9p_tag_t tag;
lib9p_lock_status_t status;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlock, lib9p_msg_Rlock);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rlink {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlink, lib9p_msg_Rlink);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rrenameat {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rrenameat, lib9p_msg_Rrenameat);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Runlinkat {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Runlinkat, lib9p_msg_Runlinkat);
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
@@ -979,13 +921,11 @@ struct lib9p_msg_Tsession {
lib9p_tag_t tag;
uint64_t key;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsession, lib9p_msg_Tsession);
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rsession {
lib9p_tag_t tag;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rsession, lib9p_msg_Rsession);
/* min_size = 11 ; exp_size = 8,203 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) ; max_iov = 2 ; max_copy = 11 */
struct lib9p_msg_Rsread {
@@ -993,14 +933,12 @@ struct lib9p_msg_Rsread {
uint32_t count;
[[gnu::nonstring]] char *data;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rsread, lib9p_msg_Rsread);
/* size = 11 ; max_iov = 1 ; max_copy = 11 */
struct lib9p_msg_Rswrite {
lib9p_tag_t tag;
uint32_t count;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite);
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -1027,7 +965,6 @@ struct lib9p_stat {
lib9p_nuid_t last_modifier_unum;
#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_stat, lib9p_stat);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
@@ -1037,7 +974,6 @@ struct lib9p_msg_Tversion {
uint32_t max_msg_size;
struct lib9p_s version;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tversion, lib9p_msg_Tversion);
/* min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 2 ; max_copy = 13 */
struct lib9p_msg_Rversion {
@@ -1045,7 +981,6 @@ struct lib9p_msg_Rversion {
uint32_t max_msg_size;
struct lib9p_s version;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -1063,14 +998,12 @@ struct lib9p_msg_Tauth {
lib9p_nuid_t unum;
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth);
/* size = 20 ; max_iov = 1 ; max_copy = 20 */
struct lib9p_msg_Rauth {
lib9p_tag_t tag;
struct lib9p_qid aqid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rauth, lib9p_msg_Rauth);
/* LIB9P_VER_9P2000 : min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 4 ; max_copy = 19 */
/* LIB9P_VER_9P2000_L : min_size = 23 ; exp_size = 77 ; max_size = 131,093 ; max_iov = 5 ; max_copy = 23 */
@@ -1087,14 +1020,12 @@ struct lib9p_msg_Tattach {
lib9p_nuid_t unum;
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach);
/* size = 20 ; max_iov = 1 ; max_copy = 20 */
struct lib9p_msg_Rattach {
lib9p_tag_t tag;
struct lib9p_qid qid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
@@ -1110,7 +1041,6 @@ struct lib9p_msg_Rerror {
lib9p_errno_t errnum;
#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rerror, lib9p_msg_Rerror);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -1122,7 +1052,6 @@ struct lib9p_msg_Twalk {
uint16_t nwname;
struct lib9p_s *wname;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twalk, lib9p_msg_Twalk);
/* min_size = 9 ; exp_size = 217 ; max_size = 217 ; max_iov = 1 ; max_copy = 217 */
struct lib9p_msg_Rwalk {
@@ -1130,7 +1059,6 @@ struct lib9p_msg_Rwalk {
uint16_t nwqid;
struct lib9p_qid *wqid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rwalk, lib9p_msg_Rwalk);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -1140,7 +1068,6 @@ struct lib9p_msg_Ropen {
struct lib9p_qid qid;
uint32_t iounit;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Ropen, lib9p_msg_Ropen);
/* min_size = 18 ; exp_size = 45 ; max_size = 65,553 ; max_iov = 3 ; max_copy = 18 */
struct lib9p_msg_Tcreate {
@@ -1150,7 +1077,6 @@ struct lib9p_msg_Tcreate {
lib9p_dm_t perm;
lib9p_o_t mode;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tcreate, lib9p_msg_Tcreate);
/* size = 24 ; max_iov = 1 ; max_copy = 24 */
struct lib9p_msg_Rcreate {
@@ -1158,7 +1084,6 @@ struct lib9p_msg_Rcreate {
struct lib9p_qid qid;
uint32_t iounit;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rcreate, lib9p_msg_Rcreate);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_p9p
@@ -1169,7 +1094,6 @@ struct lib9p_msg_Ropenfd {
uint32_t iounit;
uint32_t unixfd;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Ropenfd, lib9p_msg_Ropenfd);
#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
#if CONFIG_9P_ENABLE_9P2000_L
@@ -1179,7 +1103,6 @@ struct lib9p_msg_Rlopen {
struct lib9p_qid qid;
uint32_t iounit;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlopen, lib9p_msg_Rlopen);
/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */
struct lib9p_msg_Tlcreate {
@@ -1190,7 +1113,6 @@ struct lib9p_msg_Tlcreate {
lib9p_mode_t mode;
lib9p_nuid_t gid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlcreate, lib9p_msg_Tlcreate);
/* size = 24 ; max_iov = 1 ; max_copy = 24 */
struct lib9p_msg_Rlcreate {
@@ -1198,7 +1120,6 @@ struct lib9p_msg_Rlcreate {
struct lib9p_qid qid;
uint32_t iounit;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlcreate, lib9p_msg_Rlcreate);
/* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 5 ; max_copy = 19 */
struct lib9p_msg_Tsymlink {
@@ -1208,14 +1129,12 @@ struct lib9p_msg_Tsymlink {
struct lib9p_s symtgt;
lib9p_nuid_t gid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsymlink, lib9p_msg_Tsymlink);
/* size = 20 ; max_iov = 1 ; max_copy = 20 */
struct lib9p_msg_Rsymlink {
lib9p_tag_t tag;
struct lib9p_qid qid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rsymlink, lib9p_msg_Rsymlink);
/* min_size = 29 ; exp_size = 56 ; max_size = 65,564 ; max_iov = 3 ; max_copy = 29 */
struct lib9p_msg_Tmknod {
@@ -1227,14 +1146,12 @@ struct lib9p_msg_Tmknod {
uint32_t minor;
lib9p_nuid_t gid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tmknod, lib9p_msg_Tmknod);
/* size = 20 ; max_iov = 1 ; max_copy = 20 */
struct lib9p_msg_Rmknod {
lib9p_tag_t tag;
struct lib9p_qid qid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rmknod, lib9p_msg_Rmknod);
/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */
struct lib9p_msg_Trename {
@@ -1243,14 +1160,12 @@ struct lib9p_msg_Trename {
lib9p_fid_t dfid;
struct lib9p_s name;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Trename, lib9p_msg_Trename);
/* min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */
struct lib9p_msg_Rreadlink {
lib9p_tag_t tag;
struct lib9p_s target;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rreadlink, lib9p_msg_Rreadlink);
/* size = 160 ; max_iov = 1 ; max_copy = 160 */
struct lib9p_msg_Rgetattr {
@@ -1276,7 +1191,6 @@ struct lib9p_msg_Rgetattr {
uint64_t gen;
uint64_t data_version;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rgetattr, lib9p_msg_Rgetattr);
/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */
struct lib9p_msg_Txattrwalk {
@@ -1285,7 +1199,6 @@ struct lib9p_msg_Txattrwalk {
lib9p_fid_t newfid;
struct lib9p_s name;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Txattrwalk, lib9p_msg_Txattrwalk);
/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */
struct lib9p_msg_Txattrcreate {
@@ -1295,7 +1208,6 @@ struct lib9p_msg_Txattrcreate {
uint64_t attr_size;
uint32_t flags;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Txattrcreate, lib9p_msg_Txattrcreate);
/* min_size = 38 ; exp_size = 65 ; max_size = 65,573 ; max_iov = 2 ; max_copy = 38 */
struct lib9p_msg_Tlock {
@@ -1308,7 +1220,6 @@ struct lib9p_msg_Tlock {
uint32_t proc_id;
struct lib9p_s client_id;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlock, lib9p_msg_Tlock);
/* min_size = 34 ; exp_size = 61 ; max_size = 65,569 ; max_iov = 2 ; max_copy = 34 */
struct lib9p_msg_Tgetlock {
@@ -1320,7 +1231,6 @@ struct lib9p_msg_Tgetlock {
uint32_t proc_id;
struct lib9p_s client_id;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tgetlock, lib9p_msg_Tgetlock);
/* min_size = 30 ; exp_size = 57 ; max_size = 65,565 ; max_iov = 2 ; max_copy = 30 */
struct lib9p_msg_Rgetlock {
@@ -1331,7 +1241,6 @@ struct lib9p_msg_Rgetlock {
uint32_t proc_id;
struct lib9p_s client_id;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rgetlock, lib9p_msg_Rgetlock);
/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */
struct lib9p_msg_Tlink {
@@ -1340,7 +1249,6 @@ struct lib9p_msg_Tlink {
lib9p_fid_t fid;
struct lib9p_s name;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlink, lib9p_msg_Tlink);
/* min_size = 21 ; exp_size = 48 ; max_size = 65,556 ; max_iov = 3 ; max_copy = 21 */
struct lib9p_msg_Tmkdir {
@@ -1350,14 +1258,12 @@ struct lib9p_msg_Tmkdir {
lib9p_mode_t mode;
lib9p_nuid_t gid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tmkdir, lib9p_msg_Tmkdir);
/* size = 20 ; max_iov = 1 ; max_copy = 20 */
struct lib9p_msg_Rmkdir {
lib9p_tag_t tag;
struct lib9p_qid qid;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rmkdir, lib9p_msg_Rmkdir);
/* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 4 ; max_copy = 19 */
struct lib9p_msg_Trenameat {
@@ -1367,7 +1273,6 @@ struct lib9p_msg_Trenameat {
lib9p_fid_t newdirfid;
struct lib9p_s newname;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Trenameat, lib9p_msg_Trenameat);
/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 3 ; max_copy = 17 */
struct lib9p_msg_Tunlinkat {
@@ -1376,7 +1281,6 @@ struct lib9p_msg_Tunlinkat {
struct lib9p_s name;
uint32_t flags;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tunlinkat, lib9p_msg_Tunlinkat);
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
@@ -1387,7 +1291,6 @@ struct lib9p_msg_Tsread {
uint16_t nwname;
struct lib9p_s *wname;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsread, lib9p_msg_Tsread);
/* min_size = 17 ; exp_size = 8,673 ; max_size = 8,589,934,607 (warning: >UINT32_MAX) ; max_iov = 2 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) ; max_copy = 17 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) */
struct lib9p_msg_Tswrite {
@@ -1398,7 +1301,6 @@ struct lib9p_msg_Tswrite {
uint32_t count;
[[gnu::nonstring]] char *data;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tswrite, lib9p_msg_Tswrite);
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
@@ -1410,7 +1312,6 @@ struct lib9p_msg_Rstat {
lib9p_tag_t tag;
struct lib9p_stat stat;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rstat, lib9p_msg_Rstat);
/* LIB9P_VER_9P2000 : min_size = 62 ; exp_size = 170 ; max_size = 262,202 ; max_iov = 8 ; max_copy = 62 */
/* LIB9P_VER_9P2000_e : min_size = 62 ; exp_size = 170 ; max_size = 262,202 ; max_iov = 8 ; max_copy = 62 */
@@ -1421,7 +1322,6 @@ struct lib9p_msg_Twstat {
lib9p_fid_t fid;
struct lib9p_stat stat;
};
-LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
/* containers *****************************************************************/
diff --git a/lib9p/core_include/lib9p/core.h b/lib9p/core_include/lib9p/core.h
index aa470de..4941220 100644
--- a/lib9p/core_include/lib9p/core.h
+++ b/lib9p/core_include/lib9p/core.h
@@ -7,9 +7,13 @@
#ifndef _LIB9P_CORE_H_
#define _LIB9P_CORE_H_
+#include <stdint.h> /* for uint{n}_t */
+#include <string.h> /* for memset() */
#include <sys/types.h> /* for ssize_t */
+#include <libhw/generic/io.h> /* for struct iovec */
#include <libmisc/assert.h>
+#include <libmisc/fmt.h>
#define CONFIG_9P_ENABLE_uninitialized 1
#include <lib9p/_core_generated.h>
@@ -55,31 +59,34 @@ void lib9p_ctx_clear_error(struct lib9p_ctx *ctx);
bool lib9p_ctx_has_error(struct lib9p_ctx *ctx);
-/* NB: This __VA_ARGS__ definition of lib9p_errorf() is handy because it
- * will produce an error if .../__VA_ARGS__ is empty; which means that
- * it should be lib9p_error() instead! */
#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
- int _lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg);
- int _lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) [[gnu::format(printf, 3, 4)]];
- /** Write an static error into ctx, return -1. */
- #define lib9p_error(ctx, errnum, errmsg) _lib9p_error(ctx, errnum, errmsg)
- /** Write a printf-style error into ctx, return -1. */
- #define lib9p_errorf(ctx, errnum, fmt, ...) _lib9p_errorf(ctx, errnum, fmt, __VA_ARGS__)
+ #define _lib9p_set_err_num(ctx, linux_errno) do { (ctx)->err_num = linux_errno; } while (0)
#else
- int _lib9p_error(struct lib9p_ctx *ctx, char const *msg);
- int _lib9p_errorf(struct lib9p_ctx *ctx, char const *fmt, ...) [[gnu::format(printf, 2, 3)]];
- /** Write an static error into ctx, return -1. */
- #define lib9p_error(ctx, errnum, errmsg) _lib9p_error(ctx, errmsg)
- /** Write a printf-style error into ctx, return -1. */
- #define lib9p_errorf(ctx, errnum, fmt, ...) _lib9p_errorf(ctx, fmt, __VA_ARGS__)
+ #define _lib9p_set_err_num(ctx, linux_errno) do { } while (0)
#endif
+/** Write a <libmisc/fmt.h>-style error into ctx, return -1. */
+#define lib9p_error(ctx, linux_errno, ...) ({ \
+ if (!lib9p_ctx_has_error(ctx)) { \
+ _lib9p_set_err_num(ctx, linux_errno); \
+ struct fmt_buf _w = { \
+ .dat = (ctx)->err_msg, \
+ .cap = sizeof((ctx)->err_msg), \
+ }; \
+ lo_interface fmt_dest w = lo_box_fmt_buf_as_fmt_dest(&_w); \
+ fmt_print(w, __VA_ARGS__); \
+ if (_w.len < _w.cap) \
+ memset(_w.dat + _w.len, 0, _w.cap - _w.len); \
+ } \
+ -1; \
+})
+
/* misc utilities *************************************************************/
uint32_t lib9p_version_min_Rerror_size(enum lib9p_version);
uint32_t lib9p_version_min_Rread_size(enum lib9p_version);
-lo_interface fmt_formatter lo_box_lib9p_msg_as_fmt_formatter(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body);
+void fmt_print_lib9p_msg(lo_interface fmt_dest w, struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body);
/* main T-message functions ***************************************************/
@@ -159,6 +166,9 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo
/* `struct lib9p_stat` helpers ************************************************/
#if _LIB9P_ENABLE_stat
+
+void fmt_print_lib9p_stat(lo_interface fmt_dest w, struct lib9p_ctx *ctx, struct lib9p_stat *stat);
+
/**
* Validate a message's `stat` structure.
*
diff --git a/lib9p/core_tables.h b/lib9p/core_tables.h
index da2027a..e3dc8f4 100644
--- a/lib9p/core_tables.h
+++ b/lib9p/core_tables.h
@@ -21,10 +21,10 @@ extern const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM];
/* message ********************************************************************/
-typedef lo_interface fmt_formatter (*_box_as_fmt_formatter_fn_t)(void *host_val);
+typedef void (*_print_fn_t)(lo_interface fmt_dest, struct lib9p_ctx *, void *);
struct _lib9p_msg_tentry {
- const char *name;
- _box_as_fmt_formatter_fn_t box_as_fmt_formatter;
+ const char *name;
+ _print_fn_t print;
};
typedef ssize_t (*_validate_fn_t)(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes);
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 1a6bbb1..18165e0 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -54,12 +54,11 @@ void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) {
ctx->flush_acknowledged = true;
}
-#define req_debugf(fmt, ...) \
- log_debugf("cid=%zu: %s(tag=%"PRIu16"): " fmt, \
- cr_getcid(), \
- lib9p_msgtype_str(ctx->basectx.version, ctx->net_bytes[4]), \
- ctx->tag \
- __VA_OPT__(,) __VA_ARGS__)
+#define req_debug(...) \
+ log_debugln( \
+ "cid=", cr_getcid(), ": ", \
+ lib9p_msgtype_str(ctx->basectx.version, ctx->net_bytes[4]), "(tag=", ctx->tag, "): ", \
+ __VA_ARGS__)
/* structs ********************************************************************/
@@ -356,13 +355,7 @@ static void srv_msglog(struct srv_req *req, enum lib9p_msg_type typ, void *hostm
srv->msglog(req, typ, hostmsg);
return;
}
- /* It sucks that %v trips -Wformat and -Wformat-extra-args
- * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47781 */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- log_infof("%c %v", typ % 2 ? '<' : '>', lo_box_lib9p_msg_as_fmt_formatter(&req->basectx, typ, hostmsg));
-#pragma GCC diagnostic pop
+ log_infoln(typ % 2 ? "< " : "> ", (lib9p_msg, &req->basectx, typ, hostmsg));
}
static ssize_t srv_write_Rmsg(struct srv_req *req, struct lib9p_Rmsg_send_buf *resp) {
@@ -373,7 +366,7 @@ static ssize_t srv_write_Rmsg(struct srv_req *req, struct lib9p_Rmsg_send_buf *r
return r;
}
-#define srv_nonrespond_errorf log_errorf
+#define srv_nonrespond_error log_errorln
static void srv_respond_error(struct srv_req *req) {
#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
@@ -409,7 +402,7 @@ static void srv_respond_error(struct srv_req *req) {
srv_msglog(req, LIB9P_TYP_Rerror, &host);
r = srv_write_Rmsg(req, &net);
if (r < 0)
- srv_nonrespond_errorf("write: %s", net_strerror(-r));
+ srv_nonrespond_error("write: ", net_strerror(-r));
}
/* read coroutine *************************************************************/
@@ -421,11 +414,11 @@ static inline bool srv_read_exactly(lo_interface net_stream_conn fd, uint8_t *bu
while (*done < goal) {
ssize_t r = io_read(fd, &buf[*done], goal - *done);
if (r < 0) {
- srv_nonrespond_errorf("read: %s", net_strerror(-r));
+ srv_nonrespond_error("read: ", net_strerror(-r));
return true;
} else if (r == 0) {
if (*done != 0)
- srv_nonrespond_errorf("read: unexpected EOF");
+ srv_nonrespond_error("read: unexpected EOF");
return true;
}
*done += r;
@@ -443,7 +436,7 @@ void lib9p_srv_accept_and_read_loop(struct lib9p_srv *srv, lo_interface net_stre
for (;;) {
lo_interface net_stream_conn conn = LO_CALL(listener, accept);
if (LO_IS_NULL(conn)) {
- srv_nonrespond_errorf("accept: error");
+ srv_nonrespond_error("accept: error");
srv->readers--;
if (srv->readers == 0)
while (srv->writers > 0)
@@ -478,7 +471,7 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
break;
size_t goal = uint32le_decode(buf);
if (goal < 7) {
- srv_nonrespond_errorf("T-message is impossibly small");
+ srv_nonrespond_error("T-message is impossibly small");
break;
}
if (srv_read_exactly(conn.fd, buf, 7, &done))
@@ -494,11 +487,9 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
.net_bytes = buf,
};
if (goal > sess.max_msg_size) {
- lib9p_errorf(&req.basectx,
- LIB9P_ERRNO_L_EMSGSIZE, "T-message larger than %s limit (%zu > %"PRIu32")",
- sess.initialized ? "negotiated" : "server",
- goal,
- sess.max_msg_size);
+ lib9p_error(&req.basectx, LIB9P_ERRNO_L_EMSGSIZE,
+ "T-message larger than ", sess.initialized ? "negotiated" : "server", " limit",
+ " (", goal, " > ", sess.max_msg_size, ")");
srv_respond_error(&req);
continue;
}
@@ -541,7 +532,7 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
MAP_FOREACH(&sess.fids, fid, fidinfo) {
srv_fid_del(&pseudoreq, fid, fidinfo, false);
if (lib9p_ctx_has_error(&pseudoreq.basectx)) {
- srv_nonrespond_errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, pseudoreq.basectx.err_msg);
+ srv_nonrespond_error("clunk: ", (strn, pseudoreq.basectx.err_msg, CONFIG_9P_MAX_ERR_SIZE));
lib9p_ctx_clear_error(&pseudoreq.basectx);
}
}
@@ -612,8 +603,6 @@ _HANDLER_PROTO(sread);
_HANDLER_PROTO(swrite);
#endif
-typedef void (*tmessage_handler)(struct srv_req *, void *);
-
void lib9p_srv_worker(struct srv_req *ctx) {
uint8_t *host_req = NULL;
@@ -631,35 +620,35 @@ void lib9p_srv_worker(struct srv_req *ctx) {
srv_msglog(ctx, typ, host_req);
/* Handle it. ********************************************************/
- tmessage_handler handler;
+#define CASE(typ) case LIB9P_TYP_##typ: handle_##typ(ctx, (void *)host_req); break
LM_PARTIAL_SWITCH (typ) {
- case LIB9P_TYP_Tversion: handler = (tmessage_handler)handle_Tversion; break;
+ CASE(Tversion);
#if _LIB9P_ENABLE_stat
- case LIB9P_TYP_Tauth: handler = (tmessage_handler)handle_Tauth; break;
- case LIB9P_TYP_Tattach: handler = (tmessage_handler)handle_Tattach; break;
- case LIB9P_TYP_Tflush: handler = (tmessage_handler)handle_Tflush; break;
- case LIB9P_TYP_Twalk: handler = (tmessage_handler)handle_Twalk; break;
- case LIB9P_TYP_Topen: handler = (tmessage_handler)handle_Topen; break;
- case LIB9P_TYP_Tcreate: handler = (tmessage_handler)handle_Tcreate; break;
- case LIB9P_TYP_Tread: handler = (tmessage_handler)handle_Tread; break;
- case LIB9P_TYP_Twrite: handler = (tmessage_handler)handle_Twrite; break;
- case LIB9P_TYP_Tclunk: handler = (tmessage_handler)handle_Tclunk; break;
- case LIB9P_TYP_Tremove: handler = (tmessage_handler)handle_Tremove; break;
- case LIB9P_TYP_Tstat: handler = (tmessage_handler)handle_Tstat; break;
- case LIB9P_TYP_Twstat: handler = (tmessage_handler)handle_Twstat; break;
+ CASE(Tauth);
+ CASE(Tattach);
+ CASE(Tflush);
+ CASE(Twalk);
+ CASE(Topen);
+ CASE(Tcreate);
+ CASE(Tread);
+ CASE(Twrite);
+ CASE(Tclunk);
+ CASE(Tremove);
+ CASE(Tstat);
+ CASE(Twstat);
#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
- case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break;
+ CASE(Topenfd);
#endif
#if CONFIG_9P_ENABLE_9P2000_e
- case LIB9P_TYP_Tsession: handler = (tmessage_handler)handle_Tsession; break;
- case LIB9P_TYP_Tsread: handler = (tmessage_handler)handle_Tsread; break;
- case LIB9P_TYP_Tswrite: handler = (tmessage_handler)handle_Tswrite; break;
+ CASE(Tsession);
+ CASE(Tsread);
+ CASE(Tswrite);
#endif
+#undef CASE
default:
assert_notreached("lib9p_Tmsg_validate() should have rejected unknown typ");
}
- handler(ctx, (void *)host_req);
assert(ctx->responded);
/* Release resources. ************************************************/
@@ -748,9 +737,9 @@ static void handle_Tversion(struct srv_req *ctx,
uint32_t min_msg_size = _LIB9P_MAX(lib9p_version_min_Rerror_size(ctx->basectx.version),
lib9p_version_min_Rread_size(ctx->basectx.version)+1);
if (req->max_msg_size < min_msg_size) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EDOM, "requested max_msg_size is less than minimum for %s (%"PRIu32" < %"PRIu32")",
- lib9p_version_str(version), req->max_msg_size, min_msg_size);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EDOM, "requested max_msg_size is less than minimum for ", lib9p_version_str(version),
+ " (", req->max_msg_size, " < ", min_msg_size,")");
goto tversion_return;
}
@@ -782,7 +771,7 @@ static void handle_Tversion(struct srv_req *ctx,
MAP_FOREACH(&ctx->parent_sess->fids, fid, fidinfo) {
srv_fid_del(ctx, fid, fidinfo, false);
if (lib9p_ctx_has_error(&ctx->basectx)) {
- srv_nonrespond_errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, ctx->basectx.err_msg);
+ srv_nonrespond_error("clunk: ", (strn, ctx->basectx.err_msg, CONFIG_9P_MAX_ERR_SIZE));
lib9p_ctx_clear_error(&ctx->basectx);
}
}
@@ -841,21 +830,22 @@ static void handle_Tattach(struct srv_req *ctx,
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is not an auth-file");
else if (!lib9p_str_eq(afid->user->name, req->uname))
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"",
- afid->user->name.len, afid->user->name.utf8,
- req->uname.len, req->uname.utf8);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EACCES,
+ "FID provided as auth-file is for user=", (qmem, afid->user->name.utf8, afid->user->name.len),
+ " and cannot be used for user=", (qmem, req->uname.utf8, req->uname.len));
#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
else if (afid->user->num != req->unum)
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=%"PRIu32" and cannot be used for user=%"PRIu32,
- afid->user->num, req->unum);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EACCES,
+ "FID provided as auth-file is for user=", afid->user->num,
+ " and cannot be used for user=", req->unum);
#endif
else if (!lib9p_str_eq(afid->auth.aname, req->aname))
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for tree=\"%.*s\" and cannot be used for tree=\"%.*s\"",
- afid->auth.aname.len, afid->auth.aname.utf8,
- req->aname.len, req->aname.utf8);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EACCES,
+ "FID provided as auth-file is for tree=", (qmem, afid->auth.aname.utf8, afid->auth.aname.len),
+ " and cannot be used for tree=", (qmem, req->aname.utf8, req->aname.len));
else if (!afid->auth.completed)
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "FID provided as auth-file has not completed authentication");
@@ -907,11 +897,11 @@ static void handle_Tflush(struct srv_req *ctx,
switch (cr_select_l(CR_SELECT_RECV(&oldreq->flush_ch, &res),
CR_SELECT_SEND(&ctx->flush_ch, &res))) {
case 0: /* original request returned */
- req_debugf("original request (tag=%"PRIu16") returned", req->oldtag);
+ req_debug("original request (tag=", req->oldtag, ") returned");
ctx->flush_acknowledged = (res == _LIB9P_SRV_FLUSH_SILENT);
break;
case 1: /* flush itself got flushed */
- req_debugf("flush itself flushed");
+ req_debug("flush itself flushed");
ctx->flush_acknowledged = true;
break;
}
@@ -931,8 +921,8 @@ static void handle_Twalk(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBADF, "bad file number ", req->fid);
goto twalk_return;
}
if (fidinfo->flags & FIDFLAG_OPEN) {
@@ -1009,8 +999,8 @@ static void handle_Topen(struct srv_req *ctx,
/* Check that the FID is valid for this. */
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBADF, "bad file number ", req->fid);
goto topen_return;
}
if (fidinfo->flags & FIDFLAG_OPEN) {
@@ -1179,8 +1169,8 @@ static void handle_Tread(struct srv_req *ctx,
/* Check that the FID is valid for this. */
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBADF, "bad file number ", req->fid);
goto tread_return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_R)) {
@@ -1200,9 +1190,8 @@ static void handle_Tread(struct srv_req *ctx,
fidinfo->dir.off = 0;
fidinfo->dir.buffered_dirent = (struct lib9p_srv_dirent){};
} else if (req->offset != fidinfo->dir.off) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EINVAL, "invalid offset (must be 0 or %"PRIu64"): %"PRIu64,
- fidinfo->dir.off, req->offset);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EINVAL, "invalid offset (must be 0 or ", fidinfo->dir.off, "): ", req->offset);
goto tread_return;
}
/* Read. */
@@ -1301,8 +1290,8 @@ static void handle_Twrite(struct srv_req *ctx,
/* Check that the FID is valid for this. */
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBADF, "bad file number ", req->fid);
goto twrite_return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_W)) {
@@ -1328,8 +1317,8 @@ static void handle_Tclunk(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBADF, "bad file number ", req->fid);
goto tclunk_return;
}
@@ -1345,8 +1334,8 @@ static void handle_Tremove(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBADF, "bad file number ", req->fid);
goto tremove_return;
}
@@ -1381,8 +1370,8 @@ static void handle_Tstat(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBADF, "bad file number ", req->fid);
goto tstat_return;
}
struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c
index d7819eb..4caff16 100644
--- a/lib9p/tests/test_server/main.c
+++ b/lib9p/tests/test_server/main.c
@@ -38,9 +38,9 @@
static lo_interface lib9p_srv_file get_root(struct lib9p_srv_ctx *, struct lib9p_s);
-const char *hexdig = "0123456789abcdef";
+static const char *hexdig = "0123456789abcdef";
-struct {
+static struct {
uint16_t port;
struct hostnet_tcp_listener listeners[_CONFIG_9P_MAX_CONNS];
struct lib9p_srv srv;
@@ -67,7 +67,7 @@ struct {
__VA_OPT__(,) __VA_ARGS__ \
}))
-struct lib9p_srv_file root =
+static struct lib9p_srv_file root =
STATIC_DIR(1, "",
STATIC_DIR(2, "Documentation",
STATIC_FILE(3, "x", Documentation_x_txt),
@@ -128,22 +128,26 @@ static COROUTINE init_cr(void *) {
cr_exit();
}
-static void log_fct(char character, void *_stream) {
- FILE *stream = _stream;
- putc(character, stream);
- putchar(character);
+struct tstlog_stdout {};
+LO_IMPLEMENTATION_H(fmt_dest, struct tstlog_stdout, tstlog_stdout);
+LO_IMPLEMENTATION_C(fmt_dest, struct tstlog_stdout, tstlog_stdout, static);
+
+static size_t tstlog_bytes = 0;
+
+static void tstlog_stdout_putb(struct tstlog_stdout *, uint8_t b) {
+ putc(b, globals.logstream);
+ putchar(b);
+ tstlog_bytes++;
}
-static void log_msg(struct lib9p_srv_ctx *ctx, enum lib9p_msg_type typ, void *hostmsg) {
- /* It sucks that %v trips -Wformat and -Wformat-extra-args
- * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47781 */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat"
-#pragma GCC diagnostic ignored "-Wformat-extra-args"
- fmt_fctprintf(log_fct, globals.logstream,
- "%c %v\n", typ % 2 ? '<' : '>',
- lo_box_lib9p_msg_as_fmt_formatter(&ctx->basectx, typ, hostmsg));
-#pragma GCC diagnostic pop
+static size_t tstlog_stdout_tell(struct tstlog_stdout *) {
+ return tstlog_bytes;
+}
+
+static lo_interface fmt_dest tstlog_dest = { .vtable = &_lo_tstlog_stdout_fmt_dest_vtable };
+
+static void tstlog_msg(struct lib9p_srv_ctx *ctx, enum lib9p_msg_type typ, void *hostmsg) {
+ fmt_print(tstlog_dest, typ % 2 ? "< " : "> ", (lib9p_msg, &ctx->basectx, typ, hostmsg), "\n");
fflush(globals.logstream);
}
@@ -155,7 +159,7 @@ int main(int argc, char *argv[]) {
globals.logstream = fopen(argv[2], "w");
if (!globals.logstream)
error(2, errno, "fopen");
- globals.srv.msglog = log_msg;
+ globals.srv.msglog = tstlog_msg;
struct hostclock clock_monotonic = {
.clock_id = CLOCK_MONOTONIC,
diff --git a/libcr/coroutine.c b/libcr/coroutine.c
index 4c0b7e8..920c371 100644
--- a/libcr/coroutine.c
+++ b/libcr/coroutine.c
@@ -556,8 +556,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
assert_cid_state(parent, state == CR_RUNNING);
assert(stack_size);
assert(fn);
- log_debugf("coroutine_add_with_stack_size(%zu, \"%s\", %p, %p)...",
- stack_size, name, fn, args);
+ log_debugln("coroutine_add_with_stack_size(", stack_size, ", ", (qstr, name), ", ", (ptr, fn), ", ", (ptr, args), ")...");
if (!coroutine_initialized) {
cr_plat_init();
@@ -567,7 +566,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
cid_t child = coroutine_allocate_cid();
if (!child)
return 0;
- log_debugf("...child=%zu", child);
+ log_debugln("...child=", child);
/* 1. state *************************************************/
coroutine_table[child-1].state = CR_INITIALIZING;
@@ -580,13 +579,13 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
/* 3. stack *************************************************/
coroutine_table[child-1].stack_size = stack_size + 2*CR_STACK_GUARD_SIZE;
- log_infof("allocing \"%s\" stack with size %zu+2*%zu=%zu",
- name, stack_size, CR_STACK_GUARD_SIZE, coroutine_table[child-1].stack_size);
+ log_infoln("allocing ", (qstr, name), " stack with size ",
+ stack_size, "+2*", (base10, CR_STACK_GUARD_SIZE), "=", coroutine_table[child-1].stack_size);
coroutine_table[child-1].stack =
aligned_alloc(CR_PLAT_STACK_ALIGNMENT, coroutine_table[child-1].stack_size);
- log_infof("... done, stack is [0x%p,0x%p)",
- coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE,
- coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE + stack_size);
+ log_infoln("... done, stack is [",
+ (ptr, coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE), ",",
+ (ptr, coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE + stack_size), ")");
#if CONFIG_COROUTINE_MEASURE_STACK || CONFIG_COROUTINE_PROTECT_STACK
for (size_t i = 0; i < coroutine_table[child-1].stack_size; i++)
((uint8_t *)coroutine_table[child-1].stack)[i] =
@@ -608,8 +607,8 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
+ stack_size
#endif
;
- log_debugf("...stack =%p", coroutine_table[child-1].stack);
- log_debugf("...stack_base=%p", stack_base);
+ log_debugln("...stack =", (ptr, coroutine_table[child-1].stack));
+ log_debugln("...stack_base=", (ptr, stack_base));
/* run until cr_begin() */
cr_plat_call_with_stack(stack_base, fn, args);
assert_notreached("should cr_begin() instead of returning");
@@ -630,7 +629,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
/* coroutine_main() ***********************************************************/
void coroutine_main(void) {
- log_debugf("coroutine_main()");
+ log_debugln("coroutine_main()");
if (!coroutine_initialized) {
cr_plat_init();
coroutine_initialized = true;
@@ -675,7 +674,7 @@ void coroutine_main(void) {
/* cr_*() *********************************************************************/
void cr_begin(void) {
- log_debugf("cid=%zu: cr_begin()", coroutine_running);
+ log_debugln("cid=", coroutine_running, ": cr_begin()");
assert_cid_state(coroutine_running, state == CR_INITIALIZING);
bool saved = cr_save_and_disable_interrupts();
@@ -707,7 +706,7 @@ static inline void _cr_yield() {
}
void cr_yield(void) {
- log_debugf("cid=%zu: cr_yield()", coroutine_running);
+ log_debugln("cid=", coroutine_running ,": cr_yield()");
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -719,7 +718,7 @@ void cr_yield(void) {
}
void cr_pause_and_yield(void) {
- log_debugf("cid=%zu: cr_pause_and_yield()", coroutine_running);
+ log_debugln("cid=", coroutine_running, ": cr_pause_and_yield()");
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -730,7 +729,7 @@ void cr_pause_and_yield(void) {
}
[[noreturn]] void cr_exit(void) {
- log_debugf("cid=%zu: cr_exit()", coroutine_running);
+ log_debugln("cid=", coroutine_running, ": cr_exit()");
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -747,7 +746,7 @@ static void _cr_unpause(cid_t cid) {
}
void cr_unpause(cid_t cid) {
- log_debugf("cr_unpause(%zu)", cid);
+ log_debugln("cr_unpause(", cid, ")");
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -757,7 +756,7 @@ void cr_unpause(cid_t cid) {
}
void cr_unpause_from_intrhandler(cid_t cid) {
- log_debugf("cr_unpause_from_intrhandler(%zu)", cid);
+ log_debugln("cr_unpause_from_intrhandler(", cid, ")");
assert(cr_plat_is_in_intrhandler());
_cr_unpause(cid);
diff --git a/libdhcp/dhcp_client.c b/libdhcp/dhcp_client.c
index a561cbf..8e8361d 100644
--- a/libdhcp/dhcp_client.c
+++ b/libdhcp/dhcp_client.c
@@ -460,11 +460,11 @@ static bool dhcp_client_send(struct dhcp_client *client, uint8_t msgtyp, const c
/**********************************************************************\
* Send *
\**********************************************************************/
- log_debugf("state %s: sending DHCP %s", state_strs[client->state], dhcp_msgtyp_str(msgtyp));
+ log_debugln("state ", state_strs[client->state], ": sending DHCP ", dhcp_msgtyp_str(msgtyp));
ssize_t r = LO_CALL(client->sock, sendto, scratch_msg, DHCP_MSG_BASE_SIZE + optlen,
client_broadcasts ? net_ip4_addr_broadcast : client->lease_server_id, DHCP_PORT_SERVER);
if (r < 0) {
- log_debugf("error: sendto: %zd", r);
+ log_debugln("error: sendto: ", r);
return true;
}
client->last_sent_msgtyp = msgtyp;
@@ -704,7 +704,7 @@ static ssize_t dhcp_client_recv(struct dhcp_client *client, struct dhcp_recv_msg
static bool dhcp_check_conflict(lo_interface net_packet_conn sock, struct net_ip4_addr addr) {
assert(!LO_IS_NULL(sock));
ssize_t v = LO_CALL(sock, sendto, "CHECK_IP_CONFLICT", 17, addr, 5000);
- log_debugf("check_ip_conflict => %zd", v);
+ log_debugln("check_ip_conflict => ", v);
return v != -NET_EARP_TIMEOUT;
}
@@ -740,10 +740,10 @@ static void dhcp_client_take_lease(struct dhcp_client *client, struct dhcp_recv_
client->lease_time_ns_end = (dur_ns_end == DHCP_INFINITY * NS_PER_S) ? 0 : client->time_ns_init + dur_ns_end;
if (ifup) {
- log_infof("applying configuration to "PRI_net_eth_addr, ARG_net_eth_addr(client->self_eth_addr));
- log_infof(":: addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_client_addr));
- log_infof(":: gateway_addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_auxdata.gateway_addr));
- log_infof(":: subnet_mask = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_auxdata.subnet_mask));
+ log_infoln("applying configuration to ", (net_eth_addr, client->self_eth_addr));
+ log_infoln(":: addr = ", (net_ip4_addr, client->lease_client_addr));
+ log_infoln(":: gateway_addr = ", (net_ip4_addr, client->lease_auxdata.gateway_addr));
+ log_infoln(":: subnet_mask = ", (net_ip4_addr, client->lease_auxdata.subnet_mask));
LO_CALL(client->iface, ifup, (struct net_iface_config){
.addr = client->lease_client_addr,
.gateway_addr = client->lease_auxdata.gateway_addr,
@@ -767,7 +767,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
/* State transition diagram: https://datatracker.ietf.org/doc/html/rfc2131#page-35 */
for (;;) {
- log_debugf("loop: state=%s", state_strs[client->state]);
+ log_debugln("loop: state=", state_strs[client->state]);
switch (client->state) {
case STATE_INIT:
client->xid = rand_uint63n(UINT32_MAX);
@@ -793,7 +793,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
break;
default:
assert(r < 0);
- log_debugf("error: recvfrom: %d", r);
+ log_debugln("error: recvfrom: ", r);
}
break;
case STATE_REQUESTING:
@@ -806,8 +806,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
break;
case DHCP_MSGTYP_ACK:
if (dhcp_check_conflict(client->sock, client->lease_client_addr)) {
- log_debugf("IP "PRI_net_ip4_addr" is already in use",
- ARG_net_ip4_addr(client->lease_client_addr));
+ log_debugln("IP ", (net_ip4_addr, client->lease_client_addr), " is already in use");
dhcp_client_setstate(client, STATE_INIT, DHCP_MSGTYP_DECLINE, "IP is already in use", scratch_msg);
} else {
dhcp_client_take_lease(client, scratch_msg, true);
@@ -820,7 +819,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
break;
default:
assert(r < 0);
- log_debugf("error: recvfrom: %d", r);
+ log_debugln("error: recvfrom: ", r);
}
break;
case STATE_BOUND:
@@ -834,7 +833,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
break;
default:
assert(r < 0);
- log_debugf("error: recvfrom: %d", r);
+ log_debugln("error: recvfrom: ", r);
}
break;
case STATE_RENEWING:
@@ -863,7 +862,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
break;
default:
assert(r < 0);
- log_debugf("error: recvfrom: %d", r);
+ log_debugln("error: recvfrom: ", r);
}
break;
case STATE_REBINDING:
@@ -889,7 +888,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
break;
default:
assert(r < 0);
- log_debugf("error: recvfrom: %d", r);
+ log_debugln("error: recvfrom: ", r);
}
break;
case STATE_INIT_REBOOT:
diff --git a/libfmt/CMakeLists.txt b/libfmt/CMakeLists.txt
deleted file mode 100644
index dc626f7..0000000
--- a/libfmt/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# libfmt/CMakeLists.txt - Support for pico-fmt
-#
-# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
-# SPDX-License-Identifier: AGPL-3.0-or-later
-
-add_library(libfmt INTERFACE)
-target_include_directories(libfmt PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
-target_sources(libfmt INTERFACE
- libmisc.c
- quote.c
-)
-target_link_libraries(libfmt INTERFACE
- pico_fmt
- libmisc
-)
diff --git a/libfmt/include/libfmt/fmt.h b/libfmt/include/libfmt/fmt.h
deleted file mode 100644
index 692abf2..0000000
--- a/libfmt/include/libfmt/fmt.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* libfmt/fmt.h - Support for pico-fmt
- *
- * Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#ifndef _LIBFMT_FMT_H_
-#define _LIBFMT_FMT_H_
-
-#include <pico/fmt_printf.h>
-#include <pico/fmt_install.h>
-
-#include <libmisc/obj.h>
-
-/**
- * An object that implements fmt_formatter can be printed using
- * `printf("%v", boxed_obj)`.
- */
-#define fmt_formatter_LO_IFACE \
- LO_FUNC(void, format, struct fmt_state *)
-LO_INTERFACE(fmt_formatter);
-
-#endif /* _LIBFMT_FMT_H_ */
diff --git a/libfmt/libmisc.c b/libfmt/libmisc.c
deleted file mode 100644
index 134b9f0..0000000
--- a/libfmt/libmisc.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* libfmt/libmisc.c - Integrate pico-fmt with libmisc
- *
- * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#include <stdarg.h> /* for va_list, va_start(), va_end() */
-#include <stdio.h> /* for vprintf(), putchar(), fflush() */
-#if LIB_PICO_STDIO
-#include <pico/stdio.h> /* for stdio_putchar_raw() */
-#endif
-
-#include <libmisc/macro.h> /* for LM_UNUSED() */
-#include <libmisc/_intercept.h> /* for __lm_printf() and __lm_light_printf() */
-
-#include <libfmt/fmt.h> /* for fmt_vfctprintf() */
-
-#if LIB_PICO_STDIO
-static void libfmt_light_fct(char character, void *LM_UNUSED(arg)) {
- if (character == '\n')
- stdio_putchar_raw('\r');
- stdio_putchar_raw(character);
-}
-#else
-static void libfmt_libc_fct(char character, void *LM_UNUSED(arg)) {
- putchar(character);
-}
-#endif
-
-int __lm_printf(const char *format, ...) {
- va_list va;
- va_start(va, format);
-#if LIB_PICO_STDIO
- /* pico_stdio has already intercepted vprintf for us, and
- * their stdio_buffered_printer() is better than our
- * libfmt_libc_fct() because buffering. */
- int ret = vprintf(format, va);
-#else
- int ret = fmt_vfctprintf(libfmt_libc_fct, NULL, format, va);
- fflush(stdout);
-#endif
- va_end(va);
- return ret;
-}
-
-int __lm_light_printf(const char *format, ...) {
- va_list va;
- va_start(va, format);
-#if LIB_PICO_STDIO
- /* libfmt_light_fct() and stdio_buffered_printer() both use 68
- * bytes of stack; but the buffer lives on the stack of
- * stdio.c:__wrap_vprintf(); so that's where you'll see the
- * numbers be different if you're analyzing it. (Also, being
- * able to skip the stdio_stack_buffer_flush() call.) */
- int ret = fmt_vfctprintf(libfmt_light_fct, NULL, format, va);
- stdio_flush();
-#else
- int ret = fmt_vfctprintf(libfmt_libc_fct, NULL, format, va);
- fflush(stdout);
-#endif
- va_end(va);
- return ret;
-}
-
-static void libfmt_conv_formatter(struct fmt_state *state) {
- lo_interface fmt_formatter obj = va_arg(*state->args, lo_interface fmt_formatter);
- LO_CALL(obj, format, state);
-}
-
-[[gnu::constructor]]
-static void libfmt_install_formatter(void) {
- fmt_install('v', libfmt_conv_formatter);
-}
diff --git a/libfmt/quote.c b/libfmt/quote.c
deleted file mode 100644
index c91e0b0..0000000
--- a/libfmt/quote.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* libfmt/quote.c - C-string quoting for pico-fmt
- *
- * Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#include <string.h> /* for strnlen() */
-#include <stdint.h> /* for uint{n}_t() */
-
-#include <libfmt/fmt.h>
-
-enum quote {
- QUOTE_NONE, /* c */
- QUOTE_SIMPLE, /* \c */
- QUOTE_U4, /* \uABCD */
- QUOTE_U8, /* \UABCDABCD */
-};
-
-static inline enum quote needs_quote(uint32_t ch) {
- if (ch == '\a' ||
- ch == '\b' ||
- ch == '\f' ||
- ch == '\n' ||
- ch == '\r' ||
- ch == '\t' ||
- ch == '\v' ||
- ch == '\\' ||
- ch == '\'' ||
- ch == '"' ||
- ch == '?')
- return QUOTE_SIMPLE;
- else if (' ' <= ch && ch <= '~')
- return QUOTE_NONE;
- else if (ch < 0x10000)
- return QUOTE_U4;
- else
- return QUOTE_U8;
-}
-
-/**
- * Quote a string to ASCII-only C syntax. Valid UTF-8 is quoted as
- * short C-escape characters, \uABCD or \UABCDABCD; invalid UTF-8 is
- * quoted as \xAB.
- */
-static void libfmt_conv_quote(struct fmt_state *state) {
- uint32_t ch;
- uint8_t chlen;
-
- const char *in = va_arg(*state->args, char*);
- size_t in_len = strnlen(in, (state->flags & FMT_FLAG_PRECISION) ? state->precision : (size_t)-1);
-
- size_t out_len = 2;
- for (size_t pos = 0; pos < in_len;) {
- if ((in[pos] & 0b10000000) == 0b00000000) { ch = in[pos] & 0b01111111; chlen = 1; }
- else if ((in[pos] & 0b11100000) == 0b11000000) { ch = in[pos] & 0b00011111; chlen = 2; }
- else if ((in[pos] & 0b11110000) == 0b11100000) { ch = in[pos] & 0b00001111; chlen = 3; }
- else if ((in[pos] & 0b11111000) == 0b11110000) { ch = in[pos] & 0b00000111; chlen = 4; }
- else goto measure_invalid_utf8;
- if ((ch == 0 && chlen != 1) || pos + chlen > in_len) goto measure_invalid_utf8;
- for (uint8_t i = 1; i < chlen; i++) {
- if ((in[pos+i] & 0b11000000) != 0b10000000) goto measure_invalid_utf8;
- ch = (ch << 6) | (in[pos+i] & 0b00111111);
- }
- if (ch > 0x10FFFF) goto measure_invalid_utf8;
- pos += chlen;
-
- switch (needs_quote(ch)) {
- case QUOTE_NONE : out_len += 1; break;
- case QUOTE_SIMPLE : out_len += 2; break;
- case QUOTE_U4 : out_len += 6; break;
- case QUOTE_U8 : out_len += 10; break;
- }
- continue;
- measure_invalid_utf8:
- pos++;
- out_len += 4; /* \xAB */
- }
-
- if (!(state->flags & FMT_FLAG_LEFT)) {
- for (size_t i = 0; i + out_len < state->width; i++) {
- fmt_state_putchar(state, ' ');
- }
- }
-
- fmt_state_putchar(state, '"');
- for (size_t pos = 0; pos < in_len;) {
- if ((in[pos] & 0b10000000) == 0b00000000) { ch = in[pos] & 0b01111111; chlen = 1; }
- else if ((in[pos] & 0b11100000) == 0b11000000) { ch = in[pos] & 0b00011111; chlen = 2; }
- else if ((in[pos] & 0b11110000) == 0b11100000) { ch = in[pos] & 0b00001111; chlen = 3; }
- else if ((in[pos] & 0b11111000) == 0b11110000) { ch = in[pos] & 0b00000111; chlen = 4; }
- else goto output_invalid_utf8;
- if ((ch == 0 && chlen != 1) || pos + chlen > in_len) goto output_invalid_utf8;
- for (uint8_t i = 1; i < chlen; i++) {
- if ((in[pos+i] & 0b11000000) != 0b10000000) goto output_invalid_utf8;
- ch = (ch << 6) | (in[pos+i] & 0b00111111);
- }
- if (ch > 0x10FFFF) goto output_invalid_utf8;
- pos += chlen;
-
- switch (needs_quote(ch)) {
- case QUOTE_NONE:
- fmt_state_putchar(state, ch);
- break;
- case QUOTE_SIMPLE:
- fmt_state_putchar(state, '\\');
- switch (ch) {
- case '\a': fmt_state_putchar(state, 'a'); break;
- case '\b': fmt_state_putchar(state, 'b'); break;
- case '\f': fmt_state_putchar(state, 'f'); break;
- case '\n': fmt_state_putchar(state, 'n'); break;
- case '\r': fmt_state_putchar(state, 'r'); break;
- case '\t': fmt_state_putchar(state, 't'); break;
- case '\v': fmt_state_putchar(state, 'v'); break;
- case '\\': fmt_state_putchar(state, '\\'); break;
- case '\'': fmt_state_putchar(state, '\''); break;
- case '"': fmt_state_putchar(state, '"'); break;
- case '?': fmt_state_putchar(state, '?'); break;
- }
- break;
- case QUOTE_U4:
- fmt_state_putchar(state, '\\');
- fmt_state_putchar(state, 'u');
- fmt_state_putchar(state, (ch >> 12) & 0xF);
- fmt_state_putchar(state, (ch >> 8) & 0xF);
- fmt_state_putchar(state, (ch >> 4) & 0xF);
- fmt_state_putchar(state, (ch >> 0) & 0xF);
- break;
- case QUOTE_U8:
- fmt_state_putchar(state, '\\');
- fmt_state_putchar(state, 'U');
- fmt_state_putchar(state, (ch >> 28) & 0xF);
- fmt_state_putchar(state, (ch >> 24) & 0xF);
- fmt_state_putchar(state, (ch >> 20) & 0xF);
- fmt_state_putchar(state, (ch >> 16) & 0xF);
- fmt_state_putchar(state, (ch >> 12) & 0xF);
- fmt_state_putchar(state, (ch >> 8) & 0xF);
- fmt_state_putchar(state, (ch >> 4) & 0xF);
- fmt_state_putchar(state, (ch >> 0) & 0xF);
- break;
- }
- continue;
- output_invalid_utf8:
- fmt_state_putchar(state, '\\');
- fmt_state_putchar(state, 'x');
- fmt_state_putchar(state, (in[pos] >> 4) & 0xF);
- fmt_state_putchar(state, (in[pos] >> 0) & 0xF);
- pos++;
- }
- fmt_state_putchar(state, '"');
-
- for (size_t i = 0; i + out_len < state->width; i++) {
- fmt_state_putchar(state, ' ');
- }
-}
-
-[[gnu::constructor]]
-static void libfmt_install_quote(void) {
- fmt_install('q', libfmt_conv_quote);
-}
diff --git a/libhw_cr/rp2040_hwspi.c b/libhw_cr/rp2040_hwspi.c
index 3bf3f84..75acd58 100644
--- a/libhw_cr/rp2040_hwspi.c
+++ b/libhw_cr/rp2040_hwspi.c
@@ -70,7 +70,7 @@ void _rp2040_hwspi_init(struct rp2040_hwspi *self,
assert(self);
assert(baudrate_hz);
uint32_t clk_peri_hz = clock_get_hz(clk_peri);
- log_debugf("clk_peri = %"PRIu32"Hz", clk_peri_hz);
+ log_debugln("clk_peri = ", clk_peri_hz, "Hz");
assert(baudrate_hz*2 <= clk_peri_hz);
assert_4distinct(pin_miso, pin_mosi, pin_clk, pin_cs);
assert_4distinct(dma1, dma2, dma3, dma4);
@@ -97,7 +97,7 @@ void _rp2040_hwspi_init(struct rp2040_hwspi *self,
}
actual_baudrate_hz = spi_init(inst, baudrate_hz);
- log_debugf("baudrate = %uHz", actual_baudrate_hz);
+ log_debugln("baudrate = ", actual_baudrate_hz, "Hz");
assert(actual_baudrate_hz == baudrate_hz);
spi_set_format(inst, 8,
(mode & 0b10) ? SPI_CPOL_1 : SPI_CPOL_0,
diff --git a/libhw_cr/w5500.c b/libhw_cr/w5500.c
index 2893e8f..6f3f302 100644
--- a/libhw_cr/w5500.c
+++ b/libhw_cr/w5500.c
@@ -79,7 +79,7 @@
#include <libhw/generic/alarmclock.h> /* for sleep_*() */
#define LOG_NAME W5500
-#include <libmisc/log.h> /* for log_errorf(), log_debugf(), const_byte_str() */
+#include <libmisc/log.h>
#define IMPLEMENTATION_FOR_LIBHW_W5500_H YES
#include <libhw/w5500.h>
@@ -187,7 +187,7 @@ static COROUTINE w5500_irq_cr(void *_chip) {
bool had_intr = false;
uint8_t chipintr = w5500ll_read_common_reg(chip->spidev, chip_interrupt);
- log_n_debugf(W5500_LL, "w5500_irq_cr(): chipintr=%"PRIu8, chipintr);
+ log_n_debugln(W5500_LL, "w5500_irq_cr(): chipintr=", chipintr);
had_intr = had_intr || (chipintr != 0);
if (chipintr)
w5500ll_write_common_reg(chip->spidev, chip_interrupt, 0xFF);
@@ -196,7 +196,7 @@ static COROUTINE w5500_irq_cr(void *_chip) {
struct _w5500_socket *socket = &chip->sockets[socknum];
uint8_t sockintr = w5500ll_read_sock_reg(chip->spidev, socknum, interrupt);
- log_n_debugf(W5500_LL, "w5500_irq_cr(): sockintr[%"PRIu8"]=%"PRIu8, socknum, sockintr);
+ log_n_debugln(W5500_LL, "w5500_irq_cr(): sockintr[", socknum, "]=", sockintr);
had_intr = had_intr || (sockintr != 0);
switch (socket->mode) {
@@ -208,15 +208,15 @@ static COROUTINE w5500_irq_cr(void *_chip) {
recv_bits = sockintr & (SOCKINTR_RECV_DAT|SOCKINTR_RECV_FIN);
if (listen_bits) {
- log_debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->listen_sema", socknum);
+ log_debugln("w5500_irq_cr(): signal sock[", socknum, "]->listen_sema");
cr_sema_signal(&socket->listen_sema);
}
if (recv_bits) {
- log_debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->read_sema", socknum);
+ log_debugln("w5500_irq_cr(): signal sock[", socknum, "]->read_sema");
cr_sema_signal(&socket->read_sema);
}
if (send_bits) {
- log_debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->write_ch", socknum);
+ log_debugln("w5500_irq_cr(): signal sock[", socknum, "]->write_ch");
cr_chan_send(&socket->write_ch, send_bits);
}
break;
@@ -228,7 +228,7 @@ static COROUTINE w5500_irq_cr(void *_chip) {
cr_mutex_unlock(&chip->mu);
if (!had_intr && gpio_get(chip->pin_intr)) {
- log_debugf("w5500_irq_cr(): looks like all interrupts have been processed, sleeping...");
+ log_debugln("w5500_irq_cr(): looks like all interrupts have been processed, sleeping...");
cr_sema_wait(&chip->intr);
} else
cr_yield();
@@ -283,7 +283,7 @@ static inline void w5500_socket_close(struct _w5500_socket *socket) {
static void w5500_intrhandler(void *_chip, uint LM_UNUSED(gpio), enum gpio_irq_level LM_UNUSED(event)) {
struct w5500 *chip = _chip;
- log_debugf("w5500_intrhandler()");
+ log_debugln("w5500_intrhandler()");
cr_sema_signal_from_intrhandler(&chip->intr);
}
@@ -322,7 +322,7 @@ void _w5500_init(struct w5500 *chip,
w5500ll_write_sock_reg(chip->spidev, 0, mode, a);
uint8_t b = w5500ll_read_sock_reg(chip->spidev, 0, mode);
if (b != a) {
- log_errorf("SPI to W5500 does not appear to be functional: wrote:0x%02"PRIx16" != read:0x%02"PRIx8, a, b);
+ log_errorln("SPI to W5500 does not appear to be functional: wrote:", (base16_u8_, a), " != read:", (base16_u8_, b));
spi_ok = false;
}
}
@@ -427,15 +427,15 @@ static void _w5500_if_up(struct w5500 *chip, struct net_iface_config cfg) {
}
static void w5500_if_ifup(struct w5500 *chip, struct net_iface_config cfg) {
- log_debugf("if_up()");
- log_debugf(":: addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.addr));
- log_debugf(":: gateway_addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.gateway_addr));
- log_debugf(":: subnet_mask = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.subnet_mask));
+ log_debugln("if_up()");
+ log_debugln(":: addr = ", (net_ip4_addr, cfg.addr));
+ log_debugln(":: gateway_addr = ", (net_ip4_addr, cfg.gateway_addr));
+ log_debugln(":: subnet_mask = ", (net_ip4_addr, cfg.subnet_mask));
_w5500_if_up(chip, cfg);
}
static void w5500_if_ifdown(struct w5500 *chip) {
- log_debugf("if_down()");
+ log_debugln("if_down()");
_w5500_if_up(chip, (struct net_iface_config){});
}
@@ -444,10 +444,10 @@ static lo_interface net_stream_listener w5500_if_tcp_listen(struct w5500 *chip,
struct _w5500_socket *sock = w5500_alloc_socket(chip);
if (!sock) {
- log_debugf("tcp_listen() => no sock");
+ log_debugln("tcp_listen() => no sock");
return LO_NULL(net_stream_listener);
}
- log_debugf("tcp_listen() => sock[%"PRIu8"]", sock->socknum);
+ log_debugln("tcp_listen() => sock[", sock->socknum, "]");
if (!local_port)
local_port = w5500_alloc_local_port(chip);
@@ -470,11 +470,11 @@ static lo_interface net_stream_conn w5500_if_tcp_dial(struct w5500 *chip,
struct _w5500_socket *socket = w5500_alloc_socket(chip);
if (!socket) {
- log_debugf("tcp_dial() => no sock");
+ log_debugln("tcp_dial() => no sock");
return LO_NULL(net_stream_conn);
}
uint8_t socknum = socket->socknum;
- log_debugf("tcp_dial() => sock[%"PRIu8"]", socknum);
+ log_debugln("tcp_dial() => sock[", socknum, "]");
uint16_t local_port = w5500_alloc_local_port(chip);
@@ -502,7 +502,7 @@ static lo_interface net_stream_conn w5500_if_tcp_dial(struct w5500 *chip,
cr_mutex_unlock(&chip->mu);
for (;;) {
uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state);
- log_debugf("tcp_dial(): state=%s", w5500_state_str(state));
+ log_debugln("tcp_dial(): state=", w5500_state_str(state));
switch (state) {
case STATE_TCP_SYNSENT:
cr_yield();
@@ -520,11 +520,11 @@ static lo_interface net_packet_conn w5500_if_udp_conn(struct w5500 *chip, uint16
struct _w5500_socket *socket = w5500_alloc_socket(chip);
if (!socket) {
- log_debugf("udp_conn() => no sock");
+ log_debugln("udp_conn() => no sock");
return LO_NULL(net_packet_conn);
}
uint8_t socknum = socket->socknum;
- log_debugf("udp_conn() => sock[%"PRIu8"]", socknum);
+ log_debugln("udp_conn() => sock[", socknum, "]");
if (!local_port)
local_port = w5500_alloc_local_port(chip);
@@ -554,7 +554,7 @@ static lo_interface net_stream_conn w5500_tcplist_accept(struct _w5500_socket *s
restart:
if (!socket->list_open) {
- log_debugf("tcp_listener.accept() => already closed");
+ log_debugln("tcp_listener.accept() => already closed");
return LO_NULL(net_stream_conn);
}
@@ -573,7 +573,7 @@ static lo_interface net_stream_conn w5500_tcplist_accept(struct _w5500_socket *s
cr_mutex_unlock(&chip->mu);
for (;;) {
uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state);
- log_debugf("tcp_listener.accept() => state=%s", w5500_state_str(state));
+ log_debugln("tcp_listener.accept() => state=", w5500_state_str(state));
switch (state) {
case STATE_TCP_LISTEN:
case STATE_TCP_SYNRECV:
@@ -592,7 +592,7 @@ static lo_interface net_stream_conn w5500_tcplist_accept(struct _w5500_socket *s
}
static int w5500_tcplist_close(struct _w5500_socket *socket) {
- log_debugf("tcp_listener.close()");
+ log_debugln("tcp_listener.close()");
ASSERT_SELF(stream_listener, TCP);
socket->list_open = false;
@@ -609,7 +609,7 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec
for (int i = 0; i < iovcnt; i++)
count += iov[i].iov_len;
assert(count);
- log_debugf("tcp_conn.write(%zu)", count);
+ log_debugln("tcp_conn.write(", count, ")");
ASSERT_SELF(stream_conn, TCP);
/* What we really want is to pause until we receive an ACK for
@@ -635,14 +635,14 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec
size_t done = 0;
while (done < count) {
if (!socket->write_open) {
- log_debugf(" => soft closed");
+ log_debugln(" => soft closed");
return -NET_ECLOSED;
}
cr_mutex_lock(&chip->mu);
uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state);
if (state != STATE_TCP_ESTABLISHED && state != STATE_TCP_CLOSE_WAIT) {
cr_mutex_unlock(&chip->mu);
- log_debugf(" => hard closed");
+ log_debugln(" => hard closed");
return -NET_ECLOSED;
}
@@ -667,11 +667,11 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec
cr_mutex_unlock(&chip->mu);
switch (cr_chan_recv(&socket->write_ch)) {
case SOCKINTR_SEND_OK:
- log_debugf(" => sent %zu", freesize);
+ log_debugln(" => sent ", freesize);
done += freesize;
break;
case SOCKINTR_SEND_TIMEOUT:
- log_debugf(" => ACK timeout");
+ log_debugln(" => ACK timeout");
return -NET_EACK_TIMEOUT;
case SOCKINTR_SEND_OK|SOCKINTR_SEND_TIMEOUT:
assert_notreached("send both OK and timed out?");
@@ -679,12 +679,12 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec
assert_notreached("invalid write_ch bits");
}
}
- log_debugf(" => send finished");
+ log_debugln(" => send finished");
return done;
}
static void w5500_tcp_set_read_deadline(struct _w5500_socket *socket, uint64_t ns) {
- log_debugf("tcp_conn.set_read_deadline(%"PRIu64")", ns);
+ log_debugln("tcp_conn.set_read_deadline(", ns, ")");
ASSERT_SELF(stream_conn, TCP);
socket->read_deadline_ns = ns;
}
@@ -701,7 +701,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec
for (int i = 0; i < iovcnt; i++)
count += iov[i].iov_len;
assert(count);
- log_debugf("tcp_conn.read(%zu)", count);
+ log_debugln("tcp_conn.read(", count, ")");
ASSERT_SELF(stream_conn, TCP);
struct alarmclock_trigger trigger = {};
@@ -716,12 +716,12 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec
for (;;) {
if (!socket->read_open) {
LO_CALL(bootclock, del_trigger, &trigger);
- log_debugf(" => soft closed");
+ log_debugln(" => soft closed");
return -NET_ECLOSED;
}
if (socket->read_deadline_ns && socket->read_deadline_ns <= LO_CALL(bootclock, get_time_ns)) {
LO_CALL(bootclock, del_trigger, &trigger);
- log_debugf(" => recv timeout");
+ log_debugln(" => recv timeout");
return -NET_ERECV_TIMEOUT;
}
cr_mutex_lock(&chip->mu);
@@ -734,7 +734,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec
default:
LO_CALL(bootclock, del_trigger, &trigger);
cr_mutex_unlock(&chip->mu);
- log_debugf(" => hard closed");
+ log_debugln(" => hard closed");
return -NET_ECLOSED;
}
@@ -745,7 +745,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec
if (state == STATE_TCP_CLOSE_WAIT) {
LO_CALL(bootclock, del_trigger, &trigger);
cr_mutex_unlock(&chip->mu);
- log_debugf(" => EOF");
+ log_debugln(" => EOF");
return 0;
}
@@ -753,7 +753,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec
cr_sema_wait(&socket->read_sema);
}
assert(avail);
- log_debugf(" => received %"PRIu16" bytes", avail);
+ log_debugln(" => received ", avail, " bytes");
uint16_t ptr = uint16be_unmarshal(w5500ll_read_sock_reg(chip->spidev, socknum, rx_read_pointer));
/* Read the data. */
if ((size_t)avail > count)
@@ -769,7 +769,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec
}
static int w5500_tcp_close_inner(struct _w5500_socket *socket, bool rd, bool wr) {
- log_debugf("tcp_conn.close(rd=%s, wr=%s)", rd ? "true" : "false", wr ? "true" : "false");
+ log_debugln("tcp_conn.close(rd=", rd, ", wr=", wr, ")");
ASSERT_SELF(stream_conn, TCP);
if (rd)
@@ -807,14 +807,14 @@ static int w5500_tcp_close_write(struct _w5500_socket *socket) { return w5500_tc
static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t count,
struct net_ip4_addr node, uint16_t port) {
- log_debugf("udp_conn.sendto()");
+ log_debugln("udp_conn.sendto()");
ASSERT_SELF(packet_conn, UDP);
assert(buf);
assert(count);
uint16_t bufsize = ((uint16_t)w5500ll_read_sock_reg(chip->spidev, socknum, tx_buf_size))*1024;
if (count > bufsize) {
- log_debugf(" => msg too large");
+ log_debugln(" => msg too large");
return -NET_EMSGSIZE;
}
@@ -823,7 +823,7 @@ static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t
uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state);
if (state != STATE_UDP) {
cr_mutex_unlock(&chip->mu);
- log_debugf(" => closed");
+ log_debugln(" => closed");
return -NET_ECLOSED;
}
@@ -853,10 +853,10 @@ static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t
cr_mutex_unlock(&chip->mu);
switch (cr_chan_recv(&socket->write_ch)) {
case SOCKINTR_SEND_OK:
- log_debugf(" => sent");
+ log_debugln(" => sent");
return count;
case SOCKINTR_SEND_TIMEOUT:
- log_debugf(" => ARP timeout");
+ log_debugln(" => ARP timeout");
return -NET_EARP_TIMEOUT;
case SOCKINTR_SEND_OK|SOCKINTR_SEND_TIMEOUT:
assert_notreached("send both OK and timed out?");
@@ -866,7 +866,7 @@ static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t
}
static void w5500_udp_set_recv_deadline(struct _w5500_socket *socket, uint64_t ns) {
- log_debugf("udp_conn.set_recv_deadline(%"PRIu64")", ns);
+ log_debugln("udp_conn.set_recv_deadline(", ns, ")");
ASSERT_SELF(packet_conn, UDP);
socket->read_deadline_ns = ns;
}
@@ -878,7 +878,7 @@ static void w5500_udp_alarm_handler(void *_arg) {
static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_t count,
struct net_ip4_addr *ret_node, uint16_t *ret_port) {
- log_debugf("udp_conn.recvfrom()");
+ log_debugln("udp_conn.recvfrom()");
ASSERT_SELF(packet_conn, UDP);
assert(buf);
assert(count);
@@ -895,14 +895,14 @@ static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_
for (;;) {
if (socket->read_deadline_ns && socket->read_deadline_ns <= LO_CALL(bootclock, get_time_ns)) {
LO_CALL(bootclock, del_trigger, &trigger);
- log_debugf(" => recv timeout");
+ log_debugln(" => recv timeout");
return -NET_ERECV_TIMEOUT;
}
cr_mutex_lock(&chip->mu);
uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state);
if (state != STATE_UDP) {
LO_CALL(bootclock, del_trigger, &trigger);
- log_debugf(" => hard closed");
+ log_debugln(" => hard closed");
return -NET_ECLOSED;
}
@@ -933,7 +933,7 @@ static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_
if (ret_port)
*ret_port = uint16be_decode(&hdr[4]);
uint16_t len = uint16be_decode(&hdr[6]);
- log_debugf(" => received %"PRIu16" bytes%s", len, len < avail-8 ? " (plus more messages)" : "");
+ log_debugln(" => received ", len, " bytes", len < avail-8 ? " (plus more messages)" : "");
/* Now read the actual data. */
if (count > len)
count = len;
@@ -951,7 +951,7 @@ static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_
}
static int w5500_udp_close(struct _w5500_socket *socket) {
- log_debugf("udp_conn.close()");
+ log_debugln("udp_conn.close()");
ASSERT_SELF(packet_conn, UDP);
w5500_socket_close(socket);
diff --git a/libhw_cr/w5500_ll.h b/libhw_cr/w5500_ll.h
index 738a7f1..aa41e7a 100644
--- a/libhw_cr/w5500_ll.h
+++ b/libhw_cr/w5500_ll.h
@@ -54,14 +54,15 @@
#define CTL_OM_FDM4 0b11 /* fixed-length data mode: 4 byte data length */
#if CONFIG_W5500_LL_DEBUG
-static char *_ctl_block_part_strs[] = {
- "RES",
- "REG",
- "TX",
- "RX",
-};
-#define PRI_ctl_block "CTL_BLOCK_SOCK(%d, %s)"
-#define ARG_ctl_block(b) (((b)>>5) & 0b111), _ctl_block_part_strs[((b)>>3)&0b11]
+static void fmt_print_ctl_block(lo_interface fmt_dest, uint8_t b) {
+ static char *strs[] = {
+ "RES",
+ "REG",
+ "TX",
+ "RX",
+ };
+ fmt_print("CTL_BLOCK_SOCK(", (base10, (((b)>>5) & 0b111)), ", ", strs[((b)>>3)&0b11], ")");
+}
#endif
/* Even though SPI is a full-duplex protocol, the W5500's spiframe on top of it is only half-duplex.
@@ -83,9 +84,13 @@ w5500ll_writev(
assert(iov);
assert(iovcnt > 0);
#if CONFIG_W5500_LL_DEBUG
- log_n_debugf(W5500_LL,
- "%s(): w5500ll_write(spidev, addr=%#04x, block="PRI_ctl_block", iov, iovcnt=%d)",
- func, addr, ARG_ctl_block(block), iovcnt);
+ log_n_debugln(W5500_LL,
+ func, "(): w5500ll_write(spidev",
+ ", addr=", (base16_u16_, addr),
+ ", block=", (ctl_block, block),
+ ", iov",
+ ", iovcnt=", iovcnt,
+ ")");
#endif
uint8_t header[] = {
@@ -120,9 +125,13 @@ w5500ll_readv(
assert(iov);
assert(iovcnt > 0);
#if CONFIG_W5500_LL_DEBUG
- log_n_debugf(W5500_LL,
- "%s(): w5500ll_read(spidev, addr=%#04x, block="PRI_ctl_block", iov, iovcnt=%d)",
- func, addr, ARG_ctl_block(block), iovcnt);
+ log_n_debugln(W5500_LL,
+ func, "(): w5500ll_read(spidev",
+ ", addr=", (base16_u16_, addr),
+ ", block=", (ctl_block, block),
+ ", iov",
+ ", iovcnt=", iovcnt,
+ ")");
#endif
uint8_t header[] = {
diff --git a/libhw_generic/include/libhw/generic/net.h b/libhw_generic/include/libhw/generic/net.h
index 1052392..573a01f 100644
--- a/libhw_generic/include/libhw/generic/net.h
+++ b/libhw_generic/include/libhw/generic/net.h
@@ -12,6 +12,7 @@
#include <stdint.h> /* for uint{n}_t} */
#include <sys/types.h> /* for ssize_t */
+#include <libmisc/fmt.h>
#include <libhw/generic/io.h>
/* Errnos *********************************************************************/
@@ -34,24 +35,13 @@ struct net_ip4_addr {
static const struct net_ip4_addr net_ip4_addr_broadcast = {{255, 255, 255, 255}};
static const struct net_ip4_addr net_ip4_addr_zero = {{0, 0, 0, 0}};
-
-#define PRI_net_ip4_addr "%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8
-#define ARG_net_ip4_addr(addr) (addr).octets[0], \
- (addr).octets[1], \
- (addr).octets[2], \
- (addr).octets[3]
+void fmt_print_net_ip4_addr(lo_interface fmt_dest, struct net_ip4_addr);
struct net_eth_addr {
unsigned char octets[6];
};
-#define PRI_net_eth_addr "%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8
-#define ARG_net_eth_addr(addr) (addr).octets[0], \
- (addr).octets[1], \
- (addr).octets[2], \
- (addr).octets[3], \
- (addr).octets[4], \
- (addr).octets[5]
+void fmt_print_net_eth_addr(lo_interface fmt_dest, struct net_eth_addr);
/* Streams (e.g. TCP) *********************************************************/
diff --git a/libhw_generic/net.c b/libhw_generic/net.c
index e2785ae..d21626e 100644
--- a/libhw_generic/net.c
+++ b/libhw_generic/net.c
@@ -1,6 +1,6 @@
/* libhw_generic/net.c - Device-independent <libhw/generic/net.h> utilities
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -29,3 +29,21 @@ const char *net_strerror(int net_errno) {
assert_notreached("invalid net_errno");
}
}
+
+void fmt_print_net_ip4_addr(lo_interface fmt_dest w, struct net_ip4_addr addr) {
+ fmt_print(w,
+ addr.octets[0], ".",
+ addr.octets[1], ".",
+ addr.octets[2], ".",
+ addr.octets[3]);
+}
+
+void fmt_print_net_eth_addr(lo_interface fmt_dest w, struct net_eth_addr addr) {
+ fmt_print(w,
+ (base16_u8_, addr.octets[0]), ":",
+ (base16_u8_, addr.octets[1]), ":",
+ (base16_u8_, addr.octets[2]), ":",
+ (base16_u8_, addr.octets[3]), ":",
+ (base16_u8_, addr.octets[4]), ":",
+ (base16_u8_, addr.octets[5]));
+}
diff --git a/libmisc/CMakeLists.txt b/libmisc/CMakeLists.txt
index 8c9fa57..48407bd 100644
--- a/libmisc/CMakeLists.txt
+++ b/libmisc/CMakeLists.txt
@@ -7,6 +7,7 @@ add_library(libmisc INTERFACE)
target_include_directories(libmisc PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(libmisc INTERFACE
assert.c
+ fmt.c
intercept.c
linkedlist.c
log.c
@@ -16,6 +17,7 @@ target_sources(libmisc INTERFACE
add_lib_test(libmisc test_assert)
add_lib_test(libmisc test_assert_min)
add_lib_test(libmisc test_endian)
+add_lib_test(libmisc test_fmt)
add_lib_test(libmisc test_hash)
add_lib_test(libmisc test_log)
add_lib_test(libmisc test_macro)
diff --git a/libmisc/assert.c b/libmisc/assert.c
index 540d2fd..cb3a270 100644
--- a/libmisc/assert.c
+++ b/libmisc/assert.c
@@ -5,22 +5,20 @@
*/
#define LOG_NAME ASSERT
-#include <libmisc/log.h> /* for log_errorf() */
+#include <libmisc/log.h> /* for log_errorln() */
#include <libmisc/assert.h>
#ifndef NDEBUG
-#define __lm_printf __lm_light_printf
void __assert_msg_fail(const char *expr,
const char *file, unsigned int line, const char *func,
const char *msg) {
static bool in_fail = false;
if (!in_fail) {
in_fail = true;
- log_errorf("%s:%u:%s(): assertion \"%s\" failed%s%s",
- file, line, func,
- expr,
- msg ? ": " : "", msg ?: "");
+ log_errorln(file, ":", line, ":", func, "(): ",
+ "assertion ", (qstr, expr), " failed",
+ msg ? ": " : "", msg ?: "");
in_fail = false;
}
__lm_abort();
diff --git a/libmisc/fmt.c b/libmisc/fmt.c
new file mode 100644
index 0000000..33788b6
--- /dev/null
+++ b/libmisc/fmt.c
@@ -0,0 +1,225 @@
+/* libmisc/fmt.c - Write formatted text
+ *
+ * Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#include <string.h> /* for strnlen() */
+
+#include <libmisc/fmt.h>
+
+static const char *const hexdig = "0123456789ABCDEF";
+
+/* small/trivial formatters ***************************************************/
+
+void fmt_print_byte(lo_interface fmt_dest w, uint8_t b) {
+ LO_CALL(w, putb, b);
+}
+
+void fmt_print_bool(lo_interface fmt_dest w, bool b) {
+ fmt_print_str(w, b ? "true" : "false");
+}
+
+void fmt_print_base16_u8_(lo_interface fmt_dest w, uint8_t x) {
+ fmt_print(w, "0x", (rjust, 2, '0', (base16, x)));
+}
+void fmt_print_base16_u16_(lo_interface fmt_dest w, uint16_t x) {
+ fmt_print(w, "0x", (rjust, 4, '0', (base16, x)));
+}
+void fmt_print_base16_u32_(lo_interface fmt_dest w, uint32_t x) {
+ fmt_print(w, "0x", (rjust, 8, '0', (base16, x)));
+}
+void fmt_print_base16_u64_(lo_interface fmt_dest w, uint64_t x) {
+ fmt_print(w, "0x", (rjust, 16, '0', (base16, x)));
+}
+
+void fmt_print_ptr(lo_interface fmt_dest w, void *ptr) {
+ LM_CAT3_(fmt_print_base16_u, __INTPTR_WIDTH__, _)(w, (uintptr_t)ptr);
+}
+
+/* quote **********************************************************************/
+
+/**
+ * Quote a byte to ASCII-only C syntax.
+ */
+void fmt_print_qbyte(lo_interface fmt_dest w, uint8_t b) {
+ fmt_print_byte(w, '\'');
+ if (' ' <= b && b <= '~') {
+ if (b == '\'' || b == '\\')
+ fmt_print_byte(w, '\\');
+ fmt_print_byte(w, b);
+ } else {
+ fmt_print_byte(w, '\\');
+ fmt_print_byte(w, 'x');
+ fmt_print_byte(w, hexdig[(b >> 4) & 0xF]);
+ fmt_print_byte(w, hexdig[(b >> 0) & 0xF]);
+ }
+ fmt_print_byte(w, '\'');
+}
+
+/**
+ * Quote a region of memory to ASCII-only C string syntax. Valid
+ * UTF-8 is quoted as short C-escape characters, \uABCD, or
+ * \UABCDABCD; invalid UTF-8 is quoted as \xAB.
+ */
+void fmt_print_qmem(lo_interface fmt_dest w, const void *_str, size_t size) {
+ const uint8_t *str = _str;
+ fmt_print_byte(w, '"');
+ for (size_t pos = 0; pos < size;) {
+ uint32_t ch;
+ uint8_t chlen;
+ if ((str[pos] & 0b10000000) == 0b00000000) { ch = str[pos] & 0b01111111; chlen = 1; }
+ else if ((str[pos] & 0b11100000) == 0b11000000) { ch = str[pos] & 0b00011111; chlen = 2; }
+ else if ((str[pos] & 0b11110000) == 0b11100000) { ch = str[pos] & 0b00001111; chlen = 3; }
+ else if ((str[pos] & 0b11111000) == 0b11110000) { ch = str[pos] & 0b00000111; chlen = 4; }
+ else goto invalid_utf8;
+ if ((ch == 0 && chlen != 1) || pos + chlen > size) goto invalid_utf8;
+ for (uint8_t i = 1; i < chlen; i++) {
+ if ((str[pos+i] & 0b11000000) != 0b10000000) goto invalid_utf8;
+ ch = (ch << 6) | (str[pos+i] & 0b00111111);
+ }
+ if (ch > 0x10FFFF) goto invalid_utf8;
+
+ if (ch == '\0' ||
+ ch == '\b' ||
+ ch == '\f' ||
+ ch == '\n' ||
+ ch == '\r' ||
+ ch == '\t' ||
+ ch == '\v' ||
+ ch == '\\' ||
+ ch == '\'' ||
+ ch == '"' ||
+ ch == '?') {
+ /* short C-escape */
+ fmt_print_byte(w, '\\');
+ switch (ch) {
+ case '\0': fmt_print_byte(w, '0'); break;
+ case '\a': fmt_print_byte(w, 'a'); break;
+ case '\b': fmt_print_byte(w, 'b'); break;
+ case '\f': fmt_print_byte(w, 'f'); break;
+ case '\n': fmt_print_byte(w, 'n'); break;
+ case '\r': fmt_print_byte(w, 'r'); break;
+ case '\t': fmt_print_byte(w, 't'); break;
+ case '\v': fmt_print_byte(w, 'v'); break;
+ case '\\': fmt_print_byte(w, '\\'); break;
+ case '\'': fmt_print_byte(w, '\''); break;
+ case '"': fmt_print_byte(w, '"'); break;
+ case '?': fmt_print_byte(w, '?'); break;
+ }
+ } else if (' ' <= ch && ch <= '~') {
+ /* no escaping */
+ fmt_print_byte(w, ch);
+ } else if (ch < 0x10000) {
+ /* \uABCD */
+ fmt_print_byte(w, '\\');
+ fmt_print_byte(w, 'u');
+ fmt_print_byte(w, hexdig[(ch >> 12) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 8) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 4) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 0) & 0xF]);
+ } else {
+ /* \UABCDABCD */
+ fmt_print_byte(w, '\\');
+ fmt_print_byte(w, 'U');
+ fmt_print_byte(w, hexdig[(ch >> 28) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 24) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 20) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 16) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 12) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 8) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 4) & 0xF]);
+ fmt_print_byte(w, hexdig[(ch >> 0) & 0xF]);
+ }
+ pos += chlen;
+ continue;
+
+ invalid_utf8:
+ /* \xAB */
+ fmt_print_byte(w, '\\');
+ fmt_print_byte(w, 'x');
+ fmt_print_byte(w, hexdig[(str[pos] >> 4) & 0xF]);
+ fmt_print_byte(w, hexdig[(str[pos] >> 0) & 0xF]);
+ pos++;
+ }
+ fmt_print_byte(w, '"');
+}
+
+void fmt_print_qstr(lo_interface fmt_dest w, const char *str) {
+ fmt_print_qmem(w, str, strlen(str));
+}
+
+void fmt_print_qstrn(lo_interface fmt_dest w, const char *str, size_t n) {
+ fmt_print_qmem(w, str, strnlen(str, n));
+}
+
+/* int ************************************************************************/
+
+#define declare(BASE, BITS) \
+ void _fmt_print_base##BASE##_s##BITS(lo_interface fmt_dest w, \
+ int##BITS##_t val) { \
+ if (val < 0) { \
+ fmt_print_byte(w, '-'); \
+ val = -val; \
+ } \
+ _fmt_print_base##BASE##_u##BITS(w, (uint##BITS##_t)val); \
+ } \
+ \
+ void _fmt_print_base##BASE##_u##BITS(lo_interface fmt_dest w, \
+ uint##BITS##_t absval) { \
+ /* This digit-counting is O(log(absval)); there are \
+ * `__builtin_clz`-based O(1) ways to do this, but when I \
+ * tried them they bloated the code-size too much. And this \
+ * function as a whole is already O(log(absval)) anyway \
+ * because of actually printing the digits. */ \
+ unsigned ndigits = 1; \
+ uint##BITS##_t div = 1; \
+ while (absval / div >= BASE) { \
+ div *= BASE; \
+ ndigits++; \
+ } \
+ \
+ for (unsigned i = 0; i < ndigits; i++) { \
+ unsigned digit = (unsigned) (absval / div); \
+ absval %= div; \
+ div /= BASE; \
+ fmt_print_byte(w, hexdig[digit]); \
+ } \
+ } \
+ LM_FORCE_SEMICOLON
+
+declare(2, 8);
+declare(2, 16);
+declare(2, 32);
+declare(2, 64);
+
+declare(8, 8);
+declare(8, 16);
+declare(8, 32);
+declare(8, 64);
+
+declare(10, 8);
+declare(10, 16);
+declare(10, 32);
+declare(10, 64);
+
+declare(16, 8);
+declare(16, 16);
+declare(16, 32);
+declare(16, 64);
+
+#undef declare
+
+/* fmt_buf ********************************************************************/
+
+LO_IMPLEMENTATION_C(fmt_dest, struct fmt_buf, fmt_buf, static);
+
+static void fmt_buf_putb(struct fmt_buf *buf, uint8_t b) {
+ if (buf->len < buf->cap)
+ ((uint8_t *)(buf->dat))[buf->len] = b;
+ buf->len++;
+}
+
+static size_t fmt_buf_tell(struct fmt_buf *buf) {
+ return buf->len;
+}
diff --git a/libmisc/include/libmisc/_intercept.h b/libmisc/include/libmisc/_intercept.h
index a264144..fa327d6 100644
--- a/libmisc/include/libmisc/_intercept.h
+++ b/libmisc/include/libmisc/_intercept.h
@@ -7,21 +7,18 @@
#ifndef _LIBMISC__INTERCEPT_H_
#define _LIBMISC__INTERCEPT_H_
-/* pico-sdk/newlib define these to be [[gnu:weak]] already, but
+/* pico-sdk/newlib defines abort() to be [[gnu::weak]] already, but
* depending on optimization options glibc might not, and GCC might
- * assume it knows what they do and optimize them out. So define our
- * own `__lm_` wrappers that GCC/glibc won't interfere with.
+ * assume it knows what it does and optimize it out. So define our
+ * own `__lm_` wrapper that GCC/glibc won't interfere with.
*/
-[[gnu::format(printf, 1, 2)]]
-int __lm_printf(const char *format, ...);
-
[[noreturn]] void __lm_abort(void);
-/* __lm_light_printf is expected to have less stack use than regular
- * __lm_printf, if possible. */
+/* While newlib defines putchar() to be [[gnu::weak]], pico_stdio does
+ * not. Plus the above about optimizations.
+ */
-[[gnu::format(printf, 1, 2)]]
-int __lm_light_printf(const char *format, ...);
+void __lm_putchar(unsigned char c);
#endif /* _LIBMISC__INTERCEPT_H_ */
diff --git a/libmisc/include/libmisc/fmt.h b/libmisc/include/libmisc/fmt.h
new file mode 100644
index 0000000..c29c085
--- /dev/null
+++ b/libmisc/include/libmisc/fmt.h
@@ -0,0 +1,156 @@
+/* libmisc/fmt.h - Write formatted text
+ *
+ * Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#ifndef _LIBMISC_FMT_H_
+#define _LIBMISC_FMT_H_
+
+#include <stddef.h> /* for size_t */
+#include <stdint.h> /* for (u)int{n}_t */
+
+#include <libmisc/macro.h>
+#include <libmisc/obj.h>
+
+/* destination interface ******************************************************/
+
+#define fmt_dest_LO_IFACE \
+ LO_FUNC(void , putb, uint8_t b) \
+ LO_FUNC(size_t, tell)
+LO_INTERFACE(fmt_dest);
+
+/* type-specific fmt_print_() functions ***************************************/
+
+/* Simple bytes. */
+void fmt_print_byte(lo_interface fmt_dest w, uint8_t b);
+
+/* These are `static inline` so that the compiler can unroll the loops. */
+static inline void fmt_print_mem(lo_interface fmt_dest w, const void *_str, size_t size) {
+ const uint8_t *str = _str;
+ while (size--)
+ fmt_print_byte(w, *(str++));
+}
+static inline void fmt_print_str(lo_interface fmt_dest w, const char *str) {
+ while (*str)
+ fmt_print_byte(w, *(str++));
+}
+static inline void fmt_print_strn(lo_interface fmt_dest w, const char *str, size_t size) {
+ while (size-- && *str)
+ fmt_print_byte(w, *(str++));
+}
+
+/* Quoted bytes. */
+void fmt_print_qbyte(lo_interface fmt_dest w, uint8_t b);
+void fmt_print_qmem(lo_interface fmt_dest w, const void *str, size_t size);
+void fmt_print_qstr(lo_interface fmt_dest w, const char *str);
+void fmt_print_qstrn(lo_interface fmt_dest w, const char *str, size_t size);
+
+/* Integers. */
+#define _fmt_declare_base(base) \
+ void _fmt_print_base##base##_u8(lo_interface fmt_dest w, uint8_t val); \
+ void _fmt_print_base##base##_u16(lo_interface fmt_dest w, uint16_t val); \
+ void _fmt_print_base##base##_u32(lo_interface fmt_dest w, uint32_t val); \
+ void _fmt_print_base##base##_u64(lo_interface fmt_dest w, uint64_t val); \
+ void _fmt_print_base##base##_s8(lo_interface fmt_dest w, int8_t val); \
+ void _fmt_print_base##base##_s16(lo_interface fmt_dest w, int16_t val); \
+ void _fmt_print_base##base##_s32(lo_interface fmt_dest w, int32_t val); \
+ void _fmt_print_base##base##_s64(lo_interface fmt_dest w, int64_t val); \
+ LM_FORCE_SEMICOLON
+_fmt_declare_base(2);
+_fmt_declare_base(8);
+_fmt_declare_base(10);
+_fmt_declare_base(16);
+#undef _fmt_declare_base
+
+#define _fmt_intswitch(val, prefix) _Generic((val) , \
+ unsigned char : LM_CAT3_(prefix, u, __SCHAR_WIDTH__) , \
+ unsigned short : LM_CAT3_(prefix, u, __SHRT_WIDTH__) , \
+ unsigned int : LM_CAT3_(prefix, u, __INT_WIDTH__) , \
+ unsigned long : LM_CAT3_(prefix, u, __LONG_WIDTH__) , \
+ unsigned long long : LM_CAT3_(prefix, u, __LONG_LONG_WIDTH__) , \
+ signed char : LM_CAT3_(prefix, s, __SCHAR_WIDTH__) , \
+ signed short : LM_CAT3_(prefix, s, __SHRT_WIDTH__) , \
+ signed int : LM_CAT3_(prefix, s, __INT_WIDTH__) , \
+ signed long : LM_CAT3_(prefix, s, __LONG_WIDTH__) , \
+ signed long long : LM_CAT3_(prefix, s, __LONG_LONG_WIDTH__) )
+#define fmt_print_base2(w, val) (_fmt_intswitch((val), _fmt_print_base2_)((w), (val)))
+#define fmt_print_base8(w, val) (_fmt_intswitch((val), _fmt_print_base8_)((w), (val)))
+#define fmt_print_base10(w, val) (_fmt_intswitch((val), _fmt_print_base10_)((w), (val)))
+#define fmt_print_base16(w, val) (_fmt_intswitch((val), _fmt_print_base16_)((w), (val)))
+
+/* Booleans. */
+void fmt_print_bool(lo_interface fmt_dest w, bool b);
+
+/* The high-level fmt_print() interface ***************************************/
+
+#define fmt_print(w, ...) do { LM_FOREACH_PARAM_(_fmt_param, (w), __VA_ARGS__) } while (0)
+#define _fmt_param(w, arg) \
+ LM_IF(LM_IS_TUPLE(arg))( \
+ _fmt_param_tuple LM_EAT() (w, LM_EXPAND arg) \
+ )( \
+ _fmt_param_nontuple(w, arg) \
+ );
+#define _fmt_param_tuple(w, fn, ...) fmt_print_##fn(w __VA_OPT__(,) __VA_ARGS__)
+#define _fmt_param_nontuple(w, val) _Generic((val), \
+ unsigned char : LM_CAT2_(_fmt_print_base10_u, __SCHAR_WIDTH__) , \
+ unsigned short : LM_CAT2_(_fmt_print_base10_u, __SHRT_WIDTH__) , \
+ unsigned int : LM_CAT2_(_fmt_print_base10_u, __INT_WIDTH__) , \
+ unsigned long : LM_CAT2_(_fmt_print_base10_u, __LONG_WIDTH__) , \
+ unsigned long long : LM_CAT2_(_fmt_print_base10_u, __LONG_LONG_WIDTH__) , \
+ signed char : LM_CAT2_(_fmt_print_base10_s, __SCHAR_WIDTH__) , \
+ signed short : LM_CAT2_(_fmt_print_base10_s, __SHRT_WIDTH__) , \
+ signed int : LM_CAT2_(_fmt_print_base10_s, __INT_WIDTH__) , \
+ signed long : LM_CAT2_(_fmt_print_base10_s, __LONG_WIDTH__) , \
+ signed long long : LM_CAT2_(_fmt_print_base10_s, __LONG_LONG_WIDTH__) , \
+ char * : fmt_print_str , \
+ const char * : fmt_print_str , \
+ bool : fmt_print_bool )(w, val)
+
+/* print-to-memory ************************************************************/
+
+struct fmt_buf {
+ void *dat;
+ size_t len, cap;
+};
+LO_IMPLEMENTATION_H(fmt_dest, struct fmt_buf, fmt_buf);
+
+#define fmt_snprint(buf, n, ...) ({ \
+ struct fmt_buf _w = { .dat = buf, .cap = n }; \
+ lo_interface fmt_dest w = lo_box_fmt_buf_as_fmt_dest(&_w); \
+ fmt_print(w, __VA_ARGS__); \
+ if (_w.len < _w.cap) \
+ ((char *)_w.dat)[_w.len] = '\0'; \
+ _w.len; \
+})
+
+/* justify ********************************************************************/
+
+/* *grubles about not being allowed to nest things* */
+#define _fmt_param_indirect() _fmt_param
+#define _fmt_print2(w, ...) do { LM_FOREACH_PARAM2_(_fmt_param2, (w), __VA_ARGS__) } while (0)
+#define _fmt_param2(...) _LM_DEFER2(_fmt_param_indirect)()(__VA_ARGS__)
+
+#define fmt_print_ljust(w, width, fillchar, ...) do { \
+ size_t beg = LO_CALL(w, tell); \
+ _fmt_print2(w, __VA_ARGS__); \
+ while ((LO_CALL(w, tell) - beg) < width) \
+ fmt_print_byte(w, fillchar); \
+} while (0)
+
+#define fmt_print_rjust(w, width, fillchar, ...) do { \
+ struct fmt_buf _discard = {}; \
+ lo_interface fmt_dest discard = lo_box_fmt_buf_as_fmt_dest(&_discard); \
+ _fmt_print2(discard, __VA_ARGS__); \
+ while (_discard.len++ < width) \
+ fmt_print_byte(w, fillchar); \
+ _fmt_print2(w, __VA_ARGS__); \
+} while (0)
+
+void fmt_print_base16_u8_(lo_interface fmt_dest w, uint8_t x);
+void fmt_print_base16_u16_(lo_interface fmt_dest w, uint16_t x);
+void fmt_print_base16_u32_(lo_interface fmt_dest w, uint32_t x);
+void fmt_print_base16_u64_(lo_interface fmt_dest w, uint64_t x);
+void fmt_print_ptr(lo_interface fmt_dest w, void *ptr);
+
+#endif /* _LIBMISC_FMT_H_ */
diff --git a/libmisc/include/libmisc/log.h b/libmisc/include/libmisc/log.h
index 4529946..e6dfb52 100644
--- a/libmisc/include/libmisc/log.h
+++ b/libmisc/include/libmisc/log.h
@@ -10,6 +10,7 @@
#include <stdint.h> /* for uint8_t */
#include <libmisc/macro.h>
+#include <libmisc/fmt.h>
#include <libmisc/_intercept.h>
#ifdef NDEBUG
@@ -20,15 +21,17 @@
const char *const_byte_str(uint8_t b);
-#define log_n_errorf(nam, fmt, ...) do { __lm_printf("error: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
-#define log_n_infof(nam, fmt, ...) do { __lm_printf("info : " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
-#define log_n_debugf(nam, fmt, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \
- __lm_printf("debug: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
+extern lo_interface fmt_dest _log_dest;
+
+#define log_n_errorln(nam, ...) fmt_print(_log_dest, "error: " LM_STR_(nam) ": ", __VA_ARGS__, "\n")
+#define log_n_infoln(nam, ...) fmt_print(_log_dest, "info : " LM_STR_(nam) ": ", __VA_ARGS__, "\n")
+#define log_n_debugln(nam, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \
+ fmt_print(_log_dest, "debug: " LM_STR_(nam) ": ", __VA_ARGS__, "\n"); } while (0)
#endif /* _LIBMISC_LOG_H_ */
-#if defined(LOG_NAME) && !defined(log_errorf)
-#define log_errorf(fmt, ...) log_n_errorf(LOG_NAME, fmt, __VA_ARGS__)
-#define log_infof(fmt, ...) log_n_infof(LOG_NAME, fmt, __VA_ARGS__)
-#define log_debugf(fmt, ...) log_n_debugf(LOG_NAME, fmt, __VA_ARGS__)
+#if defined(LOG_NAME) && !defined(log_errorln)
+#define log_errorln(...) log_n_errorln(LOG_NAME, __VA_ARGS__)
+#define log_infoln(...) log_n_infoln(LOG_NAME, __VA_ARGS__)
+#define log_debugln(...) log_n_debugln(LOG_NAME, __VA_ARGS__)
#endif
diff --git a/libmisc/include/libmisc/macro.h b/libmisc/include/libmisc/macro.h
index 9ac29b9..a2d4264 100644
--- a/libmisc/include/libmisc/macro.h
+++ b/libmisc/include/libmisc/macro.h
@@ -63,6 +63,10 @@
#define LM_FIRST(a, ...) a
#define LM_SECOND(a, b, ...) b
+
+#define LM_FIRST_(...) LM_FIRST(__VA_ARGS__)
+#define LM_SECOND_(...) LM_SECOND(__VA_ARGS__)
+
#define LM_EAT(...)
#define LM_EXPAND(...) __VA_ARGS__
@@ -80,57 +84,88 @@
/* tuples */
-#define LM_IS_TUPLE(x) LM_IS_SENTINEL(_LM_IS_TUPLE x)
-#define _LM_IS_TUPLE(...) LM_SENTINEL()
+#define LM_IS_TUPLE(x) LM_IS_SENTINEL(_LM_IS_TUPLE x)
+#define _LM_IS_TUPLE(...) LM_SENTINEL()
+/* For LM_IS_EMPTY_TUPLE:
+ *
+ * Given
+ *
+ * #define HELPER(...) B, __VA_OPT__(C,) D
+ *
+ * then evaluating the sequence of tokens `HELPER x , A` will give us a
+ * new sequence of tokens according to the following table:
+ *
+ * not a tuple : HELPER x , A
+ * tuple, nonempty: B , C , D , A
+ * tuple, empty : B , D , A
+ *
+ * Looking at this table, it is clear that we must look at the 2nd
+ * resulting comma-separated-value (argument), and set A=false,
+ * C=false, D=true (and B doesn't matter).
+ */
+#define LM_IS_EMPTY_TUPLE(x) LM_SECOND_(_LM_IS_EMPTY_TUPLE x, LM_F)
+#define _LM_IS_EMPTY_TUPLE(...) bogus, __VA_OPT__(LM_F,) LM_T
/* `tuples` is a sequence of `(tuple1)(tuple2)(tuple3)` */
-#define _LM_TUPLES_COMMA(tuple...) (tuple),
-#define LM_TUPLES_NONEMPTY(tuples) LM_IS_TUPLE(_LM_TUPLES_COMMA tuples)
+#define _LM_TUPLES_COMMA(...) (__VA_ARGS__),
+#define LM_TUPLES_IS_NONEMPTY(tuples) LM_IS_TUPLE(_LM_TUPLES_COMMA tuples)
#define LM_TUPLES_HEAD(tuples) LM_EXPAND(LM_FIRST LM_EAT() (_LM_TUPLES_COMMA tuples))
#define LM_TUPLES_TAIL(tuples) LM_EAT tuples
/* iteration */
-/* BUG: LM_FOREACH_TUPLE maxes out at 1024 tuples. */
-#define LM_FOREACH_TUPLE(tuples, func, ...) \
- _LM_EVAL(_LM_FOREACH_TUPLE(tuples, func, __VA_ARGS__))
-#define _LM_FOREACH_TUPLE(tuples, func, ...) \
- LM_IF(LM_TUPLES_NONEMPTY(tuples))( \
- _LM_DEFER2(func)(__VA_ARGS__ __VA_OPT__(,) LM_EXPAND LM_TUPLES_HEAD(tuples)) \
- _LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(LM_TUPLES_TAIL(tuples), func, __VA_ARGS__) \
- )()
-#define _LM_FOREACH_TUPLE_indirect() _LM_FOREACH_TUPLE
-
-#define _LM_DEFER2(macro) macro LM_EAT LM_EAT()()
-
-#define _LM_EVAL(...) _LM_EVAL__1024(__VA_ARGS__) /* 1024 iterations aught to be enough for anybody */
-#define _LM_EVAL__1024(...) _LM_EVAL__512(_LM_EVAL__512(__VA_ARGS__))
-#define _LM_EVAL__512(...) _LM_EVAL__256(_LM_EVAL__256(__VA_ARGS__))
-#define _LM_EVAL__256(...) _LM_EVAL__128(_LM_EVAL__128(__VA_ARGS__))
-#define _LM_EVAL__128(...) _LM_EVAL__64(_LM_EVAL__64(__VA_ARGS__))
-#define _LM_EVAL__64(...) _LM_EVAL__32(_LM_EVAL__32(__VA_ARGS__))
-#define _LM_EVAL__32(...) _LM_EVAL__16(_LM_EVAL__16(__VA_ARGS__))
+/* The desire to support a high number of iterations is in competition
+ * with the desire for short compile times. 16 is the lowest
+ * power-of-2 for which the current code compiles. */
+#define _LM_EVAL _LM_EVAL__16
#define _LM_EVAL__16(...) _LM_EVAL__8(_LM_EVAL__8(__VA_ARGS__))
#define _LM_EVAL__8(...) _LM_EVAL__4(_LM_EVAL__4(__VA_ARGS__))
#define _LM_EVAL__4(...) _LM_EVAL__2(_LM_EVAL__2(__VA_ARGS__))
#define _LM_EVAL__2(...) _LM_EVAL__1(_LM_EVAL__1(__VA_ARGS__))
#define _LM_EVAL__1(...) __VA_ARGS__
-/** The same as LM_FOREACH_TUPLE(), but callable from inside of LM_FOREACH_TUPLE(). */
-#define LM_FOREACH_TUPLE2(tuples, func, ...) \
- LM_IF(LM_TUPLES_NONEMPTY(tuples))( \
- _LM_DEFER2(func)(__VA_ARGS__ __VA_OPT__(,) LM_EXPAND LM_TUPLES_HEAD(tuples)) \
- _LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(LM_TUPLES_TAIL(tuples), func, __VA_ARGS__) \
- )()
-#define LM_FOREACH_TUPLE3(tuples, func, ...) \
- LM_IF(LM_TUPLES_NONEMPTY(tuples))( \
- _LM_DEFER2(func)(__VA_ARGS__ __VA_OPT__(,) LM_EXPAND LM_TUPLES_HEAD(tuples)) \
- _LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(LM_TUPLES_TAIL(tuples), func, __VA_ARGS__) \
- )()
-#define LM_FOREACH_TUPLE4(tuples, func, ...) \
- LM_IF(LM_TUPLES_NONEMPTY(tuples))( \
+#define _LM_DEFER2(macro) macro LM_EAT LM_EAT()()
+
+/**
+ * LM_FOREACH_PARAM(func, (fixedparams), params...) calls
+ * func(fixedparams..., param) for each param.
+ *
+ * BUG: LM_FOREACH_PARAM is limited to (16*2)-1=31 params.
+ */
+#define LM_FOREACH_PARAM(func, fixedparams, ...) _LM_EVAL(_LM_FOREACH_PARAM(func, fixedparams, __VA_ARGS__))
+#define _LM_FOREACH_PARAM(func, fixedparams, ...) _LM_FOREACH_PARAM_ITEM(func, fixedparams, __VA_ARGS__, ())
+#define _LM_FOREACH_PARAM_FIXEDPARAMS(fixedparams) _LM_FOREACH_PARAM_FIXEDPARAMS_inner fixedparams
+#define _LM_FOREACH_PARAM_FIXEDPARAMS_inner(...) __VA_ARGS__ __VA_OPT__(,)
+#define _LM_FOREACH_PARAM_ITEM(func, fixedparams, param, ...) \
+ LM_IF(LM_IS_EMPTY_TUPLE(param))()( \
+ _LM_DEFER2(func)(_LM_FOREACH_PARAM_FIXEDPARAMS(fixedparams) param) \
+ _LM_DEFER2(_LM_FOREACH_PARAM_ITEM_indirect)()(func, fixedparams, __VA_ARGS__) \
+ )
+#define _LM_FOREACH_PARAM_ITEM_indirect() _LM_FOREACH_PARAM_ITEM
+
+/** The same as LM_FOREACH_PARAM(), but callable from inside of LM_FOREACH_PARAM(). */
+#define LM_FOREACH_PARAM2(...) _LM_DEFER2(_LM_FOREACH_PARAM_ITEM_indirect)()(__VA_ARGS__, ())
+
+/** The same as above, but evaluates the arguments first. */
+#define LM_FOREACH_PARAM_(...) LM_FOREACH_PARAM(__VA_ARGS__)
+#define LM_FOREACH_PARAM2_(...) LM_FOREACH_PARAM2(__VA_ARGS__)
+
+/**
+ * LM_FOREACH_TUPLE( (tup1) (tup2) (tup3), func, args...) calls
+ * func(args..., tup...) for each tuple.
+ *
+ * BUG: LM_FOREACH_TUPLE is limited to (16*2)-1=31 tuples.
+ */
+#define LM_FOREACH_TUPLE(tuples, func, ...) \
+ _LM_EVAL(_LM_FOREACH_TUPLE(tuples, func, __VA_ARGS__))
+#define _LM_FOREACH_TUPLE(tuples, func, ...) \
+ LM_IF(LM_TUPLES_IS_NONEMPTY(tuples))( \
_LM_DEFER2(func)(__VA_ARGS__ __VA_OPT__(,) LM_EXPAND LM_TUPLES_HEAD(tuples)) \
_LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(LM_TUPLES_TAIL(tuples), func, __VA_ARGS__) \
)()
+#define _LM_FOREACH_TUPLE_indirect() _LM_FOREACH_TUPLE
+
+/** The same as LM_FOREACH_TUPLE(), but callable from inside of LM_FOREACH_TUPLE(). */
+#define LM_FOREACH_TUPLE2(...) _LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(__VA_ARGS__)
#endif /* _LIBMISC_MACRO_H_ */
diff --git a/libmisc/include/libmisc/obj.h b/libmisc/include/libmisc/obj.h
index d30a6f2..6645db7 100644
--- a/libmisc/include/libmisc/obj.h
+++ b/libmisc/include/libmisc/obj.h
@@ -56,17 +56,8 @@
#define _LO_IFACE_VTABLE_lo_nest(_ARG_child_iface_name) const struct _lo_##_ARG_child_iface_name##_vtable *_lo_##_ARG_child_iface_name##_vtable; LM_FOREACH_TUPLE2(_ARG_child_iface_name##_LO_IFACE, _LO_IFACE_VTABLE2)
#define _LO_IFACE_VTABLE_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__);
-#define _LO_IFACE_VTABLE2(_tuple_typ, ...) _LO_IFACE_VTABLE2_##_tuple_typ(__VA_ARGS__)
-#define _LO_IFACE_VTABLE2_lo_nest(_ARG_child_iface_name) const struct _lo_##_ARG_child_iface_name##_vtable *_lo_##_ARG_child_iface_name##_vtable; LM_FOREACH_TUPLE3(_ARG_child_iface_name##_LO_IFACE, _LO_IFACE_VTABLE3)
-#define _LO_IFACE_VTABLE2_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__);
-
-#define _LO_IFACE_VTABLE3(_tuple_typ, ...) _LO_IFACE_VTABLE3_##_tuple_typ(__VA_ARGS__)
-#define _LO_IFACE_VTABLE3_lo_nest(_ARG_child_iface_name) const struct _lo_##_ARG_child_iface_name##_vtable *_lo_##_ARG_child_iface_name##_vtable; LM_FOREACH_TUPLE4(_ARG_child_iface_name##_LO_IFACE, _LO_IFACE_VTABLE4)
-#define _LO_IFACE_VTABLE3_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__);
-
-#define _LO_IFACE_VTABLE4(_tuple_typ, ...) _LO_IFACE_VTABLE4_##_tuple_typ(__VA_ARGS__)
-#define _LO_IFACE_VTABLE4_lo_nest(_ARG_child_iface_name) static_assert(0, "BUG: libmisc/obj.h cannot nest interfaces more than 4 deep");
-#define _LO_IFACE_VTABLE4_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__);
+#define _LO_IFACE_VTABLE_indirect() _LO_IFACE_VTABLE
+#define _LO_IFACE_VTABLE2(...) _LM_DEFER2(_LO_IFACE_VTABLE_indirect)()(__VA_ARGS__)
#define _LO_IFACE_PROTO(_ARG_iface_name, _tuple_typ, ...) _LO_IFACE_PROTO_##_tuple_typ(_ARG_iface_name, __VA_ARGS__)
#define _LO_IFACE_PROTO_lo_nest(_ARG_iface_name, _ARG_child_iface_name) \
@@ -157,17 +148,7 @@
#define _LO_IMPL_VTABLE_lo_nest(_ARG_impl_name, _ARG_child_iface_name) ._lo_##_ARG_child_iface_name##_vtable = &_lo_##_ARG_impl_name##_##_ARG_child_iface_name##_vtable, LM_FOREACH_TUPLE2(_ARG_child_iface_name##_LO_IFACE, _LO_IMPL_VTABLE2, _ARG_impl_name)
#define _LO_IMPL_VTABLE_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name,
-#define _LO_IMPL_VTABLE2(_ARG_impl_name, _tuple_typ, ...) _LO_IMPL_VTABLE2_##_tuple_typ(_ARG_impl_name, __VA_ARGS__)
-#define _LO_IMPL_VTABLE2_lo_nest(_ARG_impl_name, _ARG_child_iface_name) ._lo_##_ARG_child_iface_name##_vtable = &_lo_##_ARG_impl_name##_##_ARG_child_iface_name##_vtable, LM_FOREACH_TUPLE3(_ARG_child_iface_name##_LO_IFACE, _LO_IMPL_VTABLE3, _ARG_impl_name)
-#define _LO_IMPL_VTABLE2_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name,
-
-#define _LO_IMPL_VTABLE3(_ARG_impl_name, _tuple_typ, ...) _LO_IMPL_VTABLE3_##_tuple_typ(_ARG_impl_name, __VA_ARGS__)
-#define _LO_IMPL_VTABLE3_lo_nest(_ARG_impl_name, _ARG_child_iface_name) ._lo_##_ARG_child_iface_name##_vtable = &_lo_##_ARG_impl_name##_##_ARG_child_iface_name##_vtable, LM_FOREACH_TUPLE4(_ARG_child_iface_name##_LO_IFACE, _LO_IMPL_VTABLE4, _ARG_impl_name)
-#define _LO_IMPL_VTABLE3_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name,
-
-#define _LO_IMPL_VTABLE4(_ARG_impl_name, _tuple_typ, ...) _LO_IMPL_VTABLE4_##_tuple_typ(_ARG_impl_name, __VA_ARGS__)
-#define _LO_IMPL_VTABLE4_lo_nest(_ARG_impl_name, _ARG_child_iface_name) static_assert(0, "BUG: libmisc/obj.h cannot nest interfaces more than 4 deep");
-#define _LO_IMPL_VTABLE4_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name,
-
+#define _LO_IMPL_VTABLE_indirect() _LO_IMPL_VTABLE
+#define _LO_IMPL_VTABLE2(...) _LM_DEFER2(_LO_IMPL_VTABLE_indirect)()(__VA_ARGS__)
#endif /* _LIBMISC_OBJ_H_ */
diff --git a/libmisc/intercept.c b/libmisc/intercept.c
index 85a3801..30870bf 100644
--- a/libmisc/intercept.c
+++ b/libmisc/intercept.c
@@ -4,28 +4,14 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-#include <stdarg.h> /* for va_list, va_start(), va_end() */
-#include <stdio.h> /* for vprintf() */
+#include <stdio.h> /* for putchar() */
#include <stdlib.h> /* for abort() */
#include <libmisc/_intercept.h>
[[gnu::weak]]
-int __lm_printf(const char *format, ...) {
- va_list va;
- va_start(va, format);
- int ret = vprintf(format, va);
- va_end(va);
- return ret;
-}
-
-[[gnu::weak]]
-int __lm_light_printf(const char *format, ...) {
- va_list va;
- va_start(va, format);
- int ret = vprintf(format, va);
- va_end(va);
- return ret;
+void __lm_putchar(unsigned char c) {
+ (void) putchar(c);
}
[[gnu::weak]]
diff --git a/libmisc/log.c b/libmisc/log.c
index be87de6..da4c92e 100644
--- a/libmisc/log.c
+++ b/libmisc/log.c
@@ -8,6 +8,26 @@
#include <libmisc/assert.h> /* for static_assert() */
+#include <libmisc/log.h>
+#include <libmisc/_intercept.h>
+
+struct log_stdout {};
+LO_IMPLEMENTATION_H(fmt_dest, struct log_stdout, log_stdout);
+LO_IMPLEMENTATION_C(fmt_dest, struct log_stdout, log_stdout, static);
+
+static size_t log_bytes = 0;
+
+static void log_stdout_putb(struct log_stdout *, uint8_t b) {
+ __lm_putchar(b);
+ log_bytes++;
+}
+
+static size_t log_stdout_tell(struct log_stdout *) {
+ return log_bytes;
+}
+
+lo_interface fmt_dest _log_dest = { .vtable = &_lo_log_stdout_fmt_dest_vtable };
+
static const char *byte_strs[] = {
"0x00",
"0x01",
diff --git a/libmisc/tests/test_assert.c b/libmisc/tests/test_assert.c
index c6d2dc1..cdbc567 100644
--- a/libmisc/tests/test_assert.c
+++ b/libmisc/tests/test_assert.c
@@ -9,23 +9,22 @@
#include <stdlib.h>
#include <string.h>
-#include <libmisc/macro.h>
-#include <libmisc/assert.h>
#include <libmisc/_intercept.h>
+#include <libmisc/assert.h>
+#include <libmisc/fmt.h>
+#include <libmisc/macro.h>
#include "test.h"
/* Intercept failures and logging *********************************************/
-bool global_failed;
-char *global_log;
-jmp_buf global_env;
+static bool global_failed;
+static struct fmt_buf global_log;
+static jmp_buf global_env;
#define with_intercept() ({ \
global_failed = false; \
- if (global_log) \
- free(global_log); \
- global_log = NULL; \
+ global_log_clear(); \
setjmp(global_env) == 0; \
})
@@ -34,12 +33,19 @@ void __lm_abort(void) {
longjmp(global_env, 1);
}
-int __lm_light_printf(const char *format, ...) {
- va_list va;
- va_start(va, format);
- int ret = vasprintf(&global_log, format, va);
- va_end(va);
- return ret;
+void __lm_putchar(unsigned char c) {
+ if (global_log.len+1 >= global_log.cap) {
+ global_log.cap += 16;
+ global_log.dat = realloc(global_log.dat, global_log.cap);
+ memset(global_log.dat + global_log.len, 0, global_log.cap - global_log.len);
+ }
+ ((uint8_t *)global_log.dat)[global_log.len++] = (uint8_t)c;
+}
+
+static void global_log_clear(void) {
+ if (global_log.dat)
+ memset(global_log.dat, 0, global_log.cap);
+ global_log.len = 0;
}
#define __builtin_unreachable() test_assert(0)
@@ -51,21 +57,21 @@ int __lm_light_printf(const char *format, ...) {
test; \
} \
test_assert(global_failed == false); \
- test_assert(global_log == NULL); \
+ test_assert(global_log.len == 0); \
} while (0)
-#define test_should_fail(test, exp_log) do { \
- if (with_intercept()) { \
- test; \
- } \
- test_assert(global_failed == true); \
- if (!(global_log != NULL && \
- strcmp(global_log, exp_log) == 0)) { \
- printf("exp = \"%s\"\n" \
- "act = \"%s\"\n", \
- exp_log, global_log); \
- test_assert(0); \
- } \
+#define test_should_fail(test, exp_log) do { \
+ if (with_intercept()) { \
+ test; \
+ } \
+ test_assert(global_failed == true); \
+ if (!(global_log.len != 0 && \
+ strcmp(global_log.dat, exp_log) == 0)) { \
+ printf("exp = \"%s\"\n" \
+ "act = \"%s\"\n", \
+ exp_log, (char *)global_log.dat); \
+ test_assert(0); \
+ } \
} while (0)
/* Actual tests ***************************************************************/
@@ -83,11 +89,13 @@ int main() {
test_should_fail(assert_msg(false, NULL), "error: ASSERT: "__FILE__":"LM_STR_(__LINE__)":main(): assertion \"false\" failed\n");
test_should_fail(assert_notreached("xxx"), "error: ASSERT: "__FILE__":"LM_STR_(__LINE__)":main(): assertion \"notreached\" failed: xxx\n");
+#endif
- if (global_log) {
- free(global_log);
- global_log = NULL;
+ if (global_log.dat) {
+ global_log_clear();
+ free(global_log.dat);
+ global_log.dat = NULL;
+ global_log.cap = 0;
}
-#endif
return 0;
}
diff --git a/libmisc/tests/test_fmt.c b/libmisc/tests/test_fmt.c
new file mode 100644
index 0000000..6a6eb7c
--- /dev/null
+++ b/libmisc/tests/test_fmt.c
@@ -0,0 +1,170 @@
+/* libmisc/tests/test_fmt.c - Tests for <libmisc/fmt.h>
+ *
+ * Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#include <string.h> /* for strcmp(), memcmp(), memset() */
+
+#include <libmisc/fmt.h>
+
+#include "test.h"
+
+int main() {
+ char str[128] = {};
+#define do_print(...) fmt_snprint(str, sizeof(str), __VA_ARGS__)
+
+ do_print("hello ", 9, " world!\n");
+ test_assert(strcmp(str, "hello 9 world!\n") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print("hello ", (base8, 9), " world!\n");
+ test_assert(strcmp(str, "hello 11 world!\n") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print("hello ", (base2, 9), (qstr, " world!\n"));
+ test_assert(strcmp(str, "hello 1001\" world!\\n\"") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print("hello ", (base16, 17), " world!\n");
+ test_assert(strcmp(str, "hello 11 world!\n") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((strn, "hello ", 4));
+ test_assert(strcmp(str, "hell") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((strn, "h\0ello ", 4));
+ test_assert(memcmp(str, "h\0\0", 3) == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((mem, "hello ", 4));
+ test_assert(strcmp(str, "hell") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((mem, "hello\0world", strlen("hello world")+1));
+ test_assert(memcmp(str, "hello\0world", strlen("hello world")+1) == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((qmem, "hello\0world", strlen("hello world")+1));
+ test_assert(strcmp(str, "\"hello\\0world\\0\"") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((qstr, "hello\0world"));
+ test_assert(strcmp(str, "\"hello\"") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((qstrn, "hello\0world", strlen("hello world")+1));
+ test_assert(strcmp(str, "\"hello\"") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((qstrn, "hello\0world", 4));
+ test_assert(strcmp(str, "\"hell\"") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((byte, 'h'), (byte, 'w'));
+ test_assert(strcmp(str, "hw") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((qbyte, 'h'), (qbyte, 'w'));
+ test_assert(strcmp(str, "'h''w'") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print("zero ", 0);
+ test_assert(strcmp(str, "zero 0") == 0);
+ memset(str, 0, sizeof(str));
+
+ const char *const_str = "hello";
+ do_print(const_str);
+ test_assert(strcmp(str, "hello") == 0);
+ memset(str, 0, sizeof(str));
+
+ bool t = true;
+ do_print(t);
+ test_assert(strcmp(str, "true") == 0);
+ memset(str, 0, sizeof(str));
+
+ bool f = false;
+ do_print(f);
+ test_assert(strcmp(str, "false") == 0);
+ memset(str, 0, sizeof(str));
+
+ /* Check that it accepts all primitive types of integer, not
+ * just all sizes of integer (e.g., on x86-64,
+ * sizeof(long)==sizeof(int), but they're different primitive
+ * types). */
+ {
+ signed char x = 42;
+ do_print("schar ", x);
+ test_assert(strcmp(str, "schar 42") == 0);
+ memset(str, 0, sizeof(str));
+ }
+ {
+ unsigned char x = 43;
+ do_print("uchar ", x);
+ test_assert(strcmp(str, "uchar 43") == 0);
+ memset(str, 0, sizeof(str));
+ }
+
+ {
+ short x = 44;
+ do_print("short ", x);
+ test_assert(strcmp(str, "short 44") == 0);
+ memset(str, 0, sizeof(str));
+ }
+ {
+ unsigned short x = 45;
+ do_print("ushort ", x);
+ test_assert(strcmp(str, "ushort 45") == 0);
+ memset(str, 0, sizeof(str));
+ }
+
+ {
+ int x = 46;
+ do_print("int ", x);
+ test_assert(strcmp(str, "int 46") == 0);
+ memset(str, 0, sizeof(str));
+ }
+ {
+ unsigned int x = 47;
+ do_print("uint ", x);
+ test_assert(strcmp(str, "uint 47") == 0);
+ memset(str, 0, sizeof(str));
+ }
+
+ {
+ long x = 48;
+ do_print("long ", x);
+ test_assert(strcmp(str, "long 48") == 0);
+ memset(str, 0, sizeof(str));
+ }
+ {
+ unsigned long x = 49;
+ do_print("ulong ", x);
+ test_assert(strcmp(str, "ulong 49") == 0);
+ memset(str, 0, sizeof(str));
+ }
+
+ {
+ long long x = 50;
+ do_print("long long ", x);
+ test_assert(strcmp(str, "long long 50") == 0);
+ memset(str, 0, sizeof(str));
+ }
+ {
+ unsigned long long x = 51;
+ do_print("ulong long ", x);
+ test_assert(strcmp(str, "ulong long 51") == 0);
+ memset(str, 0, sizeof(str));
+ }
+
+ do_print((ljust, 10, ' ', (base10, 1), "x"));
+ test_assert(strcmp(str, "1x ") == 0);
+ memset(str, 0, sizeof(str));
+
+ do_print((rjust, 10, ' ', (base10, 1), "x"));
+ test_assert(strcmp(str, " 1x") == 0);
+ memset(str, 0, sizeof(str));
+
+ return 0;
+}
diff --git a/libmisc/tests/test_log.c b/libmisc/tests/test_log.c
index 02b95d6..ee762e2 100644
--- a/libmisc/tests/test_log.c
+++ b/libmisc/tests/test_log.c
@@ -4,11 +4,10 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-#define _GNU_SOURCE /* for vasprintf() */
#include <stdarg.h> /* for va_list */
-#include <stdio.h> /* for vasprintf() */
-#include <stdlib.h> /* for free() */
-#include <string.h> /* for strcmp() */
+#include <stdio.h> /* for vsnprintf() */
+#include <stdlib.h> /* for realloc(), free() */
+#include <string.h> /* for strlen(), strcmp() */
#define LOG_NAME FROBNICATE
#include <libmisc/log.h>
@@ -19,52 +18,64 @@
/* Intercept output ***********************************************************/
-static char *log_output = NULL;
+static struct fmt_buf log_output = {};
-int __lm_printf(const char *format, ...) {
- va_list va;
- va_start(va, format);
- int ret = vasprintf(&log_output, format, va);
- va_end(va);
- return ret;
+void __lm_putchar(unsigned char c) {
+ if (log_output.len+1 >= log_output.cap) {
+ log_output.cap += 16;
+ log_output.dat = realloc(log_output.dat, log_output.cap);
+ memset(log_output.dat + log_output.len, 0, log_output.cap - log_output.len);
+ }
+ ((uint8_t *)log_output.dat)[log_output.len++] = (uint8_t)c;
+}
+
+static void log_output_clear(void) {
+ if (log_output.dat)
+ memset(log_output.dat, 0, log_output.cap);
+ log_output.len = 0;
}
/* Actual tests ***************************************************************/
-#define should_print(_exp, cmd) do { \
- char *exp = _exp; \
- test_assert(!log_output); \
- cmd; \
- if (!exp) \
- test_assert(!log_output); \
- else { \
- test_assert(log_output); \
- if (strcmp(log_output, exp)) { \
- printf("exp = \"%s\"\n" \
- "act = \"%s\"\n", \
- exp, log_output); \
- test_assert(0); \
- } \
- } \
- if (log_output) { \
- free(log_output); \
- log_output = NULL; \
- } \
+#define should_print(_exp, cmd) do { \
+ char *exp = _exp; \
+ test_assert(log_output.len == 0); \
+ cmd; \
+ if (!exp) \
+ test_assert(log_output.len == 0); \
+ else { \
+ test_assert(log_output.dat); \
+ test_assert(strlen(log_output.dat) == log_output.len); \
+ if (strcmp(log_output.dat, exp)) { \
+ printf("exp = \"%s\"\n" \
+ "act = \"%s\"\n", \
+ exp, (char *)log_output.dat); \
+ test_assert(0); \
+ } \
+ } \
+ log_output_clear(); \
} while (0)
int main() {
should_print("error: FROBNICATE: val=42\n",
- log_errorf("val=%d", 42));
+ log_errorln("val=", 42));
should_print("info : FROBNICATE: val=0\n",
- log_infof("val=%d", 0));
+ log_infoln("val=", 0));
#ifndef NDEBUG
#define CONFIG_FROBNICATE_DEBUG 1
should_print("debug: FROBNICATE: val=-2\n",
- log_debugf("val=%d", -2));
+ log_debugln("val=", -2));
#undef CONFIG_FROBNICATE_DEBUG
#define CONFIG_FROBNICATE_DEBUG 0
should_print(NULL,
- log_debugf("val=%d", -2));
+ log_debugln("val=", -2));
+#undef CONFIG_FROBNICATE_DEBUG
#endif
+
+ if (log_output.dat) {
+ free(log_output.dat);
+ log_output.dat = NULL;
+ log_output.cap = 0;
+ }
return 0;
}
diff --git a/libmisc/tests/test_macro.c b/libmisc/tests/test_macro.c
index 1320eb3..5157820 100644
--- a/libmisc/tests/test_macro.c
+++ b/libmisc/tests/test_macro.c
@@ -4,10 +4,34 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+#include <stdlib.h> /* for free() */
+#include <string.h> /* for strcmp(), strlen(), memcmp(), strdup() */
+
#include <libmisc/macro.h>
#include "test.h"
+/** Given `N` from `#define _LM_EVAL _LM_EVAL__{N}`, UNDER is `(N*2)-2`. (16*2)-2=30. */
+#define UNDER 30
+/** Given `N` from `#define _LM_EVAL _LM_EVAL__{N}`, OVER is `(N*2)-1`. (16*2)-1=31. */
+#define OVER 31
+
+/** XUNDER is 0 through `UNDER` inclusive. */
+#define XUNDER \
+ X(0) X(1) X(2) X(3) X(4) X(5) X(6) X(7) X(8) X(9) X(10) X(11) X(12) X(13) X(14) X(15) \
+ X(16) X(17) X(18) X(19) X(20) X(21) X(22) X(23) X(24) X(25) X(26) X(27) X(28) X(29) X(30)
+/** XUNDER is 0 through `OVER` inclusive. */
+#define XOVER XUNDER X(OVER)
+
+static char *without_spaces(const char *in) {
+ char *out = strdup(in);
+ for (size_t i = 0; out[i]; i++)
+ while (out[i] == ' ')
+ for (size_t j = i; out[j]; j++)
+ out[j] = out[j+1];
+ return out;
+}
+
int main() {
printf("== LM_NEXT_POWER_OF_2 =====================================\n");
/* valid down to 0. */
@@ -50,5 +74,109 @@ int main() {
/* ... */
test_assert(LM_FLOORLOG2(0xFFFFFFFFFFFFFFFF) == 63);
+ printf("== LM_TUPLE ===============================================\n");
+ test_assert(LM_IF(LM_IS_TUPLE( 9 ))(0)(1));
+ test_assert(LM_IF(LM_IS_TUPLE( a ))(0)(1));
+ test_assert(LM_IF(LM_IS_TUPLE( () ))(1)(0));
+ test_assert(LM_IF(LM_IS_TUPLE( (9) ))(1)(0));
+ test_assert(LM_IF(LM_IS_TUPLE( (a) ))(1)(0));
+ test_assert(LM_IF(LM_IS_TUPLE( (a, b) ))(1)(0));
+
+ test_assert(LM_IF(LM_IS_EMPTY_TUPLE( () ))(1)(0));
+ test_assert(LM_IF(LM_IS_EMPTY_TUPLE( 9 ))(0)(1));
+ test_assert(LM_IF(LM_IS_EMPTY_TUPLE( a ))(0)(1));
+ test_assert(LM_IF(LM_IS_EMPTY_TUPLE( (9) ))(0)(1));
+ test_assert(LM_IF(LM_IS_EMPTY_TUPLE( (a) ))(0)(1));
+ test_assert(LM_IF(LM_IS_EMPTY_TUPLE( (a, b) ))(0)(1));
+
+ printf("== LM_TUPLES ==============================================\n");
+ test_assert(LM_IF(LM_TUPLES_IS_NONEMPTY( ))(0)(1));
+ test_assert(LM_IF(LM_TUPLES_IS_NONEMPTY( () ))(1)(0));
+ test_assert(LM_IF(LM_TUPLES_IS_NONEMPTY( (a) ))(1)(0));
+ test_assert(LM_IF(LM_TUPLES_IS_NONEMPTY( (a)(b) ))(1)(0));
+ test_assert(LM_IF(LM_TUPLES_IS_NONEMPTY( (a)(b)(c) ))(1)(0));
+
+ printf("== LM_FOREACH_PARAM =======================================\n");
+ /* Basic test. */
+ {
+ #define FN(A, B) A "-" #B
+ const char *str = LM_FOREACH_PARAM(FN, (" "), a, (b), c);
+ #undef FN
+ test_assert(strcmp(str, " -a -(b) -c") == 0);
+ }
+
+ /* Test that it works with the documented limit of params. */
+ {
+ #define X(n) , n
+ #define FN(n) #n "\n"
+ const char *str = LM_FOREACH_PARAM_(FN, () XUNDER);
+ #undef FN
+ #undef X
+ #define X(n) #n "\n"
+ test_assert(strcmp(str, XUNDER) == 0);
+ #undef X
+ }
+
+ /* Test that it breaks at documented_limit+1 tuples. */
+ {
+ #define X(n) , n
+ #define FN(n) n
+ const char *str = LM_STR_(LM_FOREACH_PARAM_(FN, () XOVER));
+ #undef FN
+ #undef X
+ /* This comparison is a little extra complicated in
+ * order to not be sensitive to whitespace in the
+ * suffix. */
+ #define X(n) #n " "
+ const char *exp_prefix = XUNDER;
+ #undef X
+ const char *exp_suffix = "FN(" LM_STR_(OVER) ")_LM_FOREACH_PARAM_ITEM_indirect()(FN,(),())";
+ test_assert(strlen(exp_prefix) < strlen(str) && memcmp(exp_prefix, str, strlen(exp_prefix)) == 0);
+ char *act_suffix = without_spaces(&str[strlen(exp_prefix)]);
+ test_assert(strcmp(act_suffix, exp_suffix) == 0);
+ free(act_suffix);
+ }
+
+ printf("== LM_FOREACH_TUPLE =======================================\n");
+ /* Basic test. */
+ {
+ #define FN(a, b) a "-" b
+ const char *str = LM_FOREACH_TUPLE( ("a") ("b") ("c"), FN, " ");
+ #undef FN
+ test_assert(strcmp(str, " -a -b -c") == 0);
+ }
+
+ /* Test that it works with the documented limit of tuples. */
+ {
+ #define X(n) (n)
+ #define FN(n) #n "\n"
+ const char *str = LM_FOREACH_TUPLE(XUNDER, FN);
+ #undef FN
+ #undef X
+ #define X(n) #n "\n"
+ test_assert(strcmp(str, XUNDER) == 0);
+ #undef X
+ }
+
+ /* Test that it breaks at documented_limit+1 tuples. */
+ {
+ #define X(n) (n)
+ #define FN(n) n
+ const char *str = LM_STR_(LM_FOREACH_TUPLE(XOVER, FN));
+ #undef FN
+ #undef X
+ /* This comparison is a little extra complicated in
+ * order to not be sensitive to whitespace in the
+ * suffix. */
+ #define X(n) #n " "
+ const char *exp_prefix = XUNDER;
+ #undef X
+ const char *exp_suffix = "FN(" LM_STR_(OVER) ")_LM_FOREACH_TUPLE_indirect()(,FN,)";
+ test_assert(strlen(exp_prefix) < strlen(str) && memcmp(exp_prefix, str, strlen(exp_prefix)) == 0);
+ char *act_suffix = without_spaces(&str[strlen(exp_prefix)]);
+ test_assert(strcmp(act_suffix, exp_suffix) == 0);
+ free(act_suffix);
+ }
+
return 0;
}
diff --git a/libusb/usb_common.c b/libusb/usb_common.c
index 88e01b4..32aa53f 100644
--- a/libusb/usb_common.c
+++ b/libusb/usb_common.c
@@ -68,12 +68,12 @@ uint16_t const *tud_descriptor_string_cb(uint8_t strid, uint16_t langid) {
memcpy(desc.bString, globals.serial, bytelen);
break;
default:
- log_debugf("GET STRING: unknown string id=%"PRIu8, strid);
+ log_debugln("GET STRING: unknown string id=", strid);
return NULL;
}
break;
default:
- log_debugf("GET STRING: unknown LANGID=%"PRIx16, langid);
+ log_debugln("GET STRING: unknown LANGID=", (base16_u16_, langid));
return NULL;
}
}