Skip to content
Permalink
Browse files

Fix the non-compiling utmp case, found on OpenBSD.

By not having build-tested with utmp, I made two easy mistakes:

(1) In file included from qbiff.c:3:
    ./qtmp.h:15:5: error: unknown type name 'substdio'
        substdio ssutmp; \
        ^
    ./qtmp.h:16:43: error: expected ';' after top level declarator
        char bufutmp[sizeof(struct utmp) * 16]
                                              ^
                                              ;

Mistake: missed a trailing backslash on line 14.
Fix: add it.

(2) qbiff.c:81:2: error: use of undeclared identifier 'fdutmp'; did you mean 'ssutmp'?
     UTMP_OPEN;
     ^
    ./qtmp.h:20:33: note: expanded from macro 'UTMP_OPEN'
        substdio_fdbuf(&ssutmp,read,fdutmp,bufutmp,sizeof(bufutmp))

Mistake: tried to get rid of fdutmp by checking open_read() directly,
not realizing fdutmp was still needed on the next line (!).
Fix: bring back fdutmp.

Fixes: 47baf78
  • Loading branch information...
schmonz authored and alanpost committed Aug 6, 2019
1 parent ea3a0e4 commit f9efcbfdc2d47795d193c9a851a9c4b6d41661d5
Showing with 5 additions and 3 deletions.
  1. +5 −3 qtmp.h1
@@ -11,12 +11,14 @@
#endif
#define UTMP_INIT \
struct utmp utm; \
struct utmp *ut = &utm;
struct utmp *ut = &utm; \
substdio ssutmp; \
char bufutmp[sizeof(struct utmp) * 16]
char bufutmp[sizeof(struct utmp) * 16]; \
int fdutmp
#define UTMP_USER ut_name
#define UTMP_OPEN \
if (open_read(UTMP_FILE) == -1) _exit(0); \
fdutmp = open_read(UTMP_FILE); \
if (fdutmp == -1) _exit(0); \
substdio_fdbuf(&ssutmp,read,fdutmp,bufutmp,sizeof(bufutmp))
#define UTMP_READ_MORE (substdio_get(&ssutmp,ut,sizeof(utm)) == sizeof(utm))
#define UTMP_TYPE_MATCHES 1

0 comments on commit f9efcbf

Please sign in to comment.
You can’t perform that action at this time.