From c56f67e5d0844c92823c7c9aa1a1222cf6daf22a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 8 Apr 2022 14:22:11 -0400 Subject: [PATCH] Build fix: poll compatibility mode: zmalloc prototype changed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The build fails on platforms that don't support the epoll system call (or when building with --disable-epoll on Linux): compat/poll.cpp:458:35: error: no matching function for call to 'zmalloc' wait->events = (struct pollfd *) zmalloc(size * sizeof(struct pollfd)); ^~~~~~~ ./macros.hpp:85:4: note: candidate template ignored: couldn't infer template argument 'T' T *zmalloc(size_t size) ^ ./macros.hpp:74:4: note: candidate function template not viable: requires 0 arguments, but 1 was provided T *zmalloc() ^ compat/poll.cpp:466:38: error: no matching function for call to 'zmalloc' current->events = (struct pollfd *) zmalloc(size * sizeof(struct pollfd)); ^~~~~~~ ./macros.hpp:85:4: note: candidate template ignored: couldn't infer template argument 'T' T *zmalloc(size_t size) ^ ./macros.hpp:74:4: note: candidate function template not viable: requires 0 arguments, but 1 was provided T *zmalloc() Replace the uses of "old style" malloc with the new type-safe function introduced recently. Signed-off-by: Jérémie Galarneau Change-Id: Ib1660f6a548c155f021843b7476d5d64c06c6e5a --- src/common/compat/poll.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/compat/poll.cpp b/src/common/compat/poll.cpp index 0617905a6..dfe05d59e 100644 --- a/src/common/compat/poll.cpp +++ b/src/common/compat/poll.cpp @@ -455,17 +455,17 @@ int compat_poll_create(struct lttng_poll_event *events, int size) wait = &events->wait; /* This *must* be freed by using lttng_poll_free() */ - wait->events = (struct pollfd *) zmalloc(size * sizeof(struct pollfd)); + wait->events = calloc(size); if (wait->events == NULL) { - PERROR("zmalloc struct pollfd"); + PERROR("Failed to allocate wait events array during poll initialization"); goto error; } wait->alloc_size = wait->init_size = size; - current->events = (struct pollfd *) zmalloc(size * sizeof(struct pollfd)); + current->events = calloc(size); if (current->events == NULL) { - PERROR("zmalloc struct current pollfd"); + PERROR("Failed to allocate current events array during poll initialization"); goto error; } -- 2.34.1