Re: malloc.c: correlation between random choices

2018-01-18 Thread kshe
(bp->free > 1) - bp->rotor += r; - i = bp->rotor++ & (bp->total - 1); + i = (r / MALLOC_CHUNK_LISTS) & (bp->total - 1); /* start somewhere in a short */ lp = >bits[i / MALLOC_BITS]; Regards, kshe

jot(1): remove arbitrary length limits

2018-01-03 Thread kshe
if (strlcat(format, "%", sizeof(format)) >= - sizeof(format)) - errx(1, "-w word too long"); + if ((format = realloc(format, + len + sizeof("%"))) == NULL) + err(1, NULL); + strcpy(format + len, "%"); break; } } Regards, kshe

Re: malloc cleanup and small optimization (step 2)

2018-01-02 Thread kshe
BITS] |= (u_short)1U << (i % MALLOC_BITS); at the end of the new init_chunk_info() function? Besides, a few lines above those loops, I think p->shift could directly be set to MALLOC_MINSHIFT when bits == 0, without having to recalculate it from MALLOC_MINSIZE. Regards, kshe

malloc.conf.5: minor correction

2017-12-29 Thread kshe
, junking is done without size restrictions. .It Cm R Regards, kshe

Re: malloc cleanup and small optimization (step 2)

2017-12-29 Thread kshe
NK, psz - sz); else memset(p, SOME_JUNK, psz - mopts.malloc_guard); - } - else if (mopts.chunk_canaries) + } else if (mopts.chunk_canaries) fill_canary(p, sz - mopts.malloc_guard, psz - mopts.malloc_guard); Regards, kshe

sh.1: backslash within double quotes

2017-12-29 Thread kshe
within double quotes has a special meaning Regards, kshe

jot(1): one-byte overflow in error path

2017-12-29 Thread kshe
'; errx(1, "illegal or unsupported format '%s'", p2); } while (*++p != '\0') Regards, kshe

Re: uniq: add -i option

2017-12-23 Thread kshe
and will cause the `-i' flag to have no effect at all. If you really want to do this without a ternary operator, the equivalent form is if (iflag && strcasecmp(t1, t2) || !iflag && strcmp(t1, t2)) which looks very dumb indeed, but at least it is logically sound. Regards, kshe

Re: less(1): `!' command

2017-12-23 Thread kshe
'. Until some form of agreement can be reached on that issue, I have reverted the removal of `!' in my personal tree, so I still pay the exact same price as everybody else ("proc exec"), but at least I now get something useful out of that. Regards, kshe

dc(1): minor simplification in bexp()

2017-12-23 Thread kshe
"in exponent"); + BN_free(p->number); + p->number = i; BN_free(f); - - normalize(p, 0); } neg = BN_is_negative(p->number); Regards, kshe

Re: uniq: add -i option

2017-12-23 Thread kshe
egardless of those performance considerations. Regards, kshe

Re: less(1): `!' command

2017-12-17 Thread kshe
On Sat, 16 Dec 2017 21:52:44 +, Theo de Raadt wrote: > > On Sat, 16 Dec 2017 19:39:27 +, Theo de Raadt wrote: > > > > On Sat, 16 Dec 2017 18:13:16 +, Jiri B wrote: > > > > > On Sat, Dec 16, 2017 at 04:55:44PM +, kshe wrote: > > > >

Re: less(1): `!' command

2017-12-16 Thread kshe
On Sat, 16 Dec 2017 19:39:27 +, Theo de Raadt wrote: > > On Sat, 16 Dec 2017 18:13:16 +, Jiri B wrote: > > > On Sat, Dec 16, 2017 at 04:55:44PM +, kshe wrote: > > > > Hi, > > > > > > > > Would a patch to bring back the `!' command

Re: less(1): `!' command

