summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/procps/procps/0001-src-w.c-use-utmp.h-only.patch
blob: 23c91ec77515849f5f71ce23764705b494026dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From c41b3be62fbb78e0939fddaebad519360cbd8702 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Mon, 6 Mar 2023 09:27:57 +0100
Subject: [PATCH] src/w.c: use only utmpx

Nowadays this works both on musl and glibc systems, however on musl
utmp.h is also needed to avoid the following failure:

| ../git/src/w.c: In function 'print_from':
| ../git/src/w.c:73:28: error: '__UT_HOSTSIZE' undeclared (first use in this function); did you mean 'UT_HOSTSIZE'?
|    73 | #       define UT_HOSTSIZE __UT_HOSTSIZE
|       |                            ^~~~~~~~~~~~~
| ../git/src/w.c:233:64: note: in expansion of macro 'UT_HOSTSIZE'
|   233 |                         print_display_or_interface(u->ut_host, UT_HOSTSIZE, fromlen - len);
|       |                                                                ^~~~~~~~~~~
|

It is caused by including utmpx.h, but not utmp.h, which (on musl)
lacks the needed definitions.

I have verified that both musl and glibc based builds continue to work.

Upstream-Status: Submitted [https://gitlab.com/procps-ng/procps/-/merge_requests/171]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>

---
 src/w.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/src/w.c b/src/w.c
index 5e878f04..912c5df3 100644
--- a/src/w.c
+++ b/src/w.c
@@ -46,11 +46,8 @@
 #include <termios.h>
 #include <time.h>
 #include <unistd.h>
-#ifdef HAVE_UTMPX_H
-#	include <utmpx.h>
-#else
-#	include <utmp.h>
-#endif
+#include <utmp.h>
+#include <utmpx.h>
 #include <arpa/inet.h>
 
 #include "c.h"
@@ -63,17 +60,7 @@
 static int ignoreuser = 0;	/* for '-u' */
 static int oldstyle = 0;	/* for '-o' */
 
-#ifdef HAVE_UTMPX_H
 typedef struct utmpx utmp_t;
-#else
-typedef struct utmp utmp_t;
-#endif
-
-#if !defined(UT_HOSTSIZE) || defined(__UT_HOSTSIZE)
-#	define UT_HOSTSIZE __UT_HOSTSIZE
-#	define UT_LINESIZE __UT_LINESIZE
-#	define UT_NAMESIZE __UT_NAMESIZE
-#endif
 
 #ifdef W_SHOWFROM
 # define FROM_STRING "on"