From: Paul Eggert Date: Thu, 3 Aug 2023 22:53:30 +0000 (-0700) Subject: readutmp: fix idx_t FIXME in API X-Git-Tag: v1.0~972 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=db1645dd8b4874600d12a42324d2c153ea05d9ee;p=gnulib.git readutmp: fix idx_t FIXME in API * lib/readutmp.c (read_utmp): 2nd arg is now idx_t *, not size_t *. * lib/readutmp.h: Include idx.h, for idx_t. * modules/readutmp (Depends-on): Add idx. --- diff --git a/ChangeLog b/ChangeLog index 56b27d129f..a87e6537b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2023-08-03 Paul Eggert + readutmp: fix idx_t FIXME in API + * lib/readutmp.c (read_utmp): 2nd arg is now idx_t *, not + size_t *. + * lib/readutmp.h: Include idx.h, for idx_t. + * modules/readutmp (Depends-on): Add idx. + readutmp: go back to simple ‘free’ Omit the new free_utmp function. Instead, allocate storage in one block, so that using code can still just call ‘free’. diff --git a/NEWS b/NEWS index 24139d4660..f1c9b72aa9 100644 --- a/NEWS +++ b/NEWS @@ -74,8 +74,9 @@ User visible incompatible changes Date Modules Changes -2023-08-01 readutmp Some STRUCT_UTMP members can be char *, - rather than fixed-length char arrays. +2023-08-02 readutmp Some STRUCT_UTMP members can be char *, +2023-08-01 rather than fixed-length char arrays. + read_utmp's 2nd arg is now idx_t * not size_t *. Link additionally with $(READUTMP_LIB). 2023-07-10 dfa The signature of the function diff --git a/lib/readutmp.c b/lib/readutmp.c index 508978ba79..66314ec1db 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -299,7 +299,7 @@ add_utmp (struct utmp_alloc a, int options, } int -read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, +read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { /* Fill entries, simulating what a utmp file would contain. */ @@ -508,7 +508,7 @@ copy_utmp_entry (STRUCT_UTMP *dst, STRUCT_UTMP *src) } int -read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, +read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { idx_t n_read = 0; @@ -544,7 +544,7 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, # else int -read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, +read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { idx_t n_read = 0; @@ -586,7 +586,7 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, #else /* dummy fallback */ int -read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, +read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { errno = ENOSYS; diff --git a/lib/readutmp.h b/lib/readutmp.h index 956a8cafd9..4897b102d2 100644 --- a/lib/readutmp.h +++ b/lib/readutmp.h @@ -27,6 +27,8 @@ # error "Please include config.h first." # endif +# include "idx.h" + # include # include @@ -385,8 +387,7 @@ char *extract_trimmed_name (const STRUCT_UTMP *ut) process-IDs do not currently exist. If OPTIONS & READ_UTMP_USER_PROCESS is nonzero, omit entries which do not correspond to a user process. */ -/* FIXME: This header should use idx_t, not size_t. */ -int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, +int read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options); #endif /* __READUTMP_H__ */ diff --git a/modules/readutmp b/modules/readutmp index 484edd1842..534ce4fa19 100644 --- a/modules/readutmp +++ b/modules/readutmp @@ -9,6 +9,7 @@ m4/systemd.m4 Depends-on: extensions +idx xalloc stdbool stdint