doas needs doas.conf
Say explicitly that doas needs doas.conf to exist, and point to the example one. Jan Index: doas.1 === RCS file: /cvs/src/usr.bin/doas/doas.1,v retrieving revision 1.25 diff -u -p -r1.25 doas.1 --- doas.1 16 Jan 2021 09:18:41 - 1.25 +++ doas.1 19 Feb 2021 19:20:58 - @@ -43,6 +43,15 @@ is specified. The user will be required to authenticate by entering their password, unless configured otherwise. .Pp +.Nm +will not execute the +.Ar command +if the file +.Pa /etc/doas.conf +does not exist. +An example is provided in +.Pa /etc/examples/ . +.Pp By default, a new environment is created. The variables .Ev HOME , @@ -110,6 +119,11 @@ or Execute the command as .Ar user . The default is root. +.El +.Sh FILES +.Bl -tag -compact +.It Pa /etc/doas.conf +.It Pa /etc/examples/doas.conf .El .Sh EXIT STATUS .Ex -std doas
Re: extern int optreset not needed
On Dec 26 23:24:57, h...@stare.cz wrote: > ftpd doesn't need to declare extern int optreset > as that is already done in the included unistd.h Here's more for usr.sbin/, if desirable. Jan Index: usr.sbin//amd/amd/get_args.c === RCS file: /cvs/src/usr.sbin/amd/amd/get_args.c,v retrieving revision 1.14 diff -u -p -u -p -r1.14 get_args.c --- usr.sbin//amd/amd/get_args.c20 Oct 2014 02:33:42 - 1.14 +++ usr.sbin//amd/amd/get_args.c27 Dec 2020 18:44:15 - @@ -44,9 +44,6 @@ #include #include -extern int optind; -extern char *optarg; - #if defined(DEBUG) && defined(PARANOID) char **gargv; #endif /* defined(DEBUG) && defined(PARANOID) */ Index: usr.sbin//amd/amq/amq.c === RCS file: /cvs/src/usr.sbin/amd/amq/amq.c,v retrieving revision 1.21 diff -u -p -u -p -r1.21 amq.c --- usr.sbin//amd/amq/amq.c 21 Jan 2017 08:33:51 - 1.21 +++ usr.sbin//amd/amq/amq.c 27 Dec 2020 18:44:15 - @@ -59,9 +59,6 @@ static char *xlog_optstr; static char localhost[] = "localhost"; static char *def_server = localhost; -extern int optind; -extern char *optarg; - static struct timeval tmo = { 10, 0 }; #defineTIMEOUT tmo Index: usr.sbin//crunchgen/crunchgen.c === RCS file: /cvs/src/usr.sbin/crunchgen/crunchgen.c,v retrieving revision 1.21 diff -u -p -u -p -r1.21 crunchgen.c --- usr.sbin//crunchgen/crunchgen.c 18 Oct 2018 14:25:14 - 1.21 +++ usr.sbin//crunchgen/crunchgen.c 27 Dec 2020 18:44:15 - @@ -117,8 +117,6 @@ main(int argc, char *argv[]) { char *p; int optc; - extern int optind; - extern char*optarg; if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) { perror("pledge"); Index: usr.sbin//mtree/mtree.c === RCS file: /cvs/src/usr.sbin/mtree/mtree.c,v retrieving revision 1.26 diff -u -p -u -p -r1.26 mtree.c --- usr.sbin//mtree/mtree.c 16 Sep 2018 12:43:40 - 1.26 +++ usr.sbin//mtree/mtree.c 27 Dec 2020 18:44:15 - @@ -55,8 +55,6 @@ static void usage(void); int main(int argc, char *argv[]) { - extern int optind; - extern char *optarg; int ch; char *dir, *p; int status; Index: usr.sbin//npppctl/npppctl.c === RCS file: /cvs/src/usr.sbin/npppctl/npppctl.c,v retrieving revision 1.9 diff -u -p -u -p -r1.9 npppctl.c --- usr.sbin//npppctl/npppctl.c 28 Jun 2019 13:32:49 - 1.9 +++ usr.sbin//npppctl/npppctl.c 27 Dec 2020 18:44:15 - @@ -80,8 +80,6 @@ main(int argc, char *argv[]) struct parse_result *result; struct sockaddr_un sun; const char *npppd_ctlpath = NPPPD_SOCKET; - extern int optind; - extern char *optarg; while ((ch = getopt(argc, argv, "ns:")) != -1) switch (ch) { Index: usr.sbin//npppd/npppd/npppd.c === RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd.c,v retrieving revision 1.50 diff -u -p -u -p -r1.50 npppd.c --- usr.sbin//npppd/npppd/npppd.c 10 May 2019 01:29:31 - 1.50 +++ usr.sbin//npppd/npppd/npppd.c 27 Dec 2020 18:44:15 - @@ -136,7 +136,6 @@ int main(int argc, char *argv[]) { intch, stop_by_error, runasdaemon = 1, nflag = 0; - extern char *optarg; const char*npppd_conf0 = DEFAULT_NPPPD_CONF; struct passwd *pw; Index: usr.sbin//pstat/pstat.c === RCS file: /cvs/src/usr.sbin/pstat/pstat.c,v retrieving revision 1.123 diff -u -p -u -p -r1.123 pstat.c --- usr.sbin//pstat/pstat.c 28 Sep 2020 15:53:13 - 1.123 +++ usr.sbin//pstat/pstat.c 27 Dec 2020 18:44:15 - @@ -150,8 +150,6 @@ main(int argc, char *argv[]) int fileflag = 0, swapflag = 0, ttyflag = 0, vnodeflag = 0, ch; char buf[_POSIX2_LINE_MAX]; const char *dformat = NULL; - extern char *optarg; - extern int optind; int i; hideroot = getuid(); Index: usr.sbin//quotaon/quotaon.c === RCS file: /cvs/src/usr.sbin/quotaon/quotaon.c,v retrieving revision 1.27 diff -u -p -u -p -r1.27 quotaon.c --- usr.sbin//quotaon/quotaon.c 26 Apr 2018 12:42:51 - 1.27 +++ usr.sbin//quotaon/quotaon.c 27 Dec 2020 18:44:15 - @@ -66,7 +66,6 @@ main(int argc, char *argv[]) char *qfnp, *whoami; long argnum, done = 0; int i, offmode = 0, errs = 0; - extern int optind; int ch; whoami = strrchr(*argv, '/') + 1; Index:
extern int optreset not needed
ftpd doesn't need to declare extern int optreset as that is already done in the included unistd.h Jan Index: popen.c === RCS file: /cvs/src/libexec/ftpd/popen.c,v retrieving revision 1.29 diff -u -p -r1.29 popen.c --- popen.c 15 Jan 2020 22:06:59 - 1.29 +++ popen.c 26 Dec 2020 22:05:49 - @@ -113,7 +113,6 @@ ftpd_ls(const char *path, pid_t *pidptr) (void)close(pdes[0]); closelog(); - extern int optreset; extern int ls_main(int, char **); /* reset getopt for ls_main */
Re: mixerctl names
On Oct 17 11:12:28, cpb_t...@bennettconstruction.us wrote: > On Sat, Oct 17, 2020 at 05:52:58PM +0200, Jan Stary wrote: > > Currently, mixerctl.conf(5) says > > > > Most devices have a number of digital to analogue converters > > (DACs), used for sound playback, and each DAC has a corresponding > > output mixer. The mixers are labelled “mix” or “sel”. > > > > That doesn't seem to be the case, at least not universaly > > as the wording seems to imply. For example, this is > > mixerctl output on a Thinkpad T400: > > > > inputs.dac-0:1=222,222 > > inputs.dac-2:3=222,222 > > inputs.beep=0 > > record.adc-2:3_source=mic2 > > record.adc-2:3=219,219 > > record.adc-0:1_source=mic > > record.adc-0:1=219,219 > > outputs.hp_source=dac-0:1 > > outputs.hp_boost=on > > inputs.mic=189,189 > > outputs.mic_dir=input-vr80 > > outputs.spkr_source=dac-2:3 > > outputs.spkr_eapd=on > > inputs.mic2=189,189 > > outputs.hp_sense=unplugged > > outputs.mic_sense=unplugged > > outputs.master=240,240 > > outputs.master.mute=off > > outputs.master.slaves= > > record.volume=240,240 > > record.volume.mute=off > > record.volume.slaves= > > record.enable=sysctl > > > > Apparently, it has two DACS (for the speakers and the headphones). > > The current wording might confuse the user into thinking he has > > no output mixer, but the > > > > inputs.dac-0:1=222,222 > > inputs.dac-2:3=222,222 > > > > do control the respective volumes, > > while no "mix" or "sel" exists. > > > > Similarly for recording via the two ADCs. > > > > > > Jan > > > Thank you! +1 > > I had no idea what was going on and had basically given up on having the > speakers off. > > changing outputs.master moves BOTH inputs.dac. Which is superbly > confusing! I balieve this is the purpose of outputs.master - it sets the volume for multiple widgets; outputs.master.slaves says which. See azalia(4). > Now I just manually changed each inputs.dac alone. You are not supposed to tweak these controls directly; that's mixerctl does, and it requires root privileges. Try to set your controls with sndioctl as a regular user.
mixerctl names
Currently, mixerctl.conf(5) says Most devices have a number of digital to analogue converters (DACs), used for sound playback, and each DAC has a corresponding output mixer. The mixers are labelled “mix” or “sel”. That doesn't seem to be the case, at least not universaly as the wording seems to imply. For example, this is mixerctl output on a Thinkpad T400: inputs.dac-0:1=222,222 inputs.dac-2:3=222,222 inputs.beep=0 record.adc-2:3_source=mic2 record.adc-2:3=219,219 record.adc-0:1_source=mic record.adc-0:1=219,219 outputs.hp_source=dac-0:1 outputs.hp_boost=on inputs.mic=189,189 outputs.mic_dir=input-vr80 outputs.spkr_source=dac-2:3 outputs.spkr_eapd=on inputs.mic2=189,189 outputs.hp_sense=unplugged outputs.mic_sense=unplugged outputs.master=240,240 outputs.master.mute=off outputs.master.slaves= record.volume=240,240 record.volume.mute=off record.volume.slaves= record.enable=sysctl Apparently, it has two DACS (for the speakers and the headphones). The current wording might confuse the user into thinking he has no output mixer, but the inputs.dac-0:1=222,222 inputs.dac-2:3=222,222 do control the respective volumes, while no "mix" or "sel" exists. Similarly for recording via the two ADCs. Jan Index: mixerctl.conf.5 === RCS file: /cvs/src/share/man/man5/mixerctl.conf.5,v retrieving revision 1.10 diff -u -p -r1.10 mixerctl.conf.5 --- mixerctl.conf.5 21 Apr 2020 21:32:26 - 1.10 +++ mixerctl.conf.5 17 Oct 2020 15:31:23 - @@ -66,10 +66,6 @@ TOSLink, RCA, or 1/8" mini stereo. Most devices have a number of digital to analogue converters (DACs), used for sound playback, and each DAC has a corresponding output mixer. -The mixers are labelled -.Dq mix -or -.Dq sel . Each DAC represents two channels of playback. .Pp Verify that playback works by playing an audio file @@ -104,10 +100,6 @@ shows the number of channels available. Most devices have a number of analogue to digital converters (ADCs), used for recording sound, and each ADC has a corresponding input mixer. -The mixers are labelled -.Dq mix -or -.Dq sel . Each ADC represents two channels of recording. .Pp Connect line in on the audio card to an audio source,
Re: acpicpu(4) and ACPI0007
On Aug 01 18:23:08, jonat...@d14n.org wrote: > Much better theory: the acpicpu_sc array has MAXCPUS elements, but on this > system (and all R6415s, as far as I can tell) we have more acpicpu devices > than that. I suppose we should just make acpicpu_match fail if cf->cf_unit > is >= MAXCPUS as we do with the actual cpu devices. > > > Index: acpicpu.c > === > RCS file: /cvs/src/sys/dev/acpi/acpicpu.c,v > retrieving revision 1.85 > diff -u -p -r1.85 acpicpu.c > --- acpicpu.c 27 May 2020 05:02:21 - 1.85 > +++ acpicpu.c 1 Aug 2020 08:18:49 - > @@ -186,6 +186,11 @@ struct cfdriver acpicpu_cd = { > NULL, "acpicpu", DV_DULL > }; > > +const char *acpicpu_hids[] = { > + "ACPI0007", > + NULL > +}; > + > extern int setperf_prio; > > struct acpicpu_softc *acpicpu_sc[MAXCPUS]; > @@ -650,6 +655,12 @@ acpicpu_match(struct device *parent, voi > struct acpi_attach_args *aa = aux; > struct cfdata *cf = match; > > + if (cf->cf_unit >= MAXCPUS) > + return (0); > + > + if (acpi_matchhids(aa, acpicpu_hids, cf->cf_driver->cd_name)) > + return (1); > + > /* sanity */ > if (aa->aaa_name == NULL || > strcmp(aa->aaa_name, cf->cf_driver->cd_name) != 0 || > @@ -665,6 +676,7 @@ acpicpu_attach(struct device *parent, st > struct acpicpu_softc*sc = (struct acpicpu_softc *)self; > struct acpi_attach_args *aa = aux; > struct aml_valueres; > + int64_t uid; > int i; > uint32_tstatus = 0; > CPU_INFO_ITERATOR cii; > @@ -675,6 +687,10 @@ acpicpu_attach(struct device *parent, st > acpicpu_sc[sc->sc_dev.dv_unit] = sc; > > SLIST_INIT(>sc_cstates); > + > + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, > + "_UID", 0, NULL, ) == 0) > + sc->sc_cpu = uid; > > if (aml_evalnode(sc->sc_acpi, sc->sc_devnode, 0, NULL, ) == 0) { > if (res.type == AML_OBJTYPE_PROCESSOR) { > See below for the old and the new dmesg of current/amd64 at an APU2. Edited highlights of the diff: --- apu2e.20200610 Wed Jun 10 22:24:25 2020 +++ apu2e.20200801 Sat Aug 1 19:17:00 2020 -"ACPI0007" at acpi0 not configured -"ACPI0007" at acpi0 not configured -"ACPI0007" at acpi0 not configured -"ACPI0007" at acpi0 not configured -"ACPI0007" at acpi0 not configured -"ACPI0007" at acpi0 not configured -"ACPI0007" at acpi0 not configured -"ACPI0007" at acpi0 not configured +acpicpu0 at acpi0copyvalue: 6: C2(0@400 io@0x1771), C1(@1 halt!), PSS +acpicpu1 at acpi0copyvalue: 6: C2(0@400 io@0x1771), C1(@1 halt!), PSS +acpicpu2 at acpi0copyvalue: 6: C2(0@400 io@0x1771), C1(@1 halt!), PSS +acpicpu3 at acpi0copyvalue: 6: C2(0@400 io@0x1771), C1(@1 halt!), PSS +acpicpu4 at acpi0copyvalue: 6: no cpu matching ACPI ID 4 +acpicpu5 at acpi0copyvalue: 6: no cpu matching ACPI ID 5 +acpicpu6 at acpi0copyvalue: 6: no cpu matching ACPI ID 6 +acpicpu7 at acpi0copyvalue: 6: no cpu matching ACPI ID 7 +cpu0: 998 MHz: speeds: 1000 800 600 MHz Jan OpenBSD 6.7-current (GENERIC.MP) #0: Wed Jun 10 22:14:40 CEST 2020 h...@uvt.stare.cz:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 1996484608 (1903MB) avail mem = 1921105920 (1832MB) random: good seed from bootblocks mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.8 @ 0x7ee8d020 (13 entries) bios0: vendor coreboot version "v4.11.0.5" date 03/29/2020 bios0: PC Engines apu2 acpi0 at bios0: ACPI 4.0 acpi0: sleep states S0 S1 S4 S5 acpi0: tables DSDT FACP SSDT MCFG TPM2 APIC HEST SSDT SSDT HPET acpi0: wakeup devices PWRB(S4) PBR4(S4) PBR5(S4) PBR6(S4) PBR7(S4) PBR8(S4) UOH1(S3) UOH2(S3) UOH3(S3) UOH4(S3) UOH5(S3) UOH6(S3) XHC0(S4) acpitimer0 at acpi0: 3579545 Hz, 32 bits acpimcfg0 at acpi0 acpimcfg0: addr 0xf800, bus 0-64 acpimadt0 at acpi0 addr 0xfee0: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: AMD GX-412TC SOC, 998.26 MHz, 16-30-01 cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,DBKP,PERFTSC,PCTRL3,ITSC,BMI1,XSAVEOPT cpu0: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB 64b/line 16-way L2 cache cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative cpu0: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges cpu0: apic clock running at 99MHz cpu0: mwait min=64, max=64, IBE cpu1 at mainbus0: apid 1 (application processor) cpu1: AMD GX-412TC SOC, 998.14 MHz, 16-30-01 cpu1:
Re: LOCALE_HOME for strtime(3)
ping On Jul 16 09:23:22, h...@stare.cz wrote: > On Jul 15 15:48:41, mill...@openbsd.org wrote: > > Upstream tzcode removed the LOCALE_HOME bits in 2014. There's no > > reason for us to keep it. > > With that removed, the header file can go too. > > Jan > > > Index: lib/libc/time/strftime.c > === > RCS file: /cvs/src/lib/libc/time/strftime.c,v > retrieving revision 1.32 > diff -u -p -r1.32 strftime.c > --- lib/libc/time/strftime.c 29 Jun 2019 16:12:21 - 1.32 > +++ lib/libc/time/strftime.c 16 Jul 2020 07:20:23 - > @@ -29,7 +29,6 @@ > */ > > #include > -#include > #include > > #include "private.h" > @@ -48,16 +47,7 @@ struct lc_time_T { > const char *date_fmt; > }; > > -#ifdef LOCALE_HOME > -#include "sys/stat.h" > -static struct lc_time_T localebuf; > -static struct lc_time_T *_loc(void); > -#define Locale _loc() > -#endif /* defined LOCALE_HOME */ > -#ifndef LOCALE_HOME > #define Locale (_time_locale) > -#endif /* !defined LOCALE_HOME */ > - > static const struct lc_time_TC_time_locale = { > { > "Jan", "Feb", "Mar", "Apr", "May", "Jun", > @@ -124,9 +114,6 @@ strftime(char *s, size_t maxsize, const > int warn; > > tzset(); > -#ifdef LOCALE_HOME > - localebuf.mon[0] = 0; > -#endif /* defined LOCALE_HOME */ > warn = IN_NONE; > p = _fmt(((format == NULL) ? "%c" : format), t, s, s + maxsize, ); > if (p == s + maxsize) { > @@ -558,135 +545,3 @@ _yconv(int a, int b, int convert_top, in > pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim); > return pt; > } > - > -#ifdef LOCALE_HOME > -static struct lc_time_T * > -_loc(void) > -{ > - static const char locale_home[] = LOCALE_HOME; > - static const char lc_time[] = "LC_TIME"; > - static char * locale_buf; > - > - int fd; > - int oldsun; /* "...ain't got nothin' to do..." */ > - int len; > - char * lbuf; > - char * nlbuf; > - char * name; > - char * p; > - const char ** ap; > - const char *plim; > - charfilename[PATH_MAX]; > - struct stat st; > - size_t namesize; > - size_t bufsize; > - > - /* > - ** Use localebuf.mon[0] to signal whether locale is already set up. > - */ > - if (localebuf.mon[0]) > - return > - name = setlocale(LC_TIME, (char *) NULL); > - if (name == NULL || *name == '\0') > - goto no_locale; > - /* > - ** If the locale name is the same as our cache, use the cache. > - */ > - lbuf = locale_buf; > - if (lbuf != NULL && strcmp(name, lbuf) == 0) { > - p = lbuf; > - for (ap = (const char **) > - ap < (const char **) ( + 1); > - ++ap) > - *ap = p += strlen(p) + 1; > - return > - } > - /* > - ** Slurp the locale file into the cache. > - */ > - namesize = strlen(name) + 1; > - if (sizeof filename < > - ((sizeof locale_home) + namesize + (sizeof lc_time))) > - goto no_locale; > - oldsun = 0; > - len = snprintf(filename, sizeof filename, "%s/%s/%s", locale_home, > - name, lc_time); > - if (len < 0 || len >= sizeof filename) > - goto no_locale; > - fd = open(filename, O_RDONLY); > - if (fd == -1) { > - /* > - ** Old Sun systems have a different naming and data convention. > - */ > - oldsun = 1; > - len = snprintf(filename, sizeof filename, "%s/%s/%s", > - locale_home, lc_time, name); > - if (len < 0 || len >= sizeof filename) > - goto no_locale; > - fd = open(filename, O_RDONLY); > - if (fd == -1) > - goto no_locale; > - } > - if (fstat(fd, ) == -1) > - goto bad_locale; > - if (st.st_size <= 0) > - goto bad_locale; > - bufsize = namesize + st.st_size; > - locale_buf = NULL; > - nlbuf = realloc(lbuf, bufsize); > - if (nlbuf == NULL) { > - free(lbuf); > - lbuf = NULL; > - goto bad_locale; > - } > - lbuf = nlbuf; > - (void) strlcpy(lbuf, name, bufsize); > - p = lbuf + namesize; > - plim = p + st.st_size; > - if (read(fd, p, st.st_size) != st.st_size) > - goto bad_lbuf; > - if (close(fd) != 0) > - goto bad_lbuf; > - /* > - ** Parse the locale file into localebuf. > - */ > - if (plim[-1] != '\n') > - goto bad_lbuf; > - for
LC_MESSAGES in xargs(1)
Does xargs need to set LC_MESSAGES? Jan Index: usr.bin/xargs/xargs.c === RCS file: /cvs/src/usr.bin/xargs/xargs.c,v retrieving revision 1.34 diff -u -p -r1.34 xargs.c --- usr.bin/xargs/xargs.c 12 Jun 2018 15:24:31 - 1.34 +++ usr.bin/xargs/xargs.c 16 Jul 2020 07:40:26 - @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -85,8 +84,6 @@ main(int argc, char *argv[]) ep = environ; eofstr = ""; Jflag = nflag = 0; - - (void)setlocale(LC_MESSAGES, ""); /* * POSIX.2 limits the exec line length to ARG_MAX - 2K. Running that
Re: LOCALE_HOME for strtime(3)
On Jul 15 15:48:41, mill...@openbsd.org wrote: > Upstream tzcode removed the LOCALE_HOME bits in 2014. There's no > reason for us to keep it. With that removed, the header file can go too. Jan Index: lib/libc/time/strftime.c === RCS file: /cvs/src/lib/libc/time/strftime.c,v retrieving revision 1.32 diff -u -p -r1.32 strftime.c --- lib/libc/time/strftime.c29 Jun 2019 16:12:21 - 1.32 +++ lib/libc/time/strftime.c16 Jul 2020 07:20:23 - @@ -29,7 +29,6 @@ */ #include -#include #include #include "private.h" @@ -48,16 +47,7 @@ struct lc_time_T { const char *date_fmt; }; -#ifdef LOCALE_HOME -#include "sys/stat.h" -static struct lc_time_Tlocalebuf; -static struct lc_time_T * _loc(void); -#define Locale _loc() -#endif /* defined LOCALE_HOME */ -#ifndef LOCALE_HOME #define Locale (_time_locale) -#endif /* !defined LOCALE_HOME */ - static const struct lc_time_T C_time_locale = { { "Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -124,9 +114,6 @@ strftime(char *s, size_t maxsize, const int warn; tzset(); -#ifdef LOCALE_HOME - localebuf.mon[0] = 0; -#endif /* defined LOCALE_HOME */ warn = IN_NONE; p = _fmt(((format == NULL) ? "%c" : format), t, s, s + maxsize, ); if (p == s + maxsize) { @@ -558,135 +545,3 @@ _yconv(int a, int b, int convert_top, in pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim); return pt; } - -#ifdef LOCALE_HOME -static struct lc_time_T * -_loc(void) -{ - static const char locale_home[] = LOCALE_HOME; - static const char lc_time[] = "LC_TIME"; - static char * locale_buf; - - int fd; - int oldsun; /* "...ain't got nothin' to do..." */ - int len; - char * lbuf; - char * nlbuf; - char * name; - char * p; - const char ** ap; - const char *plim; - charfilename[PATH_MAX]; - struct stat st; - size_t namesize; - size_t bufsize; - - /* - ** Use localebuf.mon[0] to signal whether locale is already set up. - */ - if (localebuf.mon[0]) - return - name = setlocale(LC_TIME, (char *) NULL); - if (name == NULL || *name == '\0') - goto no_locale; - /* - ** If the locale name is the same as our cache, use the cache. - */ - lbuf = locale_buf; - if (lbuf != NULL && strcmp(name, lbuf) == 0) { - p = lbuf; - for (ap = (const char **) - ap < (const char **) ( + 1); - ++ap) - *ap = p += strlen(p) + 1; - return - } - /* - ** Slurp the locale file into the cache. - */ - namesize = strlen(name) + 1; - if (sizeof filename < - ((sizeof locale_home) + namesize + (sizeof lc_time))) - goto no_locale; - oldsun = 0; - len = snprintf(filename, sizeof filename, "%s/%s/%s", locale_home, - name, lc_time); - if (len < 0 || len >= sizeof filename) - goto no_locale; - fd = open(filename, O_RDONLY); - if (fd == -1) { - /* - ** Old Sun systems have a different naming and data convention. - */ - oldsun = 1; - len = snprintf(filename, sizeof filename, "%s/%s/%s", - locale_home, lc_time, name); - if (len < 0 || len >= sizeof filename) - goto no_locale; - fd = open(filename, O_RDONLY); - if (fd == -1) - goto no_locale; - } - if (fstat(fd, ) == -1) - goto bad_locale; - if (st.st_size <= 0) - goto bad_locale; - bufsize = namesize + st.st_size; - locale_buf = NULL; - nlbuf = realloc(lbuf, bufsize); - if (nlbuf == NULL) { - free(lbuf); - lbuf = NULL; - goto bad_locale; - } - lbuf = nlbuf; - (void) strlcpy(lbuf, name, bufsize); - p = lbuf + namesize; - plim = p + st.st_size; - if (read(fd, p, st.st_size) != st.st_size) - goto bad_lbuf; - if (close(fd) != 0) - goto bad_lbuf; - /* - ** Parse the locale file into localebuf. - */ - if (plim[-1] != '\n') - goto bad_lbuf; - for (ap = (const char **) - ap < (const char **) ( + 1); - ++ap) { - if (p == plim) -
LOCALE_HOME for strtime(3)
The OpenBSD libc tends to ignore the LC_* except LC_CTYPE. However, strftime(3) seems to support a LOCALE_HOME thing, where the user overrides LC_TIME with his own names of months etc. Looking at http://cvsweb.openbsd.org/src/lib/libc/time/strftime.c , it has been there since the beginning. The manpage does not mention it; on the contrary, The OpenBSD implementation always uses the C locale and ignores the global locale, the thread-specific locale, and the locale argument. and On systems other than OpenBSD, the LC_TIME locale(1) category can cause erratic output; see CAVEATS in setlocale(3) for details. Is that code intentionally there? The diff below removes it. Jan Index: lib/libc/time/strftime.c === RCS file: /cvs/src/lib/libc/time/strftime.c,v retrieving revision 1.32 diff -u -p -r1.32 strftime.c --- lib/libc/time/strftime.c29 Jun 2019 16:12:21 - 1.32 +++ lib/libc/time/strftime.c15 Jul 2020 21:40:10 - @@ -48,16 +48,7 @@ struct lc_time_T { const char *date_fmt; }; -#ifdef LOCALE_HOME -#include "sys/stat.h" -static struct lc_time_Tlocalebuf; -static struct lc_time_T * _loc(void); -#define Locale _loc() -#endif /* defined LOCALE_HOME */ -#ifndef LOCALE_HOME #define Locale (_time_locale) -#endif /* !defined LOCALE_HOME */ - static const struct lc_time_T C_time_locale = { { "Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -124,9 +115,6 @@ strftime(char *s, size_t maxsize, const int warn; tzset(); -#ifdef LOCALE_HOME - localebuf.mon[0] = 0; -#endif /* defined LOCALE_HOME */ warn = IN_NONE; p = _fmt(((format == NULL) ? "%c" : format), t, s, s + maxsize, ); if (p == s + maxsize) { @@ -558,135 +546,3 @@ _yconv(int a, int b, int convert_top, in pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim); return pt; } - -#ifdef LOCALE_HOME -static struct lc_time_T * -_loc(void) -{ - static const char locale_home[] = LOCALE_HOME; - static const char lc_time[] = "LC_TIME"; - static char * locale_buf; - - int fd; - int oldsun; /* "...ain't got nothin' to do..." */ - int len; - char * lbuf; - char * nlbuf; - char * name; - char * p; - const char ** ap; - const char *plim; - charfilename[PATH_MAX]; - struct stat st; - size_t namesize; - size_t bufsize; - - /* - ** Use localebuf.mon[0] to signal whether locale is already set up. - */ - if (localebuf.mon[0]) - return - name = setlocale(LC_TIME, (char *) NULL); - if (name == NULL || *name == '\0') - goto no_locale; - /* - ** If the locale name is the same as our cache, use the cache. - */ - lbuf = locale_buf; - if (lbuf != NULL && strcmp(name, lbuf) == 0) { - p = lbuf; - for (ap = (const char **) - ap < (const char **) ( + 1); - ++ap) - *ap = p += strlen(p) + 1; - return - } - /* - ** Slurp the locale file into the cache. - */ - namesize = strlen(name) + 1; - if (sizeof filename < - ((sizeof locale_home) + namesize + (sizeof lc_time))) - goto no_locale; - oldsun = 0; - len = snprintf(filename, sizeof filename, "%s/%s/%s", locale_home, - name, lc_time); - if (len < 0 || len >= sizeof filename) - goto no_locale; - fd = open(filename, O_RDONLY); - if (fd == -1) { - /* - ** Old Sun systems have a different naming and data convention. - */ - oldsun = 1; - len = snprintf(filename, sizeof filename, "%s/%s/%s", - locale_home, lc_time, name); - if (len < 0 || len >= sizeof filename) - goto no_locale; - fd = open(filename, O_RDONLY); - if (fd == -1) - goto no_locale; - } - if (fstat(fd, ) == -1) - goto bad_locale; - if (st.st_size <= 0) - goto bad_locale; - bufsize = namesize + st.st_size; - locale_buf = NULL; - nlbuf = realloc(lbuf, bufsize); - if (nlbuf == NULL) { - free(lbuf); - lbuf = NULL; - goto bad_locale; - } - lbuf = nlbuf; - (void) strlcpy(lbuf, name, bufsize); - p = lbuf + namesize; - plim = p + st.st_size; - if (read(fd, p,
no need for "extern optind" etc
This is in the vein of https://marc.info/?l=openbsd-cvs=158170787221615=2 declares "extern int optind" and friends, so there is no need to declare them again. Still builds on current/amd64. Leaving out gnu, nsd, unbound (third party) and tic (is that third party)? Also leaving out pr and rcs who do their own thing. Jan Index: sys/dev/microcode/aic7xxx/aicasm.c === RCS file: /cvs/src/sys/dev/microcode/aic7xxx/aicasm.c,v retrieving revision 1.16 diff -u -p -r1.16 aicasm.c --- sys/dev/microcode/aic7xxx/aicasm.c 19 Dec 2014 22:44:58 - 1.16 +++ sys/dev/microcode/aic7xxx/aicasm.c 15 Jul 2020 14:45:14 - @@ -112,8 +112,6 @@ int main(int argc, char *argv[]); int main(int argc, char *argv[]) { - extern char *optarg; - extern int optind; int ch; int retval; char *inputfilename; Index: usr.bin/env/env.c === RCS file: /cvs/src/usr.bin/env/env.c,v retrieving revision 1.17 diff -u -p -r1.17 env.c --- usr.bin/env/env.c 28 Oct 2016 07:22:59 - 1.17 +++ usr.bin/env/env.c 15 Jul 2020 14:45:14 - @@ -42,7 +42,6 @@ int main(int argc, char *argv[]) { extern char **environ; - extern int optind; char **ep, *p; int ch; Index: usr.bin/finger/finger.c === RCS file: /cvs/src/usr.bin/finger/finger.c,v retrieving revision 1.27 diff -u -p -r1.27 finger.c --- usr.bin/finger/finger.c 26 Apr 2018 12:42:51 - 1.27 +++ usr.bin/finger/finger.c 15 Jul 2020 14:45:14 - @@ -76,7 +76,6 @@ PERSON *phead, *ptail; int main(int argc, char *argv[]) { - extern int optind; extern char *__progname; int ch; char domain[HOST_NAME_MAX+1]; Index: usr.bin/ftp/cmds.c === RCS file: /cvs/src/usr.bin/ftp/cmds.c,v retrieving revision 1.84 diff -u -p -r1.84 cmds.c --- usr.bin/ftp/cmds.c 18 Nov 2019 04:37:35 - 1.84 +++ usr.bin/ftp/cmds.c 15 Jul 2020 14:45:14 - @@ -217,7 +217,6 @@ usage: void mput(int argc, char *argv[]) { - extern int optind, optreset; int ch, i, restartit = 0; sig_t oldintr; char *cmd, *tp, *xargv[] = { argv[0], NULL, NULL }; Index: usr.bin/ftp/small.c === RCS file: /cvs/src/usr.bin/ftp/small.c,v retrieving revision 1.12 diff -u -p -r1.12 small.c --- usr.bin/ftp/small.c 18 Nov 2019 04:37:35 - 1.12 +++ usr.bin/ftp/small.c 15 Jul 2020 14:45:14 - @@ -326,7 +326,6 @@ mabort(int signo) void mget(int argc, char *argv[]) { - extern int optind, optreset; sig_t oldintr; int xargc = 2; char *cp, localcwd[PATH_MAX], *xargv[] = { argv[0], NULL, NULL }; Index: usr.bin/getopt/getopt.c === RCS file: /cvs/src/usr.bin/getopt/getopt.c,v retrieving revision 1.10 diff -u -p -r1.10 getopt.c --- usr.bin/getopt/getopt.c 9 Oct 2015 01:37:07 - 1.10 +++ usr.bin/getopt/getopt.c 15 Jul 2020 14:45:14 - @@ -13,8 +13,6 @@ int main(int argc, char *argv[]) { - extern int optind; - extern char *optarg; int c; int status = 0; Index: usr.bin/locate/code/locate.code.c === RCS file: /cvs/src/usr.bin/locate/code/locate.code.c,v retrieving revision 1.21 diff -u -p -r1.21 locate.code.c --- usr.bin/locate/code/locate.code.c 17 Jan 2019 06:15:44 - 1.21 +++ usr.bin/locate/code/locate.code.c 15 Jul 2020 14:45:14 - @@ -106,8 +106,6 @@ int bgindex(char *); void usage(void); -extern int optind; -extern int optopt; int main(int argc, char *argv[]) Index: usr.bin/m4/main.c === RCS file: /cvs/src/usr.bin/m4/main.c,v retrieving revision 1.87 diff -u -p -r1.87 main.c --- usr.bin/m4/main.c 15 Jun 2017 13:48:42 - 1.87 +++ usr.bin/m4/main.c 15 Jul 2020 14:45:14 - @@ -138,9 +138,6 @@ struct keyblk keywrds[] = { /* m4 keywor #define MAXKEYS(sizeof(keywrds)/sizeof(struct keyblk)) -extern int optind; -extern char *optarg; - #define MAXRECORD 50 static struct position { char *name; Index: usr.bin/mklocale/yacc.y === RCS file: /cvs/src/usr.bin/mklocale/yacc.y,v retrieving revision 1.10 diff -u -p -r1.10 yacc.y --- usr.bin/mklocale/yacc.y 8 May 2016 15:25:44 - 1.10 +++ usr.bin/mklocale/yacc.y 15 Jul 2020 14:45:14 - @@ -250,9 +250,6 @@ main(int ac, char *av[]) { int x; -extern char *optarg; -extern int optind; - if (pledge("stdio rpath wpath cpath", NULL) == -1) { perror("pledge"); exit(1); Index:
dd bs= supercede ibs= and obs=
On Feb 14 17:04:51, schwa...@usta.de wrote: > Jason McIntyre wrote on Fri, Feb 14, 2020 at 07:28:59AM +: > > On Thu, Feb 13, 2020 at 11:25:07PM +0100, Jan Stary wrote: > >> * Fix a factual error in the description of bs: it does not > >> supersede ibs/obs, dd will error out when both are specified. > > In fact, that's a bug in the code. POSIX requires: > > bs=expr > Set both input and output block sizes to expr bytes, > superseding ibs= and obs=. > > (see https://pubs.opengroup.org/onlinepubs/9699919799/utilities/dd.html ) This is the line that makes it illegal to specify bs= if ibs= or obs= (or bs= for that matter) has already been specified. Jan Index: args.c === RCS file: /cvs/src/bin/dd/args.c,v retrieving revision 1.31 diff -u -p -r1.31 args.c --- args.c 16 Feb 2019 10:54:00 - 1.31 +++ args.c 15 Feb 2020 10:05:25 - @@ -68,7 +68,7 @@ static const struct arg { void (*f)(char *); u_int set, noset; } args[] = { - { "bs", f_bs, C_BS,C_BS|C_IBS|C_OBS|C_OSYNC }, + { "bs", f_bs, C_BS,C_BS|C_OSYNC }, { "cbs",f_cbs, C_CBS, C_CBS }, { "conv", f_conv, 0, 0 }, { "count", f_count,C_COUNT, C_COUNT },
Re: dd(1) wording and style
Hi, On Feb 14 17:37:27, schwa...@usta.de wrote: > Hi, > > Jason McIntyre wrote on Fri, Feb 14, 2020 at 07:28:59AM +: > > On Thu, Feb 13, 2020 at 11:25:07PM +0100, Jan Stary wrote: > > >> -.It Cm seek= Ns Ar n > >> +.It Cm seek Ns = Ns Ar n > >> Seek > >> .Ar n > >> blocks from the beginning of the output before copying. > >> -On non-tape devices, an > >> -.Xr lseek 2 > >> -operation is used. > >> -Otherwise, existing blocks are read and the data discarded. > >> -If the user does not have read permission for the tape, it is positioned > >> -using the tape > >> +On a tape device, existing blocks are read and the data discarded; > >> +if the user does not have read permission for the tape, > >> +it is positioned using the tape > >> .Xr ioctl 2 > >> function calls. > >> +On all other devices devices, an > >> +.Xr lseek 2 > >> +operation is used. > >> If the seek operation is past the end of file, space from the current > >> end of file to the specified offset is filled with blocks of NUL bytes. > > > i think this change is ok. however i think non-tape is clearer than "on > > all other devices". it's not a biggie, but i think the current stress on > > non-tape devices is probably intentional. > > The patch is misleading. The sentence "If the seek operation is > past the end of file..." only applies to tape devices, so it must > not follow a sentence about lseek(2). Why does it only apply to tape devices? dd if=/dev/zero of=file bs=1 seek=10 count=1 will seek 10 bytes into the output (filling it with zeros) and then write the 1 byte from input, as intended. -rw-r--r-- 1 hans wheel 11 Feb 15 10:50 file Jan
Re: extern already declared
; RCS file: /cvs/src/regress/lib/libutil/fmt_scaled/fmt_test.c,v > retrieving revision 1.15 > diff -u -p -r1.15 fmt_test.c > --- regress/lib/libutil/fmt_scaled/fmt_test.c 16 Mar 2017 02:42:31 - > 1.15 > +++ regress/lib/libutil/fmt_scaled/fmt_test.c 9 Feb 2020 16:23:49 - > @@ -36,8 +36,6 @@ __dead static void usage(int stat) > int > main(int argc, char **argv) > { > - extern char *optarg; > - extern int optind; > int i, ch; > > while ((ch = getopt(argc, argv, "hv")) != -1) { > > On Feb 09 09:49:35, mill...@openbsd.org wrote: > On Sun, 09 Feb 2020 17:46:51 +0100, Jan Stary wrote: > > > Whenever unistd.h declares getopt(3), it also declares > > the extern optind and optarg, so files including unistd.h > > don't need to declare those themselves, right? > > Correct. Most of those date back from before optind and optarg > were defined for you by unistd.h. So can they be removed now?
Re: remove needless #ifdef
On Feb 10 09:28:38, yasu...@openbsd.org wrote: > Hi, > > On Sun, 09 Feb 2020 19:28:50 +0100 > Jeremie Courreges-Anglas wrote: > > On Sun, Feb 09 2020, Jan Stary wrote: > >> Currently, sys/net/pipex_local.h asks #ifdef __OpenBSD__ > >> and if so, defines "Static" to be nothing, to use it later. > >> That can go away, right? > > > > I believe that's something the IIJ folks want to keep, cc'ing Yasuoka. > > I once thought keeping "static" is better for maintaining the code, > but now I don't think it's necessary. So it's ok to remove them. So can we remove the please? Jan > >> > >> Index: sys/net/pipex_local.h > >> === > >> RCS file: /cvs/src/sys/net/pipex_local.h,v > >> retrieving revision 1.30 > >> diff -u -p -r1.30 pipex_local.h > >> --- sys/net/pipex_local.h 31 Jan 2019 18:01:14 - 1.30 > >> +++ sys/net/pipex_local.h 9 Feb 2020 15:26:51 - > >> @@ -26,12 +26,6 @@ > >> * SUCH DAMAGE. > >> */ > >> > >> -#ifdef __OpenBSD__ > >> -#define Static > >> -#else > >> -#define Static static > >> -#endif > >> - > >> #define PIPEX_PPTP 1 > >> #define PIPEX_L2TP 1 > >> #define PIPEX_PPPOE 1 > >> @@ -372,59 +366,56 @@ extern struct pipex_hash_headpipex_id_h > >> #define PIPEX_TCP_OPTLEN 40 > >> #define PIPEX_L2TP_MINLEN 8 > >> > >> -/* > >> - * static function prototypes > >> - */ > >> -Static void pipex_iface_start (struct > >> pipex_iface_context *); > >> -Static void pipex_iface_stop (struct pipex_iface_context > >> *); > >> -Static int pipex_add_session (struct pipex_session_req > >> *, struct pipex_iface_context *); > >> -Static int pipex_close_session (struct > >> pipex_session_close_req *); > >> -Static int pipex_config_session (struct > >> pipex_session_config_req *); > >> -Static int pipex_get_stat (struct > >> pipex_session_stat_req *); > >> -Static int pipex_get_closed (struct > >> pipex_session_list_req *); > >> -Static int pipex_destroy_session (struct pipex_session > >> *); > >> -Static struct pipex_session *pipex_lookup_by_ip_address (struct in_addr); > >> -Static struct pipex_session *pipex_lookup_by_session_id (int, int); > >> -Static void pipex_ip_output (struct mbuf *, struct > >> pipex_session *); > >> -Static void pipex_ppp_output (struct mbuf *, struct > >> pipex_session *, int); > >> -Static int pipex_ppp_proto (struct mbuf *, struct > >> pipex_session *, int, int *); > >> -Static void pipex_ppp_input (struct mbuf *, struct > >> pipex_session *, int); > >> -Static void pipex_ip_input (struct mbuf *, struct > >> pipex_session *); > >> +void pipex_iface_start (struct pipex_iface_context *); > >> +void pipex_iface_stop (struct pipex_iface_context *); > >> +int pipex_add_session (struct pipex_session_req *, > >> struct pipex_iface_context *); > >> +int pipex_close_session (struct pipex_session_close_req > >> *); > >> +int pipex_config_session (struct > >> pipex_session_config_req *); > >> +int pipex_get_stat (struct pipex_session_stat_req *); > >> +int pipex_get_closed (struct pipex_session_list_req *); > >> +int pipex_destroy_session (struct pipex_session *); > >> +struct pipex_session *pipex_lookup_by_ip_address (struct in_addr); > >> +struct pipex_session *pipex_lookup_by_session_id (int, int); > >> +void pipex_ip_output (struct mbuf *, struct > >> pipex_session *); > >> +void pipex_ppp_output (struct mbuf *, struct > >> pipex_session *, int); > >> +int pipex_ppp_proto (struct mbuf *, struct > >> pipex_session *, int, int *); > >> +void pipex_ppp_input (struct mbuf *, struct > >> pipex_session *, int); > >> +void pipex_ip_input (struct mbuf *, struct pipex_session > >> *); > >> #ifdef INET6
Re: dd(1) wording and style
On Feb 13 23:25:07, h...@stare.cz wrote: > This diff changes the dd(1) manpage in the following ways: > > * Replace "It Cm if= Ns Ar file" with "It Cm if Ns = Ns Ar file" > and similarly for others. The operand is "if", not "if="; > the "Ns = Ns" might be a slightly excessive markup, > but common: grep -Fr 'Ns = Ns' /usr/share/man | wc -l > and is symmetric around the = > > * Fix a factual error in the description of bs: it does not > supersede ibs/obs, dd will error out when both are specified. > > * "On non-tape devices ... Otherwise ..." is a convoluted way > to say "tape"; describe tape first and remove the double negative. > > * Say "It Cm status Ns = Ns Ar value" instead of > > .It Xo > .Sm off > .Cm status= Ar value > .Sm on > .Xc > > * "Where every value" is not a beginning of a sentence. > > * Tweak the wording of osync: regular-sized output block > is enforced in every case, drop the "if not a multiple". > > Jan > > > Index: dd.1 > === > RCS file: /cvs/src/bin/dd/dd.1,v > retrieving revision 1.35 > diff -u -p -r1.35 dd.1 > --- dd.1 16 Feb 2019 17:01:24 - 1.35 > +++ dd.1 13 Feb 2020 21:45:56 - > @@ -57,11 +57,11 @@ and truncated input records to the stand > .Pp > The following operands are available: > .Bl -tag -width of=file > -.It Cm if= Ns Ar file > +.It Cm if Ns = Ns Ar file > Read input from > .Ar file > instead of the standard input. > -.It Cm of= Ns Ar file > +.It Cm of Ns = Ns Ar file > Write output to > .Ar file > instead of the standard output. > @@ -72,22 +72,24 @@ If an initial portion of the output file > .Cm seek > operand), > the output file is truncated at that point. > -.It Cm ibs= Ns Ar n > +.It Cm ibs Ns = Ns Ar n > Set the input block size to > .Ar n > bytes instead of the default 512. > -.It Cm obs= Ns Ar n > +.It Cm obs Ns = Ns Ar n > Set the output block size to > .Ar n > bytes instead of the default 512. > -.It Cm bs= Ns Ar n > +.It Cm bs Ns = Ns Ar n > Set both the input and output block size to > .Ar n > -bytes, superseding the > +bytes. > +It is an error to specify both > +.Cm bs > +and either of > .Cm ibs > -and > -.Cm obs > -operands. > +or > +.Cm obs . > If no conversion values other than > .Cm noerror , > .Cm notrunc , > @@ -95,36 +97,36 @@ or > .Cm sync > are specified, then each input block is copied to the output as a > single block without any aggregation of short blocks. > -.It Cm cbs= Ns Ar n > +.It Cm cbs Ns = Ns Ar n > Set the conversion record size to > .Ar n > bytes. > The conversion record size is required by the record oriented conversion > values. > -.It Cm count= Ns Ar n > +.It Cm count Ns = Ns Ar n > Copy only > .Ar n > input blocks. > -.It Cm files= Ns Ar n > +.It Cm files Ns = Ns Ar n > Copy > .Ar n > input files before terminating. > This operand is only applicable when the input device is a tape. > -.It Cm seek= Ns Ar n > +.It Cm seek Ns = Ns Ar n > Seek > .Ar n > blocks from the beginning of the output before copying. > -On non-tape devices, an > -.Xr lseek 2 > -operation is used. > -Otherwise, existing blocks are read and the data discarded. > -If the user does not have read permission for the tape, it is positioned > -using the tape > +On a tape device, existing blocks are read and the data discarded; > +if the user does not have read permission for the tape, > +it is positioned using the tape > .Xr ioctl 2 > function calls. > +On all other devices devices, an devices devices sorry > +.Xr lseek 2 > +operation is used. > If the seek operation is past the end of file, space from the current > end of file to the specified offset is filled with blocks of NUL bytes. > -.It Cm skip= Ns Ar n > +.It Cm skip Ns = Ns Ar n > Skip > .Ar n > blocks from the beginning of the input before copying. > @@ -135,14 +137,10 @@ Otherwise, input data is read and discar > For pipes, the correct number of bytes is read. > For all other devices, the correct number of blocks is read without > distinguishing between a partial or complete block being read. > -.It Xo > -.Sm off > -.Cm status= Ar value > -.Sm on > -.Xc > -Where > +.It Cm status Ns = Ns Ar value > +where > .Ar value > -is one of the symbols from the following list. > +is one of following. > .Bl -tag -width unblock > .It Cm noxfer > Do not print the transfer statistics as the last line of status output. > @@ -150,15 +148,10 @@ Do not print the transfer statistics as > Do not print the status output. > Error messages are shown; informational messages are not. > .El > -.It Xo > -.Sm off > -.Cm conv= Ar value Oo , > -.Sm on > -.Ar value ... Oc > -.Xc > -Where > +.It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value , Ns ... > +where every > .Ar value > -is one of the symbols from the following list. > +is one of the following. > .Bl -tag -width unblock > .It Cm ascii > The same as the > @@ -235,13 +228,11 @@
dd(1) wording and style
This diff changes the dd(1) manpage in the following ways: * Replace "It Cm if= Ns Ar file" with "It Cm if Ns = Ns Ar file" and similarly for others. The operand is "if", not "if="; the "Ns = Ns" might be a slightly excessive markup, but common: grep -Fr 'Ns = Ns' /usr/share/man | wc -l and is symmetric around the = * Fix a factual error in the description of bs: it does not supersede ibs/obs, dd will error out when both are specified. * "On non-tape devices ... Otherwise ..." is a convoluted way to say "tape"; describe tape first and remove the double negative. * Say "It Cm status Ns = Ns Ar value" instead of .It Xo .Sm off .Cm status= Ar value .Sm on .Xc * "Where every value" is not a beginning of a sentence. * Tweak the wording of osync: regular-sized output block is enforced in every case, drop the "if not a multiple". Jan Index: dd.1 === RCS file: /cvs/src/bin/dd/dd.1,v retrieving revision 1.35 diff -u -p -r1.35 dd.1 --- dd.116 Feb 2019 17:01:24 - 1.35 +++ dd.113 Feb 2020 21:45:56 - @@ -57,11 +57,11 @@ and truncated input records to the stand .Pp The following operands are available: .Bl -tag -width of=file -.It Cm if= Ns Ar file +.It Cm if Ns = Ns Ar file Read input from .Ar file instead of the standard input. -.It Cm of= Ns Ar file +.It Cm of Ns = Ns Ar file Write output to .Ar file instead of the standard output. @@ -72,22 +72,24 @@ If an initial portion of the output file .Cm seek operand), the output file is truncated at that point. -.It Cm ibs= Ns Ar n +.It Cm ibs Ns = Ns Ar n Set the input block size to .Ar n bytes instead of the default 512. -.It Cm obs= Ns Ar n +.It Cm obs Ns = Ns Ar n Set the output block size to .Ar n bytes instead of the default 512. -.It Cm bs= Ns Ar n +.It Cm bs Ns = Ns Ar n Set both the input and output block size to .Ar n -bytes, superseding the +bytes. +It is an error to specify both +.Cm bs +and either of .Cm ibs -and -.Cm obs -operands. +or +.Cm obs . If no conversion values other than .Cm noerror , .Cm notrunc , @@ -95,36 +97,36 @@ or .Cm sync are specified, then each input block is copied to the output as a single block without any aggregation of short blocks. -.It Cm cbs= Ns Ar n +.It Cm cbs Ns = Ns Ar n Set the conversion record size to .Ar n bytes. The conversion record size is required by the record oriented conversion values. -.It Cm count= Ns Ar n +.It Cm count Ns = Ns Ar n Copy only .Ar n input blocks. -.It Cm files= Ns Ar n +.It Cm files Ns = Ns Ar n Copy .Ar n input files before terminating. This operand is only applicable when the input device is a tape. -.It Cm seek= Ns Ar n +.It Cm seek Ns = Ns Ar n Seek .Ar n blocks from the beginning of the output before copying. -On non-tape devices, an -.Xr lseek 2 -operation is used. -Otherwise, existing blocks are read and the data discarded. -If the user does not have read permission for the tape, it is positioned -using the tape +On a tape device, existing blocks are read and the data discarded; +if the user does not have read permission for the tape, +it is positioned using the tape .Xr ioctl 2 function calls. +On all other devices devices, an +.Xr lseek 2 +operation is used. If the seek operation is past the end of file, space from the current end of file to the specified offset is filled with blocks of NUL bytes. -.It Cm skip= Ns Ar n +.It Cm skip Ns = Ns Ar n Skip .Ar n blocks from the beginning of the input before copying. @@ -135,14 +137,10 @@ Otherwise, input data is read and discar For pipes, the correct number of bytes is read. For all other devices, the correct number of blocks is read without distinguishing between a partial or complete block being read. -.It Xo -.Sm off -.Cm status= Ar value -.Sm on -.Xc -Where +.It Cm status Ns = Ns Ar value +where .Ar value -is one of the symbols from the following list. +is one of following. .Bl -tag -width unblock .It Cm noxfer Do not print the transfer statistics as the last line of status output. @@ -150,15 +148,10 @@ Do not print the transfer statistics as Do not print the status output. Error messages are shown; informational messages are not. .El -.It Xo -.Sm off -.Cm conv= Ar value Oo , -.Sm on -.Ar value ... Oc -.Xc -Where +.It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value , Ns ... +where every .Ar value -is one of the symbols from the following list. +is one of the following. .Bl -tag -width unblock .It Cm ascii The same as the @@ -235,13 +228,11 @@ The value is not supported for tapes. .It Cm osync Pad the final output block to the full output block size. -If the input file is not a multiple of the output block size -after conversion, this conversion forces the final output block -to be the same size as preceding blocks for use on devices that require +This forces the final output block to be the same size +as preceding
Re: Audio control API, part 1: libsndio, sndiod bits
On Feb 12 21:38:56, a...@caoua.org wrote: > On Wed, Feb 12, 2020 at 09:22:20PM +0100, Jan Stary wrote: > > Hi, > > > > On Feb 09 13:13:02, a...@caoua.org wrote: > > > cd /usr/src > > > patch -p0 <1.diff > > > patch -p0 <2.diff > > > patch -p0 <3.diff > > > cd /usr/src/include && doas make includes > > > cd /usr/src/lib/libsndio && make obj && make && doas make install > > > cd /usr/src/lib/libossaudio && make obj && make && doas make install > > > cd /usr/src/usr.bin/sndiod && make obj && make && doas make install > > > cd /usr/src/usr.bin/sndioctl && make obj && make && doas make install > > > doas rcctl restart sndiod > > > > > > I'm very interested in any regression. > > > > After restarting sndiod (with empty flags), > > starting sndioctl -m makes sndiod crash with > > > > Feb 12 21:02:31 box /bsd: sndiod[95433]: pledge "tty", syscall 54 > > > > That's ioctl(2). I don't see that in any of the three pledge(2) calls > > revealed by a grep in (the patched) .../sndiod/, but apparently > > the new code does call ioctl(). > > sndiod does unauthorized ioctls on this kernel, see below > > > > > Strangely, this happens on > > > > OpenBSD 6.6-current (GENERIC.MP) #0: Tue Feb 4 17:33:19 CET 2020 > > h...@box.stare.cz:/usr/src/sys/arch/amd64/compile/GENERIC.MP > > > > but not on > > > > OpenBSD 6.6-current (GENERIC.MP) #0: Sun Feb 9 17:30:47 CET 2020 > > h...@dell.stare.cz:/usr/src/sys/arch/amd64/compile/GENERIC.MP > > > > (Did I miss somethong pledge() related in that window?) > > > > Yes, there was a kernel commit to allow programs with the "audio" > promise (like sndiod) to use the mixer ioctl()s. Indeed, the problem disappears with the current curent. Sorry for the noise. Jan
Re: Audio control API, part 1: libsndio, sndiod bits
Hi, On Feb 09 13:13:02, a...@caoua.org wrote: > cd /usr/src > patch -p0 <1.diff > patch -p0 <2.diff > patch -p0 <3.diff > cd /usr/src/include && doas make includes > cd /usr/src/lib/libsndio && make obj && make && doas make install > cd /usr/src/lib/libossaudio && make obj && make && doas make install > cd /usr/src/usr.bin/sndiod && make obj && make && doas make install > cd /usr/src/usr.bin/sndioctl && make obj && make && doas make install > doas rcctl restart sndiod > cd /usr/ports > patch -p0 <4.diff > cd /usr/ports/audio/gqmpeg && make && make install > cd /usr/ports/sysutils/tray-app && make && make install > > Feedback about the new features > is of course welcome as well. sndioctl -m works fine with e.g. mplayer, i.e. sndioctl notices the "added" app, and reports the volume changes. With ffplay and firefox:youtube, volume changes are not reported. Is that expected? Do they tweak their "internal" volume knob but not the volume they register with sndio? As opposed to mplayer? At any rate, thanks for the new tool! Jan
Re: Audio control API, part 1: libsndio, sndiod bits
Hi, On Feb 09 13:13:02, a...@caoua.org wrote: > cd /usr/src > patch -p0 <1.diff > patch -p0 <2.diff > patch -p0 <3.diff > cd /usr/src/include && doas make includes > cd /usr/src/lib/libsndio && make obj && make && doas make install > cd /usr/src/lib/libossaudio && make obj && make && doas make install > cd /usr/src/usr.bin/sndiod && make obj && make && doas make install > cd /usr/src/usr.bin/sndioctl && make obj && make && doas make install > doas rcctl restart sndiod > > I'm very interested in any regression. After restarting sndiod (with empty flags), starting sndioctl -m makes sndiod crash with Feb 12 21:02:31 box /bsd: sndiod[95433]: pledge "tty", syscall 54 That's ioctl(2). I don't see that in any of the three pledge(2) calls revealed by a grep in (the patched) .../sndiod/, but apparently the new code does call ioctl(). Strangely, this happens on OpenBSD 6.6-current (GENERIC.MP) #0: Tue Feb 4 17:33:19 CET 2020 h...@box.stare.cz:/usr/src/sys/arch/amd64/compile/GENERIC.MP but not on OpenBSD 6.6-current (GENERIC.MP) #0: Sun Feb 9 17:30:47 CET 2020 h...@dell.stare.cz:/usr/src/sys/arch/amd64/compile/GENERIC.MP (Did I miss somethong pledge() related in that window?) Jan
Re: don't try to signal with newsyslog -r
On Feb 10 14:53:33, mill...@openbsd.org wrote: > On Mon, 10 Feb 2020 17:12:53 +0100, Jan Stary wrote: > > > The -r option of newsyslog(8) removes the requirement > > that newsyslog runs as root. Would it also make sense > > to not try to send the SIGHUP to syslogd in that case? > > This seems wrong to me. You are disabling more than just sending > a signal to SIGHUP, this will cause newsyslog to ignore *all* pid > files. Yes; it is wrong. A better way to avoid trying to send the signal seems to be to simply specify an empty command in the config file. Jan
Re: don't try to signal with newsyslog -r
Hi Ingo, On Feb 10 22:40:20, schwa...@usta.de wrote: > > The -r option of newsyslog(8) removes the requirement > > that newsyslog runs as root. Would it also make sense > > to not try to send the SIGHUP to syslogd in that case? > > While i'm not sure that i want to take care of this patch, > given that i'm not quite sure what the point of the -r option > even is in the first place, for example, I use it to rotate ~/battery/battery.log on my laptop upon boot, obtaining a concise history of the battery's life. Without -r, newsyslog would refuse to run. It is my impression that this is the inteded use: people rotating their own logs, not just system logs. I don't know why newsyslog refuses to run without root, creating a "need" for -r in the first place, > i'd like to point out that you > are also removing the warning. Is that intentional? Yes. > Naively, getting a warning when files are rotated but the > daemon isn't notified seems useful to me, even if you kind > of requested it with -r. > > In that case, wouldn't it make more sense to say something > like (untested, and no code auditing done) > > else if (needroot == 0 || kill(pid, signal)) > > ? > > That would also avoid the hopeless attempt to send a signal, > but would still print the warning. Sorry for being unclear. The log I am rotating is not written by syslog; it is written by my user's cronjob (basicaly saving the voltage and capacity from hw.sensors.acpibat0 every cron minutes). Given that, and the fact that I am not running newsyslog as root, I don't need or expect to signal syslog; the warning then only informs me about the hopeless attempt to send the signal. Jan > > Index: newsyslog.8 > > === > > RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.8,v > > retrieving revision 1.54 > > diff -u -p -r1.54 newsyslog.8 > > --- newsyslog.8 20 Jul 2017 18:39:16 - 1.54 > > +++ newsyslog.8 10 Feb 2020 16:08:51 - > > @@ -124,7 +124,7 @@ Removes the restriction that > > must be running as root. > > Note that in this mode > > .Nm > > -will not be able to send a > > +will not try to send a > > .Dv SIGHUP > > signal to > > .Xr syslogd 8 . > > Index: newsyslog.c > > === > > RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.c,v > > retrieving revision 1.112 > > diff -u -p -r1.112 newsyslog.c > > --- newsyslog.c 28 Jun 2019 13:35:02 - 1.112 > > +++ newsyslog.c 10 Feb 2020 16:08:51 - > > @@ -394,7 +394,7 @@ send_signal(char *pidfile, int signal) > > warnx("%s pid file: %s", err, pidfile); > > else if (noaction) > > (void)printf("kill -%s %ld\n", sys_signame[signal], (long)pid); > > - else if (kill(pid, signal)) > > + else if (needroot && kill(pid, signal)) > > warnx("warning - could not send SIG%s to PID from pid file %s", > > sys_signame[signal], pidfile); > > } > >
don't try to signal with newsyslog -r
The -r option of newsyslog(8) removes the requirement that newsyslog runs as root. Would it also make sense to not try to send the SIGHUP to syslogd in that case? Jan Index: newsyslog.8 === RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.8,v retrieving revision 1.54 diff -u -p -r1.54 newsyslog.8 --- newsyslog.8 20 Jul 2017 18:39:16 - 1.54 +++ newsyslog.8 10 Feb 2020 16:08:51 - @@ -124,7 +124,7 @@ Removes the restriction that must be running as root. Note that in this mode .Nm -will not be able to send a +will not try to send a .Dv SIGHUP signal to .Xr syslogd 8 . Index: newsyslog.c === RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.c,v retrieving revision 1.112 diff -u -p -r1.112 newsyslog.c --- newsyslog.c 28 Jun 2019 13:35:02 - 1.112 +++ newsyslog.c 10 Feb 2020 16:08:51 - @@ -394,7 +394,7 @@ send_signal(char *pidfile, int signal) warnx("%s pid file: %s", err, pidfile); else if (noaction) (void)printf("kill -%s %ld\n", sys_signame[signal], (long)pid); - else if (kill(pid, signal)) + else if (needroot && kill(pid, signal)) warnx("warning - could not send SIG%s to PID from pid file %s", sys_signame[signal], pidfile); }
setlocale() in cron
Why does cron(8) and crontab(1) need to setlocale()? Jan Index: cron.c === RCS file: /cvs/src/usr.sbin/cron/cron.c,v retrieving revision 1.77 diff -u -p -r1.77 cron.c --- cron.c 23 Oct 2017 15:15:22 - 1.77 +++ cron.c 10 Feb 2020 12:12:13 - @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -83,8 +82,6 @@ main(int argc, char *argv[]) struct sigaction sact; sigset_t blocked, omask; struct group *grp; - - setlocale(LC_ALL, ""); setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stderr, NULL, _IOLBF, 0); Index: crontab.c === RCS file: /cvs/src/usr.sbin/cron/crontab.c,v retrieving revision 1.93 diff -u -p -r1.93 crontab.c --- crontab.c 28 Jun 2019 13:32:47 - 1.93 +++ crontab.c 10 Feb 2020 12:12:13 - @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -92,7 +91,6 @@ main(int argc, char *argv[]) user_gid = getgid(); crontab_gid = getegid(); - setlocale(LC_ALL, ""); openlog(__progname, LOG_PID, LOG_CRON); setvbuf(stderr, NULL, _IOLBF, 0);
cp.c and rm.c embedded in mv(1)
mv code contains copies of cp.c and rm.c - is that so that mv can avoid the fork+exec (and call the relevant cp/rm code itself)? If so, is it so that mv can be pledged? It isn't. There must be something worth the duplication ... Jan
Re: Add -R alias to -r for scp(1)
On Jan 02 11:30:35, es...@nerim.net wrote: > Once in three times, I type scp -R and go "oh fuck" when it doesn't work. Same here with 'ssh -p' vs 'scp -P'.
remove the 'support' for troff fonts in lp[rd]
(Replying to an old thread) On Jan 28 12:06:42, chrisbenn...@bennettconstruction.us wrote: > #define _PATH_VFONT "/usr/libdata/vfont/" > #define _PATH_VFONTB"/usr/libdata/vfont/B" > #define _PATH_VFONTI"/usr/libdata/vfont/I" > #define _PATH_VFONTR"/usr/libdata/vfont/R" > #define _PATH_VFONTS"/usr/libdata/vfont/S" On Jan 28 11:18:58, todd.mil...@courtesan.com wrote: > The troff support in lpd is of the old phototypesetter variety. It > has no real value in today's world. The "ditroff" support is what > we would consider modern troff. > > I think we can safely remove the old font bits and the associated > control file bits. The diff below * removes the nonexistent font support from lpr and lpd * removes the -1234 options from the code and manpage * removes the BUGS section mentioning that the nonexistent fonts must be located at the printserver, where they are not implemented Jan Index: usr.sbin/lpd/printer.c === RCS file: /cvs/src/usr.sbin/lpd/printer.c,v retrieving revision 1.2 diff -u -p -r1.2 printer.c --- usr.sbin/lpd/printer.c 3 Jul 2019 03:24:03 - 1.2 +++ usr.sbin/lpd/printer.c 9 Feb 2020 21:32:41 - @@ -474,13 +474,6 @@ printjob(const char *cfname, int retry) log_warnx("strtonum: %s", errstr); break; - case '1': /* troff fonts */ - case '2': - case '3': - case '4': - /* XXX not implemented */ - break; - default: if (line[0] < 'a' || line[0] > 'z') break; Index: usr.sbin/lpr/common_source/pathnames.h === RCS file: /cvs/src/usr.sbin/lpr/common_source/pathnames.h,v retrieving revision 1.6 diff -u -p -r1.6 pathnames.h --- usr.sbin/lpr/common_source/pathnames.h 28 Oct 2015 13:25:55 - 1.6 +++ usr.sbin/lpr/common_source/pathnames.h 9 Feb 2020 21:32:41 - @@ -40,8 +40,3 @@ #define_PATH_PR"/usr/bin/pr" #define_PATH_PRINTCAP "/etc/printcap" #define_PATH_SOCKETNAME"/var/run/printer" -#define_PATH_VFONT "/usr/libdata/vfont/" -#define_PATH_VFONTB"/usr/libdata/vfont/B" -#define_PATH_VFONTI"/usr/libdata/vfont/I" -#define_PATH_VFONTR"/usr/libdata/vfont/R" -#define_PATH_VFONTS"/usr/libdata/vfont/S" Index: usr.sbin/lpr/lpd/lpd.8 === RCS file: /cvs/src/usr.sbin/lpr/lpd/lpd.8,v retrieving revision 1.30 diff -u -p -r1.30 lpd.8 --- usr.sbin/lpr/lpd/lpd.8 8 Feb 2020 01:09:58 - 1.30 +++ usr.sbin/lpr/lpd/lpd.8 9 Feb 2020 21:32:41 - @@ -261,18 +261,6 @@ The file contains a raster image. .It r The file contains text data with FORTRAN carriage control characters. -.It \&1 -Troff Font R. -Name of the font file to use instead of the default. -.It \&2 -Troff Font I. -Name of the font file to use instead of the default. -.It \&3 -Troff Font B. -Name of the font file to use instead of the default. -.It \&4 -Troff Font S. -Name of the font file to use instead of the default. .It W Width. Changes the page width (in characters) used by Index: usr.sbin/lpr/lpd/printjob.c === RCS file: /cvs/src/usr.sbin/lpr/lpd/printjob.c,v retrieving revision 1.61 diff -u -p -r1.61 printjob.c --- usr.sbin/lpr/lpd/printjob.c 3 Jul 2019 03:24:03 - 1.61 +++ usr.sbin/lpr/lpd/printjob.c 9 Feb 2020 21:32:41 - @@ -316,16 +316,6 @@ again: goto again; } -#defineFONTLEN 50 -char fonts[4][FONTLEN]; /* fonts for troff */ - -char ifonts[4][40] = { - _PATH_VFONTR, - _PATH_VFONTI, - _PATH_VFONTB, - _PATH_VFONTS, -}; - /* * The remaining part is the reading of the control file (cf) * and performing the various actions. @@ -348,15 +338,6 @@ printit(char *file) return(OK); } /* -* Reset troff fonts. -*/ - for (i = 0; i < 4; i++) - strlcpy(fonts[i], ifonts[i], FONTLEN); - (void)snprintf([2], sizeof(width) - 2, "%ld", PW); - indent[2] = '0'; - indent[3] = '\0'; - - /* * read the control file for work to do * * file format -- first character in the line is a command @@ -381,10 +362,6 @@ printit(char *file) * g -- "file name" plot(1G) file to print * v -- "file name" plain raster file to print * c -- "file name" cifplot file to print -* 1 -- "R font file" for
Re: extern already declared
On Feb 09 09:49:35, mill...@openbsd.org wrote: > On Sun, 09 Feb 2020 17:46:51 +0100, Jan Stary wrote: > > > Whenever unistd.h declares getopt(3), it also declares > > the extern optind and optarg, so files including unistd.h > > don't need to declare those themselves, right? > > Correct. Most of those date back from before optind and optarg > were defined for you by unistd.h. But the externs should be mentioned in the manpage, right? That's the only place they are mentioned before being talked about in the text; although I suspect that's why people keep declaring them in source code - it's what SYNOPSIS said. Jan
afile.h not wav.h
The afile.h include has been so named for some time but the corresponding #define has not been changed from WAV_H - not that it matters much of course. Jan Index: afile.h === RCS file: /cvs/src/usr.bin/aucat/afile.h,v retrieving revision 1.1 diff -u -p -r1.1 afile.h --- afile.h 21 Jan 2015 08:43:55 - 1.1 +++ afile.h 9 Feb 2020 17:42:02 - @@ -14,8 +14,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef WAV_H -#define WAV_H +#ifndef AFILE_H +#define AFILE_H #include #include "dsp.h" @@ -52,4 +52,4 @@ size_t afile_write(struct afile *, void int afile_seek(struct afile *, off_t); void afile_close(struct afile *); -#endif /* !defined(WAV_H) */ +#endif /* !defined(AFILE_H) */
extern already declared
Whenever unistd.h declares getopt(3), it also declares the extern optind and optarg, so files including unistd.h don't need to declare those themselves, right? Jan Index: games/fortune/strfile/strfile.c === RCS file: /cvs/src/games/fortune/strfile/strfile.c,v retrieving revision 1.29 diff -u -p -r1.29 strfile.c --- games/fortune/strfile/strfile.c 4 Jun 2017 13:39:25 - 1.29 +++ games/fortune/strfile/strfile.c 9 Feb 2020 16:23:42 - @@ -252,8 +252,6 @@ main(int ac, char *av[]) void getargs(int argc, char *argv[]) { - extern char *optarg; - extern int optind; int ch; while ((ch = getopt(argc, argv, "c:hiorsx")) != -1) { Index: games/hunt/hunt/hunt.c === RCS file: /cvs/src/games/hunt/hunt/hunt.c,v retrieving revision 1.22 diff -u -p -r1.22 hunt.c --- games/hunt/hunt/hunt.c 8 Apr 2017 22:50:41 - 1.22 +++ games/hunt/hunt/hunt.c 9 Feb 2020 16:23:42 - @@ -85,8 +85,6 @@ int main(int ac, char **av) { int c; - extern int optind; - extern char *optarg; longenter_status; int option; struct servent *se; Index: games/hunt/huntd/driver.c === RCS file: /cvs/src/games/hunt/huntd/driver.c,v retrieving revision 1.29 diff -u -p -r1.29 driver.c --- games/hunt/huntd/driver.c 21 Jan 2017 08:22:57 - 1.29 +++ games/hunt/huntd/driver.c 9 Feb 2020 16:23:42 - @@ -80,8 +80,6 @@ main(int ac, char **av) static fd_set read_fds; static FLAG first = TRUE; static FLAG server = FALSE; - extern int optind; - extern char *optarg; extern char *__progname; int c; static struct timeval linger = { 0, 0 }; Index: games/robots/main.c === RCS file: /cvs/src/games/robots/main.c,v retrieving revision 1.28 diff -u -p -r1.28 main.c --- games/robots/main.c 28 Jun 2019 13:32:52 - 1.28 +++ games/robots/main.c 9 Feb 2020 16:23:42 - @@ -56,7 +56,6 @@ main(int ac, char *av[]) int score_err = 0; /* hold errno from score file open */ int ch; int ret; - extern int optind; char*home; #ifdef FANCY char*sp; Index: regress/lib/libc/db/dbtest.c === RCS file: /cvs/src/regress/lib/libc/db/dbtest.c,v retrieving revision 1.16 diff -u -p -r1.16 dbtest.c --- regress/lib/libc/db/dbtest.c27 Jul 2017 15:08:37 - 1.16 +++ regress/lib/libc/db/dbtest.c9 Feb 2020 16:23:48 - @@ -76,8 +76,6 @@ int XXlineno; /* Fast breakpoint for int main(int argc, char *argv[]) { - extern int optind; - extern char *optarg; enum S command, state; DB *dbp; DBT data, key, keydata; Index: regress/lib/libc/getaddrinfo/gaitest.c === RCS file: /cvs/src/regress/lib/libc/getaddrinfo/gaitest.c,v retrieving revision 1.6 diff -u -p -r1.6 gaitest.c --- regress/lib/libc/getaddrinfo/gaitest.c 9 Jun 2009 18:15:08 - 1.6 +++ regress/lib/libc/getaddrinfo/gaitest.c 9 Feb 2020 16:23:48 - @@ -119,8 +119,6 @@ main(argc, argv) struct addrinfo *res; int error, i; char *p, *q; - extern int optind; - extern char *optarg; int c; char nbuf[10]; Index: regress/lib/libc/regex/main.c === RCS file: /cvs/src/regress/lib/libc/regex/main.c,v retrieving revision 1.10 diff -u -p -r1.10 main.c --- regress/lib/libc/regex/main.c 13 Jul 2016 06:17:11 - 1.10 +++ regress/lib/libc/regex/main.c 9 Feb 2020 16:23:48 - @@ -41,8 +41,6 @@ main(int argc, char *argv[]) int c; int errflg = 0; register int i; - extern int optind; - extern char *optarg; progname = argv[0]; Index: regress/lib/libutil/fmt_scaled/fmt_test.c === RCS file: /cvs/src/regress/lib/libutil/fmt_scaled/fmt_test.c,v retrieving revision 1.15 diff -u -p -r1.15 fmt_test.c --- regress/lib/libutil/fmt_scaled/fmt_test.c 16 Mar 2017 02:42:31 - 1.15 +++ regress/lib/libutil/fmt_scaled/fmt_test.c 9 Feb 2020 16:23:49 - @@ -36,8 +36,6 @@ __dead static void usage(int stat) int main(int argc, char **argv) { - extern char *optarg; - extern int optind; int i, ch; while ((ch = getopt(argc, argv, "hv")) != -1) {
remove needless #ifdef
Currently, sys/net/pipex_local.h asks #ifdef __OpenBSD__ and if so, defines "Static" to be nothing, to use it later. That can go away, right? Jan Index: sys/net/pipex_local.h === RCS file: /cvs/src/sys/net/pipex_local.h,v retrieving revision 1.30 diff -u -p -r1.30 pipex_local.h --- sys/net/pipex_local.h 31 Jan 2019 18:01:14 - 1.30 +++ sys/net/pipex_local.h 9 Feb 2020 15:26:51 - @@ -26,12 +26,6 @@ * SUCH DAMAGE. */ -#ifdef __OpenBSD__ -#define Static -#else -#define Static static -#endif - #definePIPEX_PPTP 1 #definePIPEX_L2TP 1 #definePIPEX_PPPOE 1 @@ -372,59 +366,56 @@ extern struct pipex_hash_head pipex_id_h #define PIPEX_TCP_OPTLEN 40 #definePIPEX_L2TP_MINLEN 8 -/* - * static function prototypes - */ -Static void pipex_iface_start (struct pipex_iface_context *); -Static void pipex_iface_stop (struct pipex_iface_context *); -Static int pipex_add_session (struct pipex_session_req *, struct pipex_iface_context *); -Static int pipex_close_session (struct pipex_session_close_req *); -Static int pipex_config_session (struct pipex_session_config_req *); -Static int pipex_get_stat (struct pipex_session_stat_req *); -Static int pipex_get_closed (struct pipex_session_list_req *); -Static int pipex_destroy_session (struct pipex_session *); -Static struct pipex_session *pipex_lookup_by_ip_address (struct in_addr); -Static struct pipex_session *pipex_lookup_by_session_id (int, int); -Static void pipex_ip_output (struct mbuf *, struct pipex_session *); -Static void pipex_ppp_output (struct mbuf *, struct pipex_session *, int); -Static int pipex_ppp_proto (struct mbuf *, struct pipex_session *, int, int *); -Static void pipex_ppp_input (struct mbuf *, struct pipex_session *, int); -Static void pipex_ip_input (struct mbuf *, struct pipex_session *); +void pipex_iface_start (struct pipex_iface_context *); +void pipex_iface_stop (struct pipex_iface_context *); +int pipex_add_session (struct pipex_session_req *, struct pipex_iface_context *); +int pipex_close_session (struct pipex_session_close_req *); +int pipex_config_session (struct pipex_session_config_req *); +int pipex_get_stat (struct pipex_session_stat_req *); +int pipex_get_closed (struct pipex_session_list_req *); +int pipex_destroy_session (struct pipex_session *); +struct pipex_session *pipex_lookup_by_ip_address (struct in_addr); +struct pipex_session *pipex_lookup_by_session_id (int, int); +void pipex_ip_output (struct mbuf *, struct pipex_session *); +void pipex_ppp_output (struct mbuf *, struct pipex_session *, int); +int pipex_ppp_proto (struct mbuf *, struct pipex_session *, int, int *); +void pipex_ppp_input (struct mbuf *, struct pipex_session *, int); +void pipex_ip_input (struct mbuf *, struct pipex_session *); #ifdef INET6 -Static void pipex_ip6_input (struct mbuf *, struct pipex_session *); +void pipex_ip6_input (struct mbuf *, struct pipex_session *); #endif -Static struct mbuf *pipex_common_input(struct pipex_session *, struct mbuf *, int, int, int); +struct mbuf *pipex_common_input(struct pipex_session *, struct mbuf *, int, int, int); #ifdef PIPEX_PPPOE -Static void pipex_pppoe_output (struct mbuf *, struct pipex_session *); +void pipex_pppoe_output (struct mbuf *, struct pipex_session *); #endif #ifdef PIPEX_PPTP -Static void pipex_pptp_output (struct mbuf *, struct pipex_session *, int, int); -Static struct pipex_session *pipex_pptp_userland_lookup_session(struct mbuf *, struct sockaddr *); +void pipex_pptp_output (struct mbuf *, struct pipex_session *, int, int); +struct pipex_session *pipex_pptp_userland_lookup_session(struct mbuf *, struct sockaddr *); #endif #ifdef PIPEX_L2TP -Static void pipex_l2tp_output (struct mbuf *, struct pipex_session *); +void pipex_l2tp_output (struct mbuf *, struct pipex_session *); #endif #ifdef PIPEX_MPPE -Static void pipex_mppe_init (struct pipex_mppe *, int, int, u_char *, int); -Static void GetNewKeyFromSHA (u_char *, u_char *, int, u_char *); -Static void pipex_mppe_reduce_key (struct pipex_mppe *); -Static void mppe_key_change (struct pipex_mppe *); -Static void pipex_mppe_input (struct mbuf *, struct
EC_POINT_new.3 glitch
This seems to be a missed newline. Jan Index: EC_POINT_new.3 === RCS file: /cvs/src/lib/libcrypto/man/EC_POINT_new.3,v retrieving revision 1.9 diff -u -p -r1.9 EC_POINT_new.3 --- EC_POINT_new.3 29 Mar 2018 20:56:49 - 1.9 +++ EC_POINT_new.3 18 Mar 2019 07:36:50 - @@ -472,7 +472,8 @@ on error. .Pp .Fn EC_POINT_hex2point returns the pointer to the -.Vt EC_POINT supplied or +.Vt EC_POINT +supplied or .Dv NULL on error. .Sh SEE ALSO
zic(8) unneeded header
zic.c does not need to include Jan Index: zic.c === RCS file: /cvs/src/usr.sbin/zic/zic.c,v retrieving revision 1.22 diff -u -p -r1.22 zic.c --- zic.c 15 Mar 2016 19:50:47 - 1.22 +++ zic.c 11 Jan 2019 21:03:39 - @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include
locale in locate(1)
Does locate(1) need to setlocale(3)? Jan Index: locate/locate.c === RCS file: /cvs/src/usr.bin/locate/locate/locate.c,v retrieving revision 1.31 diff -u -p -r1.31 locate.c --- locate/locate.c 19 Nov 2015 21:46:05 - 1.31 +++ locate/locate.c 10 Jan 2019 20:34:16 - @@ -73,7 +73,6 @@ #include #include #include -#include #include #include #include @@ -122,7 +121,6 @@ main(int argc, char *argv[]) { int ch; char **dbv = NULL; - (void) setlocale(LC_ALL, ""); if (pledge("stdio rpath", NULL) == -1) err(1, "pledge");
locale in comm(1)
Does comm(1) need to setlocale(3)? It uses strcoll(3) by default, which ignores the locale and does what strcmp(3) does, or strcasecmp(3) with -f, which ignores the locale too. So remove the setlocale(3), remove the header, the LC_ that have been commented out since the initial revision in 1995, and just use strcmp(3) or strcasecmp(3). Jan Index: comm.1 === RCS file: /cvs/src/usr.bin/comm/comm.1,v retrieving revision 1.15 diff -u -p -r1.15 comm.1 --- comm.1 3 Sep 2010 11:09:28 - 1.15 +++ comm.1 10 Jan 2019 20:24:35 - @@ -83,14 +83,6 @@ printed in column number three will have .Nm assumes that the files are lexically sorted; all characters participate in line comparisons. -.\" .Sh ENVIRONMENT -.\" .Bl -tag -width indent -.\" .It Ev LANG -.\" .It Ev LC_ALL -.\" .It Ev LC_CTYPE -.\" .It Ev LC_COLLATE -.\" .It Ev LC_MESSAGES -.\" .El .Sh EXIT STATUS .Ex -std comm .Sh SEE ALSO Index: comm.c === RCS file: /cvs/src/usr.bin/comm/comm.c,v retrieving revision 1.10 diff -u -p -r1.10 comm.c --- comm.c 9 Oct 2015 01:37:07 - 1.10 +++ comm.c 10 Jan 2019 20:24:35 - @@ -35,7 +35,6 @@ #include #include -#include #include #include #include @@ -59,13 +58,11 @@ main(int argc, char *argv[]) char **p, line1[MAXLINELEN], line2[MAXLINELEN]; int (*compare)(const char * ,const char *); - setlocale(LC_ALL, ""); - if (pledge("stdio rpath", NULL) == -1) err(1, "pledge"); flag1 = flag2 = flag3 = 1; - compare = strcoll; + compare = strcmp; while ((ch = getopt(argc, argv, "123f")) != -1) switch(ch) { case '1':
LC_TIME in calendar(1)
calendar imho doesn't need to setlocale(LC_TIME, ...) before and after strftime(3), as LC_TIME is ignored. Jan Index: day.c === RCS file: /cvs/src/usr.bin/calendar/day.c,v retrieving revision 1.34 diff -u -p -r1.34 day.c --- day.c 14 Sep 2016 15:09:46 - 1.34 +++ day.c 10 Jan 2019 15:23:45 - @@ -169,11 +169,7 @@ settime(time_t *now) if (f_SetdayAfter) offset = 0; /* Except not when range is set explicitly */ header[5].iov_base = dayname; - - (void) setlocale(LC_TIME, "C"); header[5].iov_len = strftime(dayname, sizeof(dayname), "%A", tp); - (void) setlocale(LC_TIME, ""); - setnnames(); }
Re: LC_NUMERIC in wprintf(3)
On Jan 10 14:43:39, h...@stare.cz wrote: > The wprintf(3) manpage says > > The decimal point character is defined > in the program's locale (category LC_NUMERIC) > > but LC_NUMERIC is ignored in OpenBSD's C library, > as explained in setlocale(3). > > Would it be an improvement to remove that sentence? > (Removing a needless newline while here.) > > Jan > > > Index: wprintf.3 > === > RCS file: /cvs/src/lib/libc/stdio/wprintf.3,v > retrieving revision 1.5 > diff -u -p -r1.5 wprintf.3 > --- wprintf.3 1 Dec 2017 10:56:07 - 1.5 > +++ wprintf.3 10 Jan 2019 13:29:41 - > @@ -578,14 +578,9 @@ is > .Ql %% . > .El > .Pp > -The decimal point > -character is defined in the program's locale (category > -.Dv LC_NUMERIC ) . > -.Pp > In no case does a non-existent or small field width cause truncation of > a numeric field; if the result of a conversion is wider than the field > -width, the > -field is expanded to contain the conversion result. > +width, the field is expanded to contain the conversion result. > .Sh SEE ALSO > .Xr btowc 3 , > .Xr fputws 3 , same for wscanf(3): Index: wscanf.3 === RCS file: /cvs/src/lib/libc/stdio/wscanf.3,v retrieving revision 1.2 diff -u -p -r1.2 wscanf.3 --- wscanf.32 Nov 2011 22:29:07 - 1.2 +++ wscanf.310 Jan 2019 14:14:08 - @@ -389,10 +389,6 @@ a conversion, although it can be suppres flag. .El .Pp -The decimal point -character is defined in the program's locale (category -.Dv LC_NUMERIC ) . -.Pp For backwards compatibility, a .Dq conversion of
LC_NUMERIC in wprintf(3)
The wprintf(3) manpage says The decimal point character is defined in the program's locale (category LC_NUMERIC) but LC_NUMERIC is ignored in OpenBSD's C library, as explained in setlocale(3). Would it be an improvement to remove that sentence? (Removing a needless newline while here.) Jan Index: wprintf.3 === RCS file: /cvs/src/lib/libc/stdio/wprintf.3,v retrieving revision 1.5 diff -u -p -r1.5 wprintf.3 --- wprintf.3 1 Dec 2017 10:56:07 - 1.5 +++ wprintf.3 10 Jan 2019 13:29:41 - @@ -578,14 +578,9 @@ is .Ql %% . .El .Pp -The decimal point -character is defined in the program's locale (category -.Dv LC_NUMERIC ) . -.Pp In no case does a non-existent or small field width cause truncation of a numeric field; if the result of a conversion is wider than the field -width, the -field is expanded to contain the conversion result. +width, the field is expanded to contain the conversion result. .Sh SEE ALSO .Xr btowc 3 , .Xr fputws 3 ,
Re: pcap_dispatch() returning zero
No really, it reads 20 packets and returns zero. On Dec 08 13:56:09, h...@stare.cz wrote: > The return value of pcap_dispatch() is described in pcap.3 as follows: > > The number of packets read is returned. > Zero is returned when EOF is reached in a savefile. > A return of -1 indicates an error in which case ... > > It will also return zero on the last short read (as "EOF is reached"). > So if you read the packets in chunks of 100, like > > while ((r = pcap_dispatch(src, 100, callback, NULL)) > 0) { > /* ... */ > } > if (r == 0) { > /* EOF */ > } else if (r == -1) { > /* ERROR */ > } > > and the file contains 120 packets, you will have > r == 100 the first time (reading 100 packets) and > r == 0 the second time (reading 20 packets). > > It seems there is no way for the caller to know > how many packets were actually there in the last short read > besides counting the packets himself in the callback(). > > Is that intended? It seems more natural, and less surprising, > to have it return the actual number of packets. That would make > the sequence above 100, then 20, then 0 (like read(2) does). > > Anyway, should this be explicitly mentioned in the manpage? > > Jan > > > Index: pcap.3 > === > RCS file: /cvs/src/lib/libpcap/pcap.3,v > retrieving revision 1.48 > diff -u -p -r1.48 pcap.3 > --- pcap.33 Jun 2018 10:45:15 - 1.48 > +++ pcap.38 Dec 2018 12:53:59 - > @@ -345,7 +345,11 @@ and a > .Fa u_char > pointer to the packet data. > The number of packets read is returned. > -Zero is returned when EOF is reached in a savefile. > +Zero is returned when EOF is reached in a savefile; > +this includes a short read near the end of savefile, > +when less than > +.Fa cnt > +packets are available. > A return of \-1 indicates an error in which case > .Fn pcap_perror > or >
Re: pcap_dispatch() returning zero
ping On Dec 08 13:56:09, h...@stare.cz wrote: > The return value of pcap_dispatch() is described in pcap.3 as follows: > > The number of packets read is returned. > Zero is returned when EOF is reached in a savefile. > A return of -1 indicates an error in which case ... > > It will also return zero on the last short read (as "EOF is reached"). > So if you read the packets in chunks of 100, like > > while ((r = pcap_dispatch(src, 100, callback, NULL)) > 0) { > /* ... */ > } > if (r == 0) { > /* EOF */ > } else if (r == -1) { > /* ERROR */ > } > > and the file contains 120 packets, you will have > r == 100 the first time (reading 100 packets) and > r == 0 the second time (reading 20 packets). > > It seems there is no way for the caller to know > how many packets were actually there in the last short read > besides counting the packets himself in the callback(). > > Is that intended? It seems more natural, and less surprising, > to have it return the actual number of packets. That would make > the sequence above 100, then 20, then 0 (like read(2) does). > > Anyway, should this be explicitly mentioned in the manpage? > > Jan > > > Index: pcap.3 > === > RCS file: /cvs/src/lib/libpcap/pcap.3,v > retrieving revision 1.48 > diff -u -p -r1.48 pcap.3 > --- pcap.33 Jun 2018 10:45:15 - 1.48 > +++ pcap.38 Dec 2018 12:53:59 - > @@ -345,7 +345,11 @@ and a > .Fa u_char > pointer to the packet data. > The number of packets read is returned. > -Zero is returned when EOF is reached in a savefile. > +Zero is returned when EOF is reached in a savefile; > +this includes a short read near the end of savefile, > +when less than > +.Fa cnt > +packets are available. > A return of \-1 indicates an error in which case > .Fn pcap_perror > or >
[no subject]
Currently, pcap_setdirection() is described in pcap.3 as follows: pcap_setdirection() is used to limit the direction that packets must be flowing in order to be captured. The "direction" is not described, except in pcap.h. Should the constants be mentioned in the manpage? Also, the direction only seems to matter for live captures. Jan Index: pcap.3 === RCS file: /cvs/src/lib/libpcap/pcap.3,v retrieving revision 1.48 diff -u -p -r1.48 pcap.3 --- pcap.3 3 Jun 2018 10:45:15 - 1.48 +++ pcap.3 10 Dec 2018 07:12:53 - @@ -535,6 +535,15 @@ datalink types. .Fn pcap_setdirection is used to limit the direction that packets must be flowing in order to be captured. +The direction is either +.Dv PCAP_D_INOUT , +.Dv PCAP_D_IN +or +.Dv PCAP_D_OUT . +Direction is only relevant to live captures. +When reading from a dump file, +.Fn pcap_setdirection +has no effect . .Pp .Fn pcap_list_datalinks returns an array of the supported datalink types for an opened live capture
pcap_dump() arguments
pcap_dump() is described in pcap.3 as follows: pcap_dump() outputs a packet to the savefile opened with pcap_dump_open(). Note that its calling arguments are suitable for use with pcap_dispatch(). That formulation is imho not entirely clear, as the arguments mention no "savefile". (Looking at the source, it just treats the 'user' argument as a FILE* which is what a pcap_dumper_t* returned by pcap_dump_open() really is, and fwrite()s the header and packet data there.) It would be clearer if the manpage said that the 'user' is the savefile, and that it is to be passed as the last argument to pcap_dispatch() when using pcap_dump() as a callback function. Jan Index: pcap.3 === RCS file: /cvs/src/lib/libpcap/pcap.3,v retrieving revision 1.48 diff -u -p -r1.48 pcap.3 --- pcap.3 3 Jun 2018 10:45:15 - 1.48 +++ pcap.3 10 Dec 2018 07:01:13 - @@ -353,9 +353,17 @@ or may be used to display the error text. .Pp .Fn pcap_dump -outputs a packet to the savefile opened with -.Fn pcap_dump_open . -Note that its calling arguments are suitable for use with +outputs a packet to a previously opened savefile, +if the pointer obtained with +.Fn pcap_dump_open +is passed as the +.Fa user +argument. +This makes +.Fn pcap_dump +a suitable +.Fa callback +to use with .Fn pcap_dispatch . .Pp .Fn pcap_inject
pcap_dispatch() returning zero
The return value of pcap_dispatch() is described in pcap.3 as follows: The number of packets read is returned. Zero is returned when EOF is reached in a savefile. A return of -1 indicates an error in which case ... It will also return zero on the last short read (as "EOF is reached"). So if you read the packets in chunks of 100, like while ((r = pcap_dispatch(src, 100, callback, NULL)) > 0) { /* ... */ } if (r == 0) { /* EOF */ } else if (r == -1) { /* ERROR */ } and the file contains 120 packets, you will have r == 100 the first time (reading 100 packets) and r == 0 the second time (reading 20 packets). It seems there is no way for the caller to know how many packets were actually there in the last short read besides counting the packets himself in the callback(). Is that intended? It seems more natural, and less surprising, to have it return the actual number of packets. That would make the sequence above 100, then 20, then 0 (like read(2) does). Anyway, should this be explicitly mentioned in the manpage? Jan Index: pcap.3 === RCS file: /cvs/src/lib/libpcap/pcap.3,v retrieving revision 1.48 diff -u -p -r1.48 pcap.3 --- pcap.3 3 Jun 2018 10:45:15 - 1.48 +++ pcap.3 8 Dec 2018 12:53:59 - @@ -345,7 +345,11 @@ and a .Fa u_char pointer to the packet data. The number of packets read is returned. -Zero is returned when EOF is reached in a savefile. +Zero is returned when EOF is reached in a savefile; +this includes a short read near the end of savefile, +when less than +.Fa cnt +packets are available. A return of \-1 indicates an error in which case .Fn pcap_perror or
ifconfig DIAGNOSTICS
The wording of ifconfig DIAGNOSTICS can possibly baffle a non-native speaker (such as me) with Messages indicating the specified interface does not exist, namely, only after parsing the (non)sentence does one realize that the diagnostics consists of messages indicating THAT the interface does not exist etc. As the paragraph does not list the messages (surely there are many), this really boils down to mentioning that ifconfig does indeed have diagnostic messages. I believe nothing would be lost if this paragraph was deleted. Jan Index: ifconfig.8 === RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v retrieving revision 1.319 diff -u -p -r1.319 ifconfig.8 --- ifconfig.8 8 Sep 2018 15:21:03 - 1.319 +++ ifconfig.8 22 Oct 2018 06:35:01 - @@ -1871,10 +1871,6 @@ Create the gif1 network interface: Put the athn0 wireless interface into monitor mode: .Pp .Dl # ifconfig athn0 mediaopt monitor -.Sh DIAGNOSTICS -Messages indicating the specified interface does not exist, the -requested address is unknown, or the user is not privileged and -tried to alter an interface's configuration. .Sh SEE ALSO .Xr netstat 1 , .Xr ifmedia 4 ,
interpolation -> interpretation
I am not a native speaker, but printf(3) "interprets" the conversion specifiers, it does not "interpolate" them, right? Jan Index: printf.3 === RCS file: /cvs/src/lib/libc/stdio/printf.3,v retrieving revision 1.78 diff -u -p -r1.78 printf.3 --- printf.32 Jan 2018 08:05:03 - 1.78 +++ printf.311 Apr 2018 20:53:05 - @@ -870,7 +870,7 @@ This holds true even if the string has b using a function like .Fn snprintf , as the resulting string may still contain user-supplied conversion specifiers -for later interpolation by +for later interpretation by .Fn printf . .Pp Be sure to use the proper secure idiom:
/usr/local/sbin in default PATH?
Both _PATH_DEFPATH and _PATH_STDPATH, as defined in paths.h, include /usr/local/bin but not /usr/local/sbin, as opposed to /usr/bin:/bin:/usr/sbin:/sbin. Is that intentional? Jan Index: include/paths.h === RCS file: /cvs/src/include/paths.h,v retrieving revision 1.25 diff -u -p -r1.25 paths.h --- include/paths.h 13 Mar 2014 15:24:41 - 1.25 +++ include/paths.h 6 Dec 2017 12:43:29 - @@ -36,9 +36,9 @@ #define_PATHS_H_ /* Default search path. */ -#define_PATH_DEFPATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin" +#define_PATH_DEFPATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin" /* All standard utilities path. */ -#define_PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin" +#define_PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin" #define_PATH_BSHELL"/bin/sh" #define_PATH_CONSOLE "/dev/console" Index: share/man/man7/environ.7 === RCS file: /cvs/src/share/man/man7/environ.7,v retrieving revision 1.19 diff -u -p -r1.19 environ.7 --- share/man/man7/environ.710 Sep 2015 18:47:57 - 1.19 +++ share/man/man7/environ.76 Dec 2017 12:43:29 - @@ -99,8 +99,9 @@ but expanded to include .Pa /usr/sbin , .Pa /sbin , .Pa /usr/X11R6/bin , -and .Pa /usr/local/bin +and +.Pa /usr/local/sbin in .Ox . .It Ev PRINTER
Re: Sh FILES without Pa
On Nov 09 12:36:29, h...@stare.cz wrote: > Question: > > static int > child_an(const struct roff_node *n) > { > for (n = n->child; n != NULL; n = n->next) > if ((n->tok == MDOC_An && n->child != NULL) || child_an(n)) > return 1; > return 0; > } > > If I'm reading this right, it tests whether the given node has an An child; > the child_pa() below is an obvious modification. Does the recursive > child_an(n) mean that an An node can itself have an An child? > Similar question for child_pa() then. Ah, just a child of a child, like an An inside a Bl inside AUTHORS. Sorry for the confusion. Jan > > Index: mandoc.1 > === > RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v > retrieving revision 1.143 > diff -u -p -r1.143 mandoc.1 > --- mandoc.1 7 Sep 2017 14:22:58 - 1.143 > +++ mandoc.1 9 Nov 2017 11:28:44 - > @@ -1171,6 +1171,12 @@ An AUTHORS sections contains no > .Ic \ > macros, or only empty ones. > Probably, there are author names lacking markup. > +.It Sy "FILES section without Pa macro" > +.Pq mdoc > +A FILES sections contains no > +.Ic \ > +macros, or only empty ones. > +Probably, there are file names lacking markup. > .El > .Ss "Warnings related to macros and nesting" > .Bl -ohang > Index: mandoc.h > === > RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v > retrieving revision 1.187 > diff -u -p -r1.187 mandoc.h > --- mandoc.h 8 Jul 2017 14:51:01 - 1.187 > +++ mandoc.h 9 Nov 2017 11:28:44 - > @@ -105,6 +105,7 @@ enum mandocerr { > MANDOCERR_XR_ORDER, /* unusual Xr order: ... after ... */ > MANDOCERR_XR_PUNCT, /* unusual Xr punctuation: ... after ... */ > MANDOCERR_AN_MISSING, /* AUTHORS section without An macro */ > + MANDOCERR_PA_MISSING, /* FILES section without Pa macro */ > > /* related to macros and nesting */ > MANDOCERR_MACRO_OBS, /* obsolete macro: macro */ > Index: mdoc_validate.c > === > RCS file: /cvs/src/usr.bin/mandoc/mdoc_validate.c,v > retrieving revision 1.268 > diff -u -p -r1.268 mdoc_validate.c > --- mdoc_validate.c 12 Sep 2017 18:20:32 - 1.268 > +++ mdoc_validate.c 9 Nov 2017 11:28:44 - > @@ -105,6 +105,7 @@ staticvoid post_sh_head(POST_ARGS); > static void post_sh_name(POST_ARGS); > static void post_sh_see_also(POST_ARGS); > static void post_sh_authors(POST_ARGS); > +static void post_sh_files(POST_ARGS); > static void post_sm(POST_ARGS); > static void post_st(POST_ARGS); > static void post_std(POST_ARGS); > @@ -2080,6 +2081,9 @@ post_sh(POST_ARGS) > case SEC_AUTHORS: > post_sh_authors(mdoc); > break; > + case SEC_FILES: > + post_sh_files(mdoc); > + break; > default: > break; > } > @@ -2216,6 +2220,25 @@ post_sh_authors(POST_ARGS) > > if ( ! child_an(mdoc->last)) > mandoc_msg(MANDOCERR_AN_MISSING, mdoc->parse, > + mdoc->last->line, mdoc->last->pos, NULL); > +} > + > +static int > +child_pa(const struct roff_node *n) > +{ > + > + for (n = n->child; n != NULL; n = n->next) > + if ((n->tok == MDOC_Pa && n->child != NULL) || child_pa(n)) > + return 1; > + return 0; > +} > + > +static void > +post_sh_files(POST_ARGS) > +{ > + > + if ( ! child_pa(mdoc->last)) > + mandoc_msg(MANDOCERR_PA_MISSING, mdoc->parse, > mdoc->last->line, mdoc->last->pos, NULL); > } > > Index: read.c > === > RCS file: /cvs/src/usr.bin/mandoc/read.c,v > retrieving revision 1.164 > diff -u -p -r1.164 read.c > --- read.c20 Jul 2017 14:36:32 - 1.164 > +++ read.c9 Nov 2017 11:28:44 - > @@ -141,6 +141,7 @@ staticconst char * const mandocerrs[MAN > "unusual Xr order", > "unusual Xr punctuation", > "AUTHORS section without An macro", > + "FILES section without Pa macro", > > /* related to macros and nesting */ > "obsolete macro", >
Sh FILES without Pa
Hi Ingo, currently, mandoc DIAGNOSTICS recognizes an AUTHORS section without An. Would it be similarly useful to recognize a FILES section without Pa? I left the empty lines after the opening { in case they are intended, just like child_an() and post_sh_authors() have them, but feel free to remove them all if they are not. Question: static int child_an(const struct roff_node *n) { for (n = n->child; n != NULL; n = n->next) if ((n->tok == MDOC_An && n->child != NULL) || child_an(n)) return 1; return 0; } If I'm reading this right, it tests whether the given node has an An child; the child_pa() below is an obvious modification. Does the recursive child_an(n) mean that an An node can itself have an An child? Similar question for child_pa() then. Jan Index: mandoc.1 === RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v retrieving revision 1.143 diff -u -p -r1.143 mandoc.1 --- mandoc.17 Sep 2017 14:22:58 - 1.143 +++ mandoc.19 Nov 2017 11:28:44 - @@ -1171,6 +1171,12 @@ An AUTHORS sections contains no .Ic \ macros, or only empty ones. Probably, there are author names lacking markup. +.It Sy "FILES section without Pa macro" +.Pq mdoc +A FILES sections contains no +.Ic \ +macros, or only empty ones. +Probably, there are file names lacking markup. .El .Ss "Warnings related to macros and nesting" .Bl -ohang Index: mandoc.h === RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v retrieving revision 1.187 diff -u -p -r1.187 mandoc.h --- mandoc.h8 Jul 2017 14:51:01 - 1.187 +++ mandoc.h9 Nov 2017 11:28:44 - @@ -105,6 +105,7 @@ enummandocerr { MANDOCERR_XR_ORDER, /* unusual Xr order: ... after ... */ MANDOCERR_XR_PUNCT, /* unusual Xr punctuation: ... after ... */ MANDOCERR_AN_MISSING, /* AUTHORS section without An macro */ + MANDOCERR_PA_MISSING, /* FILES section without Pa macro */ /* related to macros and nesting */ MANDOCERR_MACRO_OBS, /* obsolete macro: macro */ Index: mdoc_validate.c === RCS file: /cvs/src/usr.bin/mandoc/mdoc_validate.c,v retrieving revision 1.268 diff -u -p -r1.268 mdoc_validate.c --- mdoc_validate.c 12 Sep 2017 18:20:32 - 1.268 +++ mdoc_validate.c 9 Nov 2017 11:28:44 - @@ -105,6 +105,7 @@ static void post_sh_head(POST_ARGS); static void post_sh_name(POST_ARGS); static void post_sh_see_also(POST_ARGS); static void post_sh_authors(POST_ARGS); +static void post_sh_files(POST_ARGS); static void post_sm(POST_ARGS); static void post_st(POST_ARGS); static void post_std(POST_ARGS); @@ -2080,6 +2081,9 @@ post_sh(POST_ARGS) case SEC_AUTHORS: post_sh_authors(mdoc); break; + case SEC_FILES: + post_sh_files(mdoc); + break; default: break; } @@ -2216,6 +2220,25 @@ post_sh_authors(POST_ARGS) if ( ! child_an(mdoc->last)) mandoc_msg(MANDOCERR_AN_MISSING, mdoc->parse, + mdoc->last->line, mdoc->last->pos, NULL); +} + +static int +child_pa(const struct roff_node *n) +{ + + for (n = n->child; n != NULL; n = n->next) + if ((n->tok == MDOC_Pa && n->child != NULL) || child_pa(n)) + return 1; + return 0; +} + +static void +post_sh_files(POST_ARGS) +{ + + if ( ! child_pa(mdoc->last)) + mandoc_msg(MANDOCERR_PA_MISSING, mdoc->parse, mdoc->last->line, mdoc->last->pos, NULL); } Index: read.c === RCS file: /cvs/src/usr.bin/mandoc/read.c,v retrieving revision 1.164 diff -u -p -r1.164 read.c --- read.c 20 Jul 2017 14:36:32 - 1.164 +++ read.c 9 Nov 2017 11:28:44 - @@ -141,6 +141,7 @@ static const char * const mandocerrs[MAN "unusual Xr order", "unusual Xr punctuation", "AUTHORS section without An macro", + "FILES section without Pa macro", /* related to macros and nesting */ "obsolete macro",
Re: optind and friends are already declared
If there is any interest in this at all, there's a similar diff for usr.bin/ and usr.sbin/ Jan > On Nov 03 18:34:11, h...@stare.cz wrote: > > Including when using getopt(3) also makes > > extern int opterr, optind, optopt, optreset; > > and friends declared, but many utils redeclare them again. > > > > Is there a reason for that, or can those be removed? > > As a harmless example, here's a diff to games. > > > > Jan > > > > > > Index: fortune/strfile/strfile.c > > === > > RCS file: /cvs/src/games/fortune/strfile/strfile.c,v > > retrieving revision 1.29 > > diff -u -p -r1.29 strfile.c > > --- fortune/strfile/strfile.c 4 Jun 2017 13:39:25 - 1.29 > > +++ fortune/strfile/strfile.c 3 Nov 2017 17:32:52 - > > @@ -252,8 +252,6 @@ main(int ac, char *av[]) > > void > > getargs(int argc, char *argv[]) > > { > > - extern char *optarg; > > - extern int optind; > > int ch; > > > > while ((ch = getopt(argc, argv, "c:hiorsx")) != -1) { > > Index: hunt/hunt/hunt.c > > === > > RCS file: /cvs/src/games/hunt/hunt/hunt.c,v > > retrieving revision 1.22 > > diff -u -p -r1.22 hunt.c > > --- hunt/hunt/hunt.c8 Apr 2017 22:50:41 - 1.22 > > +++ hunt/hunt/hunt.c3 Nov 2017 17:32:52 - > > @@ -85,8 +85,6 @@ int > > main(int ac, char **av) > > { > > int c; > > - extern int optind; > > - extern char *optarg; > > longenter_status; > > int option; > > struct servent *se; > > Index: hunt/huntd/driver.c > > === > > RCS file: /cvs/src/games/hunt/huntd/driver.c,v > > retrieving revision 1.29 > > diff -u -p -r1.29 driver.c > > --- hunt/huntd/driver.c 21 Jan 2017 08:22:57 - 1.29 > > +++ hunt/huntd/driver.c 3 Nov 2017 17:32:52 - > > @@ -80,8 +80,6 @@ main(int ac, char **av) > > static fd_set read_fds; > > static FLAG first = TRUE; > > static FLAG server = FALSE; > > - extern int optind; > > - extern char *optarg; > > extern char *__progname; > > int c; > > static struct timeval linger = { 0, 0 }; > > Index: robots/main.c > > === > > RCS file: /cvs/src/games/robots/main.c,v > > retrieving revision 1.26 > > diff -u -p -r1.26 main.c > > --- robots/main.c 28 May 2017 21:01:13 - 1.26 > > +++ robots/main.c 3 Nov 2017 17:32:52 - > > @@ -56,7 +56,6 @@ main(int ac, char *av[]) > > int score_err = 0; /* hold errno from score file open */ > > int ch; > > int ret; > > - extern int optind; > > char*home; > > #ifdef FANCY > > char*sp; > > >
Re: ieee80211: disable wpa/wep when changing nwid
On Nov 05 17:57:25, phess...@openbsd.org wrote: > Changing nwid on a wifi network means it is a new network. By definition > the WPA crypto keys use the nwid as part of the crypto hash. And it is > super unlikely that a differently named network will have the same WEP > key. In that case, you can enter it again. > > With this, when you change wifi networks, you don't have to remember what > else you have to remove. Please! $ doas ifconfig iwm0 down -nwid -wpakey -nwkey $ doas ifconfig iwm0 up nwid ...
Re: optind and friends are already declared
> On Nov 03 18:34:11, h...@stare.cz wrote: > > Including when using getopt(3) also makes > > extern int opterr, optind, optopt, optreset; > > and friends declared, but many utils redeclare them again. Here is a diff for regress/ Jan Index: lib/libc/db/dbtest.c === RCS file: /cvs/src/regress/lib/libc/db/dbtest.c,v retrieving revision 1.16 diff -u -p -r1.16 dbtest.c --- lib/libc/db/dbtest.c27 Jul 2017 15:08:37 - 1.16 +++ lib/libc/db/dbtest.c3 Nov 2017 18:14:15 - @@ -76,8 +76,6 @@ int XXlineno; /* Fast breakpoint for int main(int argc, char *argv[]) { - extern int optind; - extern char *optarg; enum S command, state; DB *dbp; DBT data, key, keydata; Index: lib/libc/getaddrinfo/gaitest.c === RCS file: /cvs/src/regress/lib/libc/getaddrinfo/gaitest.c,v retrieving revision 1.6 diff -u -p -r1.6 gaitest.c --- lib/libc/getaddrinfo/gaitest.c 9 Jun 2009 18:15:08 - 1.6 +++ lib/libc/getaddrinfo/gaitest.c 3 Nov 2017 18:14:15 - @@ -119,8 +119,6 @@ main(argc, argv) struct addrinfo *res; int error, i; char *p, *q; - extern int optind; - extern char *optarg; int c; char nbuf[10]; Index: lib/libc/regex/main.c === RCS file: /cvs/src/regress/lib/libc/regex/main.c,v retrieving revision 1.10 diff -u -p -r1.10 main.c --- lib/libc/regex/main.c 13 Jul 2016 06:17:11 - 1.10 +++ lib/libc/regex/main.c 3 Nov 2017 18:14:15 - @@ -41,8 +41,6 @@ main(int argc, char *argv[]) int c; int errflg = 0; register int i; - extern int optind; - extern char *optarg; progname = argv[0]; Index: lib/libpthread/switch/switch.c === RCS file: /cvs/src/regress/lib/libpthread/switch/switch.c,v retrieving revision 1.5 diff -u -p -r1.5 switch.c --- lib/libpthread/switch/switch.c 23 Dec 2003 20:09:42 - 1.5 +++ lib/libpthread/switch/switch.c 3 Nov 2017 18:14:15 - @@ -89,10 +89,6 @@ main(int argc, char *argv[]) int ch, count = 4; long i; - /* Getopt variables. */ - extern int optind, opterr; - extern char *optarg; - while ((ch = getopt(argc, argv, "c:?")) != -1) switch (ch) { Index: lib/libutil/fmt_scaled/fmt_test.c === RCS file: /cvs/src/regress/lib/libutil/fmt_scaled/fmt_test.c,v retrieving revision 1.15 diff -u -p -r1.15 fmt_test.c --- lib/libutil/fmt_scaled/fmt_test.c 16 Mar 2017 02:42:31 - 1.15 +++ lib/libutil/fmt_scaled/fmt_test.c 3 Nov 2017 18:14:15 - @@ -36,8 +36,6 @@ __dead static void usage(int stat) int main(int argc, char **argv) { - extern char *optarg; - extern int optind; int i, ch; while ((ch = getopt(argc, argv, "hv")) != -1) {
Re: optind and friends are already declared
> On Nov 03 18:34:11, h...@stare.cz wrote: > > Including when using getopt(3) also makes > > extern int opterr, optind, optopt, optreset; > > and friends declared, but many utils redeclare them again. > > > > Is there a reason for that, or can those be removed? > > As a harmless example, here's a diff to games. optreset too. Strangely, ftpd/popen.c redeclares optreset but none of the others. Jan Index: popen.c === RCS file: /cvs/src/libexec/ftpd/popen.c,v retrieving revision 1.26 diff -u -p -r1.26 popen.c --- popen.c 29 Feb 2016 17:50:34 - 1.26 +++ popen.c 3 Nov 2017 17:44:07 - @@ -132,7 +132,6 @@ ftpd_popen(char *program, char *type, pi closelog(); if (strcmp(gargv[0], "/bin/ls") == 0) { - extern int optreset; extern int ls_main(int, char **); /* reset getopt for ls_main */
Re: optind and friends are already declared
(Sorry for the missing Subject.) On Nov 03 18:34:11, h...@stare.cz wrote: > Including when using getopt(3) also makes > extern int opterr, optind, optopt, optreset; > and friends declared, but many utils redeclare them again. > > Is there a reason for that, or can those be removed? > As a harmless example, here's a diff to games. > > Jan > > > Index: fortune/strfile/strfile.c > === > RCS file: /cvs/src/games/fortune/strfile/strfile.c,v > retrieving revision 1.29 > diff -u -p -r1.29 strfile.c > --- fortune/strfile/strfile.c 4 Jun 2017 13:39:25 - 1.29 > +++ fortune/strfile/strfile.c 3 Nov 2017 17:32:52 - > @@ -252,8 +252,6 @@ main(int ac, char *av[]) > void > getargs(int argc, char *argv[]) > { > - extern char *optarg; > - extern int optind; > int ch; > > while ((ch = getopt(argc, argv, "c:hiorsx")) != -1) { > Index: hunt/hunt/hunt.c > === > RCS file: /cvs/src/games/hunt/hunt/hunt.c,v > retrieving revision 1.22 > diff -u -p -r1.22 hunt.c > --- hunt/hunt/hunt.c 8 Apr 2017 22:50:41 - 1.22 > +++ hunt/hunt/hunt.c 3 Nov 2017 17:32:52 - > @@ -85,8 +85,6 @@ int > main(int ac, char **av) > { > int c; > - extern int optind; > - extern char *optarg; > longenter_status; > int option; > struct servent *se; > Index: hunt/huntd/driver.c > === > RCS file: /cvs/src/games/hunt/huntd/driver.c,v > retrieving revision 1.29 > diff -u -p -r1.29 driver.c > --- hunt/huntd/driver.c 21 Jan 2017 08:22:57 - 1.29 > +++ hunt/huntd/driver.c 3 Nov 2017 17:32:52 - > @@ -80,8 +80,6 @@ main(int ac, char **av) > static fd_set read_fds; > static FLAG first = TRUE; > static FLAG server = FALSE; > - extern int optind; > - extern char *optarg; > extern char *__progname; > int c; > static struct timeval linger = { 0, 0 }; > Index: robots/main.c > === > RCS file: /cvs/src/games/robots/main.c,v > retrieving revision 1.26 > diff -u -p -r1.26 main.c > --- robots/main.c 28 May 2017 21:01:13 - 1.26 > +++ robots/main.c 3 Nov 2017 17:32:52 - > @@ -56,7 +56,6 @@ main(int ac, char *av[]) > int score_err = 0; /* hold errno from score file open */ > int ch; > int ret; > - extern int optind; > char*home; > #ifdef FANCY > char*sp; >
[no subject]
Including when using getopt(3) also makes extern int opterr, optind, optopt, optreset; and friends declared, but many utils redeclare them again. Is there a reason for that, or can those be removed? As a harmless example, here's a diff to games. Jan Index: fortune/strfile/strfile.c === RCS file: /cvs/src/games/fortune/strfile/strfile.c,v retrieving revision 1.29 diff -u -p -r1.29 strfile.c --- fortune/strfile/strfile.c 4 Jun 2017 13:39:25 - 1.29 +++ fortune/strfile/strfile.c 3 Nov 2017 17:32:52 - @@ -252,8 +252,6 @@ main(int ac, char *av[]) void getargs(int argc, char *argv[]) { - extern char *optarg; - extern int optind; int ch; while ((ch = getopt(argc, argv, "c:hiorsx")) != -1) { Index: hunt/hunt/hunt.c === RCS file: /cvs/src/games/hunt/hunt/hunt.c,v retrieving revision 1.22 diff -u -p -r1.22 hunt.c --- hunt/hunt/hunt.c8 Apr 2017 22:50:41 - 1.22 +++ hunt/hunt/hunt.c3 Nov 2017 17:32:52 - @@ -85,8 +85,6 @@ int main(int ac, char **av) { int c; - extern int optind; - extern char *optarg; longenter_status; int option; struct servent *se; Index: hunt/huntd/driver.c === RCS file: /cvs/src/games/hunt/huntd/driver.c,v retrieving revision 1.29 diff -u -p -r1.29 driver.c --- hunt/huntd/driver.c 21 Jan 2017 08:22:57 - 1.29 +++ hunt/huntd/driver.c 3 Nov 2017 17:32:52 - @@ -80,8 +80,6 @@ main(int ac, char **av) static fd_set read_fds; static FLAG first = TRUE; static FLAG server = FALSE; - extern int optind; - extern char *optarg; extern char *__progname; int c; static struct timeval linger = { 0, 0 }; Index: robots/main.c === RCS file: /cvs/src/games/robots/main.c,v retrieving revision 1.26 diff -u -p -r1.26 main.c --- robots/main.c 28 May 2017 21:01:13 - 1.26 +++ robots/main.c 3 Nov 2017 17:32:52 - @@ -56,7 +56,6 @@ main(int ac, char *av[]) int score_err = 0; /* hold errno from score file open */ int ch; int ret; - extern int optind; char*home; #ifdef FANCY char*sp;
xargs doesn't need to setlocale()
It seems that xargs(1) sets LC_MESSAGE in case someone would like to give a 'y' response to xargs -p in their native tongue. Is that so, and is that intended? I never new locale(1) is also supposed to specify what "an affirmative response, ‘y’ in the POSIX locale" is, as the current manpage puts it. Jan Index: xargs.1 === RCS file: /cvs/src/usr.bin/xargs/xargs.1,v retrieving revision 1.28 diff -u -p -r1.28 xargs.1 --- xargs.1 4 Jun 2014 06:48:33 - 1.28 +++ xargs.1 3 Nov 2017 16:32:35 - @@ -213,9 +213,8 @@ at once. .It Fl p Echo each command to be executed and ask the user whether it should be executed. -An affirmative response, +An affirmative response of .Ql y -in the POSIX locale, causes the command to be executed, any other response causes it to be skipped. No commands are executed if the process is not attached to a terminal. Index: xargs.c === RCS file: /cvs/src/usr.bin/xargs/xargs.c,v retrieving revision 1.33 diff -u -p -r1.33 xargs.c --- xargs.c 16 Oct 2017 13:10:50 - 1.33 +++ xargs.c 3 Nov 2017 16:32:35 - @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -85,8 +84,6 @@ main(int argc, char *argv[]) ep = environ; eofstr = ""; Jflag = nflag = 0; - - (void)setlocale(LC_MESSAGES, ""); /* * POSIX.2 limits the exec line length to ARG_MAX - 2K. Running that
pr(1) - ignore LC_TIME
Doesn't OpenBSD strftime() ignore LC_TIME anyway? Jan Index: pr.c === RCS file: /cvs/src/usr.bin/pr/pr.c,v retrieving revision 1.39 diff -u -p -r1.39 pr.c --- pr.c11 Nov 2015 02:52:46 - 1.39 +++ pr.c1 Nov 2017 15:58:48 - @@ -124,7 +124,6 @@ charschar; /* text column separation c intsflag; /* -s option for multiple columns */ intnohead; /* do not write head and trailer */ intpgwd; /* page width with multiple col output */ -char *timefrmt; /* time conversion string */ /* * misc globals @@ -1546,7 +1545,7 @@ nxtfile(int argc, char *argv[], char **f /* * set up time field used in header */ -if (strftime(buf, HDBUF, timefrmt, timeptr) == 0) { +if (strftime(buf, HDBUF, TIMEFMT, timeptr) == 0) { ++errcnt; if (inf != stdin) (void)fclose(inf); @@ -2006,7 +2005,5 @@ setup(int argc, char *argv[]) } } -if ((timefrmt = getenv("LC_TIME")) == NULL) - timefrmt = TIMEFMT; return(0); }
zic.c does not need locale.h
Index: zic.c === RCS file: /cvs/src/usr.sbin/zic/zic.c,v retrieving revision 1.22 diff -u -p -r1.22 zic.c --- zic.c 15 Mar 2016 19:50:47 - 1.22 +++ zic.c 1 Nov 2017 15:52:04 - @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include
awk setlocale(LC_NUMERIC)
Why does awk need to fiddle with LC_NUMERIC? Jan Index: main.c === RCS file: /cvs/src/usr.bin/awk/main.c,v retrieving revision 1.21 diff -u -p -r1.21 main.c --- main.c 9 Oct 2017 14:51:31 - 1.21 +++ main.c 1 Nov 2017 15:50:11 - @@ -28,7 +28,6 @@ const char*version = "version 20110810" #define DEBUG #include #include -#include #include #include #include @@ -61,9 +60,6 @@ int main(int argc, char *argv[]) { const char *fs = NULL; - setlocale(LC_ALL, ""); - setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */ - cmdname = __progname; if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) { fprintf(stderr, "%s: pledge: incorrect arguments\n", @@ -185,7 +181,6 @@ int main(int argc, char *argv[]) if (!safe) envinit(environ); yyparse(); - setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */ if (fs) *FS = qstring(fs, '\0'); DPRINTF( ("errorflag=%d\n", errorflag) );
rm exits 0
"rm exits 0" does not seem right (though I'm not a native speaker). Jan Index: rm.1 === RCS file: /cvs/src/bin/rm/rm.1,v retrieving revision 1.42 diff -u -p -r1.42 rm.1 --- rm.128 Jun 2017 06:24:39 - 1.42 +++ rm.127 Oct 2017 09:41:37 - @@ -115,7 +115,8 @@ doing something like .Sh EXIT STATUS The .Nm -utility exits 0 if all of the named files or file hierarchies were removed, +utility exits with 0 +if all of the named files or file hierarchies were removed, or if the .Fl f option was specified and all of the existing files or file hierarchies were
Re: bc(1) examples
On Oct 08 11:31:16, o...@drijf.net wrote: > On Fri, Oct 06, 2017 at 02:12:01PM +0200, Jan Stary wrote: > > > Isn't "4 * a(1)" a more natural incarnation of pi than "2 * a(2^1)"? > > The point of this example is to (also) show that a() works on very > large numbers. My itch is that 4 * a(1) _is_ pi, and the "approximation" is in how precisely you compute it; while 2 * a(2^1) is _not_ pi, however precisely you compute it. Do you mean that a() _works_ in that it not only accepts the very large argument, but actually computes a sensible value? Unlike the other functions, arctg() has a limit at infinity. Interestingly, in bc.library, a() is the "basic" function approximated with (i)rational functions, and s() and c() are built on top of it (using a(1) of course :-), giving e.g. bc -l -e 'scale = 500; s(2^1 * 4 * a(1))' -e quit around -.855 instead of zero. Indeed, it seems to be s() which has this problem, while a() gives a good approximation. So do you mean to illustrate that a() works with large arguments, _unlike_ e.g. s()? Jan
bc -l wording
Currently, the bc(1) manpage describes "-l" as Allow specification of an arbitrary precision math library I am not a native speaker, but "specification of a library" seems unclear here. It loads /usr/share/misc/bc.library, not that the user could "specify" some other library to load. Later in the manpage, "the functions available in _the_ library" are described, and FILES makes it explicit that this is the one. Perhaps a native speaker will come up with some better wording. Jan Index: bc.1 === RCS file: /cvs/src/usr.bin/bc/bc.1,v retrieving revision 1.32 diff -u -p -r1.32 bc.1 --- bc.117 Nov 2015 05:45:35 - 1.32 +++ bc.16 Oct 2017 12:20:10 - @@ -76,7 +76,7 @@ If multiple options are specified, they are processed in the order given, separated by newlines. .It Fl l -Allow specification of an arbitrary precision math library. +Load an arbitrary precision math library. The definitions in the library are available to command line expressions. .El
bc(1) examples
Isn't "4 * a(1)" a more natural incarnation of pi than "2 * a(2^1)"? Jan Index: bc.1 === RCS file: /cvs/src/usr.bin/bc/bc.1,v retrieving revision 1.32 diff -u -p -r1.32 bc.1 --- bc.117 Nov 2015 05:45:35 - 1.32 +++ bc.16 Oct 2017 12:10:47 - @@ -332,7 +332,7 @@ the exponential function and prints approximate values of the exponential function of the first ten integers. .Bd -literal -offset indent -$ bc -l -e 'scale = 500; 2 * a(2^1)' -e quit +$ bc -l -e 'scale = 500; 4 * a(1)' -e quit .Ed .Pp prints an approximation of pi.
int32_t float word of M_PI_4
The int32_t float word of M_PI_4 is 0x3f490fdb, not 0x3f490fd8. Jan On Sep 26 11:57:29, i...@darwinsys.com wrote: > On 2017-09-26 11:41 AM, Jan Stary wrote: > >double 0.785398, high word 0x3fe921fb > >float 0.785398, float word 0x3f490fdb > > > > In case of double, it's exactly 0x3fe921fb. > > But why then does s_sinf.c use 0x3f490fd8 instead of 0x3f490fdb? > > > Educated guess? Because 8 and upper-case B look alike when you've had too > much beer or when you left your reading glasses in the car. Index: s_sinf.c === RCS file: /cvs/src/lib/libm/src/s_sinf.c,v retrieving revision 1.4 diff -u -p -r1.4 s_sinf.c --- s_sinf.c12 Sep 2016 19:47:02 - 1.4 +++ s_sinf.c26 Sep 2017 22:42:26 - @@ -26,7 +26,7 @@ sinf(float x) /* |x| ~< pi/4 */ ix &= 0x7fff; - if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0); + if(ix <= 0x3f490fdb) return __kernel_sinf(x,z,0); /* sin(Inf or NaN) is NaN */ else if (ix>=0x7f80) return x-x; Index: s_cosf.c === RCS file: /cvs/src/lib/libm/src/s_cosf.c,v retrieving revision 1.5 diff -u -p -r1.5 s_cosf.c --- s_cosf.c12 Sep 2016 19:47:02 - 1.5 +++ s_cosf.c26 Sep 2017 22:42:26 - @@ -26,7 +26,7 @@ cosf(float x) /* |x| ~< pi/4 */ ix &= 0x7fff; - if(ix <= 0x3f490fd8) return __kernel_cosf(x,z); + if(ix <= 0x3f490fdb) return __kernel_cosf(x,z); /* cos(Inf or NaN) is NaN */ else if (ix>=0x7f80) return x-x;
Xr cos(3) in sin(3)
Every trigonometric function's manpage references every other, with a single exception: sin(3) does not Xr cos 3. Jan Index: sin.3 === RCS file: /cvs/src/lib/libm/man/sin.3,v retrieving revision 1.16 diff -u -p -r1.16 sin.3 --- sin.3 17 Jul 2013 05:42:11 - 1.16 +++ sin.3 26 Sep 2017 22:18:57 - @@ -72,6 +72,7 @@ functions return the sine value. .Xr asin 3 , .Xr atan 3 , .Xr atan2 3 , +.Xr cos 3 , .Xr cosh 3 , .Xr sinh 3 , .Xr tan 3 ,
Re: sin() implementation
On Sep 26 17:41:17, h...@stare.cz wrote: > > > s_sin.c normalizes the argument to [-pi/4, +pi/4]. > > > This is how |x| <= pi/4 is tested: > > > > > > GET_HIGH_WORD(ix,x); > > > ix &= 0x7fff; > > > if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); > > > > > > Why is it done like that? Is it faster or more portable > > > or in any way better that comparing the value itself to M_PI_4? > > > (Or was it, in 1993?) > > > > Hm, is 0x3fe921fb the nearest float <= pi/4? > > s_sinf.c uses 0x3f490fd8 for that test. > > Yes. > > #include > #include > #include "math_private.h" > > int > main() > { > double d = M_PI_4; > double f = M_PI_4; float f, sorry. > int32_t i, j; > > GET_HIGH_WORD(i, d); > GET_FLOAT_WORD(j, f); > > printf("double %f, high word %#x\n", d, i); > printf("float %f, float word %#x\n", f, j); > > return 0; > } > > This says > > double 0.785398, high word 0x3fe921fb > float 0.785398, float word 0x3f490fdb > > In case of double, it's exactly 0x3fe921fb. > But why then does s_sinf.c use 0x3f490fd8 instead of 0x3f490fdb? > > Jan >
Re: sin() implementation
These (diff below) seem to be obvious typos in k_sin.c, but only in comments. The comment that says if x < 2^-27 (hx<0x3e40), return x with inexact if x!=0 also puzzles me a bit: what the code does is GET_HIGH_WORD(ix,x); ix &= 0x7fff; /* high word of x */ if(ix<0x3e40) /* |x| < 2**-27 */ {if((int)x==0) return x;} /* generate inexact */ If the high word of a double x is less than 0x3e40, how could (int)x be anything else than zero? The "if x!= 0" also puzzles me: the sine of zero _is_ zero, exactly. What would change with this: if (ix < 0x3e40) return x; What is the role of the iy indicator? Is it easier/faster to test the integer indicator for iy == 0 than it would be to test y == 0 itself? Or is there another reason? Jan Index: k_sin.c === RCS file: /cvs/src/lib/libm/src/k_sin.c,v retrieving revision 1.3 diff -u -p -r1.3 k_sin.c --- k_sin.c 27 Oct 2009 23:59:30 - 1.3 +++ k_sin.c 26 Sep 2017 16:07:45 - @@ -10,15 +10,15 @@ * */ -/* __kernel_sin( x, y, iy) +/* __kernel_sin(x, y, iy) * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854 * Input x is assumed to be bounded by ~pi/4 in magnitude. * Input y is the tail of x. - * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). + * Input iy indicates whether y is 0. (if iy=0, assume y to be 0). * * Algorithm * 1. Since sin(-x) = -sin(x), we need only to consider positive x. - * 2. if x < 2^-27 (hx<0x3e40 0), return x with inexact if x!=0. + * 2. if x < 2^-27 (hx<0x3e40), return x with inexact if x!=0. * 3. sin(x) is approximated by a polynomial of degree 13 on *[0,pi/4] * 313
Re: sin() implementation
> > s_sin.c normalizes the argument to [-pi/4, +pi/4]. > > This is how |x| <= pi/4 is tested: > > > > GET_HIGH_WORD(ix,x); > > ix &= 0x7fff; > > if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); > > > > Why is it done like that? Is it faster or more portable > > or in any way better that comparing the value itself to M_PI_4? > > (Or was it, in 1993?) > > Hm, is 0x3fe921fb the nearest float <= pi/4? > s_sinf.c uses 0x3f490fd8 for that test. Yes. #include #include #include "math_private.h" int main() { double d = M_PI_4; double f = M_PI_4; int32_t i, j; GET_HIGH_WORD(i, d); GET_FLOAT_WORD(j, f); printf("double %f, high word %#x\n", d, i); printf("float %f, float word %#x\n", f, j); return 0; } This says double 0.785398, high word 0x3fe921fb float 0.785398, float word 0x3f490fdb In case of double, it's exactly 0x3fe921fb. But why then does s_sinf.c use 0x3f490fd8 instead of 0x3f490fdb? Jan
Re: sin() implementation
On Sep 26 13:27:52, h...@stare.cz wrote: > I picked sin() as an example while trying to walk though the implementation > of (pieces of) libm. If someone has the time for it, I have some questions. > > I understand the implementation originaly stems from Sun's libm of 1993. > (As does that of FreeBSD and NetBSD.) And Android https://android.googlesource.com/platform/external/fdlibm/ and Julia http://openlibm.org/, apparently. > It has been tweaked over the years, > but the code that actually computes the values is mostly untouched. > > s_sin.c normalizes the argument to [-pi/4, +pi/4]. > This is how |x| <= pi/4 is tested: > > GET_HIGH_WORD(ix,x); > ix &= 0x7fff; > if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); > > Why is it done like that? Is it faster or more portable > or in any way better that comparing the value itself to M_PI_4? > (Or was it, in 1993?) Hm, is 0x3fe921fb the nearest float <= pi/4? s_sinf.c uses 0x3f490fd8 for that test. Jan > For Inf and NaN arguments, NaN is returned as follows: > > /* sin(Inf or NaN) is NaN */ > else if (ix>=0x7ff0) return x-x; > > Again, why the integer conversion? Would > > else if (isinf(x) || isnan(x)) > > be slower? Less portable? > > Also, is "return x-x" just a fast/clever way to return NaN > for x being Inf _or_ NaN, preferable to return nan("")? > > I have other questions in k_sin.c and elsewhere, but I'll stop here. > Please see my naive diff below. I tried this on amd64, macppc and armv7; > regress/lib/libm/fpaccuracy results in zero difference. The only > other thing I tried is "sox -n out.raw synth 10 sin" which also gives > the same result. (That's hardly "testing" of course.) > > Surely I am missing something elementary. > I'll be glad for any insight. > > Thank you for your time > > Jan > > > Index: s_sin.c > === > RCS file: /cvs/src/lib/libm/src/s_sin.c,v > retrieving revision 1.11 > diff -u -p -r1.11 s_sin.c > --- s_sin.c 12 Sep 2016 19:47:02 - 1.11 > +++ s_sin.c 26 Sep 2017 08:54:03 - > @@ -50,17 +50,12 @@ double > sin(double x) > { > double y[2],z=0.0; > - int32_t n, ix; > + int32_t n; > > -/* High word of x. */ > - GET_HIGH_WORD(ix,x); > - > -/* |x| ~< pi/4 */ > - ix &= 0x7fff; > - if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); > - > -/* sin(Inf or NaN) is NaN */ > - else if (ix>=0x7ff0) return x-x; > + if (-M_PI_4 < x && x < M_PI_4) > + return __kernel_sin(x,z,0); > + else if (isinf(x) || isnan(x)) > + return nan(""); > > /* argument reduction needed */ > else { >
sin() implementation
I picked sin() as an example while trying to walk though the implementation of (pieces of) libm. If someone has the time for it, I have some questions. I understand the implementation originaly stems from Sun's libm of 1993. (As does that of FreeBSD and NetBSD.) It has been tweaked over the years, but the code that actually computes the values is mostly untouched. s_sin.c normalizes the argument to [-pi/4, +pi/4]. This is how |x| <= pi/4 is tested: GET_HIGH_WORD(ix,x); ix &= 0x7fff; if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); Why is it done like that? Is it faster or more portable or in any way better that comparing the value itself to M_PI_4? (Or was it, in 1993?) For Inf and NaN arguments, NaN is returned as follows: /* sin(Inf or NaN) is NaN */ else if (ix>=0x7ff0) return x-x; Again, why the integer conversion? Would else if (isinf(x) || isnan(x)) be slower? Less portable? Also, is "return x-x" just a fast/clever way to return NaN for x being Inf _or_ NaN, preferable to return nan("")? I have other questions in k_sin.c and elsewhere, but I'll stop here. Please see my naive diff below. I tried this on amd64, macppc and armv7; regress/lib/libm/fpaccuracy results in zero difference. The only other thing I tried is "sox -n out.raw synth 10 sin" which also gives the same result. (That's hardly "testing" of course.) Surely I am missing something elementary. I'll be glad for any insight. Thank you for your time Jan Index: s_sin.c === RCS file: /cvs/src/lib/libm/src/s_sin.c,v retrieving revision 1.11 diff -u -p -r1.11 s_sin.c --- s_sin.c 12 Sep 2016 19:47:02 - 1.11 +++ s_sin.c 26 Sep 2017 08:54:03 - @@ -50,17 +50,12 @@ double sin(double x) { double y[2],z=0.0; - int32_t n, ix; + int32_t n; -/* High word of x. */ - GET_HIGH_WORD(ix,x); - -/* |x| ~< pi/4 */ - ix &= 0x7fff; - if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); - -/* sin(Inf or NaN) is NaN */ - else if (ix>=0x7ff0) return x-x; + if (-M_PI_4 < x && x < M_PI_4) + return __kernel_sin(x,z,0); + else if (isinf(x) || isnan(x)) + return nan(""); /* argument reduction needed */ else {
calendar vs KOI8
Is 5.9 out yet? Index: io.c === RCS file: /cvs/src/usr.bin/calendar/io.c,v retrieving revision 1.44 diff -u -p -r1.44 io.c --- io.c31 Aug 2016 09:38:47 - 1.44 +++ io.c26 Jul 2017 20:21:09 - @@ -89,13 +89,9 @@ cal(void) if (strncmp(buf, "LANG=", 5) == 0) { (void) setlocale(LC_ALL, buf + 5); setnnames(); - /* XXX remove KOI8 lines after 5.9 is out */ if (!strcmp(buf + 5, "ru_RU.UTF-8") || !strcmp(buf + 5, "uk_UA.UTF-8") || - !strcmp(buf + 5, "by_BY.UTF-8") || - !strcmp(buf + 5, "ru_RU.KOI8-R") || - !strcmp(buf + 5, "uk_UA.KOI8-U") || - !strcmp(buf + 5, "by_BY.KOI8-B")) { + !strcmp(buf + 5, "by_BY.UTF-8")) { bodun_maybe++; bodun = 0; free(prefix);
LC_NUMERIC in awk
Does awk really need to set and reset LC_NUMERIC? Does it need to set locale at all? Jan Index: main.c === RCS file: /cvs/src/usr.bin/awk/main.c,v retrieving revision 1.19 diff -u -p -r1.19 main.c --- main.c 22 Oct 2015 04:08:17 - 1.19 +++ main.c 26 Jul 2017 20:15:48 - @@ -28,7 +28,6 @@ const char*version = "version 20110810" #define DEBUG #include #include -#include #include #include #include @@ -61,9 +60,6 @@ int main(int argc, char *argv[]) { const char *fs = NULL; - setlocale(LC_ALL, ""); - setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */ - if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) { fprintf(stderr, "%s: pledge: incorrect arguments\n", cmdname); @@ -185,7 +181,6 @@ int main(int argc, char *argv[]) if (!safe) envinit(environ); yyparse(); - setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */ if (fs) *FS = qstring(fs, '\0'); dprintf( ("errorflag=%d\n", errorflag) );
Re: kern.allowkmem in examples?
> On Mon, May 22, 2017 at 02:00:51PM +0200, Jan Stary wrote: > > acpidump(8) wants kern.allowkmem. > > Does it make sense to put that into examples sysctl.conf? On May 22 09:06:51, dera...@openbsd.org wrote: > No, in fact I want to kill that sysctl eventually, perhaps couple this > with securelevel=0, and never allow it otherwise. On May 22 14:09:57, sema...@online.fr wrote: > It should be rare to need to run acpidump(8) post-boot. The system > already runs it at startup and stock files under /var/db/acpi. On May 22 14:42:57, mark.kette...@xs4all.nl wrote: > The bootscript already runs acpidump ad stores the results in /var/db/acpi. > So there is no reason to run acpidump. Should the manpage say so? Index: acpidump.8 === RCS file: /cvs/src/usr.sbin/acpidump/acpidump.8,v retrieving revision 1.17 diff -u -p -r1.17 acpidump.8 --- acpidump.8 26 Sep 2016 19:58:26 - 1.17 +++ acpidump.8 22 May 2017 17:41:03 - @@ -71,9 +71,14 @@ requires the ability to open which may be restricted based upon the value of the .Ar kern.allowkmem .Xr sysctl 8 . +.Pp +.Nm +is run at startup and stores the results in +.Pa /var/db/acpi . .Sh FILES .Bl -tag -width /dev/mem .It Pa /dev/mem +.It Pa /var/db/acpi .El .Sh SEE ALSO .Xr pkg_add 1 ,
kern.allowkmem in examples?
acpidump(8) wants kern.allowkmem. Does it make sense to put that into examples sysctl.conf? Jan Index: sysctl.conf === RCS file: /cvs/src/etc/examples/sysctl.conf,v retrieving revision 1.4 diff -u -p -r1.4 sysctl.conf --- sysctl.conf 3 Apr 2015 15:50:28 - 1.4 +++ sysctl.conf 22 May 2017 11:58:27 - @@ -33,4 +33,5 @@ #kern.nosuidcoredump=3 # 3=Put suid coredumps in /var/crash/progname #kern.watchdog.period=32 # >0=Enable hardware watchdog(4) timer if available #kern.watchdog.auto=0 # 0=Disable automatic watchdog(4) retriggering +#kern.allowkmem=1 # 1=Allow e.g. acpidump to open /dev/kmem #hw.allowpowerdown=0 # 0=Disable power button shutdown
Re: AUDIO_DEV_SOUND
On May 15 16:36:41, a...@caoua.org wrote: > On Mon, May 15, 2017 at 10:14:48AM +0200, Jan Stary wrote: > > While /dev/sound is no more, the > > > > #define AUDIO_DEV_SOUND 0 /* minor of /dev/sound0 */ > > > > apparently cannot be just removed from dev/audio.c > > - with the diff below, all audio applications complain > > that the default audio device cannot be opened. Why is that? > > That comment seems misleading at any rate. > > $ ls -al /dev/audio[0-9]* > crw-rw-rw- 1 root wheel 42, 0 Jan 16 05:59 /dev/audio0 > crw-rw-rw- 1 root wheel 42, 1 May 15 08:25 /dev/audio1 > crw-rw-rw- 1 root wheel 42, 2 Nov 12 2016 /dev/audio2 > crw-rw-rw- 1 root wheel 42, 3 Sep 9 2016 /dev/audio3 > crw-rw-rw- 1 root wheel 42, 4 Sep 8 2016 /dev/audio4 > > The devices with minor numbers 0..15 are the ones we still use. So > according to the sources: > > #define AUDIO_DEV_AUDIO 0x80/* minor of /dev/audio0 */ > > is the one to be removed (then AUDIO_DEV_SOUND should be renamed to > AUDIO_DEV_AUDIO, and comment fixed, to avoid confusion). diff below Jan > > === > > RCS file: /cvs/src/sys/dev/audio.c,v > > retrieving revision 1.163 > > diff -u -p -r1.163 audio.c > > --- dev/audio.c 3 May 2017 06:56:54 - 1.163 > > +++ dev/audio.c 15 May 2017 08:08:32 - > > @@ -50,7 +50,6 @@ > > #define DEVNAME(sc)((sc)->dev.dv_xname) > > #define AUDIO_UNIT(n) (minor(n) & 0x0f) > > #define AUDIO_DEV(n) (minor(n) & 0xf0) > > -#define AUDIO_DEV_SOUND0 /* minor of /dev/sound0 */ > > #define AUDIO_DEV_MIXER0x10/* minor of /dev/mixer0 */ > > #define AUDIO_DEV_AUDIO0x80/* minor of /dev/audio0 */ > ^ > wrong comments! Index: dev/audio.c === RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.163 diff -u -p -r1.163 audio.c --- dev/audio.c 3 May 2017 06:56:54 - 1.163 +++ dev/audio.c 15 May 2017 16:19:28 - @@ -50,9 +50,8 @@ #define DEVNAME(sc)((sc)->dev.dv_xname) #define AUDIO_UNIT(n) (minor(n) & 0x0f) #define AUDIO_DEV(n) (minor(n) & 0xf0) -#define AUDIO_DEV_SOUND0 /* minor of /dev/sound0 */ +#define AUDIO_DEV_AUDIO0 /* minor of /dev/audio0 */ #define AUDIO_DEV_MIXER0x10/* minor of /dev/mixer0 */ -#define AUDIO_DEV_AUDIO0x80/* minor of /dev/audio0 */ #define AUDIO_DEV_AUDIOCTL 0xc0/* minor of /dev/audioctl */ #define AUDIO_BUFSZ65536 /* buffer size in bytes */ @@ -1136,7 +1135,6 @@ audio_detach(struct device *self, int fl * close uses device_lookup, it returns EXIO and does nothing */ mn = self->dv_unit; - vdevgone(maj, mn | AUDIO_DEV_SOUND, mn | AUDIO_DEV_SOUND, VCHR); vdevgone(maj, mn | AUDIO_DEV_AUDIO, mn | AUDIO_DEV_AUDIO, VCHR); vdevgone(maj, mn | AUDIO_DEV_AUDIOCTL, mn | AUDIO_DEV_AUDIOCTL, VCHR); vdevgone(maj, mn | AUDIO_DEV_MIXER, mn | AUDIO_DEV_MIXER, VCHR); @@ -1607,7 +1605,6 @@ audioopen(dev_t dev, int flags, int mode error = ENXIO; else { switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_open(sc, flags); break; @@ -1633,7 +1630,6 @@ audioclose(dev_t dev, int flags, int ifm if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_close(sc); break; @@ -1658,7 +1654,6 @@ audioread(dev_t dev, struct uio *uio, in if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_read(sc, uio, ioflag); break; @@ -1683,7 +1678,6 @@ audiowrite(dev_t dev, struct uio *uio, i if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_write(sc, uio, ioflag); break; @@ -1708,7 +1702,6 @@ audioioctl(dev_t dev, u_long cmd, caddr_ if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_ioctl(sc, cmd, addr); break; @@ -17
AUDIO_DEV_SOUND
While /dev/sound is no more, the #define AUDIO_DEV_SOUND 0 /* minor of /dev/sound0 */ apparently cannot be just removed from dev/audio.c - with the diff below, all audio applications complain that the default audio device cannot be opened. Why is that? That comment seems misleading at any rate. Jan Index: dev/audio.c === RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.163 diff -u -p -r1.163 audio.c --- dev/audio.c 3 May 2017 06:56:54 - 1.163 +++ dev/audio.c 15 May 2017 08:08:32 - @@ -50,7 +50,6 @@ #define DEVNAME(sc)((sc)->dev.dv_xname) #define AUDIO_UNIT(n) (minor(n) & 0x0f) #define AUDIO_DEV(n) (minor(n) & 0xf0) -#define AUDIO_DEV_SOUND0 /* minor of /dev/sound0 */ #define AUDIO_DEV_MIXER0x10/* minor of /dev/mixer0 */ #define AUDIO_DEV_AUDIO0x80/* minor of /dev/audio0 */ #define AUDIO_DEV_AUDIOCTL 0xc0/* minor of /dev/audioctl */ @@ -1136,7 +1135,6 @@ audio_detach(struct device *self, int fl * close uses device_lookup, it returns EXIO and does nothing */ mn = self->dv_unit; - vdevgone(maj, mn | AUDIO_DEV_SOUND, mn | AUDIO_DEV_SOUND, VCHR); vdevgone(maj, mn | AUDIO_DEV_AUDIO, mn | AUDIO_DEV_AUDIO, VCHR); vdevgone(maj, mn | AUDIO_DEV_AUDIOCTL, mn | AUDIO_DEV_AUDIOCTL, VCHR); vdevgone(maj, mn | AUDIO_DEV_MIXER, mn | AUDIO_DEV_MIXER, VCHR); @@ -1607,7 +1605,6 @@ audioopen(dev_t dev, int flags, int mode error = ENXIO; else { switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_open(sc, flags); break; @@ -1633,7 +1630,6 @@ audioclose(dev_t dev, int flags, int ifm if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_close(sc); break; @@ -1658,7 +1654,6 @@ audioread(dev_t dev, struct uio *uio, in if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_read(sc, uio, ioflag); break; @@ -1683,7 +1678,6 @@ audiowrite(dev_t dev, struct uio *uio, i if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_write(sc, uio, ioflag); break; @@ -1708,7 +1702,6 @@ audioioctl(dev_t dev, u_long cmd, caddr_ if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_ioctl(sc, cmd, addr); break; @@ -1743,7 +1736,6 @@ audiopoll(dev_t dev, int events, struct if (sc == NULL) return POLLERR; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: revents = audio_poll(sc, events, p); break;
/dev/sound
Now that /dev/sound is gone, should AUDIO_DEV_SOUND be removed from audio.c ? Jan Index: audio.c === RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.161 diff -u -p -r1.161 audio.c --- audio.c 11 Mar 2017 10:12:45 - 1.161 +++ audio.c 26 Mar 2017 11:40:52 - @@ -50,7 +50,6 @@ #define DEVNAME(sc)((sc)->dev.dv_xname) #define AUDIO_UNIT(n) (minor(n) & 0x0f) #define AUDIO_DEV(n) (minor(n) & 0xf0) -#define AUDIO_DEV_SOUND0 /* minor of /dev/sound0 */ #define AUDIO_DEV_MIXER0x10/* minor of /dev/mixer0 */ #define AUDIO_DEV_AUDIO0x80/* minor of /dev/audio0 */ #define AUDIO_DEV_AUDIOCTL 0xc0/* minor of /dev/audioctl */ @@ -1137,7 +1136,6 @@ audio_detach(struct device *self, int fl * close uses device_lookup, it returns EXIO and does nothing */ mn = self->dv_unit; - vdevgone(maj, mn | AUDIO_DEV_SOUND, mn | AUDIO_DEV_SOUND, VCHR); vdevgone(maj, mn | AUDIO_DEV_AUDIO, mn | AUDIO_DEV_AUDIO, VCHR); vdevgone(maj, mn | AUDIO_DEV_AUDIOCTL, mn | AUDIO_DEV_AUDIOCTL, VCHR); vdevgone(maj, mn | AUDIO_DEV_MIXER, mn | AUDIO_DEV_MIXER, VCHR); @@ -1608,7 +1606,6 @@ audioopen(dev_t dev, int flags, int mode error = ENXIO; else { switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_open(sc, flags); break; @@ -1634,7 +1631,6 @@ audioclose(dev_t dev, int flags, int ifm if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_close(sc); break; @@ -1659,7 +1655,6 @@ audioread(dev_t dev, struct uio *uio, in if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_read(sc, uio, ioflag); break; @@ -1684,7 +1679,6 @@ audiowrite(dev_t dev, struct uio *uio, i if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_write(sc, uio, ioflag); break; @@ -1709,7 +1703,6 @@ audioioctl(dev_t dev, u_long cmd, caddr_ if (sc == NULL) return ENXIO; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: error = audio_ioctl(sc, cmd, addr); break; @@ -1744,7 +1737,6 @@ audiopoll(dev_t dev, int events, struct if (sc == NULL) return POLLERR; switch (AUDIO_DEV(dev)) { - case AUDIO_DEV_SOUND: case AUDIO_DEV_AUDIO: revents = audio_poll(sc, events, p); break;
xdm in afterboot
The transition from xdm to xenodm is not reflected in afterboot(8). Jan Index: share/man/man8/afterboot.8 === RCS file: /cvs/src/share/man/man8/afterboot.8,v retrieving revision 1.157 diff -u -p -u -p -r1.157 afterboot.8 --- share/man/man8/afterboot.8 5 Sep 2016 12:58:17 - 1.157 +++ share/man/man8/afterboot.8 1 Mar 2017 14:04:38 - @@ -420,10 +420,10 @@ and .Xr rc.shutdown 8 . .Pp If you've installed X, you may want to turn on -.Xr xdm 1 , +.Xr xenodm 1 , the X Display Manager. To do this, change the value of -.Va xdm_flags +.Va xenodm_flags in .Pa /etc/rc.conf.local . .Ss Set keyboard type
ntpd.conf
Markup a forgotten keyword. Jan Index: ntpd.conf.5 === RCS file: /cvs/src/usr.sbin/ntpd/ntpd.conf.5,v retrieving revision 1.33 diff -u -p -r1.33 ntpd.conf.5 --- ntpd.conf.5 23 Oct 2015 14:52:20 - 1.33 +++ ntpd.conf.5 28 Dec 2016 20:58:06 - @@ -127,7 +127,9 @@ sensor nmea0 refid GPS .Ed .Pp A stratum value other than the default of 1 can be assigned using -the stratum keyword. +the +.Ic stratum +keyword. .It Xo Ic server Ar address .Op Ic weight Ar weight-value .Xc
does cron/crontab need locale?
Index: cron.c === RCS file: /cvs/src/usr.sbin/cron/cron.c,v retrieving revision 1.74 diff -u -p -r1.74 cron.c --- cron.c 11 Jan 2016 14:23:50 - 1.74 +++ cron.c 5 Nov 2016 13:12:49 - @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -68,7 +67,7 @@ staticdouble batch_maxload = BATCH_MA static int NoFork; static time_t StartTime; -static void +static void __dead usage(void) { @@ -81,8 +80,6 @@ main(int argc, char *argv[]) { struct sigaction sact; sigset_t blocked, omask; - - setlocale(LC_ALL, ""); setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stderr, NULL, _IOLBF, 0); Index: crontab.c === RCS file: /cvs/src/usr.sbin/cron/crontab.c,v retrieving revision 1.92 diff -u -p -r1.92 crontab.c --- crontab.c 11 Jan 2016 14:23:50 - 1.92 +++ crontab.c 5 Nov 2016 13:12:49 - @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -92,7 +91,6 @@ main(int argc, char *argv[]) user_gid = getgid(); crontab_gid = getegid(); - setlocale(LC_ALL, ""); openlog(__progname, LOG_PID, LOG_CRON); setvbuf(stderr, NULL, _IOLBF, 0);
zic(8) does not need locale.h
Index: zic.c === RCS file: /cvs/src/usr.sbin/zic/zic.c,v retrieving revision 1.22 diff -u -p -r1.22 zic.c --- zic.c 15 Mar 2016 19:50:47 - 1.22 +++ zic.c 5 Nov 2016 13:07:52 - @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include
Re: newlines in unexpand(1)
ping On Oct 10 22:02:20, h...@stare.cz wrote: > On Oct 10 15:22:01, t...@tedunangst.com wrote: > > Jan Stary wrote: > > > Why do we need to trim the newlines in unexpand(1)? > > > The result seems to be the same without it. > > > > > > Jan > > > > > > > > > Index: unexpand.c > > > === > > > RCS file: /cvs/src/usr.bin/unexpand/unexpand.c,v > > > retrieving revision 1.12 > > > diff -u -p -r1.12 unexpand.c > > > --- unexpand.c11 Nov 2015 02:52:46 - 1.12 > > > +++ unexpand.c10 Oct 2016 17:58:40 - > > > @@ -72,10 +72,6 @@ main(int argc, char *argv[]) > > > argc--, argv++; > > > } > > > while (fgets(genbuf, BUFSIZ, stdin) != NULL) { > > > - for (cp = linebuf; *cp; cp++) > > > - continue; > > > - if (cp > linebuf) > > > - cp[-1] = 0; > > > > this really looks like a bug using the wrong variable. genbuf and linebuf > > are > > different arrays. > > In the current code, these four lines are pointless, > because the linebuf gets overwritten anyway in the subsequent tabify(). > > Changing this to genbuf indeed trims the newlines from the _input_ > (as was maybe intended), but then they are also missing > in the output, wrongly. > > Removing those four lines seems to give the expected output, > as long as the input line length is < BUFSIZ (= 1024). > On a line consisting of 1026 spaces, ten spaces will be left > - but that's because the buffer does not see far enough. > > Maybe that's why the (botched) erasing of the newline is there? > To catch the case when \n happens to be the BUFSIZE-th char, > thus catching one extra tab that would be missed otherwise? > > Jan >
remove useless extern declaration
extern char *optarg is already declared in unistd.h This is the only occurence in src/sbin and src/bin; others will follow in separate mails. Jan Index: bioctl.c === RCS file: /cvs/src/sbin/bioctl/bioctl.c,v retrieving revision 1.139 diff -u -p -r1.139 bioctl.c --- bioctl.c21 Sep 2016 17:50:05 - 1.139 +++ bioctl.c19 Oct 2016 21:43:43 - @@ -59,7 +59,7 @@ struct timing { int start; }; -void usage(void); +static void __dead usage(void); const char *str2locator(const char *, struct locator *); const char *str2patrol(const char *, struct timing *); void bio_status(struct bio_status *); @@ -100,7 +100,6 @@ int main(int argc, char *argv[]) { struct bio_locate bl; - extern char *optarg; u_int64_t func = 0; char*devicename = NULL; char*realname = NULL, *al_arg = NULL; @@ -273,7 +272,7 @@ main(int argc, char *argv[]) return (0); } -void +static void __dead usage(void) { extern char *__progname;
Re: usb disk dirty after every reboot
On Oct 16 10:14:14, s...@sfritsch.de wrote: > [moving to tech@] > > On Tuesday, 20 September 2016 08:03:32 CEST Stefan Fritsch wrote: > > On Tue, 20 Sep 2016, Darren Tucker wrote: > > > On Tue, Sep 20, 2016 at 1:43 AM, Jan Stary <h...@stare.cz> wrote: > > > > This is current/i386 on an ALIX.1E (demsg below). > > > > I have an USB disk connected for /backup. > > > > > > > > Upon every reboot, the filesystem on that disk is dirty: > > > > WARNING: R/W mount of /backup denied. Filesystem is not clean - run > > > > fsck Since then, I have used three different disks and USB enclosures, each working flawlessly anywhere else. The problem is still there, so it's most probably not the disk. > > > I saw something similar on an APU where the root disk was on > > > (USB-attached) sdcard: > > > http://marc.info/?l=openbsd-misc=144237305322074=2 > > > > > > It seems to be a race. There used to be a 4sec pause in the kernel > > > that was removed: > > > > > > """ > > > Remove 4 second delay on reboot/shutdown that was added 8 years > > > ago to "workaround MP timeout/splhigh/scsi race at reboot time". > > > """ > > I think before we re-add some arbitrary delays, we should check if we are > > actually sending an explicit cache flush command to the disk controllers. > > I have some code somewhere that does this for umount and mount -ur. I will > > look for it and send it to tech@, but probably not today. For now, I just put 'umount /backup' in my rc.shutdown and that makes it umount cleanly. > I found a few cases, where we should send a cache flush but don't. > Unfortunately, none of these cases explain the problem seen by Jan and Darren. > > The cases I have found are: > > * When a R/W mount is updated to R/O. I will send patches for this in a > separate mail. Not this case. > * When a R/W mount is unmounted but there is still another partition from the > same disk mounted. Not this case. > For the usb disk issue, some more debugging is necessary. How can I help debug this? Jan Controller /dev/usb0: addr 1: high speed, self powered, config 1, EHCI root hub(0x), AMD(0x1022), rev 1.00 port 1 powered port 2 powered port 3 addr 2: high speed, self powered, config 1, Mass Storage Device(0x2506), Prolific Technology Inc.(0x067b), rev 1.00, iSerialNumber port 4 powered Controller /dev/usb1: addr 1: full speed, self powered, config 1, OHCI root hub(0x), AMD(0x1022), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered
Re: iwm: rts for long frames only
On Oct 06 17:56:50, s...@stsp.name wrote: > Stop using RTS for every data frame sent by iwm(4). > RTS adds unneccessary overhead if small data frames are sent. > > The USE_RTS flag in iwm's LQ command enables RTS unconditionally, so only > set it while the AP is enforcing protection. The flag will be kept up-to-date > as a side effect of iwm_setrates(), which is called when the Tx rate changes. > > RTS is still used for long frames since the Tx command takes care of that. > (iwm firmware exposes 3 different flags which enable RTS... don't ask.) > > ok? > > Index: if_iwm.c > === > RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v > retrieving revision 1.143 > diff -u -p -r1.143 if_iwm.c > --- if_iwm.c 5 Oct 2016 18:13:25 - 1.143 > +++ if_iwm.c 6 Oct 2016 13:52:08 - > @@ -5286,7 +5286,9 @@ iwm_setrates(struct iwm_node *in) > > memset(lq, 0, sizeof(*lq)); > lq->sta_id = IWM_STATION_ID; > - lq->flags = IWM_LQ_FLAG_USE_RTS_MSK; > + > + if (ic->ic_flags & IEEE80211_F_USEPROT) > + lq->flags |= IWM_LQ_FLAG_USE_RTS_MSK; > > sgi_ok = ((ni->ni_flags & IEEE80211_NODE_HT) && > (ni->ni_htcaps & IEEE80211_HTCAP_SGI20)); > Since I have applied this patch (dmesg below), I haven't seen the errors I was seeing before (don't know if it's related). Oct 11 16:26:56 dell /bsd: iwm0: fatal firmware error Oct 11 16:26:56 dell /bsd: iwm0: device timeout Oct 11 16:26:56 dell /bsd: iwm0: device timeout Oct 11 16:26:57 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 16:34:03 dell /bsd: iwm0: fatal firmware error Oct 11 16:34:03 dell /bsd: iwm0: device timeout Oct 11 16:34:03 dell /bsd: iwm0: device timeout Oct 11 16:34:04 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 16:37:34 dell /bsd: iwm0: fatal firmware error Oct 11 16:37:34 dell /bsd: iwm0: device timeout Oct 11 16:37:34 dell /bsd: iwm0: device timeout Oct 11 16:37:35 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:04:28 dell /bsd: iwm0: fatal firmware error Oct 11 17:04:28 dell /bsd: iwm0: device timeout Oct 11 17:04:28 dell /bsd: iwm0: device timeout Oct 11 17:04:29 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:08:37 dell /bsd: iwm0: fatal firmware error Oct 11 17:08:37 dell /bsd: iwm0: device timeout Oct 11 17:08:37 dell /bsd: iwm0: device timeout Oct 11 17:08:38 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:27:47 dell /bsd: iwm0: fatal firmware error Oct 11 17:27:47 dell /bsd: iwm0: device timeout Oct 11 17:27:47 dell /bsd: iwm0: device timeout Oct 11 17:27:48 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:31:20 dell /bsd: iwm0: fatal firmware error Oct 11 17:31:20 dell /bsd: iwm0: device timeout Oct 11 17:31:20 dell /bsd: iwm0: device timeout Oct 11 17:31:21 dell /bsd: iwm0: could not add MAC context (error 35) Jan OpenBSD 6.0-current (GENERIC.MP) #6: Fri Oct 14 10:39:16 CEST 2016 h...@dell.stare.cz:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 16810340352 (16031MB) avail mem = 16296337408 (15541MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xeac10 (107 entries) bios0: vendor Dell Inc. version "1.5.0" date 04/22/2016 bios0: Dell Inc. Latitude E5570 acpi0 at bios0: rev 2 acpi0: sleep states S0 S3 S4 S5 acpi0: tables DSDT FACP APIC FPDT FIDT MCFG HPET SSDT LPIT SSDT SSDT SSDT DBGP DBG2 SSDT UEFI SSDT SSDT SLIC ASF! acpi0: wakeup devices PEGP(S4) PEG0(S4) PEGP(S4) PEG1(S4) PEGP(S4) PEG2(S4) PXSX(S4) RP09(S4) PXSX(S4) RP10(S4) PXSX(S4) RP11(S4) PXSX(S4) RP12(S4) PXSX(S4) RP13(S4) [...] acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimadt0 at acpi0 addr 0xfee0: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz, 2295.51 MHz cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT cpu0: 256KB 64b/line 8-way L2 cache cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges cpu0: apic clock running at 23MHz cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE cpu1 at mainbus0: apid 2 (application processor) cpu1: Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz, 2294.64 MHz cpu1:
Re: drop unused locale junk from sort(1)
ping On Oct 11 15:37:03, schwa...@usta.de wrote: > Jan Stary wrote on Tue, Oct 11, 2016 at 11:26:50AM +0200: > > > Feeling encouraged by Ingo's ok to remove locale from cp/rm, > > here's a diff that removes the locale stuff we don't actually do > > from the code and documentation of sort(1). Leave just LC_CTYPE > > You removed that too, but that's OK because the code doesn't > currently use it. Right now, even though some wide character > code is there, it always operates in narrow mode. > > > which determines isblank() and case conversions. > > LC_CTYPE does NOT affect isblank(), all the wide-character-related > functions are in dead code as far as i can see, and OpenBSD does > not support wide character case conversions. > > > Your diff is related to more than one thing: > > 1. Kill LC_NUMERIC support. > I very strongly agree with that. > I think we should never support that anywhere. > It is an absolutely terrible idea no matter how you look at it. > Your removal was incomplete, though. > In the patch below, i delete some additional bits > that you left behind. > > 2. Remove LC_COLLATE support for now. > I also agree with that, even if not quite as strongly. > In the distant future, we might or might not want LC_COLLATE support. > In Belgrade, i talked to Baptiste Daroussin who just implemented > LC_COLLATE in FreeBSD libc and who was utterly scared by the complexity. > Knowing ourselves, we will be scared even more once we get there. > So it will definitely not happen quickly. > > If it ever does, the trivial bits that are present right now > are so tiny that they won't help at all. It might even be > easier to have clean earth to till when starting. > Who knows at this point. > > In any case, deleting the incomplete pieces scattered around > the current code makes maintenance easier until that time, > which seems worthwhile. > > 3. With step 2 above, some flags become explicitly const > that appear to be variable now (but actually aren't). > That would allow deleting large amounts of dead code, > but i didn't add that to the patch below. > > The grep multibyte code is absolutely horrible, with insanity > up to and including unions of char and wchar_t coming with > hosts of trivial non-standard wrapper functions and tons > of duplicate, in some case triplicate code. Another > example: Even though the code half-heartedly attempts to > isolate multibyte stuff in bwstring.{c,h} - superficially > reminding of our utf8.c technique, but half-hearted because > the respective functions are numerous and called all over the > place, such that isolation is effectively a failure - > the main program (!) at one place abuses btowc(3) (!) > on an ASCII (!) command line argument and stores the result > as wchar_t in the top level global state structure (!) - > that is obviously functionally completely futile, but very > effective for polluting *all* of the code with complicated > data types and headers. > > But cleaning up all the parts of item 3 would be way too intrusive > for this patch, so it leaves behind hundreds of lines of code > that is already both dead and duplicate right now. > > > Annotate a missed -z flag while there, > > Committed. > > > and change /var/tmp to /tmp. > > No, according to file.c, the program still writes to /var/tmp, > not to /tmp. Before changing that in the manual, we would have > to change it in the code. > > > The following version of the patch survives our test suite, > but it no doubt needs more testing. > > Yours, > Ingo > > > Index: bwstring.c > === > RCS file: /cvs/src/usr.bin/sort/bwstring.c,v > retrieving revision 1.7 > diff -u -p -r1.7 bwstring.c > --- bwstring.c1 Apr 2015 22:38:08 - 1.7 > +++ bwstring.c11 Oct 2016 13:20:59 - > @@ -40,8 +40,8 @@ > #include "bwstring.h" > #include "sort.h" > > -bool byte_sort; > -size_t sort_mb_cur_max = 1; > +static const bool byte_sort = true; > +const size_t sort_mb_cur_max = 1; > > static wchar_t **wmonths; > static char **cmonths; > Index: bwstring.h > === > RCS file: /cvs/src/usr.bin/sort/bwstring.h,v > retrieving revision 1.2 > diff -u -p -r1.2 bwstring.h > --- bwstring.h31 Dec 2015 16:09:31 - 1.2 > +++ bwstring.h11 Oct 2016 13:20:59 - > @@ -37,8 +37,7 @@ > > #include "
Re: remove unused flags from the cp.c inside mv(1)
ping On Oct 10 21:39:16, h...@stare.cz wrote: > The embedded cpmain() will never have _any_ flags set, > as mv.c calls it as > > argv[0] = from; > argv[1] = to; > argv[2] = NULL; > cpmain(2, argv); > > There is probably more code that could be romoved > form the embedded cp.c, along the lines of tedu's recent > cleanup of the embedded rm.c > > Jan > > > Index: cp.c > === > RCS file: /cvs/src/bin/mv/cp.c,v > retrieving revision 1.7 > diff -u -p -r1.7 cp.c > --- cp.c 27 Dec 2015 01:25:57 - 1.7 > +++ cp.c 10 Oct 2016 19:27:02 - > @@ -84,7 +84,6 @@ static int setfile(struct stat *, in > extern char *__progname; > > static uid_t myuid; > -static int fflag, iflag; > static mode_t myumask; > > enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; > @@ -463,13 +462,6 @@ copy_file(FTSENT *entp, int dne) > fs = entp->fts_statp; > > /* > - * In -f (force) mode, we always unlink the destination first > - * if it exists. Note that -i and -f are mutually exclusive. > - */ > - if (!dne && fflag) > - (void)unlink(to.p_path); > - > - /* >* If the file exists and we're interactive, verify with the user. >* If the file DNE, set the mode to be the from file, minus setuid >* bits, modified by the umask; arguably wrong, but it makes copying > @@ -477,17 +469,7 @@ copy_file(FTSENT *entp, int dne) >* other choice is 666 or'ed with the execute bits on the from file >* modified by the umask.) >*/ > - if (!dne && !fflag) { > - if (iflag) { > - (void)fprintf(stderr, "overwrite %s? ", to.p_path); > - checkch = ch = getchar(); > - while (ch != '\n' && ch != EOF) > - ch = getchar(); > - if (checkch != 'y' && checkch != 'Y') { > - (void)close(from_fd); > - return (0); > - } > - } > + if (!dne) { > to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0); > } else > to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT, >
remove KOI8 after 5.9 is out
Index: io.c === RCS file: /cvs/src/usr.bin/calendar/io.c,v retrieving revision 1.44 diff -u -p -r1.44 io.c --- io.c31 Aug 2016 09:38:47 - 1.44 +++ io.c14 Oct 2016 07:27:52 - @@ -89,13 +89,9 @@ cal(void) if (strncmp(buf, "LANG=", 5) == 0) { (void) setlocale(LC_ALL, buf + 5); setnnames(); - /* XXX remove KOI8 lines after 5.9 is out */ if (!strcmp(buf + 5, "ru_RU.UTF-8") || !strcmp(buf + 5, "uk_UA.UTF-8") || - !strcmp(buf + 5, "by_BY.UTF-8") || - !strcmp(buf + 5, "ru_RU.KOI8-R") || - !strcmp(buf + 5, "uk_UA.KOI8-U") || - !strcmp(buf + 5, "by_BY.KOI8-B")) { + !strcmp(buf + 5, "by_BY.UTF-8")) { bodun_maybe++; bodun = 0; free(prefix);
Re: let head(1) understand `-' as stdin
On Oct 12 23:23:18, t...@math.ethz.ch wrote: > > Let me clarify the idea. > > If a filter recognizes '-' as a name for stdin, > > then stdin can be one of the _multiple_ files being processed. > > Filters that do not recognize '-' as a name, on the other hand, > > only process stdin if it is the _only_ input. > > I understand that - is convenient, but it's not strictly needed. > If you need the standard input as one of several files (or as an > explicit file argument), you can pass /dev/stdin. This is probably what I was missing. Thank you. Sorry for the noise.
Re: let head(1) understand `-' as stdin
> > > The diff below makes head(1) recognize `-' > > > as a name for the standard input, > > > as many other utilities do. On Oct 11 23:55:26, schwa...@usta.de wrote: > > Do standards permit that extension? > > POSIX neither requires nor forbids it, but encourages consistency > among all the utilities taking [file ...] arguments within a given > operating system: > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html > > This is command used in scripts. Scripts are often portable. If one > > operating system has an extension, but others don't, then those > > scripts become unportable to use use of these extensions. [Ingo's detailed analysis snipped] > > I'm not raising a new argument here, it's been raised numerous times > > when it comes to commands commonly used in scripts. > > > > So consider that first. > > head(1) is firmly a BSD thingy, and all BSDs agree that "-" is a > file name and not standard input. POSIX explicitly encourages > treating it as standard input ***if you do that for other utilities, > too***, and GNU coreutils has the only head(1) implementation i > found so far that actually does it. > > The bigger picture seems to be that OpenBSD and illumos tend to resist > treating "-" as standard input whereever resisting is allowed, > while GNU embraces treating "-" as standard whereever allowed. > Most other systems seem to be somewhat inconsistent, in particular > in those cases where they imported GNU utilities. > > So much for the facts. > > > I see two ways forward that make sense to me: > > a) Either remain conservative - in line with both BSD and SysV > heritage - and not do it unless required by the standard. > > b) Or switch over to doing it whereever allowed - but then we > should do it not just for head(1), but also for tail(1), > grep(1), sed(1) and probably several others, and then we > should probably also try to push such patches to FreeBSD, > DragonFly, NetBSD, and illumos, or at least give them heads-ups. > > Changing only head(1) and leaving everything else as it is does not > look like a complete plan to me. Even POSIX wouldn't encourage that. Thank you for the detailed analysis. If there is any interest in possibly going b) see below for a look at the other text filters. Let me clarify the idea. If a filter recognizes '-' as a name for stdin, then stdin can be one of the _multiple_ files being processed. Filters that do not recognize '-' as a name, on the other hand, only process stdin if it is the _only_ input. For example cat(1) and paste(1) do that, head(1) and tail(1) don't. And there are other utilities that could do that, but don't. Below is a list of text filters from bin/ and usr.bin/ for which this seems relevant, separated into the two camps. Jan These recognize '-' as a name for stdin as one of possibly many inputs: cat cmp comm cut diff file join lam paste pr sdiff sort These process stdin only if it is the only (unnamed) input: column expand fmt fold grep head hexdump nl rev tail ul unexpand unvis vis wc
Re: enforce zero options
On Oct 12 15:00:23, j...@wxcvbn.org wrote: > Jan Stary <h...@stare.cz> writes: > > > Some programs in bin/ and usr.bin/ use the following idiom > > to make sure that there are no options present: > > > > while ((ch = getopt(argc, argv, "")) != -1) > > switch (ch) { > > case '?': > > default: > > usage(); > > /* NOTREACHED */ > > } > > > > if (argc != optind) { > > usage(); > > /* NOTREACHED */ > > } > > > > Why is this better then simply checking that (argc == 1)? > > getopt(3) handles --. Using getopt(3) everywhere is good for > consistency. I don't get it: why do we need to handle -- in utils which take no options and no arguments? e.g. logname(1) is supposed to be launched just like "logname". Does logname.c do the above just to handle "logname --" ? Jan
enforce zero options
Some programs in bin/ and usr.bin/ use the following idiom to make sure that there are no options present: while ((ch = getopt(argc, argv, "")) != -1) switch (ch) { case '?': default: usage(); /* NOTREACHED */ } if (argc != optind) { usage(); /* NOTREACHED */ } Why is this better then simply checking that (argc == 1)? Below is a diff to logname as an example. (Remove the pointless locale while there.) Jan Index: logname.c === RCS file: /cvs/src/usr.bin/logname/logname.c,v retrieving revision 1.9 diff -u -p -r1.9 logname.c --- logname.c 9 Oct 2015 01:37:08 - 1.9 +++ logname.c 12 Oct 2016 08:38:49 - @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -44,23 +43,11 @@ main(int argc, char *argv[]) int ch; char *p; - setlocale(LC_ALL, ""); - if (pledge("stdio", NULL) == -1) err(1, "pledge"); - while ((ch = getopt(argc, argv, "")) != -1) - switch (ch) { - case '?': - default: - usage(); - /* NOTREACHED */ - } - - if (argc != optind) { + if (argc != 1) usage(); - /* NOTREACHED */ - } if ((p = getlogin()) == NULL) err(1, NULL);
remove locale from logname(1)
Why does logname(1) need to setlocale? Jan Index: logname.c === RCS file: /cvs/src/usr.bin/logname/logname.c,v retrieving revision 1.9 diff -u -p -r1.9 logname.c --- logname.c 9 Oct 2015 01:37:08 - 1.9 +++ logname.c 12 Oct 2016 08:35:11 - @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -43,8 +42,6 @@ main(int argc, char *argv[]) { int ch; char *p; - - setlocale(LC_ALL, ""); if (pledge("stdio", NULL) == -1) err(1, "pledge");
Re: hide iwn firmware error log
On Oct 06 12:46:21, s...@stsp.name wrote: > Disable the detailed fatal firmware error log in iwn(4) by default. These are my iwm errors of today on a Dell Latitude E5570. Oct 11 16:26:56 dell /bsd: iwm0: fatal firmware error Oct 11 16:26:56 dell /bsd: iwm0: device timeout Oct 11 16:26:56 dell /bsd: iwm0: device timeout Oct 11 16:26:57 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 16:34:03 dell /bsd: iwm0: fatal firmware error Oct 11 16:34:03 dell /bsd: iwm0: device timeout Oct 11 16:34:03 dell /bsd: iwm0: device timeout Oct 11 16:34:04 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 16:37:34 dell /bsd: iwm0: fatal firmware error Oct 11 16:37:34 dell /bsd: iwm0: device timeout Oct 11 16:37:34 dell /bsd: iwm0: device timeout Oct 11 16:37:35 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:04:28 dell /bsd: iwm0: fatal firmware error Oct 11 17:04:28 dell /bsd: iwm0: device timeout Oct 11 17:04:28 dell /bsd: iwm0: device timeout Oct 11 17:04:29 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:08:37 dell /bsd: iwm0: fatal firmware error Oct 11 17:08:37 dell /bsd: iwm0: device timeout Oct 11 17:08:37 dell /bsd: iwm0: device timeout Oct 11 17:08:38 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:27:47 dell /bsd: iwm0: fatal firmware error Oct 11 17:27:47 dell /bsd: iwm0: device timeout Oct 11 17:27:47 dell /bsd: iwm0: device timeout Oct 11 17:27:48 dell /bsd: iwm0: could not add MAC context (error 35) Oct 11 17:31:20 dell /bsd: iwm0: fatal firmware error Oct 11 17:31:20 dell /bsd: iwm0: device timeout Oct 11 17:31:20 dell /bsd: iwm0: device timeout Oct 11 17:31:21 dell /bsd: iwm0: could not add MAC context (error 35) I sure don't know what to do with them, but I'm glad I can at least report them. If this goes in, which one of them will disappear? (Are they all firmware errors?) I don't understand the motivation to hide them, but I can build the kernel with IWN_DEBUG. Jan > Index: if_iwn.c > === > RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v > retrieving revision 1.172 > diff -u -p -r1.172 if_iwn.c > --- if_iwn.c 5 Sep 2016 08:18:18 - 1.172 > +++ if_iwn.c 6 Oct 2016 10:42:41 - > @@ -2595,6 +2595,7 @@ iwn_wakeup_intr(struct iwn_softc *sc) > } > } > > +#ifdef IWN_DEBUG > /* > * Dump the error log of the firmware when a firmware panic occurs. Although > * we can't debug the firmware because it is neither open source nor free, it > @@ -2606,9 +2607,6 @@ iwn_fatal_intr(struct iwn_softc *sc) > struct iwn_fw_dump dump; > int i; > > - /* Force a complete recalibration on next init. */ > - sc->sc_flags &= ~IWN_FLAG_CALIB_DONE; > - > /* Check that the error log address is valid. */ > if (sc->errptr < IWN_FW_DATA_BASE || > sc->errptr + sizeof (dump) > > @@ -2657,6 +2655,7 @@ iwn_fatal_intr(struct iwn_softc *sc) > printf(" rx ring: cur=%d\n", sc->rxq.cur); > printf(" 802.11 state %d\n", sc->sc_ic.ic_state); > } > +#endif > > int > iwn_intr(void *arg) > @@ -2711,8 +2710,14 @@ iwn_intr(void *arg) > } > if (r1 & (IWN_INT_SW_ERR | IWN_INT_HW_ERR)) { > printf("%s: fatal firmware error\n", sc->sc_dev.dv_xname); > + > + /* Force a complete recalibration on next init. */ > + sc->sc_flags &= ~IWN_FLAG_CALIB_DONE; > + > /* Dump firmware error log and stop. */ > +#ifdef IWN_DEBUG > iwn_fatal_intr(sc); > +#endif > iwn_stop(ifp, 1); > task_add(systq, >init_task); > return 1; >
Re: let head(1) understand `-' as stdin
On Oct 11 13:35:34, dera...@openbsd.org wrote: > This is command used in scripts. Scripts are often portable. If one > operating system has an extension, but others don't, then those > scripts become unportable to use use of these extensions. GNU head(1) has it, Solaris does not. (I don't have access to others right now.)
Re: let head(1) understand `-' as stdin
On Oct 11 21:27:54, j...@wxcvbn.org wrote: > Jan Stary <h...@stare.cz> writes: > > > The diff below makes head(1) recognize `-' > > as a name for the standard input, > > as many other utilities do. > > Makes sense to me. The following points could be improved IMO: Updated diff below. > - using strcmp sounds cleaner than those char comparisons OK > - I don't think the man page bits are needed. Utilities that read from > stdin are supposed to support `-'. I'm not sure whether the extra > example is really helpful. I have removed the example. I think the one sentence about "-" should stay; other utils which recognize "-" mention it. > - should we avoid closing stdin (multiple times)? fixed OK? Jan Index: head.1 === RCS file: /cvs/src/usr.bin/head/head.1,v retrieving revision 1.23 diff -u -p -r1.23 head.1 --- head.1 25 Oct 2015 21:50:32 - 1.23 +++ head.1 11 Oct 2016 21:05:07 - @@ -47,6 +47,9 @@ utility copies the first lines of each specified .Ar file to the standard output. +A name of +.Sq - +is recognized as standard input. If no files are named, .Nm copies lines from the standard input. Index: head.c === RCS file: /cvs/src/usr.bin/head/head.c,v retrieving revision 1.21 diff -u -p -r1.21 head.c --- head.c 20 Mar 2016 17:14:51 - 1.21 +++ head.c 11 Oct 2016 21:05:07 - @@ -30,6 +30,7 @@ */ #include +#include #include #include #include @@ -93,7 +94,8 @@ main(int argc, char *argv[]) if (pledge("stdio", NULL) == -1) err(1, "pledge"); } else { - if ((fp = fopen(*argv, "r")) == NULL) { + fp = strcmp(*argv, "-") ? fopen(*argv, "r") : stdin; + if (fp == NULL) { warn("%s", *argv++); status = 1; continue; @@ -101,7 +103,8 @@ main(int argc, char *argv[]) if (argc > 1) { if (!firsttime) putchar('\n'); - printf("==> %s <==\n", *argv); + printf("==> %s <==\n", + fp == stdin ? "(stdin)" : *argv); } ++argv; } @@ -109,7 +112,8 @@ main(int argc, char *argv[]) while ((ch = getc(fp)) != EOF) if (putchar(ch) == '\n') break; - fclose(fp); + if (fp != stdin) + fclose(fp); } /*NOTREACHED*/ }
Re: drop unused locale junk from sort(1)
On Oct 11 15:37:03, schwa...@usta.de wrote: > > and change /var/tmp to /tmp. > > No, according to file.c, the program still writes to /var/tmp, > not to /tmp. Before changing that in the manual, we would have > to change it in the code. I sent that in a separate email; this is a leftover, sorry. Jan
let head(1) understand `-' as stdin
The diff below makes head(1) recognize `-' as a name for the standard input, as many other utilities do. Jan Index: head.1 === RCS file: /cvs/src/usr.bin/head/head.1,v retrieving revision 1.23 diff -u -p -r1.23 head.1 --- head.1 25 Oct 2015 21:50:32 - 1.23 +++ head.1 11 Oct 2016 13:33:23 - @@ -47,6 +47,9 @@ utility copies the first lines of each specified .Ar file to the standard output. +A name of +.Sq - +is recognized as standard input. If no files are named, .Nm copies lines from the standard input. @@ -77,6 +80,16 @@ To display the first 500 lines of the fi .Ar foo : .Pp .Dl $ head -n 500 foo +.Pp +To display the first line of +.Ar foo , +the standard input, +.Ar bar +and +.Ar foo +again: +.Pp +.Dl $ head -n 1 foo - bar foo .Pp .Nm can be used in conjunction with Index: head.c === RCS file: /cvs/src/usr.bin/head/head.c,v retrieving revision 1.21 diff -u -p -r1.21 head.c --- head.c 20 Mar 2016 17:14:51 - 1.21 +++ head.c 11 Oct 2016 13:33:23 - @@ -93,7 +93,9 @@ main(int argc, char *argv[]) if (pledge("stdio", NULL) == -1) err(1, "pledge"); } else { - if ((fp = fopen(*argv, "r")) == NULL) { + fp = (argv[0][0] == '-' && argv[0][1] == 0) + ? stdin : fopen(*argv, "r"); + if (fp == NULL) { warn("%s", *argv++); status = 1; continue; @@ -101,7 +103,9 @@ main(int argc, char *argv[]) if (argc > 1) { if (!firsttime) putchar('\n'); - printf("==> %s <==\n", *argv); + printf("==> %s <==\n", + (argv[0][0] == '-' && argv[0][1] == 0) + ? "(stdin)" : *argv); } ++argv; }
drop unused locale junk from sort(1)
Feeling encouraged by Ingo's ok to remove locale from cp/rm, here's a diff that removes the locale stuff we don't actually do from the code and documentation of sort(1). Leave just LC_CTYPE which determines isblank() and case conversions. Annotate a missed -z flag while there, and change /var/tmp to /tmp. Jan Index: sort.c === RCS file: /cvs/src/usr.bin/sort/sort.c,v retrieving revision 1.86 diff -u -p -r1.86 sort.c --- sort.c 14 Jul 2016 08:31:18 - 1.86 +++ sort.c 11 Oct 2016 09:21:45 - @@ -252,55 +252,6 @@ conv_mbtowc(wchar_t *wc, const char *c, } /* - * Set current locale symbols. - */ -static void -set_locale(void) -{ - struct lconv *lc; - const char *locale; - - setlocale(LC_ALL, ""); - - /* Obtain LC_NUMERIC info */ - lc = localeconv(); - - /* Convert to wide char form */ - conv_mbtowc(_decimal_point, lc->decimal_point, - symbol_decimal_point); - conv_mbtowc(_thousands_sep, lc->thousands_sep, - symbol_thousands_sep); - conv_mbtowc(_positive_sign, lc->positive_sign, - symbol_positive_sign); - conv_mbtowc(_negative_sign, lc->negative_sign, - symbol_negative_sign); - - if (getenv("GNUSORT_NUMERIC_COMPATIBILITY")) - gnusort_numeric_compatibility = true; - - locale = setlocale(LC_COLLATE, NULL); - if (locale != NULL) { - char *tmpl; - const char *byteclocale; - - tmpl = sort_strdup(locale); - byteclocale = setlocale(LC_COLLATE, "C"); - if (byteclocale && strcmp(byteclocale, tmpl) == 0) { - byte_sort = true; - } else { - byteclocale = setlocale(LC_COLLATE, "POSIX"); - if (byteclocale && strcmp(byteclocale, tmpl) == 0) - byte_sort = true; - else - setlocale(LC_COLLATE, tmpl); - } - sort_free(tmpl); - } - if (!byte_sort) - sort_mb_cur_max = MB_CUR_MAX; -} - -/* * Set directory temporary files. */ static void @@ -883,7 +834,6 @@ main(int argc, char *argv[]) atexit(clear_tmp_files); - set_locale(); set_tmpdir(); set_sort_opts(); @@ -1163,17 +1113,8 @@ main(int argc, char *argv[]) if (debug_sort) { printf("Memory to be used for sorting: %llu\n", available_free_memory); - printf("Using collate rules of %s locale\n", - setlocale(LC_COLLATE, NULL)); if (byte_sort) printf("Byte sort is used\n"); - if (print_symbols_on_debug) { - printf("Decimal Point: <%lc>\n", symbol_decimal_point); - if (symbol_thousands_sep) - printf("Thousands separator: <%lc>\n", - symbol_thousands_sep); - printf("Positive sign: <%lc>\n", symbol_positive_sign); - printf("Negative sign: <%lc>\n", symbol_negative_sign); } } Index: sort.1 === RCS file: /cvs/src/usr.bin/sort/sort.1,v retrieving revision 1.54 diff -u -p -r1.54 sort.1 --- sort.1 5 Apr 2015 14:20:22 - 1.54 +++ sort.1 11 Oct 2016 09:21:45 - @@ -52,13 +52,16 @@ The .Nm utility sorts text and binary files by lines. A line is a record separated from the subsequent record by a -newline (default) or NUL \'\\0\' character (-z option). +newline (default) or NUL \'\\0\' character +.Po +.Fl z +option +.Pc . A record can contain any printable or unprintable characters. Comparisons are based on one or more sort keys extracted from each line of input, and are performed lexicographically, -according to the current locale's collating rules and the -specified command-line options that can tune the actual -sorting behavior. +according to the specified command-line options +that can tune the actual sorting behavior. By default, if keys are not given, .Nm uses entire lines for comparison. @@ -110,7 +113,7 @@ Store temporary files in the directory The default path is the value of the environment variable .Ev TMPDIR or -.Pa /var/tmp +.Pa /tmp if .Ev TMPDIR is not defined. @@ -173,10 +176,6 @@ Unknown strings are considered smaller t .It Fl n , Fl Fl numeric-sort, Fl Fl sort=numeric An initial numeric string, consisting of optional blank space, optional minus sign, and zero or more digits (including decimal point) -.\" with -.\" optional radix character and thousands -.\" separator -.\" (as defined in the current locale), is sorted by arithmetic value. Leading blank characters are ignored. .It Fl R, Fl Fl random-sort, Fl Fl sort=random @@
Re: setlocale in cp/rm/mv
On Oct 11 10:31:38, schwa...@usta.de wrote: > > cp(1) and rm(1) call setlocale(LC_ALL, "") but mv(1) does not. > > Why do they do that, and why mv doesn't? > > That is useless and wasteful. > > I think it comes from a time when people still thought that doing > more and more and more might bring you closer to perfection. > > Here is a simple diff to remove that junk Can we confront http://marc.info/?l=openbsd-tech=147586358208770=2 with this please? I still believe it should be removed from sort(1) too (diff in a separate mail). Jan
cp.c and rm.c embedded in mv(1)
mv's copies of cp.c and rm.c were imported about 10 months ago so that mv can avoid the fork+exec; instead, mv just calls the relevant cp/rm code itself. What was the motivation for that? Was that a step needed to have a stricter pledge() for mv (no forking and execing)? Currently, mv does not make a pledge. Would it make sense to pledge what cp+rm does (diff below)? Or is having the embedded copies beneficial in itself, even without the pledge? It saves a fork+exec, but we have duplicit code now: while the imported copies of cp.c and rm.c were streamlined a bit over the time (usage, locale, unused flags), the actual fts traversal and the copying/unlinking needs to be there, obviously. Jan Index: mv.c === RCS file: /cvs/src/bin/mv/mv.c,v retrieving revision 1.43 diff -u -p -r1.43 mv.c --- mv.c17 Nov 2015 18:34:00 - 1.43 +++ mv.c11 Oct 2016 06:46:19 - @@ -92,6 +92,9 @@ main(int argc, char *argv[]) if (argc < 2) usage(); + if (pledge("stdio rpath wpath cpath fattr getpw", NULL) == -1) + err(1, "pledge"); + stdin_ok = isatty(STDIN_FILENO); /*