X11 startup scripts: sync ssh key list
The X11 session startup files for xenodm and xinit share the same snippet which checks if any of the default ssh private key files exist, and if so, starts ssh-agent and runs ssh-add. The list of key files is outdated. SSH1 "identity" is gone, and "id_ecdsa_sk" and "id_ed25519_sk" have been added for FIDO-based keys. The patch below updates the list and rephrases the shell code a bit. I have tested the xenodm Xsession script. ok? diff c65268ffd62e66b859aaf782a75cfa2f086925cb /usr/xenocara blob - 1a1b6ab21ddb00673ddb17d7fb5f855ad21aa461 file + app/xenodm/config/Xsession.in --- app/xenodm/config/Xsession.in +++ app/xenodm/config/Xsession.in @@ -23,18 +23,22 @@ else fi # if we have private ssh key(s), start ssh-agent and add the key(s) -id1=$HOME/.ssh/identity -id2=$HOME/.ssh/id_dsa -id3=$HOME/.ssh/id_rsa -id4=$HOME/.ssh/id_ecdsa -id5=$HOME/.ssh/id_ed25519 -if [ -z "$SSH_AGENT_PID" ]; +if [ -z "$SSH_AGENT_PID" ] && [ -x /usr/bin/ssh-agent ] then - if [ -x /usr/bin/ssh-agent ] && [ -f $id1 -o -f $id2 -o -f $id3 -o -f $id4 -o -f $id5 ]; - then - eval `ssh-agent -s` - ssh-add < /dev/null - fi + for keyfile in \ + "$HOME/.ssh/id_rsa" \ + "$HOME/.ssh/id_ecdsa" \ + "$HOME/.ssh/id_ecdsa_sk" \ + "$HOME/.ssh/id_ed25519" \ + "$HOME/.ssh/id_ed25519_sk" \ + "$HOME/.ssh/id_dsa" + do + if [ -f "$keyfile" ]; then + eval `ssh-agent -s` + ssh-add < /dev/null + break + fi + done fi do_exit() { blob - 4c9c3ae8aae50e3fe43f02aa1fb13b72712cbb64 file + app/xinit/xinitrc.cpp --- app/xinit/xinitrc.cpp +++ app/xinit/xinitrc.cpp @@ -41,19 +41,23 @@ if [ -f "$usermodmap" ]; then fi XCOMM if we have private ssh key(s), start ssh-agent and add the key(s) -id1=$HOME/.ssh/identity -id2=$HOME/.ssh/id_dsa -id3=$HOME/.ssh/id_rsa -id4=$HOME/.ssh/id_ecdsa -id5=$HOME/.ssh/id_ed25519 -if [ -z "$SSH_AGENT_PID" ]; +if [ -z "$SSH_AGENT_PID" ] && [ -x /usr/bin/ssh-agent ] then - if [ -x /usr/bin/ssh-agent ] && [ -f $id1 -o -f $id2 -o -f $id3 -o -f $id4 -o -f $id5 ]; - then - eval `ssh-agent -s` - ssh-add < /dev/null - fi + for keyfile in \ + "$HOME/.ssh/id_rsa" \ + "$HOME/.ssh/id_ecdsa" \ + "$HOME/.ssh/id_ecdsa_sk" \ + "$HOME/.ssh/id_ed25519" \ + "$HOME/.ssh/id_ed25519_sk" \ + "$HOME/.ssh/id_dsa" + do + if [ -f "$keyfile" ]; then + eval `ssh-agent -s` + ssh-add < /dev/null + break + fi + done fi XCOMM start some nice programs -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: obsolete dump options syntax
Jan Stary: > http://cvsweb.netbsd.org/bsdweb.cgi/src/sbin/dump/main.c.diff?r1=1.4=1.5=h > "Use getopt(3), with obsolete() from restore(8) for backward compatibility." > > So it's restore(8); I write "restore rf" myself. > Is this it? Does that still need to be supported by dump(8)? The same "bundled flags" syntax is supported by dump(8), restore(8), tar(1), and ar(1). -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: ssh-keygen(1): resident fido2 keys
Florian Obser: > Sounds reasonable, this adds the FIDO section and moves the -O bits in. > The wording is inspired by / copied from the 8.2 release notes and the > CERTIFICATES section. I think that makes sense. s/token/authenticator/g We standardized on "FIDO authenticator" some time ago, because "token" is already used for % expansion, and "security key" was confusing. "Authenticator" is also the official term used in the FIDO standard. ... I see some instances of "FIDO token" already slipped in over the last months, but that needs to be fixed. > Maybe you have text for DESCRIPTION? > Not sure what to do about -K, maybe > see > .Sx FIDO > for details. "... for more information."? -- Christian "naddy" Weisgerber na...@mips.inka.de
arm64: constify miscellaneous pin and clock tables
So I did "objdump -t bsd | fgrep 'O .data' | sort -k5r" on arm64. Oh my. The diff below constifies a myriad of pin, clock, etc. tables. This is all very mechanical. An arm64 GENERIC.MP kernel still builds and boots with this. OK? M sys/dev/fdt/amlclock.c M sys/dev/fdt/amlpinctrl.c M sys/dev/fdt/axppmic.c M sys/dev/fdt/bd718x7.c M sys/dev/fdt/hiclock.c M sys/dev/fdt/hitemp.c M sys/dev/fdt/imxccm.c M sys/dev/fdt/imxccm_clocks.h M sys/dev/fdt/imxsrc.c M sys/dev/fdt/mvpinctrl.c M sys/dev/fdt/mvpinctrl_pins.h M sys/dev/fdt/mvtemp.c M sys/dev/fdt/rkclock.c M sys/dev/fdt/rkpinctrl.c M sys/dev/fdt/rkpmic.c M sys/dev/fdt/rktemp.c M sys/dev/fdt/sxiccmu.c M sys/dev/fdt/sxiccmu_clocks.h M sys/dev/fdt/sxipio.c M sys/dev/fdt/sxipio_pins.h M sys/dev/ic/imxiicvar.h diff 1258159c23de129a92e61d9298f34d98b4b5be29 5f4acf3c29cf6656bcd1b87f26aad6cec8a72d21 blob - 9c26eec4407b5c58d3797d382d9978c395d6a100 blob + 6a8071eadb0fdadb2b4406090c1d07a02d2e5d87 --- sys/dev/fdt/amlclock.c +++ sys/dev/fdt/amlclock.c @@ -117,7 +117,7 @@ struct amlclock_gate { uint8_t bit; }; -struct amlclock_gate aml_g12a_gates[] = { +const struct amlclock_gate aml_g12a_gates[] = { [G12A_I2C] = { HHI_GCLK_MPEG0, 9 }, [G12A_SD_EMMC_A] = { HHI_GCLK_MPEG0, 24 }, [G12A_SD_EMMC_B] = { HHI_GCLK_MPEG0, 25 }, @@ -139,7 +139,7 @@ struct amlclock_softc { int sc_node; uint32_tsc_g12b; - struct amlclock_gate*sc_gates; + const struct amlclock_gate *sc_gates; int sc_ngates; struct clock_device sc_cd; blob - d03c0146d6d73d51730813125ac5259b4b20c371 blob + 4508166611b9aac1c9fd4d04810cfdf2a282f504 --- sys/dev/fdt/amlpinctrl.c +++ sys/dev/fdt/amlpinctrl.c @@ -162,7 +162,7 @@ struct aml_pin_group { const char *function; }; -struct aml_gpio_bank aml_g12a_gpio_banks[] = { +const struct aml_gpio_bank aml_g12a_gpio_banks[] = { /* BOOT */ { BOOT_0, 16, PERIPHS_PIN_MUX_0 - PERIPHS_PIN_MUX_0, 0, @@ -226,7 +226,7 @@ struct aml_gpio_bank aml_g12a_gpio_banks[] = { { } }; -struct aml_pin_group aml_g12a_pin_groups[] = { +const struct aml_pin_group aml_g12a_pin_groups[] = { /* GPIOZ */ { "i2c0_sda_z0", GPIOZ_0, 4, "i2c0" }, { "i2c0_sck_z1", GPIOZ_1, 4, "i2c0" }, @@ -292,7 +292,7 @@ struct aml_pin_group aml_g12a_pin_groups[] = { { } }; -struct aml_gpio_bank aml_g12a_ao_gpio_banks[] = { +const struct aml_gpio_bank aml_g12a_ao_gpio_banks[] = { /* GPIOAO */ { GPIOAO_0, 12, AO_RTI_PINMUX_0 - AO_RTI_PINMUX_0, 0, @@ -316,7 +316,7 @@ struct aml_gpio_bank aml_g12a_ao_gpio_banks[] = { { } }; -struct aml_pin_group aml_g12a_ao_pin_groups[] = { +const struct aml_pin_group aml_g12a_ao_pin_groups[] = { /* GPIOAO */ { "uart_ao_a_tx", GPIOAO_0, 1, "uart_ao_a" }, { "uart_ao_a_rx", GPIOAO_1, 1, "uart_ao_a" }, @@ -347,8 +347,8 @@ struct amlpinctrl_softc { bus_space_handle_t sc_ds_ioh; int sc_nobias; - struct aml_gpio_bank*sc_gpio_banks; - struct aml_pin_group*sc_pin_groups; + const struct aml_gpio_bank *sc_gpio_banks; + const struct aml_pin_group *sc_pin_groups; struct gpio_controller sc_gc; }; @@ -481,10 +481,10 @@ amlpinctrl_attach(struct device *parent, struct device gpio_controller_register(>sc_gc); } -struct aml_gpio_bank * +const struct aml_gpio_bank * amlpinctrl_lookup_bank(struct amlpinctrl_softc *sc, uint32_t pin) { - struct aml_gpio_bank *bank; + const struct aml_gpio_bank *bank; for (bank = sc->sc_gpio_banks; bank->num_pins > 0; bank++) { if (pin >= bank->first_pin && @@ -495,10 +495,10 @@ amlpinctrl_lookup_bank(struct amlpinctrl_softc *sc, ui return NULL; } -struct aml_pin_group * +const struct aml_pin_group * amlpinctrl_lookup_group(struct amlpinctrl_softc *sc, const char *name) { - struct aml_pin_group *group; + const struct aml_pin_group *group; for (group = sc->sc_pin_groups; group->name; group++) { if (strcmp(name, group->name) == 0) @@ -512,8 +512,8 @@ void amlpinctrl_config_func(struct amlpinctrl_softc *sc, const char *name, const char *function, int bias, int ds) { - struct aml_pin_group *group; - struct aml_gpio_bank *bank; + const struct aml_pin_group *group; + const struct aml_gpio_bank *bank; bus_addr_t off; uint32_t pin; uint32_t reg; @@ -640,7 +640,7 @@ void amlpinctrl_config_pin(void *cookie, uint32_t *cells, int config) { struct amlpinctrl_softc *sc = cookie; - struct aml_gpio_bank *bank; + const struct aml_gpio_bank *bank; bus_addr_t off; uint32_t pin = cells[0]; uint32_t flags = cells[1]; @@ -678,7 +678,7 @@ int amlpinctrl_get_pin(void *cookie, uint32_t *cells) { struct
Re: ddb: simplify "machine" command handling
Christian Weisgerber: > This will allow constifying the ddb command tables in a subsequent > step. And here's that boring follow-up diff. M sys/arch/alpha/alpha/db_interface.c M sys/arch/amd64/amd64/db_interface.c M sys/arch/arm/arm/db_interface.c M sys/arch/arm64/arm64/db_interface.c M sys/arch/i386/i386/db_interface.c M sys/arch/m88k/m88k/db_interface.c M sys/arch/mips64/mips64/db_machdep.c M sys/arch/powerpc/ddb/db_interface.c M sys/arch/powerpc64/powerpc64/db_interface.c M sys/arch/riscv64/riscv64/db_interface.c M sys/arch/sh/sh/db_interface.c M sys/arch/sparc64/sparc64/db_interface.c M sys/ddb/db_command.c M sys/ddb/db_command.h diff c5fcb00219e59f5bbd0cb5171af7fe5d01f0a0c3 6e95eec92a4f984cd0aff5dd99dd725920c1f1b6 blob - 7e9ce6cc9803586260886d5c16ff2e1219cc2c77 blob + 3f5056966aa3b44d3d4cdc1113256fc05c528026 --- sys/arch/alpha/alpha/db_interface.c +++ sys/arch/alpha/alpha/db_interface.c @@ -85,7 +85,7 @@ db_regs_t ddb_regs; void db_mach_cpu(db_expr_t, int, db_expr_t, char *); #endif -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #if defined(MULTIPROCESSOR) { "ddbcpu", db_mach_cpu,0, NULL }, #endif blob - b12b9c48cf147c1525c19e11fac84b35b02bc19f blob + bd57af87e871b65736c5f4afa8c4f3f98b9bef5c --- sys/arch/amd64/amd64/db_interface.c +++ sys/arch/amd64/amd64/db_interface.c @@ -394,7 +394,7 @@ x86_ipi_db(struct cpu_info *ci) #endif /* MULTIPROCESSOR */ #if NACPI > 0 -struct db_command db_acpi_cmds[] = { +const struct db_command db_acpi_cmds[] = { { "disasm", db_acpi_disasm, CS_OWN, NULL }, { "showval",db_acpi_showval,CS_OWN, NULL }, { "tree", db_acpi_tree, 0, NULL }, @@ -403,7 +403,7 @@ struct db_command db_acpi_cmds[] = { }; #endif /* NACPI > 0 */ -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "cpuinfo",db_cpuinfo_cmd, 0, 0 }, { "startcpu", db_startproc_cmd, 0, 0 }, blob - 719da88249590509dabb734794daedc7c2a3dd61 blob + bcc0cad7ce3f7c7c180b99d7aaa43b9d6c554738 --- sys/arch/arm/arm/db_interface.c +++ sys/arch/arm/arm/db_interface.c @@ -340,7 +340,7 @@ db_enter(void) asm(".word 0xe7ff"); } -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { { "frame", db_show_frame_cmd, 0, NULL }, #ifdef ARM32_DB_COMMANDS ARM32_DB_COMMANDS, blob - 1645b49186bed36130ffd73a933e45f8f9fc5e18 blob + cb7ecd25005541d590f94cf07152154d3340ade5 --- sys/arch/arm64/arm64/db_interface.c +++ sys/arch/arm64/arm64/db_interface.c @@ -469,7 +469,7 @@ db_stopcpu(int cpu) } #endif -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "cpuinfo",db_cpuinfo_cmd, 0, NULL }, { "startcpu", db_startproc_cmd, 0, NULL }, blob - 1807bc890744e4f32ef839e73e5647fd5488b901 blob + be2562e3a816dc0d8579275de6fc373458f5fb3e --- sys/arch/i386/i386/db_interface.c +++ sys/arch/i386/i386/db_interface.c @@ -314,7 +314,7 @@ db_ddbproc_cmd(db_expr_t addr, int have_addr, db_expr_ #endif /* MULTIPROCESSOR */ #if NACPI > 0 -struct db_command db_acpi_cmds[] = { +const struct db_command db_acpi_cmds[] = { { "disasm", db_acpi_disasm, CS_OWN, NULL }, { "showval",db_acpi_showval,CS_OWN, NULL }, { "tree", db_acpi_tree, 0, NULL }, @@ -323,7 +323,7 @@ struct db_command db_acpi_cmds[] = { }; #endif /* NACPI > 0 */ -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { { "sysregs",db_sysregs_cmd, 0, 0 }, #ifdef MULTIPROCESSOR { "cpuinfo",db_cpuinfo_cmd, 0, 0 }, blob - 55d5e5ba78719c954c4d6d1f5ffa9083e941a932 blob + eab0352da587873642a701debbbc0c00e8f19052 --- sys/arch/m88k/m88k/db_interface.c +++ sys/arch/m88k/m88k/db_interface.c @@ -654,7 +654,7 @@ m88k_db_cpu_cmd(db_expr_t addr, int have_addr, db_expr /* COMMAND TABLE / INIT */ // -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "ddbcpu", m88k_db_cpu_cmd,0, NULL }, #endif blob - 2c7d67c597c2a237420af198985aaa20781f124e blob + b5f2651c9dccdc3281ea43496bc68a8a86a73d26 --- sys/arch/mips64/mips64/db_machdep.c +++ sys/arch/mips64/mips64/db_machdep.c @@ -492,7 +492,7 @@ db_dump_tlb_cmd(db_expr_t addr, int have_addr, db_expr } -struct db_command db_machine_command_table[] = { +const struct db_command db_machi
ddb: simplify "machine" command handling
Most of our architectures implement a "machine" command as a MD extension in ddb(4). Currently that is handled in this way: * A define is placed in a MD header. * The MI ddb code checks for the define, creates an incomplete entry in the command table, and provides an initialization function. * MD code calls this function to patch a pointer to the MD sub-command into the MI command table. I guess it made sense in 1990? We can simplify this: Define a consistently named db_machine_command_table[] across all archs that implement the MD "machine" command and hook this into the main command table instead of patching it at runtime. Most archs already use the name db_machine_command_table[]. This will allow constifying the ddb command tables in a subsequent step. I have tested amd64, arm64, and i386. Comments, ok? M sys/arch/alpha/alpha/db_interface.c M sys/arch/amd64/amd64/db_interface.c M sys/arch/arm/arm/db_interface.c M sys/arch/arm64/arm64/db_interface.c M sys/arch/i386/i386/db_interface.c M sys/arch/m88k/m88k/db_interface.c M sys/arch/mips64/mips64/db_machdep.c M sys/arch/powerpc/ddb/db_interface.c M sys/arch/powerpc64/powerpc64/db_interface.c M sys/arch/riscv64/riscv64/db_interface.c M sys/arch/sh/sh/db_interface.c M sys/arch/sparc64/sparc64/db_interface.c M sys/ddb/db_command.c M sys/ddb/db_command.h diff 7e559a9c431834a0b3471b1fa86985ca220b83ba c5fcb00219e59f5bbd0cb5171af7fe5d01f0a0c3 blob - fd83cb898bcddb466570b0c531b0b34171a1363f blob + 7e9ce6cc9803586260886d5c16ff2e1219cc2c77 --- sys/arch/alpha/alpha/db_interface.c +++ sys/arch/alpha/alpha/db_interface.c @@ -527,5 +527,4 @@ db_mach_cpu(db_expr_t addr, int have_addr, db_expr_t c void db_machine_init() { - db_machine_commands_install(db_machine_command_table); } blob - 186fb4d83fb4d5f849e88297c311f37eaf4638c6 blob + b12b9c48cf147c1525c19e11fac84b35b02bc19f --- sys/arch/amd64/amd64/db_interface.c +++ sys/arch/amd64/amd64/db_interface.c @@ -422,10 +422,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < MAXCPUS; i++) { if (cpu_info[i] != NULL) cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING; blob - a8d7805cd6f73e9d281b448e8bb03fb77e210df2 blob + 719da88249590509dabb734794daedc7c2a3dd61 --- sys/arch/arm/arm/db_interface.c +++ sys/arch/arm/arm/db_interface.c @@ -378,8 +378,6 @@ db_machine_init(void) */ db_uh.uh_handler = db_trapper; install_coproc_handler_static(0, _uh); - - db_machine_commands_install(db_machine_command_table); } u_int blob - ed28376be206f5eb55ae034981680025b2717513 blob + 1645b49186bed36130ffd73a933e45f8f9fc5e18 --- sys/arch/arm64/arm64/db_interface.c +++ sys/arch/arm64/arm64/db_interface.c @@ -499,10 +499,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < MAXCPUS; i++) { if (cpu_info[i] != NULL) cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING; blob - b4c6a02021c944ddea37cb8add864ee1f65a454b blob + 1807bc890744e4f32ef839e73e5647fd5488b901 --- sys/arch/i386/i386/db_interface.c +++ sys/arch/i386/i386/db_interface.c @@ -342,10 +342,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif /* MULTIPROCESSOR */ - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < MAXCPUS; i++) { if (cpu_info[i] != NULL) cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING; blob - 4d540ea2ad0e5b2d0b8a3c15837309bfe5f8db8c blob + 55d5e5ba78719c954c4d6d1f5ffa9083e941a932 --- sys/arch/m88k/m88k/db_interface.c +++ sys/arch/m88k/m88k/db_interface.c @@ -654,7 +654,7 @@ m88k_db_cpu_cmd(db_expr_t addr, int have_addr, db_expr /* COMMAND TABLE / INIT */ // -struct db_command db_machine_cmds[] = { +struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "ddbcpu", m88k_db_cpu_cmd,0, NULL }, #endif @@ -671,7 +671,6 @@ struct db_command db_machine_cmds[] = { void db_machine_init() { - db_machine_commands_install(db_machine_cmds); #ifdef MULTIPROCESSOR __mp_lock_init(_mp_lock); #endif blob - bbdf2462b57e310bb79ee1890d7a5495f9487226 blob + 2c7d67c597c2a237420af198985aaa20781f124e --- sys/arch/mips64/mips64/db_machdep.c +++ sys/arch/mips64/mips64/db_machdep.c @@ -492,7 +492,7 @@ db_dump_tlb_cmd(db_expr_t addr, int have_addr, db_expr } -struct db_command mips_db_command_table[] = { +struct db_command db_machine_command_table[] = { { "tlb",db_dump_tlb_cmd,0, NULL }, { "trap", db_trap_trace_cmd, 0, NULL }, #ifdef MULTIPROCESSOR @@ -510,10 +510,7 @@ db_machine_init(void) extern char *ssym; #ifdef MULTIPROCESSOR
Re: [ouex]hci(4), dwctwo(4): constify bus/pipe method tables
Marcus Glocker: > > This constifies the bus method and pipe method tables in our USB > > host controller drivers. > > dwctwo(4) also exists on arm64. Oops, right. That arch I have. The USB host controller drivers also have another set of tables to emulate the root hub. I have extended the diff to constify those as well. xhci(4) and dwctwo(4) were already (partially) done. The *_devd descriptor template poses a problem, because its idVendor member is modified before the descriptor is memcpy()'ed into a transmit buffer. The copy can be truncated, so reordering the operations would lead to much ugliness. I have introduced a temporary variable at the cost of another copy. The code already does this for the *_hubd descriptor. The NetBSD author of dwctwo(4) also ran into this problem, but didn't solve it, simply never setting idVendor, for which there is also no ready source absent a PCI bus attachment. I _think_ the FreeBSD code for all host controllers doesn't bother setting idVendor either, so that may be another solution. Comments, okays? diff refs/heads/master refs/heads/usb blob - 9b9d1635f902afef00a4111dfba8f86d13f74b4e blob + 64dea91909ed4f77f7f24c61dd1c09809d27d031 --- sys/dev/usb/dwc2/dwc2.c +++ sys/dev/usb/dwc2/dwc2.c @@ -146,7 +146,7 @@ dwc2_free_bus_bandwidth(struct dwc2_hsotg *hsotg, u16 #define DWC2_INTR_ENDPT 1 -STATIC struct usbd_bus_methods dwc2_bus_methods = { +STATIC const struct usbd_bus_methods dwc2_bus_methods = { .open_pipe =dwc2_open, .dev_setaddr = dwc2_setaddr, .soft_intr =dwc2_softintr, @@ -155,7 +155,7 @@ STATIC struct usbd_bus_methods dwc2_bus_methods = { .freex =dwc2_freex, }; -STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods = { +STATIC const struct usbd_pipe_methods dwc2_root_ctrl_methods = { .transfer = dwc2_root_ctrl_transfer, .start =dwc2_root_ctrl_start, .abort =dwc2_root_ctrl_abort, @@ -164,7 +164,7 @@ STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods .done = dwc2_root_ctrl_done, }; -STATIC struct usbd_pipe_methods dwc2_root_intr_methods = { +STATIC const struct usbd_pipe_methods dwc2_root_intr_methods = { .transfer = dwc2_root_intr_transfer, .start =dwc2_root_intr_start, .abort =dwc2_root_intr_abort, @@ -173,7 +173,7 @@ STATIC struct usbd_pipe_methods dwc2_root_intr_methods .done = dwc2_root_intr_done, }; -STATIC struct usbd_pipe_methods dwc2_device_ctrl_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_ctrl_methods = { .transfer = dwc2_device_ctrl_transfer, .start =dwc2_device_ctrl_start, .abort =dwc2_device_ctrl_abort, @@ -182,7 +182,7 @@ STATIC struct usbd_pipe_methods dwc2_device_ctrl_metho .done = dwc2_device_ctrl_done, }; -STATIC struct usbd_pipe_methods dwc2_device_intr_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_intr_methods = { .transfer = dwc2_device_intr_transfer, .start =dwc2_device_intr_start, .abort =dwc2_device_intr_abort, @@ -191,7 +191,7 @@ STATIC struct usbd_pipe_methods dwc2_device_intr_metho .done = dwc2_device_intr_done, }; -STATIC struct usbd_pipe_methods dwc2_device_bulk_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_bulk_methods = { .transfer = dwc2_device_bulk_transfer, .start =dwc2_device_bulk_start, .abort =dwc2_device_bulk_abort, @@ -200,7 +200,7 @@ STATIC struct usbd_pipe_methods dwc2_device_bulk_metho .done = dwc2_device_bulk_done, }; -STATIC struct usbd_pipe_methods dwc2_device_isoc_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_isoc_methods = { .transfer = dwc2_device_isoc_transfer, .start =dwc2_device_isoc_start, .abort =dwc2_device_isoc_abort, @@ -681,7 +681,6 @@ dwc2_root_ctrl_start(struct usbd_xfer *xfer) switch (value) { case C(0, UDESC_DEVICE): l = min(len, USB_DEVICE_DESCRIPTOR_SIZE); -// USETW(dwc2_devd.idVendor, sc->sc_id_vendor); memcpy(buf, _devd, l); buf += l; len -= l; blob - 350580c00b30f8edcfd5edf8ad8d1734624462c6 blob + 834e97310fb06a73bc569a943e4b0e7906c136d5 --- sys/dev/usb/ehci.c +++ sys/dev/usb/ehci.c @@ -218,7 +218,7 @@ voidehci_dump_exfer(struct ehci_xfer *); #define EHCI_INTR_ENDPT 1 -struct usbd_bus_methods ehci_bus_methods = { +const struct usbd_bus_methods ehci_bus_methods = { .open_pipe = ehci_open, .dev_setaddr = ehci_setaddr, .soft_intr = ehci_softintr, @@ -227,7 +227,7 @@ struct usbd_bus_methods ehci_bus_methods = { .freex = ehci_freex, }; -struct usbd_pipe_methods ehci_root_ctrl_methods = { +const struct
Constify SCSI adapter entry points
This constifies the SCSI adapter entry points (struct scsi_adapter). It reaches into some archs I don't have... ok? M sys/arch/luna88k/dev/mb89352.c M sys/arch/luna88k/dev/mb89352var.h M sys/arch/luna88k/dev/spc.c M sys/arch/sparc64/dev/vdsk.c M sys/dev/ata/atascsi.c M sys/dev/atapiscsi/atapiscsi.c M sys/dev/ic/aac.c M sys/dev/ic/adv.c M sys/dev/ic/adw.c M sys/dev/ic/aic6360.c M sys/dev/ic/aic79xx_openbsd.c M sys/dev/ic/aic7xxx_openbsd.c M sys/dev/ic/ami.c M sys/dev/ic/cac.c M sys/dev/ic/ciss.c M sys/dev/ic/gdt_common.c M sys/dev/ic/mfi.c M sys/dev/ic/mpi.c M sys/dev/ic/ncr53c9x.c M sys/dev/ic/nvme.c M sys/dev/ic/oosiop.c M sys/dev/ic/osiop.c M sys/dev/ic/qla.c M sys/dev/ic/qlw.c M sys/dev/ic/siop.c M sys/dev/ic/twe.c M sys/dev/ic/uha.c M sys/dev/isa/wds.c M sys/dev/pci/arc.c M sys/dev/pci/iha_pci.c M sys/dev/pci/ips.c M sys/dev/pci/mfii.c M sys/dev/pci/mpii.c M sys/dev/pci/qle.c M sys/dev/pci/trm_pci.c M sys/dev/pci/vmwpvs.c M sys/dev/pv/hvs.c M sys/dev/pv/vioblk.c M sys/dev/pv/vioscsi.c M sys/dev/pv/xbf.c M sys/dev/sdmmc/sdmmc_scsi.c M sys/dev/softraid.c M sys/dev/usb/umass_scsi.c M sys/dev/vscsi.c M sys/scsi/mpath.c M sys/scsi/scsiconf.h diff 0dbbfe957ecc14f6850205ad3b966d242dbc9b06 e79b7c31603b0e0aea1909e2874ee6cfb95925f8 blob - 450ebece88b74eef5c577c13d0553f041cddd5dc blob + 77f9a760254025a3c99124b3d1134bc62ddafb9e --- sys/arch/luna88k/dev/mb89352.c +++ sys/arch/luna88k/dev/mb89352.c @@ -190,7 +190,7 @@ do { \ void /* spc_attach(sc) */ -spc_attach(struct spc_softc *sc, struct scsi_adapter *adapter) +spc_attach(struct spc_softc *sc, const struct scsi_adapter *adapter) { struct scsibus_attach_args saa; SPC_TRACE(("spc_attach ")); blob - 0df2bc6358fd58265c14c9630c76b955f446e97d blob + 9dae1aba0a773754f7ae6abcc8a2ce6c19138c81 --- sys/arch/luna88k/dev/mb89352var.h +++ sys/arch/luna88k/dev/mb89352var.h @@ -203,7 +203,7 @@ extern int spc_debug; /* SPC_SHOWSTART|SPC_SHOWMISC|SP #define SPC_TRACE(s) SPC_PRINT(SPC_SHOWTRACE, s) #define SPC_START(s) SPC_PRINT(SPC_SHOWSTART, s) -void spc_attach(struct spc_softc *, struct scsi_adapter *); +void spc_attach(struct spc_softc *, const struct scsi_adapter *); intspc_intr(void *); intspc_find(bus_space_tag_t, bus_space_handle_t, int); void spc_init(struct spc_softc *); blob - 91113f2ee10328c10059bb45920218fd965ffcac blob + c19244983341f7a75ccd28844766cc117a9b9eb7 --- sys/arch/luna88k/dev/spc.c +++ sys/arch/luna88k/dev/spc.c @@ -59,7 +59,7 @@ struct cfdriver spc_cd = { NULL, "spc", DV_DULL }; -struct scsi_adapter spc_switch = { +const struct scsi_adapter spc_switch = { spc_scsi_cmd, NULL, NULL, NULL, NULL }; blob - 8c3c41b06799e36244b4223db776e99ffccf7ed8 blob + 509cca15b3034c1f375ff48cc378df3e5c623134 --- sys/arch/sparc64/dev/vdsk.c +++ sys/arch/sparc64/dev/vdsk.c @@ -179,7 +179,7 @@ struct cfdriver vdsk_cd = { void vdsk_scsi_cmd(struct scsi_xfer *); -struct scsi_adapter vdsk_switch = { +const struct scsi_adapter vdsk_switch = { vdsk_scsi_cmd, NULL, NULL, NULL, NULL }; blob - 19f61480e83314afe9d58d24b52e1b1d7e64ea93 blob + f338ff373175501361455ce4e38d9fa006d9b403 --- sys/dev/ata/atascsi.c +++ sys/dev/ata/atascsi.c @@ -94,7 +94,7 @@ int atascsi_probe(struct scsi_link *); void atascsi_free(struct scsi_link *); /* template */ -struct scsi_adapter atascsi_switch = { +const struct scsi_adapter atascsi_switch = { atascsi_cmd, NULL, atascsi_probe, atascsi_free, NULL }; blob - 622d1687499d2a455a0b95fccc24e3c64739a029 blob + 743369f1edaad1f7c7fbcd3464073f0517ff2e55 --- sys/dev/atapiscsi/atapiscsi.c +++ sys/dev/atapiscsi/atapiscsi.c @@ -156,7 +156,7 @@ struct atapiscsi_softc { int wdc_atapi_ioctl(struct scsi_link *, u_long, caddr_t, int); void wdc_atapi_send_cmd(struct scsi_xfer *sc_xfer); -static struct scsi_adapter atapiscsi_switch = { +static const struct scsi_adapter atapiscsi_switch = { wdc_atapi_send_cmd, NULL, NULL, NULL, wdc_atapi_ioctl }; blob - fe91366547e96750c389547cd0e9eec188efec4a blob + 7805cba76f42c4468062ff97efcdcc12ec8f6c56 --- sys/dev/ic/aac.c +++ sys/dev/ic/aac.c @@ -129,7 +129,7 @@ struct cfdriver aac_cd = { NULL, "aac", DV_DULL }; -struct scsi_adapter aac_switch = { +const struct scsi_adapter aac_switch = { aac_scsi_cmd, NULL, NULL, NULL, NULL }; blob - 3ee97dfee35ce2429e09a887a953c2b7fe966c5a blob + 0233d7c24eaf996027a4c7297496a1b806bf800e --- sys/dev/ic/adv.c +++ sys/dev/ic/adv.c @@ -81,7 +81,7 @@ struct cfdriver adv_cd = { }; -struct scsi_adapter adv_switch = { +const struct scsi_adapter adv_switch = { adv_scsi_cmd, NULL, NULL, NULL, NULL }; blob - 60dfe556e10dcec2ee9a35e11b1c5ed72dcc5416 blob + dbf7e632768d4821ed24def1ead1359416248251 --- sys/dev/ic/adw.c +++ sys/dev/ic/adw.c @@ -82,7 +82,7 @@ struct cfdriver adw_cd = { NULL, "adw", DV_DULL }; -struct scsi_adapter adw_switch = { +const struct scsi_adapter adw_switch =
atascsi: constify method tables
This constifies the method tables used by the atascsi framework and the ahci(4) and sili(4) drivers. ok? diff 9939c0709df17eb9b8160ad1561241ed2c4b8922 83fd09f48cb0df5e29a782b651c4210e90f90b00 blob - 46c681203e8e39e25167f98907a2ecc848e9d1a4 blob + 19f61480e83314afe9d58d24b52e1b1d7e64ea93 --- sys/dev/ata/atascsi.c +++ sys/dev/ata/atascsi.c @@ -42,7 +42,7 @@ struct atascsi { struct atascsi_host_port **as_host_ports; - struct atascsi_methods *as_methods; + const struct atascsi_methods *as_methods; struct scsi_adapter as_switch; struct scsibus_softc*as_scsibus; blob - a992001e82c39dbc9305141c08264956e890348b blob + bf39ea0667b241a5cfc1118ed3890d2d6cf967f6 --- sys/dev/ata/atascsi.h +++ sys/dev/ata/atascsi.h @@ -374,7 +374,7 @@ struct atascsi_methods { struct atascsi_attach_args { void*aaa_cookie; - struct atascsi_methods *aaa_methods; + const struct atascsi_methods *aaa_methods; void(*aaa_minphys)(struct buf *, struct scsi_link *); int aaa_nports; blob - 571b29c29c4bd1113fca3314b6cf50f95db89bd0 blob + 46bf2f4526aa772461a011abe35a837c0d8ef300 --- sys/dev/ic/ahci.c +++ sys/dev/ic/ahci.c @@ -160,7 +160,7 @@ struct ata_xfer * ahci_ata_get_xfer(void *, int); void ahci_ata_put_xfer(struct ata_xfer *); void ahci_ata_cmd(struct ata_xfer *); -struct atascsi_methods ahci_atascsi_methods = { +const struct atascsi_methods ahci_atascsi_methods = { ahci_ata_probe, ahci_ata_free, ahci_ata_get_xfer, blob - b2df117d41b126204e110facccb6dc7050dea347 blob + fecd665bfe4f985c244fc281e861cf62ebef615b --- sys/dev/ic/sili.c +++ sys/dev/ic/sili.c @@ -202,7 +202,7 @@ voidsili_simulate_error(struct sili_ccb *ccb, int *need_restart, int *err_port); #endif -struct atascsi_methods sili_atascsi_methods = { +const struct atascsi_methods sili_atascsi_methods = { sili_ata_probe, sili_ata_free, sili_ata_get_xfer, -- Christian "naddy" Weisgerber na...@mips.inka.de
uoak*(4): constify method tables
This constifies the method tables in the OAK USB sensor drivers. Bycatch from the ucom changes. ok? diff b29fcdeeb3e7dfaa7565194eb526a7ece255a8a8 9939c0709df17eb9b8160ad1561241ed2c4b8922 blob - 789cef98e6a9a4d88bbb19b33e1801396618c591 blob + 511c0e62aec982253cdf4b27ae2af3e020cc6f9f --- sys/dev/usb/uoak.h +++ sys/dev/usb/uoak.h @@ -133,7 +133,7 @@ struct uoak_softc { struct uoak_config sc_config[OAK_TARGET_MAXTYPES]; /* device specific methods */ - struct uoak_methods *sc_methods; + const struct uoak_methods *sc_methods; }; blob - d04fd5c5823740d5071c611c07f0dbe6249f6dfc blob + 1ce4d75968d1031d4a610fd0535e46491874cd63 --- sys/dev/usb/uoaklux.c +++ sys/dev/usb/uoaklux.c @@ -96,7 +96,7 @@ const struct cfattach uoaklux_ca = { uoaklux_detach, }; -struct uoak_methods uoaklux_methods = { +const struct uoak_methods uoaklux_methods = { uoaklux_dev_print, uoaklux_dev_setting }; blob - 0257f4ee36873f494ad336150b26a3d51aa302e9 blob + ad54d29cdaf560cbc7120d846ee416bb59204b6f --- sys/dev/usb/uoakrh.c +++ sys/dev/usb/uoakrh.c @@ -99,7 +99,7 @@ const struct cfattach uoakrh_ca = { uoakrh_detach, }; -struct uoak_methods uoakrh_methods = { +const struct uoak_methods uoakrh_methods = { uoakrh_dev_print, uoakrh_dev_setting }; blob - 011f5c858aa4c9b5d39a472a10eae7e05ba7148c blob + 9f53491997ad6c1f3487079aca808a3046d2fb37 --- sys/dev/usb/uoakv.c +++ sys/dev/usb/uoakv.c @@ -100,7 +100,7 @@ const struct cfattach uoakv_ca = { }; -struct uoak_methods uoakv_methods = { +const struct uoak_methods uoakv_methods = { uoakv_dev_print, uoakv_dev_setting }; -- Christian "naddy" Weisgerber na...@mips.inka.de
ucom(4): constify method tables in USB serial drivers
This constifies the ucom method tables in the USB serial adapter drivers, i.e., moves another kilobyte of function pointers into read-only space. ok? diff 4df278d953b03573222cb39b422e005d4701614e b29fcdeeb3e7dfaa7565194eb526a7ece255a8a8 blob - 0f5d4bed40c58062bd043d0366485629d59c53cd blob + bb96ad9ba3263b2647683d45bbb429ee0821c66e --- sys/dev/usb/moscom.c +++ sys/dev/usb/moscom.c @@ -145,7 +145,7 @@ int moscom_param(void *, int, struct termios *); intmoscom_open(void *, int); intmoscom_cmd(struct moscom_softc *, int, int); -struct ucom_methods moscom_methods = { +const struct ucom_methods moscom_methods = { NULL, moscom_set, moscom_param, blob - 10b5df793ce6c39a343cedc1b375831fd7111fa9 blob + 02460365a0dbdd5f7dea9adb18da1667f224a2cb --- sys/dev/usb/uark.c +++ sys/dev/usb/uark.c @@ -72,7 +72,7 @@ int uark_param(void *, int, struct termios *); void uark_break(void *, int, int); intuark_cmd(struct uark_softc *, uint16_t, uint16_t); -struct ucom_methods uark_methods = { +const struct ucom_methods uark_methods = { uark_get_status, uark_set, uark_param, blob - 1ca8871433d18ee8f427b1d25179e04e57e01c74 blob + 537ce7248f148f73e7343eaa041e15de8ec3eac6 --- sys/dev/usb/ubsa.c +++ sys/dev/usb/ubsa.c @@ -178,7 +178,7 @@ void ubsa_databits(struct ubsa_softc *, tcflag_t); void ubsa_stopbits(struct ubsa_softc *, tcflag_t); void ubsa_flow(struct ubsa_softc *, tcflag_t, tcflag_t); -struct ucom_methods ubsa_methods = { +const struct ucom_methods ubsa_methods = { ubsa_get_status, ubsa_set, ubsa_param, blob - 654b891542c81e1728ff9c49813441fe2da45048 blob + c8582f320d5756565f5b0e0398f7a91c4496d415 --- sys/dev/usb/uchcom.c +++ sys/dev/usb/uchcom.c @@ -215,7 +215,7 @@ int uchcom_match(struct device *, void *, void *); void uchcom_attach(struct device *, struct device *, void *); intuchcom_detach(struct device *, int); -struct ucom_methods uchcom_methods = { +const struct ucom_methods uchcom_methods = { uchcom_get_status, uchcom_set, uchcom_param, blob - 8a4482fac9b511186211a5c3c83421da3db249b8 blob + 90fa0e99d53283b3d05b62d506a8bc0265698550 --- sys/dev/usb/ucom.c +++ sys/dev/usb/ucom.c @@ -102,7 +102,7 @@ struct ucom_softc { struct usbd_pipe*sc_ipipe; /* hid interrupt input pipe */ struct usbd_pipe*sc_opipe; /* hid interrupt pipe */ - struct ucom_methods *sc_methods; + const struct ucom_methods *sc_methods; void*sc_parent; int sc_portno; blob - 216725b439b347c9acc33a5ff3c46a6ac1a49aea blob + 321eed5ce3d61e64ed374b74f0555941e4a61f6b --- sys/dev/usb/ucomvar.h +++ sys/dev/usb/ucomvar.h @@ -93,7 +93,7 @@ struct ucom_attach_args { const char *info; /* attach message */ struct usbd_device *device; struct usbd_interface *iface; - struct ucom_methods *methods; + const struct ucom_methods *methods; void *arg; }; blob - 4136a4752bd02d1ff2baf1665825a5b88339a782 blob + 9d17df368adb089ba19af989396808651720f271 --- sys/dev/usb/ucrcom.c +++ sys/dev/usb/ucrcom.c @@ -36,7 +36,7 @@ struct ucrcom_softc { struct device *sc_subdev; }; -struct ucom_methods ucrcom_methods = { NULL }; +const struct ucom_methods ucrcom_methods = { NULL }; int ucrcom_match(struct device *, void *, void *); void ucrcom_attach(struct device *, struct device *, void *); blob - cd1feaeedc005b29b1ec3b15388d0ea4fb3578e7 blob + d3bd683db41e947ada0caf3db8e8a5ea1caaa8bd --- sys/dev/usb/ucycom.c +++ sys/dev/usb/ucycom.c @@ -129,7 +129,7 @@ voiducycom_close(void *, int); void ucycom_write(void *, int, u_char *, u_char *, u_int32_t *); void ucycom_read(void *, int, u_char **, u_int32_t *); -struct ucom_methods ucycom_methods = { +const struct ucom_methods ucycom_methods = { NULL, /* ucycom_get_status, */ ucycom_set, ucycom_param, blob - fb7b8ae8621207b77e449e1461ad0fab764f1378 blob + 2e3f33863d4e3f91459a29a3bff05c585fdba167 --- sys/dev/usb/uftdi.c +++ sys/dev/usb/uftdi.c @@ -100,7 +100,7 @@ voiduftdi_break(void *sc, int portno, int onoff); intuftdi_8u232am_getrate(speed_t speed, int *rate); intuftdi_2232h_getrate(speed_t speed, int *rate); -struct ucom_methods uftdi_methods = { +const struct ucom_methods uftdi_methods = { uftdi_get_status, uftdi_set, uftdi_param, blob - 7ab16eb894ec27b7ad3e4c4783b342cffcd273c1 blob + dc2321ebfc86883ca67de5f913e3c6acc7eb4434 --- sys/dev/usb/uipaq.c +++ sys/dev/usb/uipaq.c @@ -94,7 +94,7 @@ void uipaq_rts(struct uipaq_softc *sc, int onoff); void uipaq_break(struct uipaq_softc* sc, int onoff); -struct ucom_methods uipaq_methods = { +const struct ucom_methods uipaq_methods = { NULL, uipaq_set, NULL, blob - be42faf696ebae3710e7aafe33a77481e28c9cfa blob +
[ouex]hci(4), dwctwo(4): constify bus/pipe method tables
This constifies the bus method and pipe method tables in our USB host controller drivers. dwctwo(4) only exists on octeon, which I don't have access to. Could somebody check that it builds? ok? diff b5489662588c813212f71c840fa931535322293d 4df278d953b03573222cb39b422e005d4701614e blob - 9b9d1635f902afef00a4111dfba8f86d13f74b4e blob + 531b5ce59fdf62019b590df2868d57cc88912f31 --- sys/dev/usb/dwc2/dwc2.c +++ sys/dev/usb/dwc2/dwc2.c @@ -146,7 +146,7 @@ dwc2_free_bus_bandwidth(struct dwc2_hsotg *hsotg, u16 #define DWC2_INTR_ENDPT 1 -STATIC struct usbd_bus_methods dwc2_bus_methods = { +STATIC const struct usbd_bus_methods dwc2_bus_methods = { .open_pipe =dwc2_open, .dev_setaddr = dwc2_setaddr, .soft_intr =dwc2_softintr, @@ -155,7 +155,7 @@ STATIC struct usbd_bus_methods dwc2_bus_methods = { .freex =dwc2_freex, }; -STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods = { +STATIC const struct usbd_pipe_methods dwc2_root_ctrl_methods = { .transfer = dwc2_root_ctrl_transfer, .start =dwc2_root_ctrl_start, .abort =dwc2_root_ctrl_abort, @@ -164,7 +164,7 @@ STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods .done = dwc2_root_ctrl_done, }; -STATIC struct usbd_pipe_methods dwc2_root_intr_methods = { +STATIC const struct usbd_pipe_methods dwc2_root_intr_methods = { .transfer = dwc2_root_intr_transfer, .start =dwc2_root_intr_start, .abort =dwc2_root_intr_abort, @@ -173,7 +173,7 @@ STATIC struct usbd_pipe_methods dwc2_root_intr_methods .done = dwc2_root_intr_done, }; -STATIC struct usbd_pipe_methods dwc2_device_ctrl_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_ctrl_methods = { .transfer = dwc2_device_ctrl_transfer, .start =dwc2_device_ctrl_start, .abort =dwc2_device_ctrl_abort, @@ -182,7 +182,7 @@ STATIC struct usbd_pipe_methods dwc2_device_ctrl_metho .done = dwc2_device_ctrl_done, }; -STATIC struct usbd_pipe_methods dwc2_device_intr_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_intr_methods = { .transfer = dwc2_device_intr_transfer, .start =dwc2_device_intr_start, .abort =dwc2_device_intr_abort, @@ -191,7 +191,7 @@ STATIC struct usbd_pipe_methods dwc2_device_intr_metho .done = dwc2_device_intr_done, }; -STATIC struct usbd_pipe_methods dwc2_device_bulk_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_bulk_methods = { .transfer = dwc2_device_bulk_transfer, .start =dwc2_device_bulk_start, .abort =dwc2_device_bulk_abort, @@ -200,7 +200,7 @@ STATIC struct usbd_pipe_methods dwc2_device_bulk_metho .done = dwc2_device_bulk_done, }; -STATIC struct usbd_pipe_methods dwc2_device_isoc_methods = { +STATIC const struct usbd_pipe_methods dwc2_device_isoc_methods = { .transfer = dwc2_device_isoc_transfer, .start =dwc2_device_isoc_start, .abort =dwc2_device_isoc_abort, blob - 350580c00b30f8edcfd5edf8ad8d1734624462c6 blob + 77c170f164432f7df92fe7dcd64b5df9fd079dd9 --- sys/dev/usb/ehci.c +++ sys/dev/usb/ehci.c @@ -218,7 +218,7 @@ voidehci_dump_exfer(struct ehci_xfer *); #define EHCI_INTR_ENDPT 1 -struct usbd_bus_methods ehci_bus_methods = { +const struct usbd_bus_methods ehci_bus_methods = { .open_pipe = ehci_open, .dev_setaddr = ehci_setaddr, .soft_intr = ehci_softintr, @@ -227,7 +227,7 @@ struct usbd_bus_methods ehci_bus_methods = { .freex = ehci_freex, }; -struct usbd_pipe_methods ehci_root_ctrl_methods = { +const struct usbd_pipe_methods ehci_root_ctrl_methods = { .transfer = ehci_root_ctrl_transfer, .start = ehci_root_ctrl_start, .abort = ehci_root_ctrl_abort, @@ -235,7 +235,7 @@ struct usbd_pipe_methods ehci_root_ctrl_methods = { .done = ehci_root_ctrl_done, }; -struct usbd_pipe_methods ehci_root_intr_methods = { +const struct usbd_pipe_methods ehci_root_intr_methods = { .transfer = ehci_root_intr_transfer, .start = ehci_root_intr_start, .abort = ehci_root_intr_abort, @@ -243,7 +243,7 @@ struct usbd_pipe_methods ehci_root_intr_methods = { .done = ehci_root_intr_done, }; -struct usbd_pipe_methods ehci_device_ctrl_methods = { +const struct usbd_pipe_methods ehci_device_ctrl_methods = { .transfer = ehci_device_ctrl_transfer, .start = ehci_device_ctrl_start, .abort = ehci_device_ctrl_abort, @@ -251,7 +251,7 @@ struct usbd_pipe_methods ehci_device_ctrl_methods = { .done = ehci_device_ctrl_done, }; -struct usbd_pipe_methods ehci_device_intr_methods = { +const struct usbd_pipe_methods ehci_device_intr_methods = { .transfer = ehci_device_intr_transfer, .start = ehci_device_intr_start, .abort =
esm(4/i386), it(4): constify sensor tables
This constifies the tables of two unrelated sensor drivers: esm(4/i386) and it(4). ok? diff d6a09d27ff49886a6b6f4bd1f7d89c0f90a64b40 refs/heads/const blob - 0a734dc971d9402e738d08d014555c8afb95827b blob + e8a4e5eeadcdcfd23c1dd525470e70522272676b --- sys/arch/i386/i386/esm.c +++ sys/arch/i386/i386/esm.c @@ -68,7 +68,7 @@ enum esm_sensor_type { * map esm sensor types to kernel sensor types. * keep this in sync with the esm_sensor_type enum above. */ -enum sensor_type esm_typemap[] = { +const enum sensor_type esm_typemap[] = { SENSOR_INTEGER, SENSOR_INDICATOR, SENSOR_TEMP, @@ -149,7 +149,7 @@ voidesm_refresh(void *); intesm_get_devmap(struct esm_softc *, int, struct esm_devmap *); void esm_devmap(struct esm_softc *, struct esm_devmap *); void esm_make_sensors(struct esm_softc *, struct esm_devmap *, - struct esm_sensor_map *, int); + const struct esm_sensor_map *, int); intesm_thresholds(struct esm_softc *, struct esm_devmap *, struct esm_sensor *); @@ -536,7 +536,7 @@ esm_get_devmap(struct esm_softc *sc, int dev, struct e return (0); } -struct esm_sensor_map esm_sensors_esm2[] = { +const struct esm_sensor_map esm_sensors_esm2[] = { { ESM_S_UNKNOWN,0, "Motherboard" }, { ESM_S_TEMP, 0, "CPU 1" }, { ESM_S_TEMP, 0, "CPU 2" }, @@ -604,7 +604,7 @@ struct esm_sensor_map esm_sensors_esm2[] = { { ESM_S_UNKNOWN,0, "PS Over Temp" } }; -struct esm_sensor_map esm_sensors_backplane[] = { +const struct esm_sensor_map esm_sensors_backplane[] = { { ESM_S_UNKNOWN,0, "Backplane" }, { ESM_S_UNKNOWN,0, "Backplane Control" }, { ESM_S_TEMP, 0, "Backplane Top" }, @@ -639,7 +639,7 @@ struct esm_sensor_map esm_sensors_backplane[] = { { ESM_S_VOLTS, 0, "Backplane +3.3V" }, }; -struct esm_sensor_map esm_sensors_powerunit[] = { +const struct esm_sensor_map esm_sensors_powerunit[] = { { ESM_S_UNKNOWN,0, "Power Unit" }, { ESM_S_VOLTSx10, 0, "Power Supply 1 +5V" }, { ESM_S_VOLTSx10, 0, "Power Supply 1 +12V" }, @@ -698,7 +698,7 @@ struct esm_sensor_map esm_sensors_powerunit[] = { void esm_devmap(struct esm_softc *sc, struct esm_devmap *devmap) { - struct esm_sensor_map *sensor_map = NULL; + const struct esm_sensor_map *sensor_map = NULL; const char *name = NULL, *fname = NULL; int mapsize = 0; @@ -828,7 +828,7 @@ esm_devmap(struct esm_softc *sc, struct esm_devmap *de void esm_make_sensors(struct esm_softc *sc, struct esm_devmap *devmap, -struct esm_sensor_map *sensor_map, int mapsize) +const struct esm_sensor_map *sensor_map, int mapsize) { struct esm_smb_req req; struct esm_smb_resp resp; blob - 9cdce94a36e88fb46230424e35e0ef1d9c3a8878 blob + 2b8109ca2fa617f88eb012b0dcd0fd040c01 --- sys/dev/isa/it.c +++ sys/dev/isa/it.c @@ -70,7 +70,7 @@ int it_wdog_cb(void *, int); #define RFACT(x, y)(RFACT_NONE * ((x) + (y)) / (y)) -struct { +const struct { enum sensor_typetype; const char *desc; } it_sensors[IT_EC_NUMSENSORS] = { @@ -102,7 +102,7 @@ struct { }; /* rfact values for voltage sensors */ -int it_vrfact[IT_VOLT_COUNT] = { +const int it_vrfact[IT_VOLT_COUNT] = { RFACT_NONE, /* VCORE_A */ RFACT_NONE, /* VCORE_A */ RFACT_NONE, /* +3.3V*/ @@ -114,12 +114,12 @@ int it_vrfact[IT_VOLT_COUNT] = { RFACT_NONE /* VBAT */ }; -int it_fan_regs[] = { +const int it_fan_regs[] = { IT_EC_FAN_TAC1, IT_EC_FAN_TAC2, IT_EC_FAN_TAC3, IT_EC_FAN_TAC4_LSB, IT_EC_FAN_TAC5_LSB }; -int it_fan_ext_regs[] = { +const int it_fan_ext_regs[] = { IT_EC_FAN_EXT_TAC1, IT_EC_FAN_EXT_TAC2, IT_EC_FAN_EXT_TAC3, IT_EC_FAN_TAC4_MSB, IT_EC_FAN_TAC5_MSB }; -- Christian "naddy" Weisgerber na...@mips.inka.de
lm, uguru, fins, wbenv: constify sensor tables
This constifies the sensor tables of the lm(4), uguru(4), fins(4), and wbenv(4) drivers, which all share the same basic design. ok? diff refs/heads/master refs/heads/const_sensors blob - a813447ec9521a2a11a8b1f5daa38b881da007c1 blob + 3a1b2bfdc2b1d92d62f3b156479ad0ff5b57e463 --- sys/dev/i2c/w83l784r.c +++ sys/dev/i2c/w83l784r.c @@ -80,14 +80,14 @@ struct wbenv_softc { struct ksensor sc_sensors[WBENV_MAX_SENSORS]; struct ksensordev sc_sensordev; - struct wbenv_sensor *sc_wbenv_sensors; + const struct wbenv_sensor *sc_wbenv_sensors; int sc_numsensors; }; intwbenv_match(struct device *, void *, void *); void wbenv_attach(struct device *, struct device *, void *); -void wbenv_setup_sensors(struct wbenv_softc *, struct wbenv_sensor *); +void wbenv_setup_sensors(struct wbenv_softc *, const struct wbenv_sensor *); void wbenv_refresh(void *); void w83l784r_refresh_volt(struct wbenv_softc *, int); @@ -108,7 +108,7 @@ struct cfdriver wbenv_cd = { NULL, "wbenv", DV_DULL }; -struct wbenv_sensor w83l784r_sensors[] = +const struct wbenv_sensor w83l784r_sensors[] = { { "VCore", SENSOR_VOLTS_DC, W83L784R_VCORE, w83l784r_refresh_volt, RFACT_NONE }, { "VBAT", SENSOR_VOLTS_DC, W83L784R_VBAT, w83l784r_refresh_volt, RFACT(232, 99) }, @@ -123,7 +123,7 @@ struct wbenv_sensor w83l784r_sensors[] = { NULL } }; -struct wbenv_sensor w83l785r_sensors[] = +const struct wbenv_sensor w83l785r_sensors[] = { { "VCore", SENSOR_VOLTS_DC, W83L784R_VCORE, w83l785r_refresh_volt, RFACT_NONE }, { "+2.5V", SENSOR_VOLTS_DC, W83L785R_2_5V, w83l785r_refresh_volt, RFACT(100, 100) }, @@ -137,7 +137,7 @@ struct wbenv_sensor w83l785r_sensors[] = { NULL } }; -struct wbenv_sensor w83l785ts_l_sensors[] = +const struct wbenv_sensor w83l785ts_l_sensors[] = { { "", SENSOR_TEMP, W83L784R_TEMP1, wbenv_refresh_temp }, @@ -236,7 +236,7 @@ wbenv_attach(struct device *parent, struct device *sel } void -wbenv_setup_sensors(struct wbenv_softc *sc, struct wbenv_sensor *sensors) +wbenv_setup_sensors(struct wbenv_softc *sc, const struct wbenv_sensor *sensors) { int i; blob - 88538623a7a7681f9cee6206fe48770a41b700ab blob + be17af240b07da9bd1168d748354440d763a0419 --- sys/dev/ic/lm78.c +++ sys/dev/ic/lm78.c @@ -51,7 +51,7 @@ int lm_match(struct lm_softc *); int wb_match(struct lm_softc *); int def_match(struct lm_softc *); -void lm_setup_sensors(struct lm_softc *, struct lm_sensor *); +void lm_setup_sensors(struct lm_softc *, const struct lm_sensor *); void lm_refresh(void *); void lm_refresh_sensor_data(struct lm_softc *); @@ -74,13 +74,13 @@ struct lm_chip { int (*chip_match)(struct lm_softc *); }; -struct lm_chip lm_chips[] = { +const struct lm_chip lm_chips[] = { { wb_match }, { lm_match }, { def_match } /* Must be last */ }; -struct lm_sensor lm78_sensors[] = { +const struct lm_sensor lm78_sensors[] = { /* Voltage */ { "VCore A", SENSOR_VOLTS_DC, 0, 0x20, lm_refresh_volt, RFACT_NONE }, { "VCore B", SENSOR_VOLTS_DC, 0, 0x21, lm_refresh_volt, RFACT_NONE }, @@ -101,7 +101,7 @@ struct lm_sensor lm78_sensors[] = { { NULL } }; -struct lm_sensor w83627hf_sensors[] = { +const struct lm_sensor w83627hf_sensors[] = { /* Voltage */ { "VCore A", SENSOR_VOLTS_DC, 0, 0x20, lm_refresh_volt, RFACT_NONE }, { "VCore B", SENSOR_VOLTS_DC, 0, 0x21, lm_refresh_volt, RFACT_NONE }, @@ -133,7 +133,7 @@ struct lm_sensor w83627hf_sensors[] = { * need special treatment, also because the reference voltage is 2.048 V * instead of the traditional 3.6 V. */ -struct lm_sensor w83627ehf_sensors[] = { +const struct lm_sensor w83627ehf_sensors[] = { /* Voltage */ { "VCore", SENSOR_VOLTS_DC, 0, 0x20, lm_refresh_volt, RFACT_NONE / 2}, { "+12V", SENSOR_VOLTS_DC, 0, 0x21, lm_refresh_volt, RFACT(56, 10) / 2 }, @@ -163,7 +163,7 @@ struct lm_sensor w83627ehf_sensors[] = { * w83627dhg is almost identical to w83627ehf, except that * it has 9 instead of 10 voltage sensors */ -struct lm_sensor w83627dhg_sensors[] = { +const struct lm_sensor w83627dhg_sensors[] = { /* Voltage */ { "VCore", SENSOR_VOLTS_DC, 0, 0x20, lm_refresh_volt, RFACT_NONE / 2}, { "+12V", SENSOR_VOLTS_DC, 0, 0x21, lm_refresh_volt, RFACT(56, 10) / 2 }, @@ -188,7 +188,7 @@ struct lm_sensor w83627dhg_sensors[] = { { NULL } }; -struct lm_sensor nct6776f_sensors[] = { +const struct lm_sensor nct6776f_sensors[] = { /* Voltage */ { "VCore", SENSOR_VOLTS_DC, 0, 0x20, lm_refresh_volt, RFACT_NONE / 2}, { "+12V", SENSOR_VOLTS_DC, 0, 0x21, lm_refresh_volt, RFACT(56, 10) / 2 }, @@ -216,7 +216,7 @@ struct lm_sensor nct6776f_sensors[] = { }; /* NCT6779D */ -struct lm_sensor nct6779d_sensors[] = { +const struct lm_sensor nct6779d_sensors[] = { /* Voltage */ { "VCore",
Constify ifmedia descriptions
This constifies the ifmedia description tables, both in the kernel (yes, I did a test compile with option IFMEDIA_DEBUG) and one straggler in userland. ok? diff 3c78bc9451ce7ce927aaecc9f8e5113de7023a9c /usr/src blob - 0ef67c56edd8be741533ccba974c11f198887b32 file + sbin/ifconfig/ifconfig.c --- sbin/ifconfig/ifconfig.c +++ sbin/ifconfig/ifconfig.c @@ -3062,7 +3062,7 @@ const struct ifmedia_description ifm_type_descriptions const struct ifmedia_description ifm_subtype_descriptions[] = IFM_SUBTYPE_DESCRIPTIONS; -struct ifmedia_description ifm_mode_descriptions[] = +const struct ifmedia_description ifm_mode_descriptions[] = IFM_MODE_DESCRIPTIONS; const struct ifmedia_description ifm_option_descriptions[] = blob - e71f433cfa6b61350625308c1328bb8e288e9dd5 file + sys/net/if_media.c --- sys/net/if_media.c +++ sys/net/if_media.c @@ -393,7 +393,7 @@ ifmedia_delete_instance(struct ifmedia *ifm, uint64_t * Compute the interface `baudrate' from the media, for the interface * metrics (used by routing daemons). */ -struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = +const struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = IFM_BAUDRATE_DESCRIPTIONS; uint64_t @@ -413,13 +413,13 @@ ifmedia_baudrate(uint64_t mword) #ifdef IFMEDIA_DEBUG -struct ifmedia_description ifm_type_descriptions[] = +const struct ifmedia_description ifm_type_descriptions[] = IFM_TYPE_DESCRIPTIONS; -struct ifmedia_description ifm_subtype_descriptions[] = +const struct ifmedia_description ifm_subtype_descriptions[] = IFM_SUBTYPE_DESCRIPTIONS; -struct ifmedia_description ifm_option_descriptions[] = +const struct ifmedia_description ifm_option_descriptions[] = IFM_OPTION_DESCRIPTIONS; /* @@ -428,7 +428,7 @@ struct ifmedia_description ifm_option_descriptions[] = static void ifmedia_printword(uint64_t ifmw) { - struct ifmedia_description *desc; + const struct ifmedia_description *desc; uint64_t seen_option = 0; /* Print the top-level interface type. */ -- Christian "naddy" Weisgerber na...@mips.inka.de
wscons: const-ify font encoding tables
You'd think that the kernel font bitmaps are a primary example of data that could be read-only... and you'd be wrong. The font encoding tables however are indeed constant as far as I can tell. The diff below marks them as such. NetBSD has the same. ok? diff e8186ba8726c14dfc3512467cc2bc0b2ae1a3fdb c899115edffe4038f3d32db09d2986467ad3aa5a blob - 7b6df0924cc0f109d62e7fda235625adf54d5667 blob + 7354a996595496b0fef0c324d878367c2a19feb9 --- sys/dev/wsfont/wsfont.c +++ sys/dev/wsfont/wsfont.c @@ -630,23 +630,23 @@ wsfont_unlock(int cookie) */ struct wsfont_level1_glyphmap { - struct wsfont_level2_glyphmap **level2; + const struct wsfont_level2_glyphmap **level2; int base; /* High byte for first level2 entry */ int size; /* Number of level2 entries */ }; struct wsfont_level2_glyphmap { - int base; /* Low byte for first character */ - int size; /* Number of characters */ - void *chars;/* Pointer to character number entries */ - int width; /* Size of each entry in bytes (1,2,4) */ + int base; /* Low byte for first character */ + int size; /* Number of characters */ + const void *chars; /* Pointer to character number entries */ + int width; /* Size of each entry in bytes (1,2,4) */ }; /* * IBM 437 maps */ -static u_int8_t +static const u_int8_t ibm437_chars_0[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -706,7 +706,7 @@ ibm437_chars_37[] = { 254 }; -static struct wsfont_level2_glyphmap +static const struct wsfont_level2_glyphmap ibm437_level2_0 = { 0, 256, ibm437_chars_0, 1 }, ibm437_level2_1 = { 146, 1, ibm437_chars_1, 1 }, ibm437_level2_3 = { 147, 50, ibm437_chars_3, 1 }, @@ -715,7 +715,7 @@ ibm437_level2_34 = { 5, 97, ibm437_chars_34, 1 }, ibm437_level2_35 = { 16, 18, ibm437_chars_35, 1 }, ibm437_level2_37 = { 0, 161, ibm437_chars_37, 1 }; -static struct wsfont_level2_glyphmap *ibm437_level1[] = { +static const struct wsfont_level2_glyphmap *ibm437_level1[] = { _level2_0, _level2_1, NULL, _level2_3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -728,7 +728,7 @@ static struct wsfont_level2_glyphmap *ibm437_level1[] NULL, _level2_37 }; -static struct wsfont_level1_glyphmap encodings[] = { +static const struct wsfont_level1_glyphmap encodings[] = { /* WSDISPLAY_FONTENC_ISO */ { NULL, 0, 0 }, /* WSDISPLAY_FONTENC_IBM */ @@ -749,9 +749,9 @@ wsfont_map_unichar(struct wsdisplay_font *font, int c) #if !defined(SMALL_KERNEL) if (font->encoding >= 0 && font->encoding < nitems(encodings)) { int hi = (c >> 8), lo = c & 255; - struct wsfont_level1_glyphmap *map1 = + const struct wsfont_level1_glyphmap *map1 = [font->encoding]; - struct wsfont_level2_glyphmap *map2; + const struct wsfont_level2_glyphmap *map2; hi -= map1->base; -- Christian "naddy" Weisgerber na...@mips.inka.de
ftp.1: fix editing mishap
It appears that in revision 1.85 of usr.bin/ftp/ftp.1 a sentence fragment was accidentally not removed. OK? Index: usr.bin/ftp/ftp.1 === RCS file: /cvs/src/usr.bin/ftp/ftp.1,v retrieving revision 1.122 diff -u -p -r1.122 ftp.1 --- usr.bin/ftp/ftp.1 2 Feb 2021 12:58:42 - 1.122 +++ usr.bin/ftp/ftp.1 27 Mar 2022 19:12:31 - @@ -759,9 +759,6 @@ and .Ic nmap settings. .Pp -If the -.Fl c -flag is specified then The options are as follows: .Bl -tag -width Ds .It Fl c -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Power-up cc --print-file-name for .so names
Mark Kettenis: > There is a scenario where this goes wrong. If a shared library lacks > a DT_SONAME entry, the library filename is used to generate the > DT_NEEDED entries. But I would consider such a shared library broken > and we fixed base a lng time ago. Some care has to be taken when > adding the symlinks to shared libraries in ports. But I'm sure the > package management stuff could check that shared libraries in ports > have a DT_SONAME entry. We never proceeded to clean that up in ports. I just extracted all packages from the latest amd64 snapshot, and out of a total of 3551 shared libraries, 593 do not have a SONAME. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: ypldap: fix -Wunused-but-set-variable warnings
Christian Weisgerber: > usr.sbin/ypldap: fix -Wunused-but-set-variable warnings > > * "wrlen" has been write-only since the code was imported. > * Removing "dns_pid" replicates ntpd/ntp.c 1.122 (aece4353519f). > * yp_check() looks like unfinished code. Rather than removing it > we can ifdef it out. > > ok? Anybody? The commit history of ypldap does not suggest a single responsible person I could pin down. > M usr.sbin/ypldap/entries.c > M usr.sbin/ypldap/ldapclient.c > M usr.sbin/ypldap/yp.c > > diff 34d4cced9a849c8319a25fd1cc1a7567223349c3 > 5cdc3b04d0d3c70c2a9f0393913a5fdf64c11021 > blob - 3e2cc672786cad83caac1a22dfd2516c3ae9a3eb > blob + b7394892eafe85bb1e8b9bb8e8cfdcc6658606f3 > --- usr.sbin/ypldap/entries.c > +++ usr.sbin/ypldap/entries.c > @@ -38,7 +38,6 @@ > void > flatten_entries(struct env *env) > { > - size_t wrlen; > size_t len; > char*linep; > char*endp; > @@ -54,7 +53,6 @@ flatten_entries(struct env *env) >* >* An extra octet is alloced to make space for an additional NUL. >*/ > - wrlen = env->sc_user_line_len; > if ((linep = calloc(1, env->sc_user_line_len + 1)) == NULL) { > /* >* XXX: try allocating a smaller chunk of memory > @@ -76,7 +74,6 @@ flatten_entries(struct env *env) > free(ue->ue_line); > ue->ue_line = endp; > endp += len; > - wrlen -= len; > > /* >* To save memory strdup(3) the netid_line which originally used > @@ -92,7 +89,6 @@ flatten_entries(struct env *env) > env->sc_user_lines = linep; > log_debug("done pushing users"); > > - wrlen = env->sc_group_line_len; > if ((linep = calloc(1, env->sc_group_line_len + 1)) == NULL) { > /* >* XXX: try allocating a smaller chunk of memory > @@ -113,7 +109,6 @@ flatten_entries(struct env *env) > free(ge->ge_line); > ge->ge_line = endp; > endp += len; > - wrlen -= len; > } > env->sc_group_lines = linep; > log_debug("done pushing groups"); > blob - 473986a8c5ed2449844e78cab034c6736b4a0e0f > blob + 96e502ded7e3a3428a70411e628a988b4713fa90 > --- usr.sbin/ypldap/ldapclient.c > +++ usr.sbin/ypldap/ldapclient.c > @@ -357,7 +357,7 @@ client_shutdown(void) > pid_t > ldapclient(int pipe_main2client[2]) > { > - pid_tpid, dns_pid; > + pid_tpid; > int pipe_dns[2]; > struct passwd *pw; > struct event ev_sigint; > @@ -382,7 +382,7 @@ ldapclient(int pipe_main2client[2]) > > if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_dns) == -1) > fatal("socketpair"); > - dns_pid = ypldap_dns(pipe_dns, pw); > + ypldap_dns(pipe_dns, pw); > close(pipe_dns[1]); > > #ifndef DEBUG > blob - 84b5d59102057003557b1478af1b643b5aebdc69 > blob + 02a654e1daf2087889afc61630c30c02c6492156 > --- usr.sbin/ypldap/yp.c > +++ usr.sbin/ypldap/yp.c > @@ -268,12 +268,14 @@ yp_dispatch(struct svc_req *req, SVCXPRT *trans) > int > yp_check(struct svc_req *req) > { > +#ifdef notyet > struct sockaddr_in *caller; > > caller = svc_getcaller(req->rq_xprt); > /* >* We might want to know who we allow here. >*/ > +#endif > return (0); > } > -- Christian "naddy" Weisgerber na...@mips.inka.de
Summary of remaining "set but not used" warnings
First up, note that clang 13 does not produce those "variable foo set but not used" warnings by default. They need to be enabled by -Wunused-but-set-variable or, more typically, as part of -Wall. Here are the remaining warnings seen in a "make build": bin/ksh required arguments to macros libexec/spamd ifdef'ed out error handling usr.bin/cvs unfinished code usr.sbin/vmdarguments to debugging macros Third-party code: gnu/lib/libcxxabi sbin/unwind/libunbound gnu/usr.bin/clang gnu/usr.bin/binutils gnu/usr.bin/binutils-2.17 gnu/usr.bin/perl -- Christian "naddy" Weisgerber na...@mips.inka.de
ypldap: fix -Wunused-but-set-variable warnings
usr.sbin/ypldap: fix -Wunused-but-set-variable warnings * "wrlen" has been write-only since the code was imported. * Removing "dns_pid" replicates ntpd/ntp.c 1.122 (aece4353519f). * yp_check() looks like unfinished code. Rather than removing it we can ifdef it out. ok? M usr.sbin/ypldap/entries.c M usr.sbin/ypldap/ldapclient.c M usr.sbin/ypldap/yp.c diff 34d4cced9a849c8319a25fd1cc1a7567223349c3 5cdc3b04d0d3c70c2a9f0393913a5fdf64c11021 blob - 3e2cc672786cad83caac1a22dfd2516c3ae9a3eb blob + b7394892eafe85bb1e8b9bb8e8cfdcc6658606f3 --- usr.sbin/ypldap/entries.c +++ usr.sbin/ypldap/entries.c @@ -38,7 +38,6 @@ void flatten_entries(struct env *env) { - size_t wrlen; size_t len; char*linep; char*endp; @@ -54,7 +53,6 @@ flatten_entries(struct env *env) * * An extra octet is alloced to make space for an additional NUL. */ - wrlen = env->sc_user_line_len; if ((linep = calloc(1, env->sc_user_line_len + 1)) == NULL) { /* * XXX: try allocating a smaller chunk of memory @@ -76,7 +74,6 @@ flatten_entries(struct env *env) free(ue->ue_line); ue->ue_line = endp; endp += len; - wrlen -= len; /* * To save memory strdup(3) the netid_line which originally used @@ -92,7 +89,6 @@ flatten_entries(struct env *env) env->sc_user_lines = linep; log_debug("done pushing users"); - wrlen = env->sc_group_line_len; if ((linep = calloc(1, env->sc_group_line_len + 1)) == NULL) { /* * XXX: try allocating a smaller chunk of memory @@ -113,7 +109,6 @@ flatten_entries(struct env *env) free(ge->ge_line); ge->ge_line = endp; endp += len; - wrlen -= len; } env->sc_group_lines = linep; log_debug("done pushing groups"); blob - 473986a8c5ed2449844e78cab034c6736b4a0e0f blob + 96e502ded7e3a3428a70411e628a988b4713fa90 --- usr.sbin/ypldap/ldapclient.c +++ usr.sbin/ypldap/ldapclient.c @@ -357,7 +357,7 @@ client_shutdown(void) pid_t ldapclient(int pipe_main2client[2]) { - pid_tpid, dns_pid; + pid_tpid; int pipe_dns[2]; struct passwd *pw; struct event ev_sigint; @@ -382,7 +382,7 @@ ldapclient(int pipe_main2client[2]) if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_dns) == -1) fatal("socketpair"); - dns_pid = ypldap_dns(pipe_dns, pw); + ypldap_dns(pipe_dns, pw); close(pipe_dns[1]); #ifndef DEBUG blob - 84b5d59102057003557b1478af1b643b5aebdc69 blob + 02a654e1daf2087889afc61630c30c02c6492156 --- usr.sbin/ypldap/yp.c +++ usr.sbin/ypldap/yp.c @@ -268,12 +268,14 @@ yp_dispatch(struct svc_req *req, SVCXPRT *trans) int yp_check(struct svc_req *req) { +#ifdef notyet struct sockaddr_in *caller; caller = svc_getcaller(req->rq_xprt); /* * We might want to know who we allow here. */ +#endif return (0); } -- Christian "naddy" Weisgerber na...@mips.inka.de
tcpdump: fix -Wunused-but-set-variable warning
usr.sbin/tcpdump: fix -Wunused-but-set-variable warning All "infile" handling was moved into priv_exec() when tcpdump was priviledge separated. The options are scanned both in priv_exec() and in main(), so the empty case needs to remain in the latter. ok? M usr.sbin/tcpdump/tcpdump.c diff 812c6fb40ad70885ec0ec3a47d5ae49a0c43371d 34d4cced9a849c8319a25fd1cc1a7567223349c3 blob - e0b6a4b318a21ba0c344204b7673dac3ca5dd657 blob + 50e793f63fab6e9aba2964e3a1c5eac289e06e08 --- usr.sbin/tcpdump/tcpdump.c +++ usr.sbin/tcpdump/tcpdump.c @@ -208,7 +208,7 @@ main(int argc, char **argv) { int cnt = -1, op, i; bpf_u_int32 localnet, netmask; - char *cp, *infile = NULL, *RFileName = NULL; + char *cp, *RFileName = NULL; char ebuf[PCAP_ERRBUF_SIZE], *WFileName = NULL; pcap_handler printer; struct bpf_program *fcode; @@ -285,7 +285,6 @@ main(int argc, char **argv) break; case 'F': - infile = optarg; break; case 'i': -- Christian "naddy" Weisgerber na...@mips.inka.de
Remove unused variable from _asr_strdname(), print_dname()
remove unused variable from all copies of _asr_strdname() and print_dname() This also fixes -Wunused-but-set-variable warnings warnings in smtpd and smtpctl. The code was imported with asr and then copied around. ok? M lib/libc/asr/asr.c M regress/lib/libc/asr/bin/res_mkquery.c M regress/lib/libc/asr/bin/res_query.c M usr.sbin/smtpd/unpack_dns.c diff dd8cb0714181f660d0f6f501ce5d7c09e7204a5f 643c10a8541a41ff6f22d0b0ea6d3ded75b1e2b2 blob - 7cbf6aab5c9a7e5a36e3e1708fedef9fd0874821 blob + 5a40edf5caca600968dae7629988b687b5f15c35 --- lib/libc/asr/asr.c +++ lib/libc/asr/asr.c @@ -853,7 +853,7 @@ _asr_strdname(const char *_dname, char *buf, size_t ma { const unsigned char *dname = _dname; char*res; - size_t left, n, count; + size_t left, count; if (_dname[0] == 0) { strlcpy(buf, ".", max); @@ -862,7 +862,7 @@ _asr_strdname(const char *_dname, char *buf, size_t ma res = buf; left = max - 1; - for (n = 0; dname[0] && left; n += dname[0]) { + while (dname[0] && left) { count = (dname[0] < (left - 1)) ? dname[0] : (left - 1); memmove(buf, dname + 1, count); dname += dname[0] + 1; blob - b32f471cdff9998ccd613f9c705207e9d17051e5 blob + 1228e5abc927df98ad26cc2ebdb431bd1a907f7e --- regress/lib/libc/asr/bin/res_mkquery.c +++ regress/lib/libc/asr/bin/res_mkquery.c @@ -296,7 +296,7 @@ print_dname(const char *_dname, char *buf, size_t max) { const unsigned char *dname = _dname; char*res; - size_t left, n, count; + size_t left, count; if (_dname[0] == 0) { strlcpy(buf, ".", max); @@ -305,7 +305,7 @@ print_dname(const char *_dname, char *buf, size_t max) res = buf; left = max - 1; - for (n = 0; dname[0] && left; n += dname[0]) { + while (dname[0] && left) { count = (dname[0] < (left - 1)) ? dname[0] : (left - 1); memmove(buf, dname + 1, count); dname += dname[0] + 1; blob - ca95a89a7ccdb300ca060589bf77203712306e54 blob + 1309a5724014c9d2e8f8352e12ba80db03b0be89 --- regress/lib/libc/asr/bin/res_query.c +++ regress/lib/libc/asr/bin/res_query.c @@ -332,7 +332,7 @@ print_dname(const char *_dname, char *buf, size_t max) { const unsigned char *dname = _dname; char*res; - size_t left, n, count; + size_t left, count; if (_dname[0] == 0) { strlcpy(buf, ".", max); @@ -341,7 +341,7 @@ print_dname(const char *_dname, char *buf, size_t max) res = buf; left = max - 1; - for (n = 0; dname[0] && left; n += dname[0]) { + while (dname[0] && left) { count = (dname[0] < (left - 1)) ? dname[0] : (left - 1); memmove(buf, dname + 1, count); dname += dname[0] + 1; blob - fd7ec6ba6e0b745cb04a151994bcb5a51db110ae blob + 848d2be321d82a14a9da83f4f034924592377862 --- usr.sbin/smtpd/unpack_dns.c +++ usr.sbin/smtpd/unpack_dns.c @@ -195,7 +195,7 @@ print_dname(const char *_dname, char *buf, size_t max) { const unsigned char *dname = _dname; char*res; - size_t left, n, count; + size_t left, count; if (_dname[0] == 0) { (void)strlcpy(buf, ".", max); @@ -204,7 +204,7 @@ print_dname(const char *_dname, char *buf, size_t max) res = buf; left = max - 1; - for (n = 0; dname[0] && left; n += dname[0]) { + while (dname[0] && left) { count = (dname[0] < (left - 1)) ? dname[0] : (left - 1); memmove(buf, dname + 1, count); dname += dname[0] + 1; -- Christian "naddy" Weisgerber na...@mips.inka.de
usr.sbin/rad: fix -Wunused-but-set-variable warning
usr.sbin/rad: fix -Wunused-but-set-variable warning Trivial removal of unused variable. M usr.sbin/rad/frontend.c diff c9fb0989c5128843af76d1ecd08c6f483f233307 1779a21799642d5916a407f0cea6255b101c055c blob - e6f6ae0419ab1662ebb2e8cdd17c07a82d1b87f9 blob + afddc245017e4576571e89b17f3655d352dc1d0f --- usr.sbin/rad/frontend.c +++ usr.sbin/rad/frontend.c @@ -1222,10 +1222,7 @@ void build_leaving_packet(struct ra_iface *ra_iface) { struct nd_router_advert ra; - size_t len; - len = sizeof(ra); - memset(, 0, sizeof(ra)); ra.nd_ra_type = ND_ROUTER_ADVERT; -- Christian "naddy" Weisgerber na...@mips.inka.de
usr.sbin/ospf6ctl: fix -Wunused-but-set-variable warning
usr.sbin/ospf6ctl: fix -Wunused-but-set-variable warning Maybe this is uncompleted code, but I think we can remove it for the time being. M usr.sbin/ospf6ctl/ospf6ctl.c diff a992977b148f5fd9d4e3b9af9aeccac488edfa7a c9fb0989c5128843af76d1ecd08c6f483f233307 blob - fa1dc2cfd77369dc6964a6f18f6b562aa6598e5d blob + 0b943bd96a7c01981563c172c524f70b4a7bd66e --- usr.sbin/ospf6ctl/ospf6ctl.c +++ usr.sbin/ospf6ctl/ospf6ctl.c @@ -1179,9 +1179,7 @@ print_ospf_rtr_flags(u_int8_t opts) int show_rib_detail_msg(struct imsg *imsg) { - static struct in_addrarea_id; struct ctl_rt *rt; - struct area *area; char*dstnet; static u_int8_t lasttype; @@ -1250,8 +1248,6 @@ show_rib_detail_msg(struct imsg *imsg) } break; case IMSG_CTL_AREA: - area = imsg->data; - area_id = area->id; break; case IMSG_CTL_END: printf("\n"); -- Christian "naddy" Weisgerber na...@mips.inka.de
usr.sbin/ospf6d: fix -Wunused-but-set-variable warnings
usr.sbin/ospf6d: fix -Wunused-but-set-variable warnings merge_config() sets "rchange", but doesn't use it. Comparing the code to osfpd/ospfd.c makes me think that's an omission. Either way it seems odd that the two code bases differ here. rde_summary_update() is incomplete. We can simply #ifdef out the unused variables. The lack of indentation or braces following an "else" is not pretty. I don't know if we want to fix that up. M usr.sbin/ospf6d/ospf6d.c M usr.sbin/ospf6d/rde.c diff 436bb480188bab67f704c5f9fcbcf0478db9c100 a992977b148f5fd9d4e3b9af9aeccac488edfa7a blob - b1193eaf336b9f5aa6a3b076efe4080881829152 blob + af22bd43781a4eaa32b5454fe8fa4fc9992f0b4b --- usr.sbin/ospf6d/ospf6d.c +++ usr.sbin/ospf6d/ospf6d.c @@ -738,7 +738,7 @@ merge_config(struct ospfd_conf *conf, struct ospfd_con if_start(conf, iface); } } - if (a->dirty) { + if (a->dirty || rchange) { a->dirty = 0; orig_rtr_lsa(LIST_FIRST(>iface_list)->area); } blob - f4a047206ec2c2e6d2550562560d5933825fb39d blob + 4c43bb9296fef10f6d8f9e6a63fcc76e16fe5de9 --- usr.sbin/ospf6d/rde.c +++ usr.sbin/ospf6d/rde.c @@ -1249,8 +1249,10 @@ void rde_summary_update(struct rt_node *rte, struct area *area) { struct vertex *v = NULL; -//XXX struct lsa *lsa; +#if 0 /* XXX */ + struct lsa *lsa; u_int16_ttype = 0; +#endif /* first check if we actually need to announce this route */ if (!(rte->d_type == DT_NET || rte->flags & OSPF_RTR_E)) @@ -1271,13 +1273,13 @@ rde_summary_update(struct rt_node *rte, struct area *a /* TODO inter-area network route stuff */ /* TODO intra-area stuff -- condense LSA ??? */ +#if 0 /* XXX a lot todo */ if (rte->d_type == DT_NET) { type = LSA_TYPE_INTER_A_PREFIX; } else if (rte->d_type == DT_RTR) { type = LSA_TYPE_INTER_A_ROUTER; } else -#if 0 /* XXX a lot todo */ /* update lsa but only if it was changed */ v = lsa_find(area, type, rte->prefix.s_addr, rde_router_id()); lsa = orig_sum_lsa(rte, area, type, rte->invalid); -- Christian "naddy" Weisgerber na...@mips.inka.de
usr.sbin/eigrpd: fix -Wunused-but-set-variable warning
usr.sbin/eigrpd: fix -Wunused-but-set-variable warning M usr.sbin/eigrpd/rde_dual.c diff 41bbcfa017d9537de08312789d0087c674ce4732 77e83947795bf5b53aef72070d7630a825b52c1f blob - f1ed306e1371896676cf45b26e102af5e4d77b36 blob + 9465250934a6b1a5f6d565a13d32c4c450786670 --- usr.sbin/eigrpd/rde_dual.c +++ usr.sbin/eigrpd/rde_dual.c @@ -1048,11 +1048,9 @@ rde_last_reply(struct rt_node *rn) struct eigrp*eigrp = rn->eigrp; struct eigrp_route *successor; struct rde_nbr *old_successor; - uint32_t old_fdistance; struct rinfo ri; old_successor = rn->successor.nbr; - old_fdistance = rn->successor.fdistance; switch (rn->state) { case DUAL_STA_ACTIVE0: -- Christian "naddy" Weisgerber na...@mips.inka.de
usr.sbin/dvmrpctl: fix -Wunused-but-set-variable warning
usr.sbin/dvmrpctl: fix -Wunused-but-set-variable warning This looks like /* not yet implemented */, but the companion functions show_rib_detail_msg() and show_mfc_detail_msg() are equally empty. M usr.sbin/dvmrpctl/dvmrpctl.c diff 4bd575d8630c92f404211d2c625b200ac28213b9 41bbcfa017d9537de08312789d0087c674ce4732 blob - 1b06d2bd134200716094881258b254877a1bf5d1 blob + ab02e0bb29b038ddaad26a49f43ba567d43770bc --- usr.sbin/dvmrpctl/dvmrpctl.c +++ usr.sbin/dvmrpctl/dvmrpctl.c @@ -515,11 +515,8 @@ print_dvmrp_options(u_int8_t opts) int show_nbr_detail_msg(struct imsg *imsg) { - struct ctl_nbr *nbr; - switch (imsg->hdr.type) { case IMSG_CTL_SHOW_NBR: - nbr = imsg->data; break; case IMSG_CTL_END: printf("\n"); -- Christian "naddy" Weisgerber na...@mips.inka.de
usr.sbin/dhcpd: fix -Wunused-but-set-variable warning
usr.sbin/dhcpd: fix -Wunused-but-set-variable warning I think this should be fine as strtonum() will catch any errors. M usr.sbin/dhcpd/parse.c diff 5ce17aab12dafb0a17452c4e0e86b29d89d83d13 4bd575d8630c92f404211d2c625b200ac28213b9 blob - 5b719219d00046e02e932796a78dc14ceddaa109 blob + 28334a443547ac7de98e80b4ca493429bfd60b09 --- usr.sbin/dhcpd/parse.c +++ usr.sbin/dhcpd/parse.c @@ -293,9 +293,8 @@ parse_lease_time(FILE *cfile, time_t *timep) const char *errstr; char *val; uint32_t value; - int token; - token = next_token(, cfile); + next_token(, cfile); value = strtonum(val, 0, UINT32_MAX, ); if (errstr) { -- Christian "naddy" Weisgerber na...@mips.inka.de
usr.bin/mg: fix -Wunused-but-set-variable warnings
usr.bin/mg: fix -Wunused-but-set-variable warnings * strtonum() is only called to verify that a string is numerical, the return value is unused. * inlist is no longer used after the code was refactored. OK? M usr.bin/mg/interpreter.c diff 6e5c342a53c05496c18849837c67b7dc05ce3792 5ce17aab12dafb0a17452c4e0e86b29d89d83d13 blob - 320b4089849fb28a0b1ee4ff0db2542da902d56e blob + f3a4310dfe01138c77e624877eefa92d29feb039 --- usr.bin/mg/interpreter.c +++ usr.bin/mg/interpreter.c @@ -492,9 +492,8 @@ multiarg(char *cmdp, char *argbuf, int numparams) if (!doregex(regs, argp)) { const char *errstr; - int iters; - iters = strtonum(argp, 0, INT_MAX, ); + strtonum(argp, 0, INT_MAX, ); if (errstr != NULL) return (dobeep_msgs("Var not found:", argp)); @@ -628,7 +627,7 @@ expandvals(char *cmdp, char *valp, char *bp) char*argp, *endp, *p, *v, *s = " "; char*regs; int spc, cnt; - int inlist, sizof, fin, inquote; + int sizof, fin, inquote; /* now find the first argument */ p = skipwhite(valp); @@ -637,7 +636,7 @@ expandvals(char *cmdp, char *valp, char *bp) return (dobeep_msg("strlcpy error")); argp = argbuf; spc = 1; /* initially fake a space so we find first argument */ - inlist = fin = inquote = cnt = spc = 0; + fin = inquote = cnt = spc = 0; for (p = argbuf; *p != '\0'; p++) { if (*(p + 1) == '\0') @@ -693,9 +692,8 @@ expandvals(char *cmdp, char *valp, char *bp) continue; } else { const char *errstr; - int iters; - iters = strtonum(argp, 0, INT_MAX, ); + strtonum(argp, 0, INT_MAX, ); if (errstr != NULL) return (dobeep_msgs("Var not found:", argp)); -- Christian "naddy" Weisgerber na...@mips.inka.de
sbin/isakmpd: fix -Wunused-but-set-variable warnings
sbin/isakmpd: fix -Wunused-but-set-variable warnings The one in pf_key_v2.c could use an extra set of eyes, but I don't think there are any side effects. M sbin/isakmpd/ipsec.c M sbin/isakmpd/pf_key_v2.c M sbin/isakmpd/udp_encap.c M sbin/isakmpd/x509.c diff ce1a8a9dca08dd7e01f71dfff05f1e4f4ed3bb7e 7c5dd09ecd1ff078b868c9ab52aac9754cde7761 blob - 3954c5670aec76c08146272f2ab6e9038aa79c82 blob + 272b3657e8bdcf303f046d2641d11ad67f912fc2 --- sbin/isakmpd/ipsec.c +++ sbin/isakmpd/ipsec.c @@ -2090,7 +2090,6 @@ ipsec_decode_id(char *buf, size_t size, u_int8_t *id, { int id_type; char *addr = 0, *mask = 0; - u_int32_t *idp; if (id) { if (!isakmpform) { @@ -2102,7 +2101,6 @@ ipsec_decode_id(char *buf, size_t size, u_int8_t *id, id_len += ISAKMP_GEN_SZ; } id_type = GET_ISAKMP_ID_TYPE(id); - idp = (u_int32_t *) (id + ISAKMP_ID_DATA_OFF); switch (id_type) { case IPSEC_ID_IPV4_ADDR: util_ntoa(, AF_INET, id + ISAKMP_ID_DATA_OFF); blob - 04e867dedaf62dba9e3b1fc6702528432e53f243 blob + 302bcb52ee20cef9abb7ccc4fd052fcbd6486ea9 --- sbin/isakmpd/pf_key_v2.c +++ sbin/isakmpd/pf_key_v2.c @@ -2310,8 +2310,6 @@ pf_key_v2_acquire(struct pf_key_v2_msg *pmsg) struct sadb_x_policy policy; struct sadb_address *dst = 0, *src = 0; struct sockaddr *dstaddr, *srcaddr = 0; - struct sadb_comb *scmb = 0; - struct sadb_prop *sprp = 0; struct sadb_ident *srcident = 0, *dstident = 0; chardstbuf[ADDRESS_MAX], srcbuf[ADDRESS_MAX], *peer = 0; charconfname[120], *conn = 0; @@ -2354,11 +2352,6 @@ pf_key_v2_acquire(struct pf_key_v2_msg *pmsg) if (ext) src = ext->seg; - ext = pf_key_v2_find_ext(pmsg, SADB_EXT_PROPOSAL); - if (ext) { - sprp = ext->seg; - scmb = (struct sadb_comb *) (sprp + 1); - } ext = pf_key_v2_find_ext(pmsg, SADB_EXT_IDENTITY_SRC); if (ext) srcident = ext->seg; blob - ae20f98fadadebfd1467ab99ba6527d3a2c236b6 blob + 1eef9e00b5c26ae4222a6c3f95b7d47ccf9d2bb8 --- sbin/isakmpd/udp_encap.c +++ sbin/isakmpd/udp_encap.c @@ -227,7 +227,7 @@ udp_encap_create(char *name) { struct virtual_transport *v; struct udp_transport*u; - struct transport*rv, *t; + struct transport*rv; struct sockaddr *dst, *addr; struct conf_list*addr_list = 0; struct conf_list_node *addr_node; @@ -303,7 +303,6 @@ udp_encap_create(char *name) rv = 0; goto ret; } - t = (struct transport *)v; rv = udp_clone(v->encap, dst); if (rv) rv->vtbl = _encap_transport_vtbl; blob - 4ccaf0728756f61db4dfb57d59d718b92e446f71 blob + a4cc6d7ca7325cfb71977a627e779d8d42e07396 --- sbin/isakmpd/x509.c +++ sbin/isakmpd/x509.c @@ -680,7 +680,7 @@ x509_read_crls_from_dir(X509_STORE *ctx, char *name) struct stat sb; charfullname[PATH_MAX]; charfile[PATH_MAX]; - int fd, off, size; + int fd; if (strlen(name) >= sizeof fullname - 1) { log_print("x509_read_crls_from_dir: directory name too long"); @@ -695,8 +695,6 @@ x509_read_crls_from_dir(X509_STORE *ctx, char *name) return 0; } strlcpy(fullname, name, sizeof fullname); - off = strlen(fullname); - size = sizeof fullname - off; while ((fd = monitor_readdir(file, sizeof file)) != -1) { LOG_DBG((LOG_CRYPTO, 60, "x509_read_crls_from_dir: reading " -- Christian "naddy" Weisgerber na...@mips.inka.de
sbin/pfctl: fix -Wunused-but-set-variable warning
sbin/pfctl: fix -Wunused-but-set-variable warning M sbin/pfctl/pfctl_optimize.c diff 7c5dd09ecd1ff078b868c9ab52aac9754cde7761 6e5c342a53c05496c18849837c67b7dc05ce3792 blob - 1ab170a832dd183a2895774549ff93896803039a blob + 5736a0d7b0ba04afeed855daa61fc6b5ef3894e4 --- sbin/pfctl/pfctl_optimize.c +++ sbin/pfctl/pfctl_optimize.c @@ -789,7 +789,6 @@ block_feedback(struct pfctl *pf, struct superblock *bl { TAILQ_HEAD( , pf_opt_rule) queue; struct pf_opt_rule *por1, *por2; - u_int64_t total_count = 0; struct pf_rule a, b; @@ -799,8 +798,6 @@ block_feedback(struct pfctl *pf, struct superblock *bl */ TAILQ_FOREACH(por1, >sb_profiled_block->sb_rules, por_entry) { comparable_rule(, >por_rule, DC); - total_count += por1->por_rule.packets[0] + - por1->por_rule.packets[1]; TAILQ_FOREACH(por2, >sb_rules, por_entry) { if (por2->por_profile_count) continue; -- Christian "naddy" Weisgerber na...@mips.inka.de
lib/libfuse: fix -Wunused-but-set-variable warning
Since the switch to LLVM 13, there are a number of compiler warnings in base about variables that are assigned to but never used. Let's start picking the low-hanging fruit, ok? lib/libfuse: fix -Wunused-but-set-variable warning M lib/libfuse/fuse_opt.c diff 926818cffbbacfeb5685fa0f8e104986608d1a29 ce1a8a9dca08dd7e01f71dfff05f1e4f4ed3bb7e blob - 38bf34a7d157a543ee47f18bf350cb9183ab9803 blob + 26dcecd3e2486ad1f833bfee0827a2bd5406e068 --- lib/libfuse/fuse_opt.c +++ lib/libfuse/fuse_opt.c @@ -190,10 +190,9 @@ parse_opt(const struct fuse_opt *o, const char *opt, v fuse_opt_proc_t f, struct fuse_args *arg) { const char *val; - int keyval, ret, found; + int ret, found; size_t sep; - keyval = 0; found = 0; for(; o != NULL && o->templ; o++) { @@ -205,11 +204,9 @@ parse_opt(const struct fuse_opt *o, const char *opt, v val = opt; /* check key=value or -p n */ - if (o->templ[sep] == '=') { - keyval = 1; + if (o->templ[sep] == '=') val = [sep + 1]; - } else if (o->templ[sep] == ' ') { - keyval = 1; + else if (o->templ[sep] == ' ') { if (sep == strlen(opt)) { /* ask for next arg to be included */ return (IFUSE_OPT_NEED_ANOTHER_ARG); -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: unlock mmap(2) for anonymous mappings
Klemens Nanni: > > > Now this is clearly a "slow" path. I don't think there is any reason > > > not to put all the code in that if (uvw_wxabort) block under the > > > kernel lock. For now I think making access to ps_wxcounter atomic is > > > just too fine grained. > > > > Right. Lock the whole block. > > Thanks everyone, here's the combined diff for that. -snip- FWIW, I ran an amd64 package bulk build with this. No problems. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Rework UNIX sockets locking to be fine grained
Vitaliy Makkoveev: > Include missing "sys/refcnt.h" header to unpcb.h to fix libkvm and > netstat(1) build. No functional changes. I ran an amd64 package bulk build with this, four ncpu=4 machines. No problems. (Other than for dpb's ssh connection multiplexing, I don't think Unix domain sockets or FIFOs are really used by this workload, though.) -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Variable type fix in parse.y (all of them)
Christian Weisgerber: > Here's another attempt, incorporating millert's feedback and adding > a few more casts: Any interest in this or not worth the churn and I should drop it? > Index: bin/chio/parse.y > === > RCS file: /cvs/src/bin/chio/parse.y,v > retrieving revision 1.23 > diff -u -p -r1.23 parse.y > --- bin/chio/parse.y 15 Oct 2020 19:42:56 - 1.23 > +++ bin/chio/parse.y 2 Oct 2021 19:42:06 - > @@ -179,9 +179,9 @@ lookup(char *s) > > #define MAXPUSHBACK 128 > > -u_char *parsebuf; > +char *parsebuf; > int parseindex; > -u_charpushback_buffer[MAXPUSHBACK]; > +char pushback_buffer[MAXPUSHBACK]; > int pushback_index = 0; > > int > @@ -192,7 +192,7 @@ lgetc(int quotec) > if (parsebuf) { > /* Read character from the parsebuffer instead of input. */ > if (parseindex >= 0) { > - c = parsebuf[parseindex++]; > + c = (unsigned char)parsebuf[parseindex++]; > if (c != '\0') > return (c); > parsebuf = NULL; > @@ -201,7 +201,7 @@ lgetc(int quotec) > } > > if (pushback_index) > - return (pushback_buffer[--pushback_index]); > + return ((unsigned char)pushback_buffer[--pushback_index]); > > if (quotec) { > if ((c = getc(file->stream)) == EOF) { > @@ -242,10 +242,10 @@ lungetc(int c) > if (parseindex >= 0) > return (c); > } > - if (pushback_index < MAXPUSHBACK-1) > - return (pushback_buffer[pushback_index++] = c); > - else > + if (pushback_index + 1 >= MAXPUSHBACK) > return (EOF); > + pushback_buffer[pushback_index++] = c; > + return (c); > } > > int > @@ -272,8 +272,8 @@ findeol(void) > int > yylex(void) > { > - u_char buf[8096]; > - u_char *p; > + char buf[8096]; > + char*p; > int quotec, next, c; > int token; > > @@ -353,8 +353,8 @@ yylex(void) > } else { > nodigits: > while (p > buf + 1) > - lungetc(*--p); > - c = *--p; > + lungetc((unsigned char)*--p); > + c = (unsigned char)*--p; > if (c == '-') > return (c); > } > Index: sbin/dhcpleased/parse.y > === > RCS file: /cvs/src/sbin/dhcpleased/parse.y,v > retrieving revision 1.4 > diff -u -p -r1.4 parse.y > --- sbin/dhcpleased/parse.y 20 Sep 2021 11:46:22 - 1.4 > +++ sbin/dhcpleased/parse.y 2 Oct 2021 19:17:33 - > @@ -463,10 +463,10 @@ findeol(void) > int > yylex(void) > { > - unsigned charbuf[8096]; > - unsigned char *p, *val; > - int quotec, next, c; > - int token; > + char buf[8096]; > + char*p, *val; > + int quotec, next, c; > + int token; > > top: > p = buf; > @@ -502,7 +502,7 @@ top: > p = val + strlen(val) - 1; > lungetc(DONE_EXPAND); > while (p >= val) { > - lungetc(*p); > + lungetc((unsigned char)*p); > p--; > } > lungetc(START_EXPAND); > @@ -578,8 +578,8 @@ top: > } else { > nodigits: > while (p > buf + 1) > - lungetc(*--p); > - c = *--p; > + lungetc((unsigned char)*--p); > + c = (unsigned char)*--p; > if (c == '-') > return (c); > } > Index: sbin/iked/parse.y > === > RCS file: /cvs/src/sbin/iked/parse.y,v > retrieving revision 1.132 > diff -u -p -r1.132 parse.y > --- sbin/iked/parse.y 18 Sep 2021 16:45:52 - 1.132 > +++ sbin/iked/parse.y 2 Oct 2021 19:07:12 - > @@ -1510,10 +1510,10 @@ findeol(void) > int > yylex(void) > { > - unsigned charbuf[8096]; > - unsigned char *p, *val; > - int quotec, next, c; > - int token; > + char buf[8096]; > + char*p, *val; > + int quotec, next, c; > + int token; > > top: >
Re: Variable type fix in parse.y (all of them)
Here's another attempt, incorporating millert's feedback and adding a few more casts: Index: bin/chio/parse.y === RCS file: /cvs/src/bin/chio/parse.y,v retrieving revision 1.23 diff -u -p -r1.23 parse.y --- bin/chio/parse.y15 Oct 2020 19:42:56 - 1.23 +++ bin/chio/parse.y2 Oct 2021 19:42:06 - @@ -179,9 +179,9 @@ lookup(char *s) #define MAXPUSHBACK128 -u_char *parsebuf; +char *parsebuf; int parseindex; -u_char pushback_buffer[MAXPUSHBACK]; +charpushback_buffer[MAXPUSHBACK]; int pushback_index = 0; int @@ -192,7 +192,7 @@ lgetc(int quotec) if (parsebuf) { /* Read character from the parsebuffer instead of input. */ if (parseindex >= 0) { - c = parsebuf[parseindex++]; + c = (unsigned char)parsebuf[parseindex++]; if (c != '\0') return (c); parsebuf = NULL; @@ -201,7 +201,7 @@ lgetc(int quotec) } if (pushback_index) - return (pushback_buffer[--pushback_index]); + return ((unsigned char)pushback_buffer[--pushback_index]); if (quotec) { if ((c = getc(file->stream)) == EOF) { @@ -242,10 +242,10 @@ lungetc(int c) if (parseindex >= 0) return (c); } - if (pushback_index < MAXPUSHBACK-1) - return (pushback_buffer[pushback_index++] = c); - else + if (pushback_index + 1 >= MAXPUSHBACK) return (EOF); + pushback_buffer[pushback_index++] = c; + return (c); } int @@ -272,8 +272,8 @@ findeol(void) int yylex(void) { - u_char buf[8096]; - u_char *p; + char buf[8096]; + char*p; int quotec, next, c; int token; @@ -353,8 +353,8 @@ yylex(void) } else { nodigits: while (p > buf + 1) - lungetc(*--p); - c = *--p; + lungetc((unsigned char)*--p); + c = (unsigned char)*--p; if (c == '-') return (c); } Index: sbin/dhcpleased/parse.y === RCS file: /cvs/src/sbin/dhcpleased/parse.y,v retrieving revision 1.4 diff -u -p -r1.4 parse.y --- sbin/dhcpleased/parse.y 20 Sep 2021 11:46:22 - 1.4 +++ sbin/dhcpleased/parse.y 2 Oct 2021 19:17:33 - @@ -463,10 +463,10 @@ findeol(void) int yylex(void) { - unsigned charbuf[8096]; - unsigned char *p, *val; - int quotec, next, c; - int token; + char buf[8096]; + char*p, *val; + int quotec, next, c; + int token; top: p = buf; @@ -502,7 +502,7 @@ top: p = val + strlen(val) - 1; lungetc(DONE_EXPAND); while (p >= val) { - lungetc(*p); + lungetc((unsigned char)*p); p--; } lungetc(START_EXPAND); @@ -578,8 +578,8 @@ top: } else { nodigits: while (p > buf + 1) - lungetc(*--p); - c = *--p; + lungetc((unsigned char)*--p); + c = (unsigned char)*--p; if (c == '-') return (c); } Index: sbin/iked/parse.y === RCS file: /cvs/src/sbin/iked/parse.y,v retrieving revision 1.132 diff -u -p -r1.132 parse.y --- sbin/iked/parse.y 18 Sep 2021 16:45:52 - 1.132 +++ sbin/iked/parse.y 2 Oct 2021 19:07:12 - @@ -1510,10 +1510,10 @@ findeol(void) int yylex(void) { - unsigned charbuf[8096]; - unsigned char *p, *val; - int quotec, next, c; - int token; + char buf[8096]; + char*p, *val; + int quotec, next, c; + int token; top: p = buf; @@ -1549,7 +1549,7 @@ top: p = val + strlen(val) - 1; lungetc(DONE_EXPAND); while (p >= val) { - lungetc(*p); + lungetc((unsigned char)*p); p--; } lungetc(START_EXPAND); @@ -1625,8 +1625,8 @@ top: } else { nodigits: while (p > buf + 1) - lungetc(*--p); - c = *--p; + lungetc((unsigned char)*--p); + c = (unsigned char)*--p; if (c ==
Re: Variable type fix in parse.y (all of them)
Todd C. Miller: > On Thu, 30 Sep 2021 21:37:06 +0200, Christian Weisgerber wrote: > > > Unfortunately that also affects the parsebuf/pushback_buffer complex > > used in some parser.y files. > > That would require a few extra casts but it is straightforward. E.g. like this? Index: bin/chio/parse.y === RCS file: /cvs/src/bin/chio/parse.y,v retrieving revision 1.23 diff -u -p -r1.23 parse.y --- bin/chio/parse.y15 Oct 2020 19:42:56 - 1.23 +++ bin/chio/parse.y30 Sep 2021 20:13:12 - @@ -179,9 +179,9 @@ lookup(char *s) #define MAXPUSHBACK128 -u_char *parsebuf; +char *parsebuf; int parseindex; -u_char pushback_buffer[MAXPUSHBACK]; +charpushback_buffer[MAXPUSHBACK]; int pushback_index = 0; int @@ -192,7 +192,7 @@ lgetc(int quotec) if (parsebuf) { /* Read character from the parsebuffer instead of input. */ if (parseindex >= 0) { - c = parsebuf[parseindex++]; + c = (unsigned char)parsebuf[parseindex++]; if (c != '\0') return (c); parsebuf = NULL; @@ -201,7 +201,7 @@ lgetc(int quotec) } if (pushback_index) - return (pushback_buffer[--pushback_index]); + return ((unsigned char)pushback_buffer[--pushback_index]); if (quotec) { if ((c = getc(file->stream)) == EOF) { @@ -243,7 +243,7 @@ lungetc(int c) return (c); } if (pushback_index < MAXPUSHBACK-1) - return (pushback_buffer[pushback_index++] = c); + return (unsigned char)(pushback_buffer[pushback_index++] = c); else return (EOF); } @@ -272,8 +272,8 @@ findeol(void) int yylex(void) { - u_char buf[8096]; - u_char *p; + char buf[8096]; + char*p; int quotec, next, c; int token; @@ -353,8 +353,8 @@ yylex(void) } else { nodigits: while (p > buf + 1) - lungetc(*--p); - c = *--p; + lungetc((unsigned char)*--p); + c = (unsigned char)*--p; if (c == '-') return (c); } -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Variable type fix in parse.y (all of them)
Todd C. Miller: > lungetc((u_char)*p); > ... > c = (u_char)*--p; > > Since we use casts sparingly, when they are present they indicate > something you need to pay attention to. That is not the case when > we simply change the type. Unfortunately that also affects the parsebuf/pushback_buffer complex used in some parser.y files. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Variable type fix in parse.y (all of them)
Christian Weisgerber: > The oft-copied parse.y code declares some variables as "unsigned char *" > but passes them to functions that take "char *" arguments and doesn't > make any use of the unsigned property. While I'm here... > int > yylex(void) > { > - u_char buf[8096]; > - u_char *p; > + char buf[8096]; > + char*p; Is there any significance to that number 8096? It suspiciously looks like somebody mixed up the powers of two 4096 and 8192. -- Christian "naddy" Weisgerber na...@mips.inka.de
Variable type fix in parse.y (all of them)
The oft-copied parse.y code declares some variables as "unsigned char *" but passes them to functions that take "char *" arguments and doesn't make any use of the unsigned property. For OpenBSD's clang, -Wpointer-sign has been disabled by default, but when that code is built elsewhere, the compiler will complain. I noticed and fixed this for Got and millert@ suggested that it should be applied to all copies of parse.y in OpenBSD, so here we go. OK? Index: bin/chio/parse.y === RCS file: /cvs/src/bin/chio/parse.y,v retrieving revision 1.23 diff -u -p -r1.23 parse.y --- bin/chio/parse.y15 Oct 2020 19:42:56 - 1.23 +++ bin/chio/parse.y29 Sep 2021 18:32:58 - @@ -179,9 +179,9 @@ lookup(char *s) #define MAXPUSHBACK128 -u_char *parsebuf; +char *parsebuf; int parseindex; -u_char pushback_buffer[MAXPUSHBACK]; +charpushback_buffer[MAXPUSHBACK]; int pushback_index = 0; int @@ -272,8 +272,8 @@ findeol(void) int yylex(void) { - u_char buf[8096]; - u_char *p; + char buf[8096]; + char*p; int quotec, next, c; int token; Index: sbin/dhcpleased/parse.y === RCS file: /cvs/src/sbin/dhcpleased/parse.y,v retrieving revision 1.4 diff -u -p -r1.4 parse.y --- sbin/dhcpleased/parse.y 20 Sep 2021 11:46:22 - 1.4 +++ sbin/dhcpleased/parse.y 29 Sep 2021 18:14:01 - @@ -463,10 +463,10 @@ findeol(void) int yylex(void) { - unsigned charbuf[8096]; - unsigned char *p, *val; - int quotec, next, c; - int token; + char buf[8096]; + char*p, *val; + int quotec, next, c; + int token; top: p = buf; Index: sbin/iked/parse.y === RCS file: /cvs/src/sbin/iked/parse.y,v retrieving revision 1.132 diff -u -p -r1.132 parse.y --- sbin/iked/parse.y 18 Sep 2021 16:45:52 - 1.132 +++ sbin/iked/parse.y 29 Sep 2021 18:16:23 - @@ -1510,10 +1510,10 @@ findeol(void) int yylex(void) { - unsigned charbuf[8096]; - unsigned char *p, *val; - int quotec, next, c; - int token; + char buf[8096]; + char*p, *val; + int quotec, next, c; + int token; top: p = buf; Index: sbin/ipsecctl/parse.y === RCS file: /cvs/src/sbin/ipsecctl/parse.y,v retrieving revision 1.179 diff -u -p -r1.179 parse.y --- sbin/ipsecctl/parse.y 29 Dec 2020 19:50:03 - 1.179 +++ sbin/ipsecctl/parse.y 29 Sep 2021 18:33:54 - @@ -1054,9 +1054,9 @@ lookup(char *s) #define MAXPUSHBACK128 -u_char *parsebuf; +char *parsebuf; int parseindex; -u_char pushback_buffer[MAXPUSHBACK]; +charpushback_buffer[MAXPUSHBACK]; int pushback_index = 0; int @@ -1148,8 +1148,8 @@ findeol(void) int yylex(void) { - u_char buf[8096]; - u_char *p, *val; + char buf[8096]; + char*p, *val; int quotec, next, c; int token; Index: sbin/pfctl/parse.y === RCS file: /cvs/src/sbin/pfctl/parse.y,v retrieving revision 1.709 diff -u -p -r1.709 parse.y --- sbin/pfctl/parse.y 1 Feb 2021 00:31:04 - 1.709 +++ sbin/pfctl/parse.y 29 Sep 2021 18:23:47 - @@ -5170,8 +5170,8 @@ findeol(void) int yylex(void) { - u_char buf[8096]; - u_char *p, *val; + char buf[8096]; + char*p, *val; int quotec, next, c; int token; Index: sbin/unwind/parse.y === RCS file: /cvs/src/sbin/unwind/parse.y,v retrieving revision 1.27 diff -u -p -r1.27 parse.y --- sbin/unwind/parse.y 31 Aug 2021 20:18:03 - 1.27 +++ sbin/unwind/parse.y 29 Sep 2021 18:25:04 - @@ -557,10 +557,10 @@ findeol(void) int yylex(void) { - unsigned charbuf[8096]; - unsigned char *p, *val; - int quotec, next, c; - int token; + char buf[8096]; + char*p, *val; + int quotec, next, c; + int token; top: p = buf; Index: usr.sbin/acme-client/parse.y === RCS file: /cvs/src/usr.sbin/acme-client/parse.y,v retrieving revision 1.42 diff -u -p -r1.42 parse.y --- usr.sbin/acme-client/parse.y14 Sep 2020 16:00:17 - 1.42 +++ usr.sbin/acme-client/parse.y29 Sep 2021 18:28:10 - @@ -594,8 +594,8 @@ findeol(void) int yylex(void) { - u_char buf[8096]; - u_char *p, *val; + char buf[8096]; + char*p, *val; int quotec, next, c;
Re: fresh prompt after Ctrl-C in cdio(1)
Ingo Schwarze: > deraadt@ recently pointed out to me in private mail that it is good > for usability if interactive programs providing line editing > functionality are consistent what they do with Ctrl-C, ideally > discard the current input line and provide a fresh prompt. > > So i propose to do the same in cdio(1), which currently just exits > on Ctrl-C. > > OK? That looks correct and works fine for me. ok naddy@ (I still have a USB CD drive and I use it from time to time to play audio CDs with cdio. I had completely forgotten that cdio supports editline, though. The cdio interactive mode is pretty useless since interrupting a running command aborts the program.) -- Christian "naddy" Weisgerber na...@mips.inka.de
scp: tweak man page for -3 by default
scp: tweak documentation and error message for -3 by default Now that the -3 option is enabled by default, flip the documentation and an error message from "requires -3" to "blocked by -R". OK? diff 453220bf36dcff10addeceb44e98f71bfeddcd53 f457be8f3b007fb662dd10fb565ab79b602109f5 blob - 972269af7f61d7643a68fbcfa1e7a6a9b7d207e1 blob + b8d969ef781d4ef665f82dbc1a10d20e0da6e307 --- usr.bin/ssh/scp.1 +++ usr.bin/ssh/scp.1 @@ -67,10 +67,10 @@ as host specifiers. .Pp When copying between two remote hosts, if the URI format is used, a .Ar port -may only be specified on the +cannot be specified on the .Ar target if the -.Fl 3 +.Fl R option is used. .Pp The options are as follows: @@ -260,7 +260,7 @@ The program must understand options. .It Fl s Use the SFTP protocol for file transfers instead of the legacy SCP protocol. -Using SFTP provides avoids invoking a shell on the remote side and provides +Using SFTP avoids invoking a shell on the remote side and provides more predictable filename handling, as the SCP protocol relied on the remote shell for expanding .Xr glob 3 blob - ce133d87af2fff873e3202cecde7d91c6c94171f blob + 7ee66c26bce50a4bf6e0132fddb41a7850f26e83 --- usr.bin/ssh/scp.c +++ usr.bin/ssh/scp.c @@ -1063,7 +1063,7 @@ toremote(int argc, char **argv, enum scp_mode_e mode, if (tport != -1 && tport != SSH_DEFAULT_PORT) { /* This would require the remote support URIs */ fatal("target port not supported with two " - "remote hosts without the -3 option"); + "remote hosts and the -R option"); } freeargs(); -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: scp(1) changes in snaps
"Theo de Raadt": > 2) With very long names, it truncates the end of the path. This is less useful > information. Imagine a copy operation with multiple files being transferred, > one of them is huge and surprisingly long, but you cannot identify which one > because all the truncated long paths are the same. > > 3) (old) scp and rsync show the path only component only. Oh, I hadn't even realized that this affects the way _all_ source file paths are displayed, whether remote or local, whether originally specified with absolute or relative path. Path width is limited to 44 characters in a normal 80-char terminal. $ echo -n /usr/ports/distfiles/ |wc 0 1 21 $ echo -n /usr/ports/logs/amd64/paths/ |wc 0 1 28 > So I think the path-component-only scheme is better, and this should > change. Yes, please. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: scp(1) changes in snaps
Damien Miller: > Just a head-up: snaps currently contain a set of changes[1] to > make scp(1) use the SFTP protocol by default. > Please report any incompatibilities or bugs that you encounter here > (tech@), to bugs@ or to openssh@. An obvious cosmetic difference is that relative paths are prefixed with the home directory of the remote source in the progress bar: $ scp lorvorc:foo /dev/null /home/naddy/foo 100% 4099 1.6MB/s 00:00 $ scp -O lorvorc:foo /dev/null foo 100% 4099 3.7MB/s 00:00 I don't know if we care. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Avoid shifting of a negative value in sys_adjfreq()
Visa Hankala: > However, wouldn't it be better if the code avoided the > situation, for example by defining ADJFREQ_MIN as the negative > of ADJFREQ_MAX? Indeed it would. ok naddy@ > --- kern/kern_time.c 23 Dec 2020 20:45:02 - 1.151 > +++ kern/kern_time.c 30 May 2021 15:38:09 - > @@ -396,7 +396,7 @@ sys_settimeofday(struct proc *p, void *v > } > > #define ADJFREQ_MAX (5LL << 32) > -#define ADJFREQ_MIN (-5LL << 32) > +#define ADJFREQ_MIN (-ADJFREQ_MAX) > > int > sys_adjfreq(struct proc *p, void *v, register_t *retval) > -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: shell manpage tweaks wrt getopt
Marc Espie: > I would also actually be fairly happy if we changed drastically the way > sh(1) and ksh(1) look. To me, sh(1) should be the (more or less) standard > shell documentation, AND ksh(1) should contain the differences/extensions. I think that is a terrible idea. Historically the tcsh(1) man page was like this: only document the extensions to csh, point to csh(1) for the rest. This only makes sense for people who already fully know the base man page. If you don't, you now have to go back and forth between two man pages to figure out things. Eventually, the tcsh man page was overhauled and now describes the whole shell, which was a huge improvement in my book. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: shell manpage tweaks wrt getopt
Jason McIntyre: > - i'm ok with the getopt.1 and ksh.1 parts > - i'm not ok with the addition to sh.1 > > no one has really given a good reason why they think it should go into > sh.1. i've given a few why i think it should not. My understanding is that sh.1 is a subset of ksh.1, describing the POSIX-standardized functionality. Am I wrong? ksh.1 has very little in the way of examples, but I think figuring out the correct getopts idiom is difficult enough to warrant an example. The problem is that if I'm trying to write a portable shell script, I will refer to sh.1. I will not check ksh.1 for examples. But since you are the principal author of sh.1, I'm certainly deferring to your judgment. -- Christian "naddy" Weisgerber na...@mips.inka.de
switchd genmap.sh: getopt -> getopts
In this auxiliary script, replace the deprecated getopt with getopts. There is no pressing reason to do so, but let's stop perpetuating an obsolete idiom. ok? Index: usr.sbin/switchd/genmap.sh === RCS file: /cvs/src/usr.sbin/switchd/genmap.sh,v retrieving revision 1.6 diff -u -p -r1.6 genmap.sh --- usr.sbin/switchd/genmap.sh 18 Nov 2016 16:49:35 - 1.6 +++ usr.sbin/switchd/genmap.sh 30 Apr 2021 20:56:22 - @@ -21,34 +21,26 @@ INPUT="" HEADER="" DESCR=0 -args=`getopt di:o:h:t:m: $*` - -if [ $? -ne 0 ]; then - echo "usage: $0 [-d] -i input -h header -t token [-m mapfile]" - exit 1 -fi - -set -- $args -while [ $# -ne 0 ]; do - case "$1" in - -d) - DESCR=1; shift; +while getopts di:h:t:m: name; do + case $name in + d) + DESCR=1 ;; - -i) - INPUT="$2"; shift; shift; + i) + INPUT=$OPTARG ;; - -h) - HEADER="$2"; shift; shift; + h) + HEADER=$OPTARG ;; - -t) - TOKEN="$2"; shift; shift; + t) + TOKEN=$OPTARG ;; - -m) - MAPFILE="$2"; shift; shift; + m) + MAPFILE=$OPTARG ;; - --) - shift; - break + ?) + echo "usage: $0 [-d] -i input -h header -t token [-m mapfile]" + exit 1 ;; esac done -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: shell manpage tweaks wrt getopt
Marc Espie: > Until a patch from naddy, I wasn't even aware of getopts in sh(1) Let's start the discussion with this instead. This puts the deprecation notice in getopt.1 in a prominent place, and uses the same snippet in sh.1 and ksh.1. Index: bin/ksh/ksh.1 === RCS file: /cvs/src/bin/ksh/ksh.1,v retrieving revision 1.214 diff -u -p -r1.214 ksh.1 --- bin/ksh/ksh.1 11 Mar 2021 07:04:12 - 1.214 +++ bin/ksh/ksh.1 30 Apr 2021 14:40:52 - @@ -3219,6 +3219,25 @@ resetting .Ev OPTIND , may lead to unexpected results. .Pp +The following code fragment shows how one might process the arguments +for a command that can take the option +.Fl a +and the option +.Fl o , +which requires an argument. +.Bd -literal -offset indent +while getopts ao: name +do + case $name in + a) flag=1 ;; + o) oarg=$OPTARG ;; + ?) echo "Usage: ..."; exit 2 ;; + esac +done +shift $(($OPTIND - 1)) +echo "Non-option arguments: " "$@" +.Ed +.Pp .It Xo .Ic hash .Op Fl r Index: bin/ksh/sh.1 === RCS file: /cvs/src/bin/ksh/sh.1,v retrieving revision 1.152 diff -u -p -r1.152 sh.1 --- bin/ksh/sh.122 May 2019 15:23:23 - 1.152 +++ bin/ksh/sh.130 Apr 2021 14:45:22 - @@ -508,6 +508,25 @@ is a colon, .Ev OPTARG is set to the unsupported option, otherwise an error message is displayed. +.Pp +The following code fragment shows how one might process the arguments +for a command that can take the option +.Fl a +and the option +.Fl o , +which requires an argument. +.Bd -literal -offset indent +while getopts ao: name +do + case $name in + a) flag=1 ;; + o) oarg=$OPTARG ;; + ?) echo "Usage: ..."; exit 2 ;; + esac +done +shift $(($OPTIND - 1)) +echo "Non-option arguments: " "$@" +.Ed .It Ic hash Op Fl r | Ar utility Add .Ar utility Index: usr.bin/getopt/getopt.1 === RCS file: /cvs/src/usr.bin/getopt/getopt.1,v retrieving revision 1.19 diff -u -p -r1.19 getopt.1 --- usr.bin/getopt/getopt.1 16 Mar 2018 16:58:26 - 1.19 +++ usr.bin/getopt/getopt.1 30 Apr 2021 14:25:17 - @@ -14,6 +14,13 @@ .Ar optstring .Va $* .Sh DESCRIPTION +The +.Nm +utility cannot handle option arguments containing whitespace; +consider using the standard +.Ic getopts +shell built-in instead. +.Pp .Nm is used to break up options in command lines for easy parsing by shell procedures, and to check for legal options. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Unlock top part of uvm_fault()
Christian Weisgerber: > > Diff below remove the KERNEL_LOCK()/UNLOCK() dance from uvm_fault() for > > both amd64 and sparc64. That means the kernel lock will only be taken > > for lower faults and some amap/anon code will now run without it. > > I ran an amd64 bulk build with this diff on top of 6.9. PS: 4 machines, 4 cores each (Xeon CPU E3-1270 v6, HTT disabled) -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Unlock top part of uvm_fault()
Martin Pieuchot: > Diff below remove the KERNEL_LOCK()/UNLOCK() dance from uvm_fault() for > both amd64 and sparc64. That means the kernel lock will only be taken > for lower faults and some amap/anon code will now run without it. > > I'd be interested to have this tested and see how much does that impact > the build time of packages. I ran an amd64 bulk build with this diff on top of 6.9. That succeeded. No crashes, no ill effects. The impact on the build time was neglibible. From 24 hours 20-something minutes down to 24 hours 12 minutes (1 sample). -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: quiz: Fix multi-line questions (trailing newline)
Todd C. Miller: > I don't think your use of qlen is safe since it is initialized > to zero. Specifically, it looks like "qp->q_text[qlen - 1]" > would be an out of bounds read. Should qlen be initialized > to strlen(qp->q_text) if qp->q_text != NULL? Right. Next iteration: Index: quiz.c === RCS file: /cvs/src/games/quiz/quiz.c,v retrieving revision 1.30 diff -u -p -r1.30 quiz.c --- quiz.c 24 Aug 2018 11:14:49 - 1.30 +++ quiz.c 10 Mar 2021 20:04:37 - @@ -48,7 +48,6 @@ static QE qlist; static int catone, cattwo, tflag; static u_int qsize; -char *appdstr(char *, const char *, size_t); voiddowncase(char *); voidget_cats(char *, char *); voidget_file(const char *); @@ -110,7 +109,8 @@ get_file(const char *file) { FILE *fp; QE *qp; - size_t len; + ssize_t len; + size_t qlen, size; char *lp; if ((fp = fopen(file, "r")) == NULL) @@ -123,26 +123,36 @@ get_file(const char *file) */ qp = qsize = 0; - while ((lp = fgetln(fp, )) != NULL) { + lp = NULL; + size = 0; + while ((len = getline(, , fp)) != -1) { if (lp[len - 1] == '\n') - --len; + lp[--len] = '\0'; + if (qp->q_text) + qlen = strlen(qp->q_text); if (qp->q_text && qp->q_text[0] != '\0' && - qp->q_text[strlen(qp->q_text) - 1] == '\\') - qp->q_text = appdstr(qp->q_text, lp, len); - else { + qp->q_text[qlen - 1] == '\\') { + qp->q_text[--qlen] = '\0'; + qlen += len; + qp->q_text = realloc(qp->q_text, qlen + 1); + if (qp->q_text == NULL) + errx(1, "realloc"); + strlcat(qp->q_text, lp, qlen + 1); + } else { if ((qp->q_next = malloc(sizeof(QE))) == NULL) errx(1, "malloc"); qp = qp->q_next; - if ((qp->q_text = malloc(len + 1)) == NULL) - errx(1, "malloc"); - /* lp may not be zero-terminated; cannot use strlcpy */ - strncpy(qp->q_text, lp, len); - qp->q_text[len] = '\0'; + qp->q_text = strdup(lp); + if (qp->q_text == NULL) + errx(1, "strdup"); qp->q_asked = qp->q_answered = FALSE; qp->q_next = NULL; ++qsize; } } + free(lp); + if (ferror(fp)) + err(1, "getline"); (void)fclose(fp); } @@ -316,32 +326,6 @@ next_cat(const char *s) esc = 0; break; } -} - -char * -appdstr(char *s, const char *tp, size_t len) -{ - char *mp; - const char *sp; - int ch; - char *m; - - if ((m = malloc(strlen(s) + len + 1)) == NULL) - errx(1, "malloc"); - for (mp = m, sp = s; (*mp++ = *sp++) != '\0'; ) - ; - --mp; - if (*(mp - 1) == '\\') - --mp; - - while ((ch = *mp++ = *tp++) && ch != '\n') - ; - if (*(mp - 2) == '\\') - mp--; - *mp = '\0'; - - free(s); - return (m); } void -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: quiz: Fix multi-line questions (trailing newline)
Alex Karle: > Looking deeper, there is a bug in quiz(6) for datfiles with multi-line > answers. > > Specifically, the following quiz.db line: > > foo:\ > bar > > Is parsed into "foo:bar\n", which made it impossible to get right (since > the comparison was expecting a newline). This is a result of a bug in > quiz.c's appdstr(qp->q_text, lp, len), which copies the trailing newline > after "bar" (in lp) into q_text. [...] > That said, it seemed cleaner to modify the code to use getline(3) over > fgetln(3), which guarantees each iteration of the loop is a single line > and null-terminated, enabling the newline truncation in the loop and > allowing the use of strlcpy(3). This patch implements that fix. > > One can verify the bug(fix) by: > > $ cat < /tmp/qtest > foo1:bar > foo2:\\ > bar > foo3:\\ > ba\\ > r > EOF > $ echo "/tmp/qtest:test:lines" > /tmp/qindex > > # answer 'bar' to each question > $ quiz -i /tmp/qindex test lines # fails > $ /usr/obj/games/quiz/quiz -i /tmp/qindex test lines # succeeds Thanks a lot for figuring this out! I finally got around to looking at your patch. Once we have nul-terminated lines, appdstr() can be replaced with realloc() and strlcat(). This could use another pair of eyes. OK? Index: quiz.c === RCS file: /cvs/src/games/quiz/quiz.c,v retrieving revision 1.30 diff -u -p -r1.30 quiz.c --- quiz.c 24 Aug 2018 11:14:49 - 1.30 +++ quiz.c 9 Mar 2021 20:38:20 - @@ -48,7 +48,6 @@ static QE qlist; static int catone, cattwo, tflag; static u_int qsize; -char *appdstr(char *, const char *, size_t); voiddowncase(char *); voidget_cats(char *, char *); voidget_file(const char *); @@ -110,7 +109,8 @@ get_file(const char *file) { FILE *fp; QE *qp; - size_t len; + ssize_t len; + size_t qlen, size; char *lp; if ((fp = fopen(file, "r")) == NULL) @@ -123,26 +123,35 @@ get_file(const char *file) */ qp = qsize = 0; - while ((lp = fgetln(fp, )) != NULL) { + qlen = 0; + lp = NULL; + size = 0; + while ((len = getline(, , fp)) != -1) { if (lp[len - 1] == '\n') - --len; + lp[--len] = '\0'; if (qp->q_text && qp->q_text[0] != '\0' && - qp->q_text[strlen(qp->q_text) - 1] == '\\') - qp->q_text = appdstr(qp->q_text, lp, len); - else { + qp->q_text[qlen - 1] == '\\') { + qp->q_text[--qlen] = '\0'; + qp->q_text = realloc(qp->q_text, qlen + len + 1); + if (qp->q_text == NULL) + errx(1, "realloc"); + qlen = strlcat(qp->q_text, lp, qlen + len + 1); + } else { if ((qp->q_next = malloc(sizeof(QE))) == NULL) errx(1, "malloc"); qp = qp->q_next; - if ((qp->q_text = malloc(len + 1)) == NULL) - errx(1, "malloc"); - /* lp may not be zero-terminated; cannot use strlcpy */ - strncpy(qp->q_text, lp, len); - qp->q_text[len] = '\0'; + qp->q_text = strdup(lp); + if (qp->q_text == NULL) + errx(1, "strdup"); + qlen = strlen(qp->q_text); qp->q_asked = qp->q_answered = FALSE; qp->q_next = NULL; ++qsize; } } + free(lp); + if (ferror(fp)) + err(1, "getline"); (void)fclose(fp); } @@ -316,32 +325,6 @@ next_cat(const char *s) esc = 0; break; } -} - -char * -appdstr(char *s, const char *tp, size_t len) -{ - char *mp; - const char *sp; - int ch; - char *m; - - if ((m = malloc(strlen(s) + len + 1)) == NULL) - errx(1, "malloc"); - for (mp = m, sp = s; (*mp++ = *sp++) != '\0'; ) - ; - --mp; - if (*(mp - 1) == '\\') - --mp; - - while ((ch = *mp++ = *tp++) && ch != '\n') - ; - if (*(mp - 2) == '\\') - mp--; - *mp = '\0'; - - free(s); - return (m); } void -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: ftp: make use of getline(3)
Christian Weisgerber: > > Make use of getline(3) in ftp(1). > > > > Replace fparseln(3) with getline(3). This removes the only use > > of libutil.a(fparseln.o) from the ramdisk. > > Replace a complicated fgetln(3) idiom with the much simpler getline(3). > > OK? ping? I've been fetching distfiles with it, and I also built a bsd.rd and performed a http install with it. Index: distrib/special/ftp/Makefile === RCS file: /cvs/src/distrib/special/ftp/Makefile,v retrieving revision 1.14 diff -u -p -r1.14 Makefile --- distrib/special/ftp/Makefile16 May 2019 12:44:17 - 1.14 +++ distrib/special/ftp/Makefile29 Jan 2021 18:05:46 - @@ -6,7 +6,4 @@ PROG= ftp SRCS= fetch.c ftp.c main.c small.c util.c .PATH: ${.CURDIR}/../../../usr.bin/ftp -LDADD+=-lutil -DPADD+=${LIBUTIL} - .include Index: usr.bin/ftp/Makefile === RCS file: /cvs/src/usr.bin/ftp/Makefile,v retrieving revision 1.34 diff -u -p -r1.34 Makefile --- usr.bin/ftp/Makefile27 Jan 2021 22:27:41 - 1.34 +++ usr.bin/ftp/Makefile29 Jan 2021 17:57:31 - @@ -8,8 +8,8 @@ PROG= ftp SRCS= cmds.c cmdtab.c complete.c cookie.c domacro.c fetch.c ftp.c \ list.c main.c ruserpass.c small.c stringlist.c util.c -LDADD+=-ledit -lcurses -lutil -ltls -lssl -lcrypto -DPADD+=${LIBEDIT} ${LIBCURSES} ${LIBUTIL} ${LIBTLS} ${LIBSSL} ${LIBCRYPTO} +LDADD+=-ledit -lcurses -ltls -lssl -lcrypto +DPADD+=${LIBEDIT} ${LIBCURSES} ${LIBTLS} ${LIBSSL} ${LIBCRYPTO} #COPTS+= -Wall -Wconversion -Wstrict-prototypes -Wmissing-prototypes Index: usr.bin/ftp/cookie.c === RCS file: /cvs/src/usr.bin/ftp/cookie.c,v retrieving revision 1.9 diff -u -p -r1.9 cookie.c --- usr.bin/ftp/cookie.c16 May 2019 12:44:17 - 1.9 +++ usr.bin/ftp/cookie.c6 Feb 2021 16:23:32 - @@ -58,10 +58,10 @@ void cookie_load(void) { field_t field; - size_t len; time_t date; char*line; - char*lbuf; + char*lbuf = NULL; + size_t lbufsize = 0; char*param; const char *estr; FILE*fp; @@ -75,19 +75,9 @@ cookie_load(void) if (fp == NULL) err(1, "cannot open cookie file %s", cookiefile); date = time(NULL); - lbuf = NULL; - while ((line = fgetln(fp, )) != NULL) { - if (line[len - 1] == '\n') { - line[len - 1] = '\0'; - --len; - } else { - if ((lbuf = malloc(len + 1)) == NULL) - err(1, NULL); - memcpy(lbuf, line, len); - lbuf[len] = '\0'; - line = lbuf; - } - line[strcspn(line, "\r")] = '\0'; + while (getline(, , fp) != -1) { + line = lbuf; + line[strcspn(line, "\r\n")] = '\0'; line += strspn(line, " \t"); if ((*line == '#') || (*line == '\0')) { Index: usr.bin/ftp/fetch.c === RCS file: /cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.200 diff -u -p -r1.200 fetch.c --- usr.bin/ftp/fetch.c 2 Feb 2021 12:58:42 - 1.200 +++ usr.bin/ftp/fetch.c 2 Feb 2021 13:59:09 - @@ -56,7 +56,6 @@ #include #include #include -#include #include #include @@ -76,7 +75,6 @@ static void aborthttp(int); static charhextochar(const char *); static char*urldecode(const char *); static char*recode_credentials(const char *_userinfo); -static char*ftp_readline(FILE *, size_t *); static voidftp_close(FILE **, struct tls **, int *); static const char *sockerror(struct tls *); #ifdef SMALL @@ -330,6 +328,7 @@ url_get(const char *origline, const char off_t hashbytes; const char *errstr; ssize_t len, wlen; + size_t bufsize; char *proxyhost = NULL; #ifndef NOSSL char *sslpath = NULL, *sslhost = NULL; @@ -805,12 +804,13 @@ noslash: free(buf); #endif /* !NOSSL */ buf = NULL; + bufsize = 0; if (fflush(fin) == EOF) { warnx("Writing HTTP request: %s", sockerror(tls)); goto cleanup_url_get; } - if ((buf = ftp_readline(fin, )) == NULL) { + if ((len = getline(, , fin)) == -1) { warnx("Receiving HTTP reply: %s", sockerror(tls)); goto cleanup_url_get; } @@ -885,11 +885,10 @@ noslash: /* * Read the rest of the header. */ - fr
Re: ftp: make use of getline(3)
Christian Weisgerber: > Make use of getline(3) in ftp(1). > > Replace fparseln(3) with getline(3). This removes the only use > of libutil.a(fparseln.o) from the ramdisk. > Replace a complicated fgetln(3) idiom with the much simpler getline(3). New diff that fixes a bug I introduced in cookie loading. OK? Index: distrib/special/ftp/Makefile === RCS file: /cvs/src/distrib/special/ftp/Makefile,v retrieving revision 1.14 diff -u -p -r1.14 Makefile --- distrib/special/ftp/Makefile16 May 2019 12:44:17 - 1.14 +++ distrib/special/ftp/Makefile29 Jan 2021 18:05:46 - @@ -6,7 +6,4 @@ PROG= ftp SRCS= fetch.c ftp.c main.c small.c util.c .PATH: ${.CURDIR}/../../../usr.bin/ftp -LDADD+=-lutil -DPADD+=${LIBUTIL} - .include Index: usr.bin/ftp/Makefile === RCS file: /cvs/src/usr.bin/ftp/Makefile,v retrieving revision 1.34 diff -u -p -r1.34 Makefile --- usr.bin/ftp/Makefile27 Jan 2021 22:27:41 - 1.34 +++ usr.bin/ftp/Makefile29 Jan 2021 17:57:31 - @@ -8,8 +8,8 @@ PROG= ftp SRCS= cmds.c cmdtab.c complete.c cookie.c domacro.c fetch.c ftp.c \ list.c main.c ruserpass.c small.c stringlist.c util.c -LDADD+=-ledit -lcurses -lutil -ltls -lssl -lcrypto -DPADD+=${LIBEDIT} ${LIBCURSES} ${LIBUTIL} ${LIBTLS} ${LIBSSL} ${LIBCRYPTO} +LDADD+=-ledit -lcurses -ltls -lssl -lcrypto +DPADD+=${LIBEDIT} ${LIBCURSES} ${LIBTLS} ${LIBSSL} ${LIBCRYPTO} #COPTS+= -Wall -Wconversion -Wstrict-prototypes -Wmissing-prototypes Index: usr.bin/ftp/cookie.c === RCS file: /cvs/src/usr.bin/ftp/cookie.c,v retrieving revision 1.9 diff -u -p -r1.9 cookie.c --- usr.bin/ftp/cookie.c16 May 2019 12:44:17 - 1.9 +++ usr.bin/ftp/cookie.c6 Feb 2021 16:23:32 - @@ -58,10 +58,10 @@ void cookie_load(void) { field_t field; - size_t len; time_t date; char*line; - char*lbuf; + char*lbuf = NULL; + size_t lbufsize = 0; char*param; const char *estr; FILE*fp; @@ -75,19 +75,9 @@ cookie_load(void) if (fp == NULL) err(1, "cannot open cookie file %s", cookiefile); date = time(NULL); - lbuf = NULL; - while ((line = fgetln(fp, )) != NULL) { - if (line[len - 1] == '\n') { - line[len - 1] = '\0'; - --len; - } else { - if ((lbuf = malloc(len + 1)) == NULL) - err(1, NULL); - memcpy(lbuf, line, len); - lbuf[len] = '\0'; - line = lbuf; - } - line[strcspn(line, "\r")] = '\0'; + while (getline(, , fp) != -1) { + line = lbuf; + line[strcspn(line, "\r\n")] = '\0'; line += strspn(line, " \t"); if ((*line == '#') || (*line == '\0')) { Index: usr.bin/ftp/fetch.c === RCS file: /cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.200 diff -u -p -r1.200 fetch.c --- usr.bin/ftp/fetch.c 2 Feb 2021 12:58:42 - 1.200 +++ usr.bin/ftp/fetch.c 2 Feb 2021 13:59:09 - @@ -56,7 +56,6 @@ #include #include #include -#include #include #include @@ -76,7 +75,6 @@ static void aborthttp(int); static charhextochar(const char *); static char*urldecode(const char *); static char*recode_credentials(const char *_userinfo); -static char*ftp_readline(FILE *, size_t *); static voidftp_close(FILE **, struct tls **, int *); static const char *sockerror(struct tls *); #ifdef SMALL @@ -330,6 +328,7 @@ url_get(const char *origline, const char off_t hashbytes; const char *errstr; ssize_t len, wlen; + size_t bufsize; char *proxyhost = NULL; #ifndef NOSSL char *sslpath = NULL, *sslhost = NULL; @@ -805,12 +804,13 @@ noslash: free(buf); #endif /* !NOSSL */ buf = NULL; + bufsize = 0; if (fflush(fin) == EOF) { warnx("Writing HTTP request: %s", sockerror(tls)); goto cleanup_url_get; } - if ((buf = ftp_readline(fin, )) == NULL) { + if ((len = getline(, , fin)) == -1) { warnx("Receiving HTTP reply: %s", sockerror(tls)); goto cleanup_url_get; } @@ -885,11 +885,10 @@ noslash: /* * Read the rest of the header. */ - free(buf); filesize = -1; for (;;) { - if ((buf = ftp_rea
disklabel: make use of getline(3)
Replace fgetln(3) with getline(3). Since getline() returns a C string, we don't need to carry around the length separately. OK? Index: sbin/disklabel/editor.c === RCS file: /cvs/src/sbin/disklabel/editor.c,v retrieving revision 1.364 diff -u -p -r1.364 editor.c --- sbin/disklabel/editor.c 31 Jan 2021 14:18:44 - 1.364 +++ sbin/disklabel/editor.c 31 Jan 2021 14:35:03 - @@ -172,7 +172,7 @@ voidzero_partitions(struct disklabel *) u_int64_t max_partition_size(struct disklabel *, int); void display_edit(struct disklabel *, char); void psize(u_int64_t sz, char unit, struct disklabel *lp); -char *get_token(char **, size_t *); +char *get_token(char **); intapply_unit(double, u_char, u_int64_t *); intparse_sizespec(const char *, double *, char **); intparse_sizerange(char *, u_int64_t *, u_int64_t *); @@ -2331,8 +2331,8 @@ void parse_autotable(char *filename) { FILE*cfile; - size_t len; - char*buf, *t; + size_t bufsize = 0; + char*buf = NULL, *t; uint idx = 0, pctsum = 0; struct space_allocation *sa; @@ -2342,7 +2342,7 @@ parse_autotable(char *filename) err(1, NULL); alloc_table_nitems = 1; - while ((buf = fgetln(cfile, )) != NULL) { + while (getline(, , cfile) != -1) { if ((alloc_table[0].table = reallocarray(alloc_table[0].table, idx + 1, sizeof(*sa))) == NULL) err(1, NULL); @@ -2350,13 +2350,13 @@ parse_autotable(char *filename) memset(sa, 0, sizeof(*sa)); idx++; - if ((sa->mp = get_token(, )) == NULL || + if ((sa->mp = get_token()) == NULL || (sa->mp[0] != '/' && strcmp(sa->mp, "swap"))) errx(1, "%s: parse error on line %u", filename, idx); - if ((t = get_token(, )) == NULL || + if ((t = get_token()) == NULL || parse_sizerange(t, >minsz, >maxsz) == -1) errx(1, "%s: parse error on line %u", filename, idx); - if ((t = get_token(, )) != NULL && + if ((t = get_token()) != NULL && parse_pct(t, >rate) == -1) errx(1, "%s: parse error on line %u", filename, idx); if (sa->minsz > sa->maxsz) @@ -2367,29 +2367,27 @@ parse_autotable(char *filename) if (pctsum > 100) errx(1, "%s: sum of extra space allocation > 100%%", filename); alloc_table[0].sz = idx; + free(buf); fclose(cfile); } char * -get_token(char **s, size_t *len) +get_token(char **s) { char*p, *r; size_t tlen = 0; p = *s; - while (*len > 0 && !isspace((u_char)**s)) { + while (**s != '\0' && !isspace((u_char)**s)) { (*s)++; - (*len)--; tlen++; } if (tlen == 0) return (NULL); /* eat whitespace */ - while (*len > 0 && isspace((u_char)**s)) { + while (isspace((u_char)**s)) (*s)++; - (*len)--; - } if ((r = strndup(p, tlen)) == NULL) err(1, NULL); -- Christian "naddy" Weisgerber na...@mips.inka.de
fdisk: make use of getline(3)
Replace fgetln(3) with getline(3). OK? Index: sbin/fdisk/misc.c === RCS file: /cvs/src/sbin/fdisk/misc.c,v retrieving revision 1.63 diff -u -p -r1.63 misc.c --- sbin/fdisk/misc.c 3 Jul 2019 03:24:01 - 1.63 +++ sbin/fdisk/misc.c 30 Jan 2021 16:48:36 - @@ -64,20 +64,18 @@ unit_lookup(char *units) int string_from_line(char *buf, size_t buflen) { - char *line; - size_t sz; + static char *line; + static size_t sz; + ssize_t len; - line = fgetln(stdin, ); - if (line == NULL) + len = getline(, , stdin); + if (len == -1) return (1); - if (line[sz - 1] == '\n') - sz--; - if (sz >= buflen) - sz = buflen - 1; + if (line[len - 1] == '\n') + line[len - 1] = '\0'; - memcpy(buf, line, sz); - buf[sz] = '\0'; + strlcpy(buf, line, buflen); return (0); } -- Christian "naddy" Weisgerber na...@mips.inka.de
disklabel: pointer deref fix
Fix a pointer dereference in disklabel(8). This looks like somebody wrote *s[0] in place of (*s)[0]. Which in this case happens to be equivalent, but it still looks wrong. OK? Index: sbin/disklabel/editor.c === RCS file: /cvs/src/sbin/disklabel/editor.c,v retrieving revision 1.363 diff -u -p -U6 -r1.363 editor.c --- sbin/disklabel/editor.c 19 Nov 2019 06:20:37 - 1.363 +++ sbin/disklabel/editor.c 29 Jan 2021 23:50:24 - @@ -2374,22 +2374,22 @@ char * get_token(char **s, size_t *len) { char*p, *r; size_t tlen = 0; p = *s; - while (*len > 0 && !isspace((u_char)*s[0])) { + while (*len > 0 && !isspace((u_char)**s)) { (*s)++; (*len)--; tlen++; } if (tlen == 0) return (NULL); /* eat whitespace */ - while (*len > 0 && isspace((u_char)*s[0])) { + while (*len > 0 && isspace((u_char)**s)) { (*s)++; (*len)--; } if ((r = strndup(p, tlen)) == NULL) err(1, NULL); -- Christian "naddy" Weisgerber na...@mips.inka.de
sed: make use of getline(3)
Replace fgetln(3) with getline(3) in sed. The mf_fgets() part is from Johann Oskarsson for Illumos/FreeBSD. Passes our sed regression tests. OK? Index: usr.bin/sed/main.c === RCS file: /cvs/src/usr.bin/sed/main.c,v retrieving revision 1.41 diff -u -p -r1.41 main.c --- usr.bin/sed/main.c 13 Oct 2020 06:07:54 - 1.41 +++ usr.bin/sed/main.c 29 Jan 2021 23:12:23 - @@ -252,15 +252,9 @@ again: goto again; } case ST_FILE: - if ((p = fgetln(f, )) != NULL) { + if (getline(outbuf, outsize, f) != -1) { + p = *outbuf; linenum++; - if (len >= *outsize) { - free(*outbuf); - *outsize = ROUNDLEN(len + 1); - *outbuf = xmalloc(*outsize); - } - memcpy(*outbuf, p, len); - (*outbuf)[len] = '\0'; if (linenum == 1 && p[0] == '#' && p[1] == 'n') nflag = 1; return (*outbuf); @@ -344,7 +338,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag struct stat sb; size_t len; char dirbuf[PATH_MAX]; - char *p; + static char *p; + static size_t psize; int c, fd; static int firstfile; @@ -429,13 +424,13 @@ mf_fgets(SPACE *sp, enum e_spflag spflag * We are here only when infile is open and we still have something * to read from it. * -* Use fgetln so that we can handle essentially infinite input data. -* Can't use the pointer into the stdio buffer as the process space -* because the ungetc() can cause it to move. +* Use getline() so that we can handle essentially infinite input +* data. The p and psize are static so each invocation gives +* getline() the same buffer which is expanded as needed. */ - p = fgetln(infile, ); - if (ferror(infile)) - error(FATAL, "%s: %s", fname, strerror(errno ? errno : EIO)); + len = getline(, , infile); + if ((ssize_t)len == -1) + error(FATAL, "%s: %s", fname, strerror(errno)); if (len != 0 && p[len - 1] == '\n') { sp->append_newline = 1; len--; -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: ftp: make use of getline(3)
Hiltjo Posthuma: > > @@ -75,19 +74,8 @@ cookie_load(void) > > if (fp == NULL) > > err(1, "cannot open cookie file %s", cookiefile); > > date = time(NULL); > > - lbuf = NULL; > > - while ((line = fgetln(fp, )) != NULL) { > > - if (line[len - 1] == '\n') { > > - line[len - 1] = '\0'; > > - --len; > > - } else { > > - if ((lbuf = malloc(len + 1)) == NULL) > > - err(1, NULL); > > - memcpy(lbuf, line, len); > > - lbuf[len] = '\0'; > > - line = lbuf; > > - } > > - line[strcspn(line, "\r")] = '\0'; > > + while (getline(, , fp) != -1) { > > + line[strcspn(line, "\r\n")] = '\0'; > > > > getline returns the number of characters read including the delimeter. This > size could be used to '\0' terminate the string instead of a strcspn() call. A strcspn() call is already there. -- Christian "naddy" Weisgerber na...@mips.inka.de
ftp: make use of getline(3)
Make use of getline(3) in ftp(1). Replace fparseln(3) with getline(3). This removes the only use of libutil.a(fparseln.o) from the ramdisk. Replace a complicated fgetln(3) idiom with the much simpler getline(3). OK? Index: distrib/special/ftp/Makefile === RCS file: /cvs/src/distrib/special/ftp/Makefile,v retrieving revision 1.14 diff -u -p -r1.14 Makefile --- distrib/special/ftp/Makefile16 May 2019 12:44:17 - 1.14 +++ distrib/special/ftp/Makefile29 Jan 2021 18:05:46 - @@ -6,7 +6,4 @@ PROG= ftp SRCS= fetch.c ftp.c main.c small.c util.c .PATH: ${.CURDIR}/../../../usr.bin/ftp -LDADD+=-lutil -DPADD+=${LIBUTIL} - .include Index: usr.bin/ftp/Makefile === RCS file: /cvs/src/usr.bin/ftp/Makefile,v retrieving revision 1.34 diff -u -p -r1.34 Makefile --- usr.bin/ftp/Makefile27 Jan 2021 22:27:41 - 1.34 +++ usr.bin/ftp/Makefile29 Jan 2021 17:57:31 - @@ -8,8 +8,8 @@ PROG= ftp SRCS= cmds.c cmdtab.c complete.c cookie.c domacro.c fetch.c ftp.c \ list.c main.c ruserpass.c small.c stringlist.c util.c -LDADD+=-ledit -lcurses -lutil -ltls -lssl -lcrypto -DPADD+=${LIBEDIT} ${LIBCURSES} ${LIBUTIL} ${LIBTLS} ${LIBSSL} ${LIBCRYPTO} +LDADD+=-ledit -lcurses -ltls -lssl -lcrypto +DPADD+=${LIBEDIT} ${LIBCURSES} ${LIBTLS} ${LIBSSL} ${LIBCRYPTO} #COPTS+= -Wall -Wconversion -Wstrict-prototypes -Wmissing-prototypes Index: usr.bin/ftp/cookie.c === RCS file: /cvs/src/usr.bin/ftp/cookie.c,v retrieving revision 1.9 diff -u -p -r1.9 cookie.c --- usr.bin/ftp/cookie.c16 May 2019 12:44:17 - 1.9 +++ usr.bin/ftp/cookie.c29 Jan 2021 16:07:56 - @@ -58,10 +58,9 @@ void cookie_load(void) { field_t field; - size_t len; time_t date; - char*line; - char*lbuf; + char*line = NULL; + size_t linesize = 0; char*param; const char *estr; FILE*fp; @@ -75,19 +74,8 @@ cookie_load(void) if (fp == NULL) err(1, "cannot open cookie file %s", cookiefile); date = time(NULL); - lbuf = NULL; - while ((line = fgetln(fp, )) != NULL) { - if (line[len - 1] == '\n') { - line[len - 1] = '\0'; - --len; - } else { - if ((lbuf = malloc(len + 1)) == NULL) - err(1, NULL); - memcpy(lbuf, line, len); - lbuf[len] = '\0'; - line = lbuf; - } - line[strcspn(line, "\r")] = '\0'; + while (getline(, , fp) != -1) { + line[strcspn(line, "\r\n")] = '\0'; line += strspn(line, " \t"); if ((*line == '#') || (*line == '\0')) { @@ -172,7 +160,7 @@ cookie_load(void) } else TAILQ_INSERT_TAIL(, ck, entry); } - free(lbuf); + free(line); fclose(fp); } Index: usr.bin/ftp/fetch.c === RCS file: /cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.199 diff -u -p -r1.199 fetch.c --- usr.bin/ftp/fetch.c 1 Jan 2021 17:39:54 - 1.199 +++ usr.bin/ftp/fetch.c 29 Jan 2021 17:57:58 - @@ -56,7 +56,6 @@ #include #include #include -#include #include #ifndef NOSSL @@ -75,7 +74,6 @@ static void aborthttp(int); static charhextochar(const char *); static char*urldecode(const char *); static char*recode_credentials(const char *_userinfo); -static char*ftp_readline(FILE *, size_t *); static voidftp_close(FILE **, struct tls **, int *); static const char *sockerror(struct tls *); #ifdef SMALL @@ -329,6 +327,7 @@ url_get(const char *origline, const char off_t hashbytes; const char *errstr; ssize_t len, wlen; + size_t bufsize; char *proxyhost = NULL; #ifndef NOSSL char *sslpath = NULL, *sslhost = NULL; @@ -790,12 +789,13 @@ noslash: free(buf); #endif /* !NOSSL */ buf = NULL; + bufsize = 0; if (fflush(fin) == EOF) { warnx("Writing HTTP request: %s", sockerror(tls)); goto cleanup_url_get; } - if ((buf = ftp_readline(fin, )) == NULL) { + if ((len = getline(, , fin)) == -1) { warnx("Receiving HTTP reply: %s", sockerror(tls)); goto cleanup_url_get; } @@ -867,11 +867,10 @@ noslash: /* * Read the rest of the header. */ - free(buf); filesize = -1; for (;;) { - if ((buf =
Re: getopt.3 bugs section
Edgar Pettijohn: > In the BUGS section for the getopt(3) manual it mentions not using > single digits for options. I know spamd uses -4 and -6 there are > probably others. Should they be changed? Or is the manual mistaken? You misunderstand. The manual warns against the use of digits to pass numerical arguments. This usage exists in some historical cases, e.g. "nice -10" where <10> is the number 10. The use of digits as flags characters, like -4 or -6 to indicate IPv4 or IPv6, is perfectly fine. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Rename SIMPLEQ_ to STAILQ_, diff 1/7
Denis Fondras: > This diff renames SIMPLEQ_* to STAILQ_* in /usr/src/sys/sys to unify with > FreeBSD and Linux. > > I added aliases at the end of queue.h to avoid breaking base too much. they > will > be removed as soon as diff 2,3,4,5,6,7 are commited. > > net/sniproxy has a patch to define STAILQ_*, it may be removed later. I applied diffs 1 and 2 and did a "make includes" to ensure that _all_ header files were switched over to STAILQ. I then ran a package bulk build on amd64. There were seven build failures. Except for sniproxy those are all programs developed on OpenBSD that use SIMPLEQ: audio/morseplayer devel/got mail/pop3d net/adsuck net/oicb net/sniproxy x11/spectrwm sniproxy breaks because the renamed s/SIMPLEQ/STAILQ/ macros lack STAILQ_REMOVE(). -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Rename SIMPLEQ_ to STAILQ_, diff 1/7
Theo de Raadt: > What is lacking in this converstation is the justification. > Why? Providing STAILQ in OpenBSD will simplify porting to OpenBSD. (Reality check: There is one port affected by this.) Switching OpenBSD to STAILQ will simplify porting from OpenBSD. (There are three or four FreeBSD ports affected by this.) Having both SIMPLEQ and STAILQ will cause no disruption, but means providing two APIs that are identical except for their name. This appears to be a post-Berkeley divergence; 4.4BSD has neither in . -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Rename SIMPLEQ_ to STAILQ_, diff 1/7
Denis Fondras: > This diff renames SIMPLEQ_* to STAILQ_* in /usr/src/sys/sys to unify with > FreeBSD and Linux. > > I added aliases at the end of queue.h to avoid breaking base too much. they > will > be removed as soon as diff 2,3,4,5,6,7 are commited. We'll need to run a ports bulk build without the aliases. (I can do that.) There will be some breakage. -- Christian "naddy" Weisgerber na...@mips.inka.de
libcurses: --enable-const
ncurses has a configure option that adds a few more consts to its headers by way of the NCURSES_CONST define. Starting with version 6.0, this has become the default. OpenBSD is still on ncurses 5.7, but FreeBSD and I guess most Linux distributions have moved on. I suggest we also enable the additional consts. This eliminates compiler warnings when sharing code with other platforms. The diff below has successfully gone through a release build on amd64, as well as a full amd64 package build. OK? Index: lib/libcurses/curses.h === RCS file: /cvs/src/lib/libcurses/curses.h,v retrieving revision 1.61 diff -u -p -r1.61 curses.h --- lib/libcurses/curses.h 6 Sep 2010 17:26:17 - 1.61 +++ lib/libcurses/curses.h 9 Dec 2020 22:56:31 - @@ -101,7 +101,7 @@ * doing so makes it incompatible with other implementations of X/Open Curses. */ #undef NCURSES_CONST -#define NCURSES_CONST /*nothing*/ +#define NCURSES_CONST const #undef NCURSES_INLINE #define NCURSES_INLINE inline Index: lib/libcurses/term.h === RCS file: /cvs/src/lib/libcurses/term.h,v retrieving revision 1.15 diff -u -p -r1.15 term.h --- lib/libcurses/term.h14 Nov 2015 23:56:49 - 1.15 +++ lib/libcurses/term.h9 Dec 2020 23:03:46 - @@ -68,7 +68,7 @@ extern "C" { */ #undef NCURSES_CONST -#define NCURSES_CONST /*nothing*/ +#define NCURSES_CONST const #undef NCURSES_SBOOL #define NCURSES_SBOOL signed char Index: lib/libcurses/termcap.h === RCS file: /cvs/src/lib/libcurses/termcap.h,v retrieving revision 1.10 diff -u -p -r1.10 termcap.h --- lib/libcurses/termcap.h 10 Dec 2013 20:33:51 - 1.10 +++ lib/libcurses/termcap.h 9 Dec 2020 23:03:54 - @@ -62,7 +62,7 @@ extern "C" #include #undef NCURSES_CONST -#define NCURSES_CONST /*nothing*/ +#define NCURSES_CONST const #undef NCURSES_OSPEED #define NCURSES_OSPEED int -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: rpki-client: use strndup instead of malloc + memcpy
Claudio Jeker: > In tal_parse() use strndup() to create the tal descr instead of the more > complex malloc, memcpy version. Result is the same but the strndup version > is a lot nicer. Yes, but... > --- tal.c 11 Oct 2020 12:39:25 - 1.22 > +++ tal.c 3 Dec 2020 12:00:25 - > @@ -198,10 +198,8 @@ tal_parse(const char *fn, char *buf) > dlen = strlen(d); > if (strcasecmp(d + dlen - 4, ".tal") == 0) > dlen -= 4; That looks like a potential out-of-bounds access. Are we guaranteed that dlen >= 4 here? > - if ((p->descr = malloc(dlen + 1)) == NULL) > + if ((p->descr = strndup(d, dlen)) == NULL) > err(1, NULL); > - memcpy(p->descr, d, dlen); > - p->descr[dlen] = '\0'; > > return p; > } ok -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: powerpc lld fix
Mark Kettenis: > What would the impact on ports of disabling base-gcc be on powerpc? None. $ cd /usr/ports $ make ARCH=macppc MACHINE_ARCH=powerpc show=CHOSEN_COMPILER |grep -B1 base-gcc $ -- Christian "naddy" Weisgerber na...@mips.inka.de
basename(3) should have non-const arg, says POSIX
[Picking this up again after a month:] Our basename(3) and dirname(3) take a const argument: char*basename(const char *); char*dirname(const char *); POSIX says otherwise... char *basename(char *path); char *dirname(char *path); ... and explicitly says the functions may modify the input string. Our functions were const-ified in 1999 by espie@: proper const semantics for dirname & basename. (this follows FreeBSD and Linux. Single Unix 2 is still illogical) Well, four years ago, FreeBSD finally switched to the POSIX prototypes https://svnweb.freebsd.org/base/head/include/libgen.h?revision=303451=markup and in fact now has an implementation that modifies the string. Linux (GNU libc) has a bizarro solution where you get a const basename() and no dirname() if you just include , but POSIX basename() and dirname() if you instead or also include . This is a portability trap. Code written on OpenBSD may not be prepared for basename() or dirname() to splat a '\0' into the input string, despite the warning in the man page. This is not hypothetical. Both Got and OpenCVS have fallen victim to the unportable assumption. The patch below aligns the function prototypes with POSIX. All resulting warnings "passing 'const char *' to parameter of type 'char *' discards qualifiers" in the base system have been cleaned up. It successfully passes "make release". For good measure I'm also running a package bulk build with it as we speak. OK? Index: include/libgen.h === RCS file: /cvs/src/include/libgen.h,v retrieving revision 1.9 diff -u -p -r1.9 libgen.h --- include/libgen.h25 Jan 2019 00:19:25 - 1.9 +++ include/libgen.h11 Sep 2020 20:41:34 - @@ -22,8 +22,8 @@ #include __BEGIN_DECLS -char *basename(const char *); -char *dirname(const char *); +char *basename(char *); +char *dirname(char *); __END_DECLS #endif /* _LIBGEN_H_ */ Index: lib/libc/gen/basename.3 === RCS file: /cvs/src/lib/libc/gen/basename.3,v retrieving revision 1.24 diff -u -p -r1.24 basename.3 --- lib/libc/gen/basename.3 25 Jan 2019 00:19:25 - 1.24 +++ lib/libc/gen/basename.3 11 Sep 2020 20:46:30 - @@ -23,7 +23,7 @@ .Sh SYNOPSIS .In libgen.h .Ft char * -.Fn basename "const char *path" +.Fn basename "char *path" .Sh DESCRIPTION The .Fn basename Index: lib/libc/gen/basename.c === RCS file: /cvs/src/lib/libc/gen/basename.c,v retrieving revision 1.16 diff -u -p -r1.16 basename.c --- lib/libc/gen/basename.c 25 Jan 2019 00:19:25 - 1.16 +++ lib/libc/gen/basename.c 11 Sep 2020 20:43:13 - @@ -22,7 +22,7 @@ #include char * -basename(const char *path) +basename(char *path) { static char bname[PATH_MAX]; size_t len; Index: lib/libc/gen/dirname.3 === RCS file: /cvs/src/lib/libc/gen/dirname.3,v retrieving revision 1.23 diff -u -p -r1.23 dirname.3 --- lib/libc/gen/dirname.3 8 Mar 2019 17:33:23 - 1.23 +++ lib/libc/gen/dirname.3 11 Sep 2020 20:47:08 - @@ -23,7 +23,7 @@ .Sh SYNOPSIS .In libgen.h .Ft char * -.Fn dirname "const char *path" +.Fn dirname "char *path" .Sh DESCRIPTION The .Fn dirname Index: lib/libc/gen/dirname.c === RCS file: /cvs/src/lib/libc/gen/dirname.c,v retrieving revision 1.16 diff -u -p -r1.16 dirname.c --- lib/libc/gen/dirname.c 25 Jan 2019 00:19:25 - 1.16 +++ lib/libc/gen/dirname.c 11 Sep 2020 20:43:34 - @@ -24,7 +24,7 @@ /* A slightly modified copy of this file exists in libexec/ld.so */ char * -dirname(const char *path) +dirname(char *path) { static char dname[PATH_MAX]; size_t len; -- Christian "naddy" Weisgerber na...@mips.inka.de
arm64 ddb: decode "udf" instruction
This decodes the UDF ("permanently undefined") instruction in ddb's arm64 disassembler. The particular immediate16 format appears to be unique to this instruction. OK? Or don't bother? Index: arch/arm64/arm64/disasm.c === RCS file: /cvs/src/sys/arch/arm64/arm64/disasm.c,v retrieving revision 1.2 diff -u -p -r1.2 disasm.c --- arch/arm64/arm64/disasm.c 11 Sep 2020 09:27:10 - 1.2 +++ arch/arm64/arm64/disasm.c 19 Oct 2020 16:17:55 - @@ -3107,6 +3107,11 @@ OP4FUNC(op_tbz, b5, b40, imm14, Rt) PRINTF("\n"); } +OP1FUNC(op_udf, imm16) +{ + PRINTF("udf\t#0x%"PRIx64"\n", imm16); +} + OP4FUNC(op_udiv, sf, Rm, Rn, Rd) { PRINTF("udiv\t%s, %s, %s\n", @@ -3668,6 +3673,8 @@ struct insn_info { {{ 5,16}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}} #define FMT_IMM16_LL \ {{ 5,16}, { 0, 2}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}} +#define FMT_IMM16_UDF \ + {{ 0,16}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}} #define FMT_OP0_OP1_CRN_CRM_OP2_RT \ {{19, 2}, {16, 3}, {12, 4}, { 8, 4}, { 5, 3}, { 0, 5}, { 0, 0}, { 0, 0}} #define FMT_IMM7_RT2_RN_RT \ @@ -3786,6 +3793,7 @@ static const struct insn_info insn_table { 0xd800, 0xdac1, FMT_Z_M_RN_RD, op_pacia }, { 0xcc00, 0x4e284800, FMT_M_D_RN_RD, op_simd_aes }, { 0x8c00, 0x5e280800, FMT_OP3_RN_RD, op_simd_sha_reg2 }, + { 0x, 0x, FMT_IMM16_UDF, op_udf }, { 0xfff8f01f, 0xd500401f, FMT_OP1_CRM_OP2, op_msr_imm }, { 0xfff8, 0xd508, FMT_OP1_CRN_CRM_OP2_RT, op_sys }, { 0xfff8, 0xd528, FMT_OP1_CRN_CRM_OP2_RT, op_sysl }, -- Christian "naddy" Weisgerber na...@mips.inka.de
arm64, armv7: proper illegal instruction
Belatedly, ARM has taken a slice of the reserved opcode space and assigned it as a properly defined illegal instruction, udf #imm16. (Armv8 Architecture Reference Manual, edition F.c, section C6.2.335). Clang already knows about it. We really should use this instead of picking something ad-hoc out of the opcode space. I have verified that this builds on arm64, produces a SIGILL in userland, and drops me into ddb in the kernel. armv7 has an equivalent instruction. kettenis@ confirms it builds and SIGILLs there. OK? Index: lib/csu/aarch64/md_init.h === RCS file: /cvs/src/lib/csu/aarch64/md_init.h,v retrieving revision 1.9 diff -u -p -r1.9 md_init.h --- lib/csu/aarch64/md_init.h 15 Oct 2020 16:30:21 - 1.9 +++ lib/csu/aarch64/md_init.h 19 Oct 2020 11:57:02 - @@ -115,5 +115,5 @@ " svc #0 \n" \ " dsb nsh \n" \ " isb \n" \ - " .word 0xa000f7f0 /* illegal */ \n" \ + " udf #0 \n" \ ".previous"); Index: lib/csu/arm/md_init.h === RCS file: /cvs/src/lib/csu/arm/md_init.h,v retrieving revision 1.16 diff -u -p -r1.16 md_init.h --- lib/csu/arm/md_init.h 15 Oct 2020 16:30:23 - 1.16 +++ lib/csu/arm/md_init.h 19 Oct 2020 13:23:00 - @@ -159,5 +159,5 @@ " swi #0 \n" \ " dsb nsh \n" \ " isb \n" \ - " .word 0xa000f7f0 /* illegal */ \n" \ + " udf #0 \n" \ ".previous"); Index: lib/libc/arch/aarch64/sys/tfork_thread.S === RCS file: /cvs/src/lib/libc/arch/aarch64/sys/tfork_thread.S,v retrieving revision 1.5 diff -u -p -r1.5 tfork_thread.S --- lib/libc/arch/aarch64/sys/tfork_thread.S18 Oct 2020 14:28:16 - 1.5 +++ lib/libc/arch/aarch64/sys/tfork_thread.S19 Oct 2020 11:59:32 - @@ -43,6 +43,6 @@ ENTRY(__tfork_thread) mov x0, x3 blr x2 SYSTRAP(__threxit) - .word 0xa000f7f0 /* illegal on all cpus? */ + udf #0 .cfi_endproc END(__tfork_thread) Index: lib/libc/arch/arm/sys/tfork_thread.S === RCS file: /cvs/src/lib/libc/arch/arm/sys/tfork_thread.S,v retrieving revision 1.5 diff -u -p -r1.5 tfork_thread.S --- lib/libc/arch/arm/sys/tfork_thread.S18 Oct 2020 14:28:17 - 1.5 +++ lib/libc/arch/arm/sys/tfork_thread.S19 Oct 2020 13:23:35 - @@ -37,5 +37,5 @@ ENTRY(__tfork_thread) mov pc, r2 nop SYSTRAP(__threxit) - .word 0xa000f7f0 /* illegal on all cpus? */ + udf #0 END(__tfork_thread) Index: sys/arch/arm/arm/sigcode.S === RCS file: /cvs/src/sys/arch/arm/arm/sigcode.S,v retrieving revision 1.9 diff -u -p -r1.9 sigcode.S --- sys/arch/arm/arm/sigcode.S 13 Mar 2020 08:46:50 - 1.9 +++ sys/arch/arm/arm/sigcode.S 19 Oct 2020 13:23:55 - @@ -72,7 +72,7 @@ _C_LABEL(esigcode): .globl sigfill sigfill: - .word 0xa000f7f0 /* illegal on all cpus? */ + udf #0 esigfill: .data Index: sys/arch/arm64/arm64/locore.S === RCS file: /cvs/src/sys/arch/arm64/arm64/locore.S,v retrieving revision 1.31 diff -u -p -r1.31 locore.S --- sys/arch/arm64/arm64/locore.S 13 Mar 2020 00:14:38 - 1.31 +++ sys/arch/arm64/arm64/locore.S 19 Oct 2020 12:02:23 - @@ -366,7 +366,7 @@ _C_LABEL(esigcode): .globl sigfill sigfill: - .word 0xa000f7f0 /* FIXME: illegal on all cpus? */ + udf #0 esigfill: .data -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: usr.bin/cvs
Accommodate POSIX basename(3) that takes a non-const parameter and may modify the string buffer. There were only two compiler warnings about discarded const, but there are numerous instances where the code assumes non-POSIX semantics for basename() and dirname(). Given that there is at least a FreeBSD port of OpenCVS, cleaning this up is more than cosmetic. This could definitely use proofreading. I chose __func__ (otherwise not used anywhere) over breaking an overly long "function_" "name" into parts like that. OK? Index: usr.bin/cvs/admin.c === RCS file: /cvs/src/usr.bin/cvs/admin.c,v retrieving revision 1.68 diff -u -p -r1.68 admin.c --- usr.bin/cvs/admin.c 1 Jun 2017 08:08:24 - 1.68 +++ usr.bin/cvs/admin.c 16 Oct 2020 21:14:05 - @@ -246,12 +246,17 @@ cvs_admin_local(struct cvs_file *cf) struct cvs_file *ocf; struct rcs_access *acp; int ofd; - char *d, *f, fpath[PATH_MAX], repo[PATH_MAX]; + char *d, dbuf[PATH_MAX], *f, fbuf[PATH_MAX]; + char fpath[PATH_MAX], repo[PATH_MAX]; - - if ((f = basename(oldfilename)) == NULL) + if (strlcpy(fbuf, oldfilename, sizeof(fbuf)) >= sizeof(fbuf)) + fatal("cvs_admin_local: truncation"); + if ((f = basename(fbuf)) == NULL) fatal("cvs_admin_local: basename failed"); - if ((d = dirname(oldfilename)) == NULL) + + if (strlcpy(dbuf, oldfilename, sizeof(dbuf)) >= sizeof(dbuf)) + fatal("cvs_admin_local: truncation"); + if ((d = dirname(dbuf)) == NULL) fatal("cvs_admin_local: dirname failed"); cvs_get_repository_path(d, repo, PATH_MAX); Index: usr.bin/cvs/checkout.c === RCS file: /cvs/src/usr.bin/cvs/checkout.c,v retrieving revision 1.171 diff -u -p -r1.171 checkout.c --- usr.bin/cvs/checkout.c 1 Jun 2017 08:08:24 - 1.171 +++ usr.bin/cvs/checkout.c 16 Oct 2020 21:46:33 - @@ -239,7 +239,7 @@ checkout_check_repository(int argc, char struct module_checkout *mc; struct cvs_ignpat *ip; struct cvs_filelist *fl, *nxt; - char repo[PATH_MAX], fpath[PATH_MAX], *f[1]; + char repo[PATH_MAX], fpath[PATH_MAX], path[PATH_MAX], *f[1]; build_dirs = print_stdout ? 0 : 1; @@ -329,14 +329,25 @@ checkout_check_repository(int argc, char cr.flags = flags; if (!(mc->mc_flags & MODULE_ALIAS)) { + if (strlcpy(path, fl->file_path, + sizeof(path)) >= sizeof(path)) + fatal("%s: truncation", + __func__); module_repo_root = - xstrdup(dirname(fl->file_path)); + xstrdup(dirname(path)); d = wdir; + if (strlcpy(path, fl->file_path, + sizeof(path)) >= sizeof(path)) + fatal("%s: truncation", + __func__); (void)xsnprintf(fpath, sizeof(fpath), - "%s/%s", d, - basename(fl->file_path)); + "%s/%s", d, basename(path)); } else { - d = dirname(wdir); + if (strlcpy(path, wdir, + sizeof(path)) >= sizeof(path)) + fatal("%s: truncation", + __func__); + d = dirname(path); strlcpy(fpath, fl->file_path, sizeof(fpath)); } @@ -387,7 +398,7 @@ checkout_check_repository(int argc, char static int checkout_classify(const char *repo, const char *arg) { - char *d, *f, fpath[PATH_MAX]; + char *d, dbuf[PATH_MAX], *f, fbuf[PATH_MAX], fpath[PATH_MAX]; struct stat sb; if (stat(repo, ) == 0) { @@ -395,8 +406,13 @@ checkout_classify(const char *repo, cons return CVS_DIR; } - d = dirname(repo); - f = basename(repo); + if (strlcpy(dbuf, repo, sizeof(dbuf)) >= sizeof(dbuf)) + fatal("checkout_classify: truncation"); + d =
Non-const basename: usr.bin/ftp
Accommodate POSIX basename(3) that takes a non-const parameter and may modify the string buffer. I've tried to follow the conventions of the existing code. ok? Index: usr.bin/ftp/fetch.c === RCS file: /cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.197 diff -u -p -r1.197 fetch.c --- usr.bin/ftp/fetch.c 4 Jul 2020 11:23:35 - 1.197 +++ usr.bin/ftp/fetch.c 15 Oct 2020 21:14:28 - @@ -192,7 +192,7 @@ file_get(const char *path, const char *o int fd, out = -1, rval = -1, save_errno; volatile sig_t oldintr, oldinti; const char *savefile; - char*buf = NULL, *cp; + char*buf = NULL, *cp, *pathbuf = NULL; const size_t buflen = 128 * 1024; off_thashbytes; ssize_t len, wlen; @@ -215,8 +215,12 @@ file_get(const char *path, const char *o else { if (path[strlen(path) - 1] == '/') /* Consider no file */ savefile = NULL;/* after dir invalid. */ - else - savefile = basename(path); + else { + pathbuf = strdup(path); + if (pathbuf == NULL) + errx(1, "Can't allocate memory for filename"); + savefile = basename(pathbuf); + } } if (EMPTYSTRING(savefile)) { @@ -294,6 +298,7 @@ file_get(const char *path, const char *o cleanup_copy: free(buf); + free(pathbuf); if (out >= 0 && out != fileno(stdout)) close(out); close(fd); @@ -315,6 +320,7 @@ url_get(const char *origline, const char int isunavail = 0, retryafter = -1; struct addrinfo hints, *res0, *res; const char *savefile; + char *pathbuf = NULL; char *proxyurl = NULL; char *credentials = NULL, *proxy_credentials = NULL; int fd = -1, out = -1; @@ -412,8 +418,12 @@ noslash: else { if (path[strlen(path) - 1] == '/') /* Consider no file */ savefile = NULL;/* after dir invalid. */ - else - savefile = basename(path); + else { + pathbuf = strdup(path); + if (pathbuf == NULL) + errx(1, "Can't allocate memory for filename"); + savefile = basename(pathbuf); + } } if (EMPTYSTRING(savefile)) { @@ -1106,6 +1116,7 @@ cleanup_url_get: if (out >= 0 && out != fileno(stdout)) close(out); free(buf); + free(pathbuf); free(proxyhost); free(proxyurl); free(newline); Index: usr.bin/ftp/util.c === RCS file: /cvs/src/usr.bin/ftp/util.c,v retrieving revision 1.93 diff -u -p -r1.93 util.c --- usr.bin/ftp/util.c 6 Jul 2020 17:11:29 - 1.93 +++ usr.bin/ftp/util.c 15 Oct 2020 21:31:55 - @@ -763,7 +763,7 @@ progressmeter(int flag, const char *file off_t cursize, abbrevsize; double elapsed; int ratio, barlength, i, remaining, overhead = 30; - char buf[512]; + char buf[512], *filenamebuf; if (flag == -1) { clock_gettime(CLOCK_MONOTONIC, ); @@ -782,11 +782,13 @@ progressmeter(int flag, const char *file ratio = MAXIMUM(ratio, 0); ratio = MINIMUM(ratio, 100); if (!verbose && flag == -1) { - filename = basename(filename); - if (filename != NULL) { + filenamebuf = strdup(filename); + filename = basename(filenamebuf); + if (filenamebuf != NULL && filename != NULL) { free(title); title = strdup(filename); } + free(filenamebuf); } buf[0] = 0; -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: usr.sbin/vmd, usr.sbin/vmctl
Accommodate POSIX basename(3) that takes a non-const parameter and may in fact modify the string buffer. The file is built by vmd and vmctl. I'm uncertain if we want a truncation check here. Both in vmd and vmctl, the path has been validated by a previous open(), but given the code complexity, do we want to rely on this? Index: usr.sbin/vmd/vioqcow2.c === RCS file: /cvs/src/usr.sbin/vmd/vioqcow2.c,v retrieving revision 1.13 diff -u -p -r1.13 vioqcow2.c --- usr.sbin/vmd/vioqcow2.c 10 Jan 2019 19:21:02 - 1.13 +++ usr.sbin/vmd/vioqcow2.c 14 Oct 2020 20:57:31 - @@ -145,6 +145,7 @@ virtio_qcow2_init(struct virtio_backing ssize_t virtio_qcow2_get_base(int fd, char *path, size_t npath, const char *dpath) { + char dpathbuf[PATH_MAX]; char expanded[PATH_MAX]; struct qcheader header; uint64_t backingoff; @@ -186,7 +187,8 @@ virtio_qcow2_get_base(int fd, char *path return -1; } } else { - s = dirname(dpath); + strlcpy(dpathbuf, dpath, sizeof(dpathbuf)); + s = dirname(dpathbuf); if (snprintf(expanded, sizeof(expanded), "%s/%s", s, path) >= (int)sizeof(expanded)) { log_warnx("path too long: %s/%s", s, path); -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: usr.bin/rcs
Accommodate POSIX basename(3) that takes a non-const parameter and may in fact modify the string buffer. ok? Index: usr.bin/rcs/rlog.c === RCS file: /cvs/src/usr.bin/rcs/rlog.c,v retrieving revision 1.74 diff -u -p -r1.74 rlog.c --- usr.bin/rcs/rlog.c 16 Oct 2016 13:35:51 - 1.74 +++ usr.bin/rcs/rlog.c 14 Oct 2020 20:18:55 - @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -348,7 +349,7 @@ rlog_select_daterev(RCSFILE *rcsfile, ch static void rlog_file(const char *fname, RCSFILE *file) { - char numb[RCS_REV_BUFSZ]; + char fnamebuf[PATH_MAX], numb[RCS_REV_BUFSZ]; u_int nrev; struct rcs_sym *sym; struct rcs_access *acp; @@ -364,7 +365,10 @@ rlog_file(const char *fname, RCSFILE *fi } else nrev = file->rf_ndelta; - if ((workfile = basename(fname)) == NULL) + if (strlcpy(fnamebuf, fname, sizeof(fnamebuf)) >= sizeof(fnamebuf)) + errx(1, "rlog_file: truncation"); + + if ((workfile = basename(fnamebuf)) == NULL) err(1, "basename"); /* -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: sbin/pfctl
Accommodate a basename(3) that takes a non-const parameter and may in fact modify the string buffer. The length of anchor has already been checked in main(). ok? Index: sbin/pfctl/pfctl.c === RCS file: /cvs/src/sbin/pfctl/pfctl.c,v retrieving revision 1.382 diff -u -p -r1.382 pfctl.c --- sbin/pfctl/pfctl.c 16 Jan 2020 01:02:20 - 1.382 +++ sbin/pfctl/pfctl.c 13 Oct 2020 20:45:16 - @@ -2241,16 +2241,19 @@ pfctl_get_anchors(int dev, const char *a { struct pfioc_rulesetpr; static struct pfr_anchors anchors; + char anchorbuf[PATH_MAX]; char *n; SLIST_INIT(); memset(, 0, sizeof(pr)); if (*anchor != '\0') { - n = dirname(anchor); + strlcpy(anchorbuf, anchor, sizeof(anchorbuf)); + n = dirname(anchorbuf); if (n[0] != '.' && n[1] != '\0') strlcpy(pr.path, n, sizeof(pr.path)); - n = basename(anchor); + strlcpy(anchorbuf, anchor, sizeof(anchorbuf)); + n = basename(anchorbuf); if (n != NULL) strlcpy(pr.name, n, sizeof(pr.name)); } -- Christian "naddy" Weisgerber na...@mips.inka.de
net/pfvar.h: MAXPATHLEN -> PATH_MAX
In revision 1.407 of , deraadt@ replaced MAXPATHLEN with PATH_MAX so userland wouldn't have to pull in . In 1.466, sashan@ accidentally slipped one MAXPATHLEN back in, because its use is ubiquitous on the kernel side of pf. Switch this over to PATH_MAX again. pfctl(8) doesn't actually use this, so it's very cosmetic. Index: sys/net/pfvar.h === RCS file: /cvs/src/sys/net/pfvar.h,v retrieving revision 1.496 diff -u -p -r1.496 pfvar.h --- sys/net/pfvar.h 24 Aug 2020 15:30:58 - 1.496 +++ sys/net/pfvar.h 13 Oct 2020 20:21:04 - @@ -475,7 +475,7 @@ union pf_rule_ptr { }; #definePF_ANCHOR_NAME_SIZE 64 -#definePF_ANCHOR_MAXPATH (MAXPATHLEN - PF_ANCHOR_NAME_SIZE - 1) +#definePF_ANCHOR_MAXPATH (PATH_MAX - PF_ANCHOR_NAME_SIZE - 1) #definePF_OPTIMIZER_TABLE_PFX "__automatic_" struct pf_rule { -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: bin/chio
As far as I understand, the basename() here is specifically intended to skip a leading "/dev/". So how about doing this expressly? Do we want to use _PATH_DEV or "/dev/"? There's a "/dev/rst%d" a few lines outside of the diff context... Index: bin/chio/parse.y === RCS file: /cvs/src/bin/chio/parse.y,v retrieving revision 1.22 diff -u -p -r1.22 parse.y --- bin/chio/parse.y13 Feb 2019 22:57:07 - 1.22 +++ bin/chio/parse.y13 Oct 2020 19:23:22 - @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -445,10 +446,12 @@ parse_tapedev(const char *filename, cons errors = file->errors; popfile(); + if (strncmp(changer, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) + changer += sizeof(_PATH_DEV) - 1; TAILQ_FOREACH(p, , entry) { - if (strcmp(basename(changer), p->name) == 0) { + if (strcmp(changer, p->name) == 0) { if (drive >= 0 && drive < p->drivecnt) { - if (asprintf(, "/dev/%s", + if (asprintf(, _PATH_DEV "%s", p->drives[drive]) == -1) errx(1, "malloc failed"); } else -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: usr.sbin/hotplugd
Accommodate a basename(3) that takes a non-const parameter and may in fact modify the string buffer. Between access(file, ...) and execl(file, ...), no check for truncation should be necessary. ok? Index: usr.sbin/hotplugd/hotplugd.c === RCS file: /cvs/src/usr.sbin/hotplugd/hotplugd.c,v retrieving revision 1.15 diff -u -p -r1.15 hotplugd.c --- usr.sbin/hotplugd/hotplugd.c30 Apr 2019 17:05:15 - 1.15 +++ usr.sbin/hotplugd/hotplugd.c13 Oct 2020 16:19:43 - @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -163,7 +164,10 @@ exec_script(const char *file, int class, } if (pid == 0) { /* child process */ - execl(file, basename(file), strclass, name, (char *)NULL); + char filebuf[PATH_MAX]; + + strlcpy(filebuf, file, sizeof(filebuf)); + execl(file, basename(filebuf), strclass, name, (char *)NULL); syslog(LOG_ERR, "execl %s: %m", file); _exit(1); /* NOTREACHED */ -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: libkvm
Accommodate a basename(3) that takes a non-const parameter and may in fact modify the string buffer. Note that strlen(uf) >= PATH_MAX is already checked by the caller in _kvm_open(). ok? Index: lib/libkvm/kvm.c === RCS file: /cvs/src/lib/libkvm/kvm.c,v retrieving revision 1.66 diff -u -p -r1.66 kvm.c --- lib/libkvm/kvm.c28 Jun 2019 13:32:42 - 1.66 +++ lib/libkvm/kvm.c13 Oct 2020 08:55:29 - @@ -676,12 +676,13 @@ static int kvm_dbopen(kvm_t *kd, const char *uf) { char dbversion[_POSIX2_LINE_MAX], kversion[_POSIX2_LINE_MAX]; - char dbname[PATH_MAX]; + char dbname[PATH_MAX], ufbuf[PATH_MAX]; struct nlist nitem; size_t dbversionlen; DBT rec; - uf = basename(uf); + strlcpy(ufbuf, uf, sizeof(ufbuf)); + uf = basename(ufbuf); (void)snprintf(dbname, sizeof(dbname), "%skvm_%s.db", _PATH_VARDB, uf); kd->db = dbopen(dbname, O_RDONLY, 0, DB_HASH, NULL); -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Non-const basename: usr.bin/sed
Martijn van Duren: > Wouldn't the following diff be a little simpler? Yes, it would. Should dirbuf be static like oldfname and tmpfname? Index: main.c === RCS file: /cvs/src/usr.bin/sed/main.c,v retrieving revision 1.40 diff -u -p -r1.40 main.c --- main.c 8 Dec 2018 23:11:24 - 1.40 +++ main.c 11 Oct 2020 15:08:29 - @@ -96,6 +96,7 @@ const char *fname;/* File name. */ const char *outfname; /* Output file name */ static char oldfname[PATH_MAX];/* Old file name (for in-place editing) */ static char tmpfname[PATH_MAX];/* Temporary file name (for in-place editing) */ +static char dirbuf[PATH_MAX]; /* Temporary path name (for dirname(3)) */ char *inplace; /* Inplace edit file extension */ u_long linenum; @@ -397,8 +398,9 @@ mf_fgets(SPACE *sp, enum e_spflag spflag if (len > sizeof(oldfname)) error(FATAL, "%s: name too long", fname); } - len = snprintf(tmpfname, sizeof(tmpfname), "%s/sedXX", - dirname(fname)); + strlcpy(dirbuf, fname, sizeof(dirbuf)); + len = snprintf(tmpfname, sizeof(tmpfname), + "%s/sedXX", dirname(dirbuf)); if (len >= sizeof(tmpfname)) error(FATAL, "%s: name too long", fname); if ((fd = mkstemp(tmpfname)) == -1) -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: WANTLIB problems and possible solution: the libset design
Marc Espie: > The new design: > > The idea behind "libset" is to be able to specify a "set" of wantlib that > corresponds to our package, AND to just write WANTLIB wrt that libset for > that specific set of libraries. I'm struggling to understand whether this libset records the libraries a port depends on, the libraries the port provides, or both. Let's say--slightly simplified from reality--we have devel/gettext that provides libintl and depends on iconv from converters/libiconv. What would gettext's LIBSET entry look like? (1) LIBSET = iconv (2) LIBSET = intl (3) LIBSET = intl iconv -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: usr.bin/compress
Accommodate POSIX basename(3) that takes a non-const parameter and may in fact modify the string buffer. Following martijn@'s comment for the sed diff, we don't need to check for truncation because the "in" path has already been validated by a preceding open(2). ok? Index: usr.bin/compress/main.c === RCS file: /cvs/src/usr.bin/compress/main.c,v retrieving revision 1.96 diff -u -p -r1.96 main.c --- usr.bin/compress/main.c 28 Jun 2019 13:35:00 - 1.96 +++ usr.bin/compress/main.c 10 Oct 2020 20:10:44 - @@ -481,6 +481,7 @@ docompress(const char *in, char *out, co { #ifndef SMALL u_char buf[Z_BUFSIZE]; + char namebuf[PATH_MAX]; char *name; int error, ifd, ofd, oreg; void *cookie; @@ -534,7 +535,8 @@ docompress(const char *in, char *out, co } if (!pipin && storename) { - name = basename(in); + strlcpy(namebuf, in, sizeof(namebuf)); + name = basename(namebuf); mtime = (u_int32_t)sb->st_mtime; } if ((cookie = method->wopen(ofd, name, bits, mtime)) == NULL) { -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: usr.bin/sed
Changing basename(3) and dirname(3) to the POSIX-mandated non-const parameters produces this warnings when compiling sed(1): /usr/src/usr.bin/sed/main.c:401:16: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qua lifiers] Here's a fix to accommodate a basename(3) that takes a non-const parameter and may in fact modify the string buffer. Based on FreeBSD like the surrounding in-place editing code. OK? Index: main.c === RCS file: /cvs/src/usr.bin/sed/main.c,v retrieving revision 1.40 diff -u -p -r1.40 main.c --- main.c 8 Dec 2018 23:11:24 - 1.40 +++ main.c 10 Oct 2020 15:16:12 - @@ -343,6 +343,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag { struct stat sb; size_t len; + char *dirbuf; char *p; int c, fd; static int firstfile; @@ -397,8 +398,11 @@ mf_fgets(SPACE *sp, enum e_spflag spflag if (len > sizeof(oldfname)) error(FATAL, "%s: name too long", fname); } + if ((dirbuf = strdup(fname)) == NULL) + error(FATAL, "%s", strerror(errno)); len = snprintf(tmpfname, sizeof(tmpfname), "%s/sedXX", - dirname(fname)); + dirname(dirbuf)); + free(dirbuf); if (len >= sizeof(tmpfname)) error(FATAL, "%s: name too long", fname); if ((fd = mkstemp(tmpfname)) == -1) -- Christian "naddy" Weisgerber na...@mips.inka.de
Non-const basename: usr.bin/patch
Changing basename(3) and dirname(3) to the POSIX-mandated non-const parameters produces these warnings when compiling patch(1): /usr/src/usr.bin/patch/backupfile.c:61:34: warning: passing 'const char *' to pa rameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-disca rds-qualifiers] /usr/src/usr.bin/patch/backupfile.c:64:16: warning: passing 'const char *' to pa rameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-disca rds-qualifiers] Here's a fix to accommodate a basename(3) that takes a non-const parameter and may in fact modify the string buffer. This is originally from Joerg Sonnenberger for DragonFly BSD and has since spread to the other BSDs. https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/41871674d0079dec70d55eb824f39d07dc7b3310 (The corresponding change to inp.c is no longer applicable as that code has been removed.) OK? Index: usr.bin/patch/backupfile.c === RCS file: /cvs/src/usr.bin/patch/backupfile.c,v retrieving revision 1.21 diff -u -p -r1.21 backupfile.c --- usr.bin/patch/backupfile.c 26 Nov 2013 13:19:07 - 1.21 +++ usr.bin/patch/backupfile.c 10 Oct 2020 14:36:58 - @@ -53,21 +53,32 @@ static void invalid_arg(const char *, co char * find_backup_file_name(const char *file) { - char*dir, *base_versions; + char*dir, *base_versions, *tmp_file; int highest_backup; if (backup_type == simple) return concat(file, simple_backup_suffix); - base_versions = concat(basename(file), ".~"); + tmp_file = strdup(file); + if (tmp_file == NULL) + return NULL; + base_versions = concat(basename(tmp_file), ".~"); + free(tmp_file); if (base_versions == NULL) return NULL; - dir = dirname(file); + tmp_file = strdup(file); + if (tmp_file == NULL) { + free(base_versions); + return NULL; + } + dir = dirname(tmp_file); if (dir == NULL) { free(base_versions); + free(tmp_file); return NULL; } highest_backup = max_backup_version(base_versions, dir); free(base_versions); + free(tmp_file); if (backup_type == numbered_existing && highest_backup == 0) return concat(file, simple_backup_suffix); return make_version_name(file, highest_backup + 1); -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: ssh-keygen: generate ed25519 keys by default
On 2020-10-08, Eldritch wrote: > With the recent change to prefer ed25519 keys on the server side [1] > (unless I misunderstood what the change does), I think generating This only changed the client's order of preference for the various server key types. If a server doesn't offer an Ed25519 key, the client will transparently fall back to one of the other types. > ed25519 keys by default with ssh-keygen makes sense at this point. > > Is there a reason not to do this? I am curious if so, as there's no > discussion on this matter that I could find. Those are mostly user keys. What happens if you upload an Ed25519 public user key to a server that doesn't handle this key type? It won't work. And you're not likely to be presented with a helpful error message. It just doesn't work. At this point, I don't know how many SSH servers are still out there that don't handle Ed25519. I still have an ECDSA key somewhere that I use to log into a machine that still runs... "OpenSSH_6.0p1 Debian-4+deb7u7, OpenSSL 1.0.1t 3 May 2016". There is a lot of networking equipment that allows uploading of a user key for SSH login but may include a comically obsolete version of OpenSSH or some alternative implementation that doesn't do Ed25519. So... is it the right time yet? I don't know, and it's certainly not my decision, but I think that's the background. > --- ssh-keygen.c 9 Sep 2020 03:08:01 - 1.420 > +++ ssh-keygen.c 8 Oct 2020 08:21:37 - That's at least missing a corresponding change to the man page. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: basename(3) should have non-const arg, says POSIX
Todd C. Miller: > This is probably the right thing to do but we should fix the warnings > it generates. In this new world order, passing a const char * to > basename() or dirname() is unsafe. FWIW, here's the list: /usr/src/lib/libkvm/kvm.c:684:16: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] uf = basename(uf); ^~ /usr/src/bin/chio/parse.y:449:23: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] if (strcmp(basename(changer), p->name) == 0) { ^~~ /usr/src/sbin/pfctl/pfctl.c:2250:15: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] n = dirname(anchor); ^~ /usr/src/sbin/pfctl/pfctl.c:2253:16: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] n = basename(anchor); ^~ /usr/src/usr.bin/compress/main.c:537:19: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] name = basename(in); ^~ /usr/src/usr.bin/cvs/checkout.c:398:14: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] d = dirname(repo); ^~~~ /usr/src/usr.bin/cvs/checkout.c:399:15: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] f = basename(repo); ^~~~ /usr/src/usr.bin/ftp/fetch.c:219:24: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] savefile = basename(path); ^~~~ /usr/src/usr.bin/ftp/util.c:785:23: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] filename = basename(filename); ^~~~ /usr/src/usr.bin/patch/backupfile.c:61:34: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] base_versions = concat(basename(file), ".~"); ^~~~ /usr/src/usr.bin/patch/backupfile.c:64:16: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] dir = dirname(file); ^~~~ /usr/src/usr.bin/rcs/rlog.c:367:27: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] if ((workfile = basename(fname)) == NULL) ^ /usr/src/usr.bin/sed/main.c:401:16: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] dirname(fname)); ^ /usr/src/usr.sbin/hotplugd/hotplugd.c:166:24: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] execl(file, basename(file), strclass, name, (char *)NULL); ^~~~ /usr/src/usr.sbin/vmd/vioqcow2.c:189:15: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] s = dirname(dpath); ^ /usr/src/usr.sbin/vmctl/../vmd/vioqcow2.c:189:15: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] s = dirname(dpath); ^ -- Christian "naddy" Weisgerber na...@mips.inka.de
basename(3) should have non-const arg, says POSIX
Our basename(3) and dirname(3) take a const argument: char*basename(const char *); char*dirname(const char *); POSIX says otherwise... char *basename(char *path); char *dirname(char *path); ... and explicitly says the functions may modify the input string. Our functions were const-ified in 1999 by espie@: proper const semantics for dirname & basename. (this follows FreeBSD and Linux. Single Unix 2 is still illogical) Well, four years ago, FreeBSD finally switched to the POSIX prototypes https://svnweb.freebsd.org/base/head/include/libgen.h?revision=303451=markup and in fact now has an implementation that modifies the string. Linux (GNU libc) has a bizarro solution where you get a const basename() and no dirname() if you just include , but POSIX basename() and dirname() if you instead or also include . A make build with the patch below succeeds, but gains some new warnings "passing 'const char *' to parameter of type 'char *' discards qualifiers". This is a portability trap. Code written on OpenBSD may not be prepared for basename() or dirname() to splat a '\0' into the input string, despite the warning in the man page. I'm in favor of moving to the POSIX prototypes, but I don't know if there are any hidden pitfalls I may be missing. Opinions, comments? Index: include/libgen.h === RCS file: /cvs/src/include/libgen.h,v retrieving revision 1.9 diff -u -p -r1.9 libgen.h --- include/libgen.h25 Jan 2019 00:19:25 - 1.9 +++ include/libgen.h11 Sep 2020 20:41:34 - @@ -22,8 +22,8 @@ #include __BEGIN_DECLS -char *basename(const char *); -char *dirname(const char *); +char *basename(char *); +char *dirname(char *); __END_DECLS #endif /* _LIBGEN_H_ */ Index: lib/libc/gen/basename.3 === RCS file: /cvs/src/lib/libc/gen/basename.3,v retrieving revision 1.24 diff -u -p -r1.24 basename.3 --- lib/libc/gen/basename.3 25 Jan 2019 00:19:25 - 1.24 +++ lib/libc/gen/basename.3 11 Sep 2020 20:46:30 - @@ -23,7 +23,7 @@ .Sh SYNOPSIS .In libgen.h .Ft char * -.Fn basename "const char *path" +.Fn basename "char *path" .Sh DESCRIPTION The .Fn basename Index: lib/libc/gen/basename.c === RCS file: /cvs/src/lib/libc/gen/basename.c,v retrieving revision 1.16 diff -u -p -r1.16 basename.c --- lib/libc/gen/basename.c 25 Jan 2019 00:19:25 - 1.16 +++ lib/libc/gen/basename.c 11 Sep 2020 20:43:13 - @@ -22,7 +22,7 @@ #include char * -basename(const char *path) +basename(char *path) { static char bname[PATH_MAX]; size_t len; Index: lib/libc/gen/dirname.3 === RCS file: /cvs/src/lib/libc/gen/dirname.3,v retrieving revision 1.23 diff -u -p -r1.23 dirname.3 --- lib/libc/gen/dirname.3 8 Mar 2019 17:33:23 - 1.23 +++ lib/libc/gen/dirname.3 11 Sep 2020 20:47:08 - @@ -23,7 +23,7 @@ .Sh SYNOPSIS .In libgen.h .Ft char * -.Fn dirname "const char *path" +.Fn dirname "char *path" .Sh DESCRIPTION The .Fn dirname Index: lib/libc/gen/dirname.c === RCS file: /cvs/src/lib/libc/gen/dirname.c,v retrieving revision 1.16 diff -u -p -r1.16 dirname.c --- lib/libc/gen/dirname.c 25 Jan 2019 00:19:25 - 1.16 +++ lib/libc/gen/dirname.c 11 Sep 2020 20:43:34 - @@ -24,7 +24,7 @@ /* A slightly modified copy of this file exists in libexec/ld.so */ char * -dirname(const char *path) +dirname(char *path) { static char dname[PATH_MAX]; size_t len; -- Christian "naddy" Weisgerber na...@mips.inka.de
Format string check for dprintf(3)
Add format string checking annotations for dprintf(3) and vdprintf(3). This was apparently forgotten when the functions were added. It is required so the compiler can warn t.c:25:25: warning: format string is not a string literal (potentially insecure) [-Wformat-security] dprintf(STDOUT_FILENO, msg); ^~~ Absent -Werror, I do not expect any fallout from this, but I ran a successful amd64 make build with it anyway. ok? Index: include/stdio.h === RCS file: /cvs/src/include/stdio.h,v retrieving revision 1.53 diff -u -p -r1.53 stdio.h --- include/stdio.h 9 Sep 2016 18:12:37 - 1.53 +++ include/stdio.h 10 Sep 2020 15:07:08 - @@ -204,7 +204,9 @@ __END_DECLS __BEGIN_DECLS voidclearerr(FILE *); #if __POSIX_VISIBLE >= 200809 -int dprintf(int, const char * __restrict, ...); +int dprintf(int, const char * __restrict, ...) + __attribute__((__format__ (printf, 2, 3))) + __attribute__((__nonnull__ (2))); #endif int fclose(FILE *); int feof(FILE *); @@ -266,7 +268,9 @@ int vfprintf(FILE *, const char *, __va int vprintf(const char *, __va_list); int vsprintf(char *, const char *, __va_list); #if __POSIX_VISIBLE >= 200809 -int vdprintf(int, const char * __restrict, __va_list); +int vdprintf(int, const char * __restrict, __va_list) + __attribute__((__format__ (printf, 2, 0))) + __attribute__((__nonnull__ (2))); #endif #if __ISO_C_VISIBLE >= 1999 || __XPG_VISIBLE >= 500 || __BSD_VISIBLE -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: timekeep: fixing large skews on amd64 with RDTSCP
Scott Cheloha: > This "it might slow down the network stack" thing keeps coming up, and > yet nobody can point to (a) who expressed this concern or (b) what the > penalty is in practice. It was kettenis@ who simply raised the question and asked for comments from the network people. I think we should just go ahead and use rdtsc_lfence() in tsc_get_timecount(). It is *correct*. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: man find -exec -- a little bit more hand-holding
On 2020-08-14, Jason McIntyre wrote: > - i cannot work out what is with the \! examples. i know we try to make > entries work for both csh and sh style shells, but stuff like this > works without escaping: > > $ find . ! -type f Going through the CVS and SCCS history, I see that the examples came with a rewrite of find(1) at Berkeley 30 years ago. csh's behavior that "for convenience, a `!' is passed unchanged when it is followed by a blank, tab, newline, `=' or `('" has been documented as such at least since the start of the CSRG repository in 1985. bash, whose history substitution was modeled on csh, also shares this behavior. I think it was never necessary to escape the '!' and the man page examples were written with an abundance of caution and a lack of understanding of csh's exact replacement mechanism. -- Christian "naddy" Weisgerber na...@mips.inka.de
mountd: Avoid reading one byte before buffer
>From CheriBSD, via FreeBSD: | Avoid reading one byte before the path buffer. | | This happens when there's only one component (e.g. "/foo"). This | (mostly-harmless) bug has been present since June 1990 when it was | commited to mountd.c SCCS version 5.9. | | Note: the bug is on the second changed line, the first line is changed | for visual consistency. https://svnweb.freebsd.org/base?view=revision=363435 You need to look at the surrounding loop to see the problem. OK? Index: sbin/mountd/mountd.c === RCS file: /cvs/src/sbin/mountd/mountd.c,v retrieving revision 1.88 diff -u -p -r1.88 mountd.c --- sbin/mountd/mountd.c24 Jan 2020 18:51:45 - 1.88 +++ sbin/mountd/mountd.c6 Aug 2020 14:41:16 - @@ -2021,9 +2021,9 @@ do_mount(struct exportlist *ep, struct g #endif } /* back up over the last component */ - while (*cp == '/' && cp > dirp) + while (cp > dirp && *cp == '/') cp--; - while (*(cp - 1) != '/' && cp > dirp) + while (cp > dirp && *(cp - 1) != '/') cp--; if (cp == dirp) { if (debug) -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: timekeep: fixing large skews on amd64 with RDTSCP
Scott Cheloha: > --- lib/libc/arch/amd64/gen/usertc.c 8 Jul 2020 09:17:48 - 1.2 > +++ lib/libc/arch/amd64/gen/usertc.c 25 Jul 2020 17:50:38 - > @@ -21,9 +21,12 @@ > static inline u_int > rdtsc(void) > { > - uint32_t hi, lo; > - asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); > - return ((uint64_t)lo)|(((uint64_t)hi)<<32); > + uint32_t lo; > + > + asm volatile("lfence"); > + asm volatile("rdtsc" : "=a"(lo) : : "rdx"); Is there a guarantee that two separate asm()s will not be reordered? > + > + return lo; > } > > static int > --- sys/arch/amd64/amd64/tsc.c6 Jul 2020 13:33:06 - 1.19 > +++ sys/arch/amd64/amd64/tsc.c25 Jul 2020 17:50:38 - > @@ -211,7 +211,12 @@ cpu_recalibrate_tsc(struct timecounter * > u_int > tsc_get_timecount(struct timecounter *tc) > { > - return rdtsc() + curcpu()->ci_tsc_skew; > + uint32_t lo; > + > + asm volatile("lfence"); > + asm volatile("rdtsc" : "=a"(lo) : : "rdx"); > + > + return lo + curcpu()->ci_tsc_skew; > } > > void > I'd just do s/rdtsc/rdtsc_lfence/, which would agree well with the rest of the file. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: timekeep: fixing large skews on amd64 with RDTSCP
Scott Cheloha: > Can we add the missing LFENCE instructions to userspace and the > kernel? And can we excise the upper 32 bits? > + uint32_t lo; > + > + asm volatile("lfence"); > + asm volatile("rdtsc" : "=a"(lo)); That's wrong. rtdsc will clobber %rdx, whether you use that value or not. You need a corresponding constraint: asm volatile("rdtsc" : "=a"(lo) : : "rdx"); -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: armv7: tweak timercounter mask
Mark Kettenis: > > There is the strong suspicion that the 0x7fff mask in the various > > armv7 timecounters was simply copied from powerpc, and that these really > > are full 32-bit counters. > > > > I wanted to verify this from the data sheets, but I'm insufficiently > > familiar with the ARM ecosystem to locate those. > > The counter is described in the ARM Architecture Reference Manual. It > was introduced later so you need to look at revision C or later. Found it. That's agtimer. amptimer is the global timer in the ARM Cortex-A9 MPCore Technical Reference Manual. It's a 64-bit counter. For gptimer, I've found the OMAP4460 Technical Reference Manual. It's a 32-bit counter. So they should be all fine with 0x. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: powerpc(64): tweak timecounter mask
Mark Kettenis: > > Date: Sun, 12 Jul 2020 18:12:39 +0200 > > From: Christian Weisgerber > > > > The PowerPC/Power ISA Time Base is a 64-bit register. We can use > > the full lower 32 bits. > > > > OK? > > Sure, but this needs to be coordinated with the userland diff. No. tc_update_timekeep() copies the counter mask into the timekeep structure and the userland picks it up from there. -- Christian "naddy" Weisgerber na...@mips.inka.de
armv7: tweak timercounter mask
There is the strong suspicion that the 0x7fff mask in the various armv7 timecounters was simply copied from powerpc, and that these really are full 32-bit counters. I wanted to verify this from the data sheets, but I'm insufficiently familiar with the ARM ecosystem to locate those. Back in September 2017, Artturi Alm proposed the very same change here but failed to make himself heard. Index: arch/arm/cortex/agtimer.c === RCS file: /cvs/src/sys/arch/arm/cortex/agtimer.c,v retrieving revision 1.9 diff -u -p -r1.9 agtimer.c --- arch/arm/cortex/agtimer.c 11 Aug 2018 10:42:42 - 1.9 +++ arch/arm/cortex/agtimer.c 12 Jul 2020 16:13:22 - @@ -46,7 +46,7 @@ int32_t agtimer_frequency = TIMER_FREQUE u_int agtimer_get_timecount(struct timecounter *); static struct timecounter agtimer_timecounter = { - agtimer_get_timecount, NULL, 0x7fff, 0, "agtimer", 0, NULL + agtimer_get_timecount, NULL, 0x, 0, "agtimer", 0, NULL }; struct agtimer_pcpu_softc { Index: arch/arm/cortex/amptimer.c === RCS file: /cvs/src/sys/arch/arm/cortex/amptimer.c,v retrieving revision 1.7 diff -u -p -r1.7 amptimer.c --- arch/arm/cortex/amptimer.c 6 Jul 2020 13:33:06 - 1.7 +++ arch/arm/cortex/amptimer.c 12 Jul 2020 16:13:37 - @@ -67,7 +67,7 @@ int32_t amptimer_frequency = TIMER_FREQU u_int amptimer_get_timecount(struct timecounter *); static struct timecounter amptimer_timecounter = { - amptimer_get_timecount, NULL, 0x7fff, 0, "amptimer", 0, NULL, 0 + amptimer_get_timecount, NULL, 0x, 0, "amptimer", 0, NULL, 0 }; #define MAX_ARM_CPUS 8 Index: arch/armv7/omap/gptimer.c === RCS file: /cvs/src/sys/arch/armv7/omap/gptimer.c,v retrieving revision 1.8 diff -u -p -r1.8 gptimer.c --- arch/armv7/omap/gptimer.c 6 Jul 2020 13:33:07 - 1.8 +++ arch/armv7/omap/gptimer.c 12 Jul 2020 15:53:06 - @@ -117,7 +117,7 @@ int gptimer_irq = 0; u_int gptimer_get_timecount(struct timecounter *); static struct timecounter gptimer_timecounter = { - gptimer_get_timecount, NULL, 0x7fff, 0, "gptimer", 0, NULL, 0 + gptimer_get_timecount, NULL, 0x, 0, "gptimer", 0, NULL, 0 }; volatile u_int32_t nexttickevent; -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: powerpc(64): tweak timecounter mask
Christian Weisgerber: > - tb_get_timecount, NULL, 0x7fff, 0, "tb", 0, NULL, 0 > + tb_get_timecount, NULL, 0x, 0, "tb", 0, NULL, 0 PS: Do we prefer ~0u over 0x? -- Christian "naddy" Weisgerber na...@mips.inka.de
powerpc(64): tweak timecounter mask
The PowerPC/Power ISA Time Base is a 64-bit register. We can use the full lower 32 bits. OK? Index: arch/macppc/macppc/clock.c === RCS file: /cvs/src/sys/arch/macppc/macppc/clock.c,v retrieving revision 1.44 diff -u -p -r1.44 clock.c --- arch/macppc/macppc/clock.c 6 Jul 2020 13:33:08 - 1.44 +++ arch/macppc/macppc/clock.c 12 Jul 2020 15:17:48 - @@ -57,7 +57,7 @@ u_int32_t ns_per_tick = 320; static int32_t ticks_per_intr; static struct timecounter tb_timecounter = { - tb_get_timecount, NULL, 0x7fff, 0, "tb", 0, NULL, 0 + tb_get_timecount, NULL, 0x, 0, "tb", 0, NULL, 0 }; /* calibrate the timecounter frequency for the listed models */ Index: arch/powerpc64/powerpc64/clock.c === RCS file: /cvs/src/sys/arch/powerpc64/powerpc64/clock.c,v retrieving revision 1.1 diff -u -p -r1.1 clock.c --- arch/powerpc64/powerpc64/clock.c10 Jun 2020 19:06:53 - 1.1 +++ arch/powerpc64/powerpc64/clock.c12 Jul 2020 15:18:02 - @@ -37,7 +37,7 @@ struct evcount stat_count; u_int tb_get_timecount(struct timecounter *); static struct timecounter tb_timecounter = { - tb_get_timecount, NULL, 0x7fff, 0, "tb", 0, NULL + tb_get_timecount, NULL, 0x, 0, "tb", 0, NULL }; void cpu_startclock(void); -- Christian "naddy" Weisgerber na...@mips.inka.de