2017-12-16 Thread kshe
On Sat, 16 Dec 2017 18:13:16 +, Jiri B wrote: > On Sat, Dec 16, 2017 at 04:55:44PM +0000, kshe wrote: > > Hi, > > > > Would a patch to bring back the `!' command to less(1) be accepted? The > > commit message for its removal explains that ^Z should be used instead,

dc(1): properly report errors

2017-12-16 Thread kshe
errx(1, "BN failure: %s", + ERR_reason_error_string(ERR_get_error())); + } } Regards, kshe

less(1): `!' command

2017-12-16 Thread kshe
/ $ printf '99d\nwq\n' | ed - less.hlp Regards, kshe

Re: net/rtsock.c: size to free(9)

2017-12-16 Thread kshe
&& w)/* clear the message header */ @@ -1809,7 +1808,7 @@ sysctl_rtable(int *name, u_int namelen, NET_UNLOCK(); break; } - free(w.w_tmem, M_RTABLE, 0); + free(w.w_tmem, M_RTABLE, w.w_tmemsize); w.w_needed += w.w_given; if (where) { *given = w.w_where - (caddr_t)where; Regards, kshe

vi(1): cscope leftover

2017-12-16 Thread kshe
,6 @@ EXCMDLIST const cmds[] = { {"~", ex_subtilde,E_ADDR2, "s", "[line [,line]] ~ [cgr] [count] [#lp]", - "replace previous RE with previous replacement string,"}, + "replace previous RE with previous replacement string"}, {NULL}, }; Regards, kshe

Re: remove one bug, add three

2017-12-12 Thread kshe
icient approach. I am happy to wait until you find enough time for a proper evaluation of the issue at stake; this is not a race. Regards, kshe

Re: remove one bug, add three

2017-12-12 Thread kshe
On Tue, 12 Dec 2017 12:44:03 +, Todd C. Miller wrote: > On Tue, 12 Dec 2017 11:57:58 +0000, kshe wrote: > > > Perhaps the worst part of all this, though, is how the change of > > behaviour, which made sed fail hard where it previously handled input in > > a perfectly de

remove one bug, add three

2017-12-12 Thread kshe
e to provide a proper and definitive fix to deal with this issue (and, at the same time, many other unrelated bugs). Regards, kshe

Re: net/rtsock.c: size to free(9)

2017-12-11 Thread kshe
On Sun, 10 Dec 2017 11:25:50 +, Martin Pieuchot wrote: > On 08/12/17(Fri) 12:58, kshe wrote: > > I noticed one instance where the size given to free(9) can easily be > > determined. > > What about the other free(9)s in the same function? Somehow I did not immediately re

net/rtsock.c: size to free(9)

2017-12-08 Thread kshe
struct ifaddr *ifa) { struct ifnet*ifp = ifa->ifa_ifp; - struct mbuf *m = NULL; + struct mbuf *m; struct rt_addrinfo info; struct ifa_msghdr *ifam; Regards, kshe

fstat(1): fix misaligned headers

2017-12-08 Thread kshe
t;); if (oflg) printf("%s", ":OFFSET "); if (checkfile && fsflg == 0) Regards, kshe

dc(1): always use bn_checkp()

2017-12-08 Thread kshe
} Regards, kshe

dc(1): small cleanups

2017-12-08 Thread kshe
rscale = bmachine.scale; } else { @@ -1507,7 +1493,6 @@ compare(enum bcode_compare type) } } } - static void nop(void) Regards, kshe

dc(1): recycle numbers

2017-12-08 Thread kshe
(r, a, b, bmachine.scale); - - push_number(r); + bmul_number(b, a, b, bmachine.scale); free_number(a); - free_number(b); + push_number(b); } static void Regards, kshe

Re: dc(1); fix 0Z

2017-12-04 Thread kshe
On Sun, 03 Dec 2017 12:25:15 +, Philippe Meunier wrote: > kshe wrote: > >Also, the manual defines the length of a number as its number of digits, > >so perhaps it should be precised that zero is considered to have no > >digits, which might not be obvious to everyone.

