Re: [hackers] [st][PATCH v2] code-golfing: cleanup osc color related code
On Sun, Mar 20, 2022 at 12:49:22PM +0100, Hiltjo Posthuma wrote:
> > - n = snprintf(buf, sizeof buf, "\033]4;%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
> > - num, r, r, g, g, b, b);
> > -
> > - ttywrite(buf, n, 1);
> > -}
>
> A nitpick, because I think the string always fits in the buffer `buf`, but: the
> return value can be negative or on truncation >= sizeof(buf). So the pattern
> of:
>
> n = snprintf(...);
> ttywrite(..., n, ...);
>
> Is not good.
Done, attached an amended patch. And on that topic, saw there was
another place using this pattern:
case 'n': /* DSR – Device Status Report (cursor position) */
if (csiescseq.arg[0] == 6) {
len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
term.c.y+1, term.c.x+1);
ttywrite(buf, len, 0);
}
break;
Didn't touch it, since I think that's out of scope for this patch.
- NRK
Received on Sun Mar 20 2022 - 13:25:40 CET
This archive was generated by hypermail 2.3.0
: Sun Mar 20 2022 - 13:36:37 CET