[v5,03/11] client: define EPROTO if it's not defined

Submitted by Leonid Bobrov via wayland-devel on Feb. 13, 2019, 11:39 a.m.

Details

Message ID 20190213113916.75159-3-mazocomp@disroot.org
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Wayland

Not browsing as part of any series.

Commit Message

Leonid Bobrov via wayland-devel Feb. 13, 2019, 11:39 a.m.
Signed-off-by: Leonid Bobrov <mazocomp@disroot.org>
---
 src/wayland-client.h | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/wayland-client.h b/src/wayland-client.h
index 9f70fa3..690c446 100644
--- a/src/wayland-client.h
+++ b/src/wayland-client.h
@@ -39,4 +39,8 @@ 
 #include "wayland-client-core.h"
 #include "wayland-client-protocol.h"
 
+#ifndef EPROTO
+#define EPROTO ENOPROTOOPT
+#endif
+
 #endif

Comments

On Wed, 13 Feb 2019 13:39:08 +0200
Leonid Bobrov via wayland-devel <wayland-devel@lists.freedesktop.org> wrote:

> Signed-off-by: Leonid Bobrov <mazocomp@disroot.org>
> ---
>  src/wayland-client.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/wayland-client.h b/src/wayland-client.h
> index 9f70fa3..690c446 100644
> --- a/src/wayland-client.h
> +++ b/src/wayland-client.h
> @@ -39,4 +39,8 @@
>  #include "wayland-client-core.h"
>  #include "wayland-client-protocol.h"
>  
> +#ifndef EPROTO
> +#define EPROTO ENOPROTOOPT
> +#endif
> +
>  #endif

Hi Leonid,

the things in wayland-client.h are mostly deprecated stuff that could
not be removed because of stable API. New stuff should go to
wayland-client-core.h.

I'm a little confused. The Linux manual for errno says:

ENOPROTOOPT     Protocol not available (POSIX.1-2001).
EPROTO          Protocol error (POSIX.1-2001).

So both are provided by the same specification, and they are different
codes. How come you have one but not the other?

If you do this, you must also #include <errno.h> first, because you
cannot rely on the user to do that. If errno.h is not included first,
EPROTO is possibly undefined at that point, and then the real
definition through errno.h will conflict later.

I'm also not sure if wayland-client-core.h is the right place, but I
don't have better suggestions.

What if some other library uses a different fallback definition for
EPROTO? Then the order of includes would determine which library's
definition the program gets and then it unavoidably conflicts with the
other library's use.


Thanks,
pq