dc(1): global context

2017-12-04 Thread kshe
41,7 +1310,6 @@ bsqrt(void) r->scale = scale; r->number = y; BN_free(x); - BN_CTX_free(ctx); push_number(r); } Regards, kshe

Re: dc(1); fix 0Z

2017-12-02 Thread kshe
Also, the manual defines the length of a number as its number of digits, so perhaps it should be precised that zero is considered to have no digits, which might not be obvious to everyone. Other than that, I think this makes more sense indeed. Regards, kshe

Re: dc(1): floor(log_10(x)) should not cost more than O(log(log(x)))

2017-12-01 Thread kshe
On Fri, 01 Dec 2017 08:58:55 +, Otto Moerbeek wrote: > On Thu, Nov 30, 2017 at 01:10:33PM +0000, kshe wrote: > > On Thu, 30 Nov 2017 07:22:42 +, Otto Moerbeek wrote: > > > On Sun, Nov 26, 2017 at 07:40:03PM +, kshe wrote: > > > > Hi, > > > &

wprintf.3: fix synopsis

2017-11-30 Thread kshe
uot; .Ft int -.Fn vswprintf "wchar_t * restrict ws" "size_t n" "const wchar_t *restrict format" "va_list ap" +.Fn vswprintf "wchar_t * restrict ws" "size_t n" "const wchar_t * restrict format" "va_list ap" .Ft int .Fn vwprintf "const wchar_t * restrict format" "va_list ap" .Sh DESCRIPTION Regards, kshe

Re: dc(1) mishandles fractional input in bases other than 10

2017-11-30 Thread kshe
On Tue, 28 Nov 2017 09:52:26 +, Otto Moerbeek wrote: > On Sun, Nov 26, 2017 at 07:51:13PM +0000, kshe wrote: > > Hi, > > > > The following behaviour seems unacceptable to me. > > > > $ dc -e '16dio .C .C0 f' > > .C0 > > .B > >

Re: freezero(3) for stdio's internal buffers

2017-11-30 Thread kshe
(size_t)-1) { - free(mbstr); + freezero(mbstr, len); return (EOF); } if (mlen == len) @@ -82,7 +82,7 @@ vswscanf(const wchar_t * __restrict str, f._read = eofread; f._lb._base = NULL; r = __vfwscanf(, fmt, ap); - free(mbstr); + freezero(mbstr, len); return (r); } Regards, kshe

Re: dc(1): floor(log_10(x)) should not cost more than O(log(log(x)))

