Page MenuHomeFreeBSD

zfs: Disable -Wunused-variable for environ in main in zfs_main.c.
ClosedPublic

Authored by jhb on Jan 27 2023, 7:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 19 2024, 2:02 PM
Unknown Object (File)
Mar 8 2024, 12:18 AM
Unknown Object (File)
Mar 8 2024, 12:06 AM
Unknown Object (File)
Feb 26 2024, 11:14 AM
Unknown Object (File)
Dec 24 2023, 4:24 AM
Unknown Object (File)
Dec 20 2023, 8:06 AM
Unknown Object (File)
Nov 1 2023, 4:26 PM
Unknown Object (File)
Oct 11 2023, 1:11 AM

Details

Summary

There is an extern declaration of the global variable environ (which
has no portable header that defines it) that is unused on FreeBSD due
to zfs_setproctitle_init() being a stub.

Reported by: GCC

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Jan 27 2023, 7:00 PM

would it be worth the effort to fix this upstream? something like:

diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 9d48b2b32..2e48ca680 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -8672,7 +8672,6 @@ main(int argc, char **argv)
        int i = 0;
        const char *cmdname;
        char **newargv;
-       extern char **environ;

        (void) setlocale(LC_ALL, "");
        (void) setlocale(LC_NUMERIC, "C");
diff --git a/include/libzutil.h b/include/libzutil.h
index 4d4bddaad..948ac08cd 100644
--- a/include/libzutil.h
+++ b/include/libzutil.h
@@ -183,6 +183,7 @@ _LIBZUTIL_H int printf_color(const char *color, const char *format, ...);
 _LIBZUTIL_H const char *zfs_basename(const char *path);
 _LIBZUTIL_H ssize_t zfs_dirnamelen(const char *path);
 #ifdef __linux__
+extern char **environ;
 _LIBZUTIL_H void zfs_setproctitle_init(int argc, char *argv[], char *envp[]);
 _LIBZUTIL_H void zfs_setproctitle(const char *fmt, ...);
 #else

would it be worth the effort to fix this upstream?

I prefer that if someone's willing to shepherd it in, but in the meantime adding the warning flag is sensible.

This revision is now accepted and ready to land.Jan 27 2023, 9:49 PM

would it be worth the effort to fix this upstream?

I prefer that if someone's willing to shepherd it in, but in the meantime adding the warning flag is sensible.

https://github.com/openzfs/zfs/pull/14441

For now I've merged this change, but it should be reverted once an upstream fix is merged back to main.

Upstream change has been merged in, so it's now just a matter of waiting until it comes back to FreeBSD