Skip to content

Commit

Permalink
Merge pull request #496 from Tarsnap/misc
Browse files Browse the repository at this point in the history
Misc
  • Loading branch information
cperciva authored Sep 21, 2023
2 parents 3b2e076 + 38e07b4 commit 2c934c7
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 17 deletions.
4 changes: 4 additions & 0 deletions POSIX/posix-abstract-declarator.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ func(int arr[static restrict 1])
{

(void)arr; /* UNUSED */

/* Success! */
return (0);
}

Expand All @@ -17,5 +19,7 @@ main(void)
{

(void)func; /* UNUSED */

/* Success! */
return (0);
}
6 changes: 0 additions & 6 deletions POSIX/posix-cflags-filter.c

This file was deleted.

4 changes: 2 additions & 2 deletions POSIX/posix-cflags-filter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ fi
# Find directory of this script and the source files
D=$(dirname "$0")

if ! ${CC} -O2 "${D}/posix-cflags-filter.c" 2>/dev/null; then
if ${CC} "${D}/posix-cflags-filter.c" 2>/dev/null; then
if ! ${CC} -O2 "${D}/posix-trivial.c" 2>/dev/null; then
if ${CC} "${D}/posix-trivial.c" 2>/dev/null; then
echo 'CFLAGS_FILTERED=""'
echo 'for OPT in $CFLAGS; do'
echo ' if [ "$OPT" = "-O2" ]; then'
Expand Down
1 change: 1 addition & 0 deletions POSIX/posix-stat-st_mtim.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ main(void)
/* Can we reference st_mtim? */
(void)sb.st_mtim.tv_sec;

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions POSIX/posix-trivial.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ int
main(void)
{

/* Success! */
return (0);
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ libcperciva
-----------

BSD-licensed C99/POSIX library code shared between tarsnap, scrypt, kivaloo,
spiped, and bsdiff. I do not intend to create packaged releases of this code
spiped, and bsdiff. I do not intend to create packaged releases of this code
directly; it's here just to simplify the work of keeping the projects which use
it in sync.
2 changes: 2 additions & 0 deletions apisupport/Build/apisupport-LIBSSL-HOST_NAME.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ main(void)
const char * hostname = "myhostname";

(void)SSL_set_tlsext_host_name(NULL, hostname);

/* Success! */
return (0);
}
2 changes: 2 additions & 0 deletions apisupport/Build/apisupport-NONPOSIX-SETGROUPS.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ main(void)
{

(void)setgroups(0, NULL);

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions cpusupport/Build/cpusupport-ARM-AES.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ main(void)

lanes = vdupq_laneq_u32(lanes, 0);

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions cpusupport/Build/cpusupport-ARM-CRC32_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ main(void)
state = __crc32b(state, x);
state = __crc32cd(state, *(const uint64_t *)&buf[0]);

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions cpusupport/Build/cpusupport-ARM-SHA256.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ main(void)
output = vsha256su0q_u32(w0, w4);
(void)output; /* UNUSED */

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions crypto/crypto_aesctr_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ crypto_aesctr_stream_pre_wholeblock(struct crypto_aesctr * stream,
buflen_p, 16 - bytemod, bytemod);
}

/* Success! */
return (0);
}

Expand Down
1 change: 1 addition & 0 deletions tests/buildall/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ main(int argc, char * argv[])
(void) argc;
(void) argv;

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions tests/buildsingles/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ main(int argc, char * argv[])
(void) argc;
(void) argv;

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions tests/getopt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@ main(int argc, char * argv[])
(void)argc;
(void)argv;

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions tests/heap/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ main(int argc, char * argv[])
/* Free the heap. */
ptrheap_free(H);

/* Success! */
return (0);
}
29 changes: 25 additions & 4 deletions tests/shared_valgrind_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ set -o noclobber -o nounset
# - valgrind_init():
# Clear previous valgrind output, and prepare for running valgrind tests
# (if applicable).
# - valgrind_setup_cmd():
# - valgrind_setup_cmd(str):
# Set up the valgrind command if ${USE_VALGRIND} is greater than or equal to
# ${valgrind_min}.
# ${valgrind_min}. If ${str} is not blank, include it in the log filename.
# - valgrind_check_basenames(exitfile):
# Check for any memory leaks recorded in valgrind logfiles associated with a
# test exitfile. Return the filename if there's a leak; otherwise return an
Expand Down Expand Up @@ -203,6 +203,7 @@ _valgrind_ensure_suppression() {
printf "\n" | (valgrind \
--leak-check=full --show-leak-kinds=all \
--gen-suppressions=all \
--trace-children=yes \
--suppressions="${valgrind_suppressions}" \
--log-file="${this_valgrind_supp}" \
"${potential_memleaks_binary}" \
Expand All @@ -224,17 +225,27 @@ _valgrind_ensure_suppression() {

## valgrind_setup_cmd ():
# Set up the valgrind command if ${USE_VALGRIND} is greater than or equal to
# ${valgrind_min}.
# ${valgrind_min}. If ${str} is not blank, include it in the log filename.
valgrind_setup_cmd() {
str=${1:-}

# Bail if we don't want to use valgrind for this check.
if [ "${USE_VALGRIND}" -lt "${c_valgrind_min}" ]; then
return
fi

val_logfilename="${s_val_basename}-${c_count_str}-%p.log"
# Set up the log filename.
if [ -n "${str}" ]; then
val_logfilename="${s_val_basename}-${c_count_str}-${str}-%p.log"
else
val_logfilename="${s_val_basename}-${c_count_str}-%p.log"
fi

# Set up valgrind command.
c_valgrind_cmd="valgrind \
--log-file=${val_logfilename} \
--track-fds=yes \
--trace-children=yes \
--leak-check=full --show-leak-kinds=all \
--errors-for-leak-kinds=all \
--suppressions=${valgrind_suppressions}"
Expand Down Expand Up @@ -345,6 +356,16 @@ valgrind_check_basenames() {
return
fi

# If the valgrind logfiles contain "-valgrind-parent-", then we only
# want to check the parent (the lowest pid).
for logfile in ${logfiles} ; do
if [ "${logfile#*-valgrind-parent-}" != "${logfile}" ]; then
# Only check the parent
valgrind_check_logfile "${logfile}"
return "$?"
fi
done

# If there's two files, there's a fork() -- likely within
# daemonize() -- so only pay attention to the child.
if [ "${num_logfiles}" -eq "2" ]; then
Expand Down
1 change: 1 addition & 0 deletions tests/sysendian/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ perftest_func(void * cookie, uint8_t * buf, size_t buflen, size_t nreps)
PERFTEST_FULL(tests, 64);
}

/* Success! */
return (0);
}

Expand Down
4 changes: 2 additions & 2 deletions util/monoclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ monoclock_get_cputime(struct timeval * tv)

/**
* monoclock_getres(resd):
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC is
* available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC
* is available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* CLOCK_REALTIME (if available) or gettimeofday(2). For this value to be
* meaningful, we assume that clock_getres(x) succeeds iff clock_gettime(x)
* succeeds.
Expand Down
4 changes: 2 additions & 2 deletions util/monoclock.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ int monoclock_get_cputime(struct timeval *);

/**
* monoclock_getres(resd):
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC is
* available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC
* is available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* CLOCK_REALTIME (if available) or gettimeofday(2). For this value to be
* meaningful, we assume that clock_getres(x) succeeds iff clock_gettime(x)
* succeeds.
Expand Down

0 comments on commit 2c934c7

Please sign in to comment.