2017-11-30 Thread kshe
On Thu, 30 Nov 2017 07:22:42 +, Otto Moerbeek wrote: > On Sun, Nov 26, 2017 at 07:40:03PM +0000, kshe wrote: > > Hi, > > > > The `Z' command can be a handy shortcut for computing logarithms; as > > such, for example, it is the basis of the implementation of bc(1)'s

Re: sed.1: miscellaneous corrections

2017-11-28 Thread kshe
On Mon, 27 Nov 2017 10:41:05 +, Jason McIntyre wrote: > On Sun, Nov 26, 2017 at 07:47:01PM +0000, kshe wrote: > > Hi, > > > > I noticed a certain number of inaccuracies within the manual page for > > sed. The diff below corrects to most obvious ones, althou

Re: dc(1): minor cleanup

2017-11-28 Thread kshe
On Tue, 28 Nov 2017 08:08:24 +, Otto Moerbeek wrote: > On Sun, Nov 26, 2017 at 07:25:46PM +0000, kshe wrote: > > Hi, > > > > The diff below encompasses three unrelated minor changes. > > > > 1. Merge the not_equal(), not_less() and not_greater(

Re: freezero(3) for stdio's internal buffers

2017-11-27 Thread kshe
of my first patch, many of which simply mirror the already established use of recallocarray on the same buffers. Regards, kshe

Re: freezero(3) for stdio's internal buffers

2017-11-27 Thread kshe
On Mon, 27 Nov 2017 08:01:25 +, Otto Moerbeek wrote: > On Mon, Nov 27, 2017 at 05:48:14AM +0000, kshe wrote: > > On Mon, 27 Nov 2017 00:42:01 +, Theo de Raadt wrote: > > > This needs worst-case performance measurements. > > > > The only instances where

Re: freezero(3) for stdio's internal buffers

2017-11-26 Thread kshe
too slow, because doing things, as stdio does, like reading from and writing to disk or decoding and converting user input will always dominate the effect of a few calls to discard temporary buffers. Regards, kshe

Re: freezero(3) for stdio's internal buffers

2017-11-26 Thread kshe
On Sun, 26 Nov 2017 19:56:03 +, kshe wrote: > Hi, > > Shortly after recallocarray(3) was introduced, it was put into use for > several objects internal to the stdio library "to avoid leaving detritus > in memory when resizing buffers". However, in the end, this m

dc(1): smaller jump table

2017-11-26 Thread kshe
ch); + unknown(); #ifdef DEBUGGING stack_print(stderr, , "* ", Regards, kshe

dc(1): simplify print_ascii()

2017-11-26 Thread kshe
_bit_set(n->number, numbits-i-1) << (7 - i); (void)putc(ch, f); numbits -= 8; } - BN_free(v); } Regards, kshe

dc(1): earlier pledge

2017-11-26 Thread kshe
;stdio", NULL) == -1) - err(1, "pledge"); src_setstream(, stdin); reset_bmachine(); Regards, kshe

freezero(3) for stdio's internal buffers

2017-11-26 Thread kshe
vswscanf(const wchar_t * __restrict str, f._read = eofread; f._lb._base = NULL; r = __vfwscanf(, fmt, ap); - free(mbstr); + freezero(mbstr); return (r); } Regards, kshe

dc(1) mishandles fractional input in bases other than 10

2017-11-26 Thread kshe
10 could be added to the manual. Regards, kshe

sed.1: miscellaneous corrections

2017-11-26 Thread kshe
-.Ic w , \&: , +.Ic a , c , i , r , w and .Ic # . Regards, kshe

dc(1): dead store

2017-11-26 Thread kshe
default: break; } Regards, kshe

dc(1): minor cleanup

2017-11-26 Thread kshe
-static void greater(void) { compare(BCODE_GREATER); } -static void -not_greater(void) -{ - compare(BCODE_NOT_GREATER); -} - static bool compare_numbers(enum bcode_compare type, struct number *a, struct number *b) { Regards, kshe

dc(1): floor(log_10(x)) should not cost more than O(log(log(x)))

2017-11-26 Thread kshe
rt, a) >= 0) + d++; + + BN_CTX_free(ctx); + BN_free(a); + BN_free(p); + } else + d++; + + BN_free(int_part); + + return d + n->scale; } static void Regards, kshe

Re: sed(1): missing NUL in pattern space

2017-07-01 Thread kshe
ut the hassle of having to untangle such old and messy code. As a consequence, especially since no one at OpenBSD appears to have time to deal with all the deficiencies of the existing source, it might be simpler to wait until I am done with my own, as my code shall be much more readable than the current one, and therefore quite easy to review. Kind regards, kshe

Re: sed(1): missing NUL in pattern space

2017-06-13 Thread kshe
se `size_t' instead of `int' for a variable holding a length. 7. Slightly improve the logic of regsub() to avoid a bunch of no-op instructions when `len' is zero. 8. Move a goto label previously redirecting into a conditional that was always false within that context. 9. Add missing tabs to align backslashes in macro definitions. Kind regards, kshe

sed(1): missing NUL in pattern space

2017-06-09 Thread kshe
laborate on that idea after committing such an unsatisfying patch, I would of course be very happy to help. Kind regards, kshe