Skip to content

Commit

Permalink
In printf, use %d instead of %i
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Jan 28, 2024
1 parent 157ee5f commit fec8e44
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions STYLE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ not erroneous.)
The first statement in main(), after variable declarations, should be
"WARNP_INIT;" in order to set the program name used for printing warnings.

We use %d rather than %i in printf and warn0/warnp strings.

In general, functions should be structured with one return statement per
status, e.g., one return() for success and one return() for failure. Errors
should be handled by using goto to enter the error return path, e.g.,
Expand Down
2 changes: 1 addition & 1 deletion libcperciva/http/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ gotheaders(struct http_cookie * H, uint8_t * buf, size_t buflen)
return (fail(H));
}
if ((H->res.status < 100) || (H->res.status > 599)) {
warn0("Invalid HTTP status code: %i", H->res.status);
warn0("Invalid HTTP status code: %d", H->res.status);
return (fail(H));
}

Expand Down
4 changes: 2 additions & 2 deletions tests/python/dump_lbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def main():
print("No data in the LBS server.")
lbs.shutdown()
exit(0)
print("lbs has next_block %i, last_block %i" % (next_block, last_block))
print("lbs has next_block %d, last_block %d" % (next_block, last_block))

# Print data from blocks
print("------")
for i in range(last_block + 1):
status, data = proto_lbs.get(i)
if status == 0:
print("block %i:" % i)
print("block %d:" % i)
print(data)
print("------")

Expand Down
2 changes: 1 addition & 1 deletion tests/python/kivaloo/proto_lbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def append(self, nums, start, blocks):
if not isinstance(blocks, bytes):
raise NotBinaryData()
if len(blocks) % self.block_size != 0:
raise Exception("wire append: Invalid blocksize: %i" % len(blocks))
raise Exception("wire append: Invalid blocksize: %d" % len(blocks))
num_bytes = self.block_size * nums
reply = self.wire.send_recv('>IIQ%ds' % (num_bytes),
0x02, nums, start, blocks)
Expand Down
8 changes: 4 additions & 4 deletions tests/python/kivaloo/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _start(self):
cls = type(self)

if cls.proc:
logging.info("Server %s, pid %i: exists; reusing", self.cmd[0],
logging.info("Server %s, pid %d: exists; reusing", self.cmd[0],
self.get_pid_from_file())
return
proc_unowned = self._search_for_process()
Expand All @@ -95,14 +95,14 @@ def _start(self):
# Check for server fail
ret = cls.proc.wait()
if ret is not 0:
msg = "Error when running:\n%s\n\texitcode: %i, stderr:\n%s" % (
msg = "Error when running:\n%s\n\texitcode: %d, stderr:\n%s" % (
" ".join(self.cmd), ret, self.get_stderr())
# We don't have a running server
cls.proc = None
raise StartError(msg)

# Get server's daemon-forked pid
logging.info("Server %s, pid %i: started", self.cmd[0],
logging.info("Server %s, pid %d: started", self.cmd[0],
self.get_pid_from_file())

def get_stderr(self):
Expand Down Expand Up @@ -165,7 +165,7 @@ class Server_lbs(Server):
disk = os.path.join(_KIVALOO_TEST_DIR, _DISK_LBS)
# Constants for Server
sock = LBS_SOCK
cmd = ("%s -s %s -d %s -b %i" % (_BIN_LBS, sock, disk,
cmd = ("%s -s %s -d %s -b %d" % (_BIN_LBS, sock, disk,
LBS_BLOCKSIZE)).split()
pidfile = sock + ".pid"
# Variable shared between all Server_lbs objects
Expand Down
2 changes: 1 addition & 1 deletion tests/shared_test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ wait_while() {
while "$@"; do
# Notify user (if desired)
if [ "${VERBOSE}" -ne 0 ]; then
printf "waited\t%ims\t%s\n" \
printf "waited\t%dms\t%s\n" \
"${_wait_while_ms}" "$*" 1>&2
fi

Expand Down
2 changes: 1 addition & 1 deletion tests/shared_valgrind_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ _val_generalize() {
_val_generalize_i=1
while [ "${_val_generalize_i}" -le "${_val_generalize_num_segments}" ]; do
# Process segment
_val_seg "$(printf "%s%02i" \
_val_seg "$(printf "%s%02d" \
"${_val_generalize_filename}" "${_val_generalize_i}")"

# Advance to the next suppression.
Expand Down

0 comments on commit fec8e44

Please sign in to comment.