On Tue, 2 Mar 2021 23:49:17 +0100 Xabier Oneca -- xOneca <[email protected]> wrote:
> +1 on the rename to xopen_as(). > > El lun., 1 mar. 2021 18:15, Walter Harms <[email protected]> escribió: > > > nice observation, > > > > but IMHO the name is a bit misleading, i6 should be more generic > > like: xopen_as() > > > > ym2c, > > re, > > wh > > ________________________________________ > > Von: busybox <[email protected]> im Auftrag von Rasmus > > Villemoes <[email protected]> > > Gesendet: Montag, 1. März 2021 17:03:56 > > An: [email protected] > > Betreff: [PATCH 1/2] libbb: add xopen_fd() helper > > > > xmove_fd(xopen(...), ...) is a common pattern. Add a helper for > > that. On x86-64, this compiles to 18 bytes, so just a few call sites > > need to be converted for a net win. > > > > Signed-off-by: Rasmus Villemoes <[email protected]> > > --- > > include/libbb.h | 1 + > > libbb/xfuncs_printf.c | 6 ++++++ > > 2 files changed, 7 insertions(+) > > > > diff --git a/include/libbb.h b/include/libbb.h > > index cb6336474..ce5eaa5fb 100644 > > --- a/include/libbb.h > > +++ b/include/libbb.h > > @@ -608,6 +608,7 @@ int open3_or_warn(const char *pathname, int > > flags, int mode) FAST_FUNC; > > int open_or_warn(const char *pathname, int flags) FAST_FUNC; > > int xopen3(const char *pathname, int flags, int mode) FAST_FUNC; > > int xopen(const char *pathname, int flags) FAST_FUNC; > > +void xopen_fd(const char *pathname, int flags, int fd) FAST_FUNC; > > int xopen_nonblocking(const char *pathname) FAST_FUNC; > > int xopen_as_uid_gid(const char *pathname, int flags, uid_t u, > > gid_t g) FAST_FUNC; > > int open_or_warn_stdin(const char *pathname) FAST_FUNC; > > diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c > > index 99596b9d0..f7c439c2f 100644 > > --- a/libbb/xfuncs_printf.c > > +++ b/libbb/xfuncs_printf.c > > @@ -160,6 +160,12 @@ int FAST_FUNC xopen(const char *pathname, int > > flags) return xopen3(pathname, flags, 0666); > > } > > > > +// Die if we can't open a file as a given fd. > > +void FAST_FUNC xopen_fd(const char *pathname, int flags, int fd) > > +{ > > + return xmove_fd(xopen(pathname, flags), fd); > > +} > > + > > // Warn if we can't open a file and return a fd. > > int FAST_FUNC open3_or_warn(const char *pathname, int flags, int > > mode) { > > -- > > 2.29.2 Hi, maybe xopen_pathname() ? Ciao, Tito _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
