Re: __printflike macro on OpenBSD

2020-06-11 Thread Theo de Raadt
sensiblehue  wrote:

> I asked about __printflike because I found it unusual that other major
> BSDs have it and OpenBSD doesn't, despite using macros like __dead,
> __unused, etc.

Systems adopt private solutions, half the time without limiting the scope
to indicate it is private.

The assumption the should be adopted GLOBALLY requires strong
justification.

> If I understood correctly, the existence of those macros is merely a
> convenience and not an intentional effort for portability with the other
> BSDs. In that case it was wrong to assume OpenBSD should have it.

I declare the idea inconvenient.

A portability collision.

Unhelpful.




Re: __printflike macro on OpenBSD

2020-06-11 Thread sensiblehue
On Thu, Jun 11, 2020 at 01:03:46PM -0600, Theo de Raadt wrote:
> Theo de Raadt  wrote:
> 
> > sensiblehue  wrote:
> > 
> > > On Thu, Jun 11, 2020 at 03:08:01PM +0200, Marc Espie wrote:
> > > > On Thu, Jun 11, 2020 at 04:37:34AM +, sensiblehue wrote:
> > > > > Hello,
> > > > > I was wondering why OpenBSD doesn't have a `__printflike' macro in
> > > > > ? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
> > > > > available from libbsd on Linux.
> > > > > Personally I think it's cleaner and just as portable if not more
> > > > > portable, because some compilers don't support `__attribute__'.
> > > > 
> > > > 
> > > > What compilers ?
> > > 
> > > GCC < v2.5 and non GNU C compilers, though I see now that OpenBSD
> > > defines it to nothing in that case.
> > 
> > Ah, so it does actually work fine, unlike what you originally claimed.

Yes, I should've done more research beforehand.

> > 
> > 
> > > To be honest I'm mostly suggesting __printflike because I want to use it
> > > in my own code and still have it compile on OpenBSD without an #ifdef,
> > > but it would also make software from other BSDs easier to port.
> > 
> > We are using the attribute mechanism directly in a way that works on
> > all modern (10 years?).
> > 
> > Intentionally.
> 
> Let me reiterate why it is used directly.  You probably understand, but
> I'm not sure you see the value.
> 
> 1. If the compiler supports attributes but does not know this one, the
>code compiles, the special handling isn't done, and everything works.
> 
> 2. If the compiler supports attributes but and knows it, the special handling
>is performed, and everything works.
> 
> 3. If the compiler is so old that it doesn't handle unsupported attributes,
>go use a different (new) compiler.
> 

Fair enough, if __attribute__ has worked for so many years I agree
portability isn't a concern.

I asked about __printflike because I found it unusual that other major
BSDs have it and OpenBSD doesn't, despite using macros like __dead,
__unused, etc.

If I understood correctly, the existence of those macros is merely a
convenience and not an intentional effort for portability with the other
BSDs. In that case it was wrong to assume OpenBSD should have it.

> You say you want to use an old compiler which doesn't handle unknown
> attributes?

No, just pointing out an edge case.

> How will you cope with all the operating systems which lack the #define
> you request?

*BSD is the only operating system worth writing code for. :)



Re: __printflike macro on OpenBSD

2020-06-11 Thread Theo de Raadt
Theo de Raadt  wrote:

> sensiblehue  wrote:
> 
> > On Thu, Jun 11, 2020 at 03:08:01PM +0200, Marc Espie wrote:
> > > On Thu, Jun 11, 2020 at 04:37:34AM +, sensiblehue wrote:
> > > > Hello,
> > > > I was wondering why OpenBSD doesn't have a `__printflike' macro in
> > > > ? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
> > > > available from libbsd on Linux.
> > > > Personally I think it's cleaner and just as portable if not more
> > > > portable, because some compilers don't support `__attribute__'.
> > > 
> > > 
> > > What compilers ?
> > 
> > GCC < v2.5 and non GNU C compilers, though I see now that OpenBSD
> > defines it to nothing in that case.
> 
> Ah, so it does actually work fine, unlike what you originally claimed.
> 
> 
> > To be honest I'm mostly suggesting __printflike because I want to use it
> > in my own code and still have it compile on OpenBSD without an #ifdef,
> > but it would also make software from other BSDs easier to port.
> 
> We are using the attribute mechanism directly in a way that works on
> all modern (10 years?).
> 
> Intentionally.

Let me reiterate why it is used directly.  You probably understand, but
I'm not sure you see the value.

1. If the compiler supports attributes but does not know this one, the
   code compiles, the special handling isn't done, and everything works.

2. If the compiler supports attributes but and knows it, the special handling
   is performed, and everything works.

3. If the compiler is so old that it doesn't handle unsupported attributes,
   go use a different (new) compiler.


You say you want to use an old compiler which doesn't handle unknown
attributes?

How will you cope with all the operating systems which lack the #define
you request?






Re: __printflike macro on OpenBSD

2020-06-11 Thread Theo de Raadt
sensiblehue  wrote:

> On Thu, Jun 11, 2020 at 03:08:01PM +0200, Marc Espie wrote:
> > On Thu, Jun 11, 2020 at 04:37:34AM +, sensiblehue wrote:
> > > Hello,
> > > I was wondering why OpenBSD doesn't have a `__printflike' macro in
> > > ? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
> > > available from libbsd on Linux.
> > > Personally I think it's cleaner and just as portable if not more
> > > portable, because some compilers don't support `__attribute__'.
> > 
> > 
> > What compilers ?
> 
> GCC < v2.5 and non GNU C compilers, though I see now that OpenBSD
> defines it to nothing in that case.

Ah, so it does actually work fine, unlike what you originally claimed.


> To be honest I'm mostly suggesting __printflike because I want to use it
> in my own code and still have it compile on OpenBSD without an #ifdef,
> but it would also make software from other BSDs easier to port.

We are using the attribute mechanism directly in a way that works on
all modern (10 years?).

Intentionally.

Your proposal requires everyone to eventually have a new cpp symbol.
You start by requiring us to have the symbol, then you'll go after the
next people?  Why are you asking us before you ask Microsoft?





Re: __printflike macro on OpenBSD

2020-06-11 Thread sensiblehue
On Thu, Jun 11, 2020 at 03:08:01PM +0200, Marc Espie wrote:
> On Thu, Jun 11, 2020 at 04:37:34AM +, sensiblehue wrote:
> > Hello,
> > I was wondering why OpenBSD doesn't have a `__printflike' macro in
> > ? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
> > available from libbsd on Linux.
> > Personally I think it's cleaner and just as portable if not more
> > portable, because some compilers don't support `__attribute__'.
> 
> 
> What compilers ?

GCC < v2.5 and non GNU C compilers, though I see now that OpenBSD
defines it to nothing in that case. What could be an issue is that the
`format' attribute appeared in GCC v2.7, and invalid attributes
generate a warning.

To be honest I'm mostly suggesting __printflike because I want to use it
in my own code and still have it compile on OpenBSD without an #ifdef,
but it would also make software from other BSDs easier to port.



Re: __printflike macro on OpenBSD

2020-06-11 Thread Marc Espie
On Thu, Jun 11, 2020 at 06:22:55PM +, sensiblehue wrote:
> On Thu, Jun 11, 2020 at 03:08:01PM +0200, Marc Espie wrote:
> > On Thu, Jun 11, 2020 at 04:37:34AM +, sensiblehue wrote:
> > > Hello,
> > > I was wondering why OpenBSD doesn't have a `__printflike' macro in
> > > ? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
> > > available from libbsd on Linux.
> > > Personally I think it's cleaner and just as portable if not more
> > > portable, because some compilers don't support `__attribute__'.
> > 
> > 
> > What compilers ?
> 
> GCC < v2.5 and non GNU C compilers, though I see now that OpenBSD
> defines it to nothing in that case. What could be an issue is that the
> `format' attribute appeared in GCC v2.7, and invalid attributes
> generate a warning.

clang has full support for attributes, so your statement is somewhat false.




Re: __printflike macro on OpenBSD

2020-06-11 Thread Marc Espie
On Thu, Jun 11, 2020 at 04:37:34AM +, sensiblehue wrote:
> Hello,
> I was wondering why OpenBSD doesn't have a `__printflike' macro in
> ? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
> available from libbsd on Linux.
> Personally I think it's cleaner and just as portable if not more
> portable, because some compilers don't support `__attribute__'.


What compilers ?



Re: __printflike macro on OpenBSD

2020-06-10 Thread Theo de Raadt
Because we don't.

sensiblehue  wrote:

> Hello,
> I was wondering why OpenBSD doesn't have a `__printflike' macro in
> ? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
> available from libbsd on Linux.
> Personally I think it's cleaner and just as portable if not more
> portable, because some compilers don't support `__attribute__'.
> 



__printflike macro on OpenBSD

2020-06-10 Thread sensiblehue
Hello,
I was wondering why OpenBSD doesn't have a `__printflike' macro in
? FreeBSD, NetBSD, and DragonflyBSD have it and it's also
available from libbsd on Linux.
Personally I think it's cleaner and just as portable if not more
portable, because some compilers don't support `__attribute__'.