Skip to content

Commit 9a7f504

Browse files
committed
tests: minor fixes for event-timers code
Avoid a couple of magic numbers, and wrap the .py at 80. Signed-off-by: Jeremy Kerr <[email protected]>
1 parent 5f38f94 commit 9a7f504

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tests/mctp-ops-test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int wrapped_time_callback(sd_event_source *source, int fd, uint revents,
241241
ssize_t rc;
242242

243243
rc = read(fd, &usec, sizeof(usec));
244-
if (rc != 8)
244+
if (rc != sizeof(usec))
245245
errx(EXIT_FAILURE, "ops protocol error");
246246

247247
rc = wrapud->callback(source, usec, wrapud->userdata);
@@ -269,7 +269,7 @@ static int mctp_op_sd_event_add_time_relative(
269269
return -errno;
270270

271271
rc = write(sd, &usec, sizeof(usec));
272-
if (rc != 8)
272+
if (rc != sizeof(usec))
273273
errx(EXIT_FAILURE, "ops protocol error");
274274

275275
wrapud = malloc(sizeof(*wrapud));

tests/mctpenv/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,9 @@ async def run(self):
11331133

11341134
# timed out
11351135
if scope.cancelled_caught:
1136-
await self.sock.send(struct.pack('@Q', math.floor(trio.current_time() * 1000000)))
1136+
data = struct.pack('@Q',
1137+
math.floor(trio.current_time() * 1000000))
1138+
await self.sock.send(data)
11371139
self.delay = sys.maxsize
11381140
except (ConnectionResetError, BrokenPipeError) as ex:
11391141
break

0 commit comments

Comments
 (0)