diff mbox series

[3/8] compat: ENODATA compatibility for FreeBSD

Message ID 20180423123109.18590-3-christian.storm@siemens.com
State Accepted
Headers show
Series [1/8] core: warn about non-Linux parent SIGTERM tracking | expand

Commit Message

Storm, Christian April 23, 2018, 12:31 p.m. UTC
As ENODATA is not available on FreeBSD, return
ENOATTR instead which is close enough.

Signed-off-by: Thomas Zander <thomas.zander@siemens.com>
Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 corelib/swupdate_settings.c |  1 +
 include/compat.h            | 10 ++++++++++
 2 files changed, 11 insertions(+)

Comments

Stefano Babic April 23, 2018, 5:55 p.m. UTC | #1
On 23/04/2018 14:31, Christian Storm wrote:
> As ENODATA is not available on FreeBSD, return
> ENOATTR instead which is close enough.
> 
> Signed-off-by: Thomas Zander <thomas.zander@siemens.com>
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/swupdate_settings.c |  1 +
>  include/compat.h            | 10 ++++++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/corelib/swupdate_settings.c b/corelib/swupdate_settings.c
> index 9a5043a..ec726f2 100644
> --- a/corelib/swupdate_settings.c
> +++ b/corelib/swupdate_settings.c
> @@ -25,6 +25,7 @@
>  #include "swupdate.h"
>  #include "parselib.h"
>  #include "swupdate_settings.h"
> +#include "compat.h"
>  
>  struct run_as {
>  	uid_t userid;
> diff --git a/include/compat.h b/include/compat.h
> index 29d7af1..a98a388 100644
> --- a/include/compat.h
> +++ b/include/compat.h
> @@ -22,3 +22,13 @@
>  		(char *)memcpy(__out, __in, __len - 1); \
>  	}))
>  #endif
> +
> +#if defined(__FreeBSD__)
> +/*
> + * Define ENODATA (61 - No data available) to
> + * ENOATTR (87 - Attribute not found) on FreeBSD
> + * since that's closest to Linux's ENODATA, and
> + * 61 on FreeBSD is ECONNREFUSED.
> + */
> +#define ENODATA ENOATTR
> +#endif
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/swupdate_settings.c b/corelib/swupdate_settings.c
index 9a5043a..ec726f2 100644
--- a/corelib/swupdate_settings.c
+++ b/corelib/swupdate_settings.c
@@ -25,6 +25,7 @@ 
 #include "swupdate.h"
 #include "parselib.h"
 #include "swupdate_settings.h"
+#include "compat.h"
 
 struct run_as {
 	uid_t userid;
diff --git a/include/compat.h b/include/compat.h
index 29d7af1..a98a388 100644
--- a/include/compat.h
+++ b/include/compat.h
@@ -22,3 +22,13 @@ 
 		(char *)memcpy(__out, __in, __len - 1); \
 	}))
 #endif
+
+#if defined(__FreeBSD__)
+/*
+ * Define ENODATA (61 - No data available) to
+ * ENOATTR (87 - Attribute not found) on FreeBSD
+ * since that's closest to Linux's ENODATA, and
+ * 61 on FreeBSD is ECONNREFUSED.
+ */
+#define ENODATA ENOATTR
+#endif