Skip to content

Commit

Permalink
fix: pointer warning in client.cpp
Browse files Browse the repository at this point in the history
Fix the warning about pointer arithmetic in `client.cpp`.

* Change the pointer arithmetic in the `segfault` function to use `uintptr_t`.
* Update the comparison `faulting_address < (ptr + sz)` to `(uintptr_t)faulting_address < ((uintptr_t)ptr + sz)`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/kevmo314/scuda?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
kevmo314 committed Jan 11, 2025
1 parent 4418ca0 commit 5eed3c7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions client.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <arpa/inet.h>
#include <cstring>
#include <cuda.h>
Expand Down Expand Up @@ -59,7 +58,7 @@ static void segfault(int sig, siginfo_t *info, void *unused) {
faulting_address = info->si_addr;

for (const auto &[ptr, sz] : conns[0].unified_devices) {
if (ptr <= faulting_address && faulting_address < (ptr + sz)) {
if ((uintptr_t)ptr <= (uintptr_t)faulting_address && (uintptr_t)faulting_address < ((uintptr_t)ptr + sz)) {
// ensure we assign memory as close to the faulting address as possible...
// by masking via the allocated unified memory size.
uintptr_t aligned = (uintptr_t)faulting_address & ~(sz - 1);
Expand Down

0 comments on commit 5eed3c7

Please sign in to comment.