Skip to content

Commit

Permalink
Fix some compiler warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Zoltan Fridrich <[email protected]>
  • Loading branch information
ZoltanFridrich committed Mar 4, 2024
1 parent 7756404 commit 81c9e74
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ p11_dl_error (void)
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&msg_buf, 0, NULL);

if (msg_buf == NULL);
if (msg_buf == NULL)
return NULL;

result = strdup (msg_buf);
Expand Down
8 changes: 4 additions & 4 deletions common/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,19 @@ p11_lexer_msg (p11_lexer *lexer,

switch (lexer->tok_type) {
case TOK_FIELD:
p11_message ("%s:%zu: %s: %s", lexer->filename, lexer->line,
p11_message ("%s:%lu: %s: %s", lexer->filename, lexer->line,
lexer->tok.field.name, msg);
break;
case TOK_SECTION:
p11_message ("%s:%zu: [%s]: %s", lexer->filename, lexer->line,
p11_message ("%s:%lu: [%s]: %s", lexer->filename, lexer->line,
lexer->tok.section.name, msg);
break;
case TOK_PEM:
p11_message ("%s:%zu: BEGIN ...: %s", lexer->filename,
p11_message ("%s:%lu: BEGIN ...: %s", lexer->filename,
lexer->line, msg);
break;
default:
p11_message ("%s:%zu: %s", lexer->filename, lexer->line, msg);
p11_message ("%s:%lu: %s", lexer->filename, lexer->line, msg);
break;
}

Expand Down
106 changes: 106 additions & 0 deletions common/test-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/sh

set -euf

# -----------------------------------------------------------------------------
# Basic fundamentals

prefix=/usr/local
exec_prefix=${prefix}
datarootdir=${prefix}/share
datadir=${datarootdir}
sysconfdir=${prefix}/etc
libdir=${exec_prefix}/lib
libexecdir=${exec_prefix}/libexec
privatedir=${libexecdir}/p11-kit
with_trust_paths=/etc/pki/tls/certs/ca-bundle.crt
script=$(basename $0)

# -----------------------------------------------------------------------------
# Testing

warning()
{
echo "$script: $@" >&2
}

assert_fail()
{
warning $@
exit 1
}

assert_contains()
{
if ! grep -qF "$2" "$1"; then
assert_fail "$1 does not contain $2"
fi
}

assert_not_contains()
{
if grep -qF "$2" "$1"; then
assert_fail "$1 contains $2"
fi
}

teardown()
{
:
}

teardown_dirty()
{
echo "not ok $TEST_NUMBER $TEST_NAME"
teardown
}

skip()
{
TEST_SKIP=yes
echo "ok $TEST_NUMBER # skip $TEST_NAME: $@"
}

setup()
{
:
}

run()
{
TOTAL=0
for TEST_NAME in $@; do
TOTAL=$(expr $TOTAL + 1)
done

echo "1..$TOTAL"

TEST_NUMBER=0
for TEST_NAME in $@; do
TEST_NUMBER=$(expr $TEST_NUMBER + 1)
(
trap teardown_dirty EXIT
trap "teardown_dirty; exit 127" INT TERM
TD=""

PATH="$exec_prefix/bin:$PATH"
export PATH

PKG_CONFIG_PATH="$libdir/pkgconfig:$datadir/pkgconfig"
export PKG_CONFIG_PATH

TEST_SKIP=no
setup

if [ $TEST_SKIP != "yes" ]; then
$TEST_NAME
fi
if [ $TEST_SKIP != "yes" ]; then
echo "ok $TEST_NUMBER $TEST_NAME"
fi

trap - EXIT
teardown
)
done
}
2 changes: 1 addition & 1 deletion p11-kit/rpc-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ rpc_C_Initialize (CK_X_FUNCTION_LIST *self,
if (ret != CKR_OK) {
assert (module->vtable->disconnect != NULL);
(module->vtable->disconnect) (module->vtable, reserved);
ret = (module->vtable->connect) (module->vtable, reserved);
(module->vtable->connect) (module->vtable, reserved);

module->version = 0;
ret = (module->vtable->authenticate) (module->vtable,
Expand Down

0 comments on commit 81c9e74

Please sign in to comment.