[PATCH 5/6] bup: fix PROC_SELF_EXE -Werror related failures on openbsd

5 views
Skip to first unread message

Rob Browning

unread,
Oct 15, 2023, 3:36:33 PM10/15/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
Apparently the compiler couldn't detect that the variables in the
PROC_SELF_EXE NULL block were unreachable.

Thanks to Julian Smith for reporting the problem.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
lib/cmd/bup.c | 62 +++++++++++++++++++++++++--------------------------
1 file changed, 30 insertions(+), 32 deletions(-)

diff --git a/lib/cmd/bup.c b/lib/cmd/bup.c
index e61f10610..8464525f6 100644
--- a/lib/cmd/bup.c
+++ b/lib/cmd/bup.c
@@ -201,8 +201,6 @@ static char *exe_parent_dir(const char * const argv_0)
# define PROC_SELF_EXE "/proc/self/exe"
#elif defined(__sun) || defined (sun)
# define PROC_SELF_EXE "/proc/self/path/a.out"
-#else
-# define PROC_SELF_EXE NULL
#endif

static char *find_in_path(const char * const name, const char * const path)
@@ -286,40 +284,40 @@ static char *find_exe_parent(const char * const argv_0)

static char *exe_parent_dir(const char * const argv_0)
{
- if (PROC_SELF_EXE != NULL) {
- char sbuf[2048];
- char *path = sbuf;
- size_t path_n = sizeof(sbuf);
- ssize_t len;
- while (1) {
- len = readlink(PROC_SELF_EXE, path, path_n);
- if (len == -1 || (size_t) len != path_n)
- break;
- if (!INT_MULTIPLY_OK(path_n, 2, &path_n))
- die(2, "memory buffer for executable path would be too big\n");
- if (path != sbuf) free(path);
- path = malloc(path_n);
- if (!path)
- die(2, "unable to allocate memory for executable path\n");
- }
- if (len != -1) {
- path[len] = '\0';
- char *result = strdup(dirname(path));
- if (path != sbuf)
- free(path);
- return result;
- }
- switch (errno) {
- case ENOENT: case EACCES: case EINVAL: case ELOOP: case ENOTDIR:
- case ENAMETOOLONG:
- break;
- default:
- die(2, "cannot resolve %s: %s\n", path, strerror(errno));
+#ifdef PROC_SELF_EXE
+ char sbuf[2048];
+ char *path = sbuf;
+ size_t path_n = sizeof(sbuf);
+ ssize_t len;
+ while (1) {
+ len = readlink(PROC_SELF_EXE, path, path_n);
+ if (len == -1 || (size_t) len != path_n)
break;
- }
+ if (!INT_MULTIPLY_OK(path_n, 2, &path_n))
+ die(2, "memory buffer for executable path would be too big\n");
+ if (path != sbuf) free(path);
+ path = malloc(path_n);
+ if (!path)
+ die(2, "unable to allocate memory for executable path\n");
+ }
+ if (len != -1) {
+ path[len] = '\0';
+ char *result = strdup(dirname(path));
if (path != sbuf)
free(path);
+ return result;
+ }
+ switch (errno) {
+ case ENOENT: case EACCES: case EINVAL: case ELOOP: case ENOTDIR:
+ case ENAMETOOLONG:
+ break;
+ default:
+ die(2, "cannot resolve %s: %s\n", path, strerror(errno));
+ break;
}
+ if (path != sbuf)
+ free(path);
+#endif
return find_exe_parent(argv_0);
}

--
2.39.2

Rob Browning

unread,
Oct 15, 2023, 3:36:33 PM10/15/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
Apparently we lost this in the rearrangments since 0.32.

Thanks to Alain Cochard for reporting the problem.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
lib/bup/main.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/bup/main.py b/lib/bup/main.py
index 2e69672b2..385c51395 100755
--- a/lib/bup/main.py
+++ b/lib/bup/main.py
@@ -126,6 +126,7 @@ help_requested = None
do_profile = False
bup_dir = None
args = args[1:]
+subcmd = None
while args:
arg = args[0]
if arg in (b'-?', b'--help'):
@@ -152,7 +153,7 @@ while args:
else:
break

-subcmd = args
+subcmd = subcmd or args

# Make BUP_DIR absolute, so we aren't affected by chdir (i.e. save -C, etc.).
if bup_dir:
--
2.39.2

Rob Browning

unread,
Oct 15, 2023, 3:36:33 PM10/15/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
Pushed to 0.33.x

Thanks

Rob Browning (6):
README: describe how to disable -Werror via ./configure
README: mention that skipped tests are expected
update-checkout-info: simplify check for git tree (don't use git)
Restore support for "bup --version"
bup: fix PROC_SELF_EXE -Werror related failures on openbsd
README: remove fedora package link (gone); reformat others

README.md | 40 ++++++++++++++------------
dev/update-checkout-info | 6 ++--
lib/bup/main.py | 3 +-
lib/cmd/bup.c | 62 +++++++++++++++++++---------------------
4 files changed, 55 insertions(+), 56 deletions(-)

--
2.39.2

Rob Browning

unread,
Oct 15, 2023, 3:36:34 PM10/15/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
Thanks to Alain Cochard for the suggestion.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
README.md | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index fe3abe806..8ccb31974 100644
--- a/README.md
+++ b/README.md
@@ -205,11 +205,12 @@ From source
make -j check
```

- The tests should pass. If they don't pass for you, stop here and
- send an email to bup-...@googlegroups.com. Though if there are
- symbolic links along the current working directory path, the tests
- may fail. Running something like this before "make test" should
- sidestep the problem:
+ The tests should pass (with some skipped tests that weren't
+ applicable in your environment). If they don't pass for you, stop
+ here and send an email to bup-...@googlegroups.com. Though if
+ there are symbolic links along the current working directory path,
+ the tests may fail. Running something like this before "make
+ test" should sidestep the problem:

```sh
cd "$(pwd -P)"
--
2.39.2

Rob Browning

unread,
Oct 15, 2023, 3:36:34 PM10/15/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
Thanks to Julian Smith for reporting the problem.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
README.md | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 390e34411..fe3abe806 100644
--- a/README.md
+++ b/README.md
@@ -176,7 +176,15 @@ From source
```sh
make
```
-
+
+ At the moment the build treats compiler warnings as errors. If the
+ build fails as a result, try this:
+
+ ```sh
+ CFLAGS=-Wno-error ./configure
+ make
+ ```
+
- Run the tests:

```sh
--
2.39.2

Rob Browning

unread,
Oct 15, 2023, 3:36:34 PM10/15/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
The previous rev-parse check would print warnings when there was no
git tree, and since we've already attempted to make sure we're at the
top of a bup tree via the bupsplit.c test, just looking for a ./.git
dir or file (worktrees) should be sufficient.

Thanks to Alain Cochard for reporting the issue.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
dev/update-checkout-info | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/dev/update-checkout-info b/dev/update-checkout-info
index 9fd1a1682..43ff86d3d 100755
--- a/dev/update-checkout-info
+++ b/dev/update-checkout-info
@@ -17,10 +17,8 @@ if ! test -f lib/bup/bupsplit.c; then
exit 1
fi

-git_top=$(git rev-parse --show-toplevel) || true
-if test "$git_top" != "$top"; then
- # Not a checkout, or perhaps we're building from an archive dir
- # unpacked somewhere in the source tree.
+if ! test -e .git; then
+ # Not building from a git tree
rm -f "$dest"
exit 0
fi
--
2.39.2

Rob Browning

unread,
Oct 15, 2023, 3:36:34 PM10/15/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
Thanks to Alain Cochard for reporting the issue.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
README.md | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index 8ccb31974..87b5f91dc 100644
--- a/README.md
+++ b/README.md
@@ -247,19 +247,12 @@ From binary packages

Binary packages of bup are known to be built for the following OSes:

- - Debian:
- http://packages.debian.org/search?searchon=names&keywords=bup
- - Ubuntu:
- http://packages.ubuntu.com/search?searchon=names&keywords=bup
- - pkgsrc (NetBSD, Dragonfly, and others)
- http://pkgsrc.se/sysutils/bup
- http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/sysutils/bup/
- - Arch Linux:
- https://www.archlinux.org/packages/?sort=&q=bup
- - Fedora:
- https://apps.fedoraproject.org/packages/bup
- - macOS (Homebrew):
- https://formulae.brew.sh/formula/bup
+ - [Debian](https://packages.debian.org/bup)
+ - [Ubuntu](https://packages.ubuntu.com/bup)
+ - [pkgsrc.se (NetBSD, Dragonfly, and others)](https://pkgsrc.se/sysutils/bup)
+ - [NetBSD](https://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/sysutils/bup/)
+ - [Arch Linux](https://www.archlinux.org/packages/?sort=&q=bup)
+ - [macOS (Homebrew)](https://formulae.brew.sh/formula/bup)


Using bup
--
2.39.2

Rob Browning

unread,
Nov 26, 2023, 9:26:58 PM11/26/23
to bup-...@googlegroups.com, Alain....@unistra.fr, Julian Smith
Rob Browning <r...@defaultvalue.org> writes:

> Pushed to 0.33.x

...and now to main.
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
Reply all
Reply to author
Forward
0 new messages