Skip to content

Commit

Permalink
build with -Werror, make some warnings go away
Browse files Browse the repository at this point in the history
  • Loading branch information
arekinath committed Jan 30, 2024
1 parent bd26c98 commit 165ca9e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 42 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ INSTALLBIN ?= $(INSTALL) -o $(binowner) -g $(bingroup) -m 0755

SECURITY_CFLAGS = \
-fstack-protector-all -fwrapv -fPIC \
-D_FORTIFY_SOURCE=2 -Wall -g -O2 -gdwarf-2
-D_FORTIFY_SOURCE=2 -Wall -g -O2 -gdwarf-2 -Werror

SYSTEM := $(shell uname -s)
ifeq ($(SYSTEM), Linux)
Expand All @@ -64,7 +64,7 @@ ifeq ($(SYSTEM), Linux)
ifneq (,$(LIBZFS_VER))
HAVE_ZFS := $(USE_ZFS)
LIBZFS_CFLAGS = $(shell pkg-config --cflags libzfs)
LIBZFS_CFLAGS += -DUSING_SPL
LIBZFS_CFLAGS += -DUSING_SPL -Wno-macro-redefined
LIBZFS_LIBS = $(shell pkg-config --libs libzfs) -lnvpair
else
HAVE_ZFS := no
Expand Down Expand Up @@ -437,7 +437,7 @@ PIVYCA_CFLAGS= $(PCSC_CFLAGS) \
$(OPTIM_CFLAGS) \
$(SECURITY_CFLAGS) \
$(CONFIG_CFLAGS) \
-O0 -g -gdwarf-2 -D_GNU_SOURCE \
-g -gdwarf-2 -D_GNU_SOURCE \
-DPIVY_VERSION='"$(VERSION)"'
PIVYCA_LDFLAGS= $(SYSTEM_LDFLAGS) \
$(OPTIM_LDFLAGS)
Expand Down
30 changes: 8 additions & 22 deletions piv-ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
/* We need the piv_cert_comp enum */
#include "piv-internal.h"

#if !defined(JSONC_14)
size_t
json_tokener_get_parse_end(struct json_tokener *tok)
{
return ((size_t)tok->char_offset);
}
#endif

struct ca_uri {
struct ca_uri *cu_next;
char *cu_uri;
Expand Down Expand Up @@ -1417,21 +1425,6 @@ calc_cert_slug_X509(X509 *cert)
return (ret);
}

static char *
calc_cert_slug_X509_REQ(X509_REQ *req, BIGNUM *serial)
{
X509_NAME *subj;
STACK_OF(X509_EXTENSION) *exts;
char *ret;

exts = X509_REQ_get_extensions(req);
subj = X509_REQ_get_subject_name(req);

ret = calc_cert_slug(subj, exts, serial);

return (ret);
}

static void
ca_recalc_slug(struct ca *ca)
{
Expand Down Expand Up @@ -5442,10 +5435,3 @@ ca_aia_uri_add(struct ca *ca, const char *uri)
return (errf("NotImplemented", NULL, "Not implemented"));
}

#if !defined(JSONC_14)
size_t
json_tokener_get_parse_end(struct json_tokener *tok)
{
return ((size_t)tok->char_offset);
}
#endif
4 changes: 0 additions & 4 deletions piv-ca.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,4 @@ errf_t *ca_token_provision(struct ca_session *sess, struct ca_token_tpl *tpl,
errf_t *parse_dn(const char *dnstr, X509_NAME *name);
errf_t *unparse_dn(X509_NAME *name, char **out);

#if !defined(JSONC_14)
size_t json_tokener_get_parse_end(struct json_tokener *tok);
#endif

#endif
22 changes: 13 additions & 9 deletions pivy-zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ cmd_unlock(const char *fsname)
{
zfs_handle_t *ds;
nvlist_t *props, *prop;
char *b64, *description;
char *description;
const char *b64;
char *nb64;
struct sshbuf *buf;
struct ebox *ebox, *nebox;
struct ebox_tpl *ntpl;
Expand Down Expand Up @@ -363,16 +365,16 @@ cmd_unlock(const char *fsname)
if (error)
errfx(EXIT_ERROR, error, "sshbuf_put_ebox failed");

b64 = sshbuf_dtob64_string(buf, 0);
nb64 = sshbuf_dtob64_string(buf, 0);

rc = zfs_prop_set(ds, "rfd77:ebox", b64);
rc = zfs_prop_set(ds, "rfd77:ebox", nb64);
if (rc != 0) {
errno = rc;
err(EXIT_ERROR, "failed to set ZFS property rfd77:ebox "
"on dataset %s", fsname);
}

free(b64);
free(nb64);
ebox_tpl_free(ntpl);
}

Expand All @@ -387,7 +389,9 @@ cmd_rekey(const char *fsname)
{
zfs_handle_t *ds;
nvlist_t *props, *prop;
char *b64, *description;
char *description;
const char *b64;
char *nb64;
struct sshbuf *buf;
struct ebox *ebox = NULL, *nebox;
size_t desclen;
Expand Down Expand Up @@ -513,7 +517,7 @@ cmd_rekey(const char *fsname)
if (error)
errfx(EXIT_ERROR, error, "sshbuf_put_ebox failed");

b64 = sshbuf_dtob64_string(buf, 0);
nb64 = sshbuf_dtob64_string(buf, 0);

/*
* To change the wrapping key in a way that's safe against us dying or
Expand All @@ -527,7 +531,7 @@ cmd_rekey(const char *fsname)
* PROP_RFD77 and delete PROP_RFD77_TEMP.
*/
#if defined(DMU_OT_ENCRYPTED)
rc = zfs_prop_set(ds, PROP_RFD77_TEMP, b64);
rc = zfs_prop_set(ds, PROP_RFD77_TEMP, nb64);
if (rc != 0) {
errno = rc;
err(EXIT_ERROR, "failed to set temporary ZFS property "
Expand All @@ -543,7 +547,7 @@ cmd_rekey(const char *fsname)
nvlist_free(nprops);
#endif

rc = zfs_prop_set(ds, propname, b64);
rc = zfs_prop_set(ds, propname, nb64);
if (rc != 0) {
errno = rc;
err(EXIT_ERROR, "failed to set ZFS property %s on dataset %s",
Expand All @@ -559,7 +563,7 @@ cmd_rekey(const char *fsname)
}
#endif

free(b64);
free(nb64);

sshbuf_free(buf);
ebox_free(ebox);
Expand Down
12 changes: 8 additions & 4 deletions readpassphrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
(void)sigaction(SIGTTIN, &sa, &savettin);
(void)sigaction(SIGTTOU, &sa, &savettou);

if (!(flags & RPP_STDIN))
(void)write(output, prompt, strlen(prompt));
if (!(flags & RPP_STDIN)) {
ssize_t nw = write(output, prompt, strlen(prompt));
(void)nw;
}
end = buf + bufsiz - 1;
p = buf;
while ((nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') {
Expand All @@ -153,8 +155,10 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
}
*p = '\0';
save_errno = errno;
if (!(term.c_lflag & ECHO))
(void)write(output, "\n", 1);
if (!(term.c_lflag & ECHO)) {
ssize_t nw = write(output, "\n", 1);
(void)nw;
}

/* Restore old terminal settings and signals. */
if (memcmp(&term, &oterm, sizeof(term)) != 0) {
Expand Down

0 comments on commit 165ca9e

Please sign in to comment.