Re: sockaddr_un.sun_len vs. reality

2022-08-23 Thread Thomas Munro
On Tue, Aug 23, 2022 at 3:43 PM Tom Lane wrote: > Thomas Munro writes: > > I was nerd-sniped by the historical context of this single line of > > code. I'd already wondered many times (not just in PostgreSQL) > > whether and when that became a cargo-cult practice, replicated from > > other softw

Re: sockaddr_un.sun_len vs. reality

2022-08-22 Thread Tom Lane
Thomas Munro writes: > I was nerd-sniped by the historical context of this single line of > code. I'd already wondered many times (not just in PostgreSQL) > whether and when that became a cargo-cult practice, replicated from > other software and older books like Stevens. I failed to find any > s

Re: sockaddr_un.sun_len vs. reality

2022-08-22 Thread Thomas Munro
On Tue, Feb 15, 2022 at 4:21 AM Tom Lane wrote: > Thomas Munro writes: > > On Mon, Feb 14, 2022 at 7:19 PM Tom Lane wrote: > >> I'm leaning to adding a compile-time clamp on the value, > >> that is > >> > >> unp->sun_len = Min(sizeof(struct sockaddr_un), > >> (1 << (

Re: sockaddr_un.sun_len vs. reality

2022-02-14 Thread Thomas Munro
On Tue, Feb 15, 2022 at 3:25 AM Robert Haas wrote: > It's not real clear to me that it's worth complicating the code to > avoid a harmless compiler warning on an 11-year-old operating system > with minimal real-world usage. On the other hand, if you really feel > motivated to do something about it

Re: sockaddr_un.sun_len vs. reality

2022-02-14 Thread Tom Lane
Thomas Munro writes: > On Mon, Feb 14, 2022 at 7:19 PM Tom Lane wrote: >> I'm leaning to adding a compile-time clamp on the value, >> that is >> >> unp->sun_len = Min(sizeof(struct sockaddr_un), >> (1 << (sizeof(unp->sun_len) * 8)) - 1); > Any system that has sun_le

Re: sockaddr_un.sun_len vs. reality

2022-02-14 Thread Tom Lane
Robert Haas writes: > On Mon, Feb 14, 2022 at 1:19 AM Tom Lane wrote: >> For a very long time, the AIX 7.1 buildfarm members (sungazer and tern) >> have complained about >> ip.c:236:17: warning: conversion from 'long unsigned int' to 'uchar_t' {aka >> 'unsigned char'} changes value from '1025' t

Re: sockaddr_un.sun_len vs. reality

2022-02-14 Thread Robert Haas
On Mon, Feb 14, 2022 at 1:19 AM Tom Lane wrote: > For a very long time, the AIX 7.1 buildfarm members (sungazer and tern) > have complained about > > ip.c:236:17: warning: conversion from 'long unsigned int' to 'uchar_t' {aka > 'unsigned char'} changes value from '1025' to '1' [-Woverflow] > > I'

Re: sockaddr_un.sun_len vs. reality

2022-02-14 Thread Thomas Munro
On Mon, Feb 14, 2022 at 7:19 PM Tom Lane wrote: > For a very long time, the AIX 7.1 buildfarm members (sungazer and tern) > have complained about > > ip.c:236:17: warning: conversion from 'long unsigned int' to 'uchar_t' {aka > 'unsigned char'} changes value from '1025' to '1' [-Woverflow] > > I'

sockaddr_un.sun_len vs. reality

2022-02-13 Thread Tom Lane
For a very long time, the AIX 7.1 buildfarm members (sungazer and tern) have complained about ip.c:236:17: warning: conversion from 'long unsigned int' to 'uchar_t' {aka 'unsigned char'} changes value from '1025' to '1' [-Woverflow] I'd ignored this as not being very interesting, but I got motiv