Skip to content

Commit 5f5b2f2

Browse files
jk-ozlabsJunYe1993
authored andcommitted
tests: minor fixes for event-timers code
Avoid a couple of magic numbers, and wrap the .py at 80. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
1 parent 0bdcf01 commit 5f5b2f2

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
@@ -1143,7 +1143,9 @@ async def run(self):
11431143

11441144
# timed out
11451145
if scope.cancelled_caught:
1146-
await self.sock.send(struct.pack('@Q', math.floor(trio.current_time() * 1000000)))
1146+
data = struct.pack('@Q',
1147+
math.floor(trio.current_time() * 1000000))
1148+
await self.sock.send(data)
11471149
self.delay = sys.maxsize
11481150
except (ConnectionResetError, BrokenPipeError) as ex:
11491151
break

0 commit comments

Comments
 (0)