The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/remote: Fix warnings reported by clang (17) about some wrong printf formats.

+32 -20
+32 -20
src/xrt/drivers/remote/r_hub.c
··· 40 40 #define __USE_MISC // SOL_TCP on C11 41 41 #endif 42 42 43 + // Define the format to use to print a socket descriptor 44 + #ifdef XRT_OS_WINDOWS 45 + // On Windows, this is a SOCKET, aka an unsigned long long 46 + #define R_SOCKET_FMT "%llu" 47 + #else 48 + // On non-Windows, this is a file descriptor, aka an int 49 + #define R_SOCKET_FMT "%i" 50 + #endif 51 + 43 52 44 53 /* 45 54 * ··· 150 159 WSADATA wsaData; 151 160 if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { 152 161 int error = WSAGetLastError(); 153 - R_ERROR(r, "Failed to do WSAStartup %ld", error); 162 + R_ERROR(r, "Failed to do WSAStartup %d", error); 154 163 return error; 155 164 } 156 165 #endif 157 - SOCKET ret = socket_create(); 166 + r_socket_t ret = socket_create(); 158 167 159 168 if (ret < 0) { 160 - R_ERROR(r, "socket: %i", ret); 169 + R_ERROR(r, "socket: " R_SOCKET_FMT, ret); 161 170 goto cleanup; 162 171 } 163 172 ··· 166 175 int flag = 1; 167 176 ret = socket_set_opt(r->accept_fd, flag); 168 177 if (ret < 0) { 169 - R_ERROR(r, "setsockopt: %i", ret); 178 + R_ERROR(r, "setsockopt: " R_SOCKET_FMT, ret); 170 179 socket_close(r->accept_fd); 171 180 r->accept_fd = -1; 172 181 goto cleanup; ··· 178 187 179 188 ret = bind(r->accept_fd, (struct sockaddr *)&server_address, sizeof(server_address)); 180 189 if (ret < 0) { 181 - R_ERROR(r, "bind: %i", ret); 190 + R_ERROR(r, "bind: " R_SOCKET_FMT, ret); 182 191 socket_close(r->accept_fd); 183 192 r->accept_fd = -1; 184 193 goto cleanup; ··· 234 243 struct sockaddr_in addr = {0}; 235 244 r_socket_t ret = 0; 236 245 if (!wait_for_read_and_to_continue(r, r->accept_fd)) { 237 - R_ERROR(r, "Failed to wait for id %d", r->accept_fd); 246 + R_ERROR(r, "Failed to wait for id " R_SOCKET_FMT, r->accept_fd); 238 247 return -1; 239 248 } 240 249 241 250 socklen_t addr_length = (socklen_t)sizeof(addr); 242 251 ret = accept(r->accept_fd, (struct sockaddr *)&addr, &addr_length); 243 252 if (ret < 0) { 244 - R_ERROR(r, "accept: %i", ret); 253 + R_ERROR(r, "accept: " R_SOCKET_FMT, ret); 245 254 return ret; 246 255 } 247 256 ··· 250 259 int flags = 1; 251 260 ret = socket_set_opt(r->accept_fd, flags); 252 261 if (ret < 0) { 253 - R_ERROR(r, "setsockopt: %i", ret); 262 + R_ERROR(r, "setsockopt: " R_SOCKET_FMT, ret); 254 263 socket_close(conn_fd); 255 264 return ret; 256 265 } 257 266 258 267 r->rc.fd = conn_fd; 259 268 260 - R_INFO(r, "Connection received! %i", r->rc.fd); 269 + R_INFO(r, "Connection received! " R_SOCKET_FMT, r->rc.fd); 261 270 262 271 return 0; 263 272 } ··· 280 289 ssize_t ret = socket_read(rc->fd, ptr, size, current); 281 290 if (ret < 0) { 282 291 #if defined(XRT_OS_WINDOWS) 283 - RC_ERROR(rc, "recv: %zi", WSAGetLastError()); 292 + RC_ERROR(rc, "recv: %i", WSAGetLastError()); 284 293 #else 285 294 RC_ERROR(rc, "read: %zi", ret); 286 295 #endif ··· 548 557 WSADATA wsaData; 549 558 ret = WSAStartup(MAKEWORD(2, 2), &wsaData); 550 559 if (ret != 0) { 551 - RC_ERROR(rc, "Failed to do WSAStartup %ld", WSAGetLastError()); 560 + RC_ERROR(rc, "Failed to do WSAStartup %i", WSAGetLastError()); 552 561 return ret; 553 562 } 554 563 #endif ··· 569 578 goto cleanup; 570 579 } 571 580 572 - ret = socket_create(); 573 - if (ret < 0) { 581 + sock_fd = socket_create(); 574 582 #if defined(XRT_OS_WINDOWS) 575 - RC_ERROR(rc, "Failed to create socket %ld", WSAGetLastError()); 583 + if (sock_fd == INVALID_SOCKET) { 584 + RC_ERROR(rc, "Failed to create socket %i", WSAGetLastError()); 585 + goto cleanup; 586 + } 576 587 #else 588 + if (sock_fd < 0) { 577 589 RC_ERROR(rc, "Failed to create socket: %i", ret); 578 - #endif 579 590 goto cleanup; 580 591 } 592 + #endif 581 593 582 - conn_fd = ret; 594 + conn_fd = sock_fd; 583 595 584 596 ret = connect(conn_fd, (struct sockaddr *)&addr, sizeof(addr)); 585 597 // If connect operation succeed, both Windows and POSIX returns 0. 586 598 if (ret != 0) { 587 599 #if defined(XRT_OS_WINDOWS) 588 - RC_ERROR(rc, "Failed to connect id %d and addr %s with failure %d", conn_fd, inet_ntoa(addr.sin_addr), 589 - WSAGetLastError()); 600 + RC_ERROR(rc, "Failed to connect id " R_SOCKET_FMT " and addr %s with failure %d", conn_fd, 601 + inet_ntoa(addr.sin_addr), WSAGetLastError()); 590 602 #else 591 - RC_ERROR(rc, "Failed to connect id %d and addr %s with failure %d", conn_fd, inet_ntoa(addr.sin_addr), 592 - ret); 603 + RC_ERROR(rc, "Failed to connect id " R_SOCKET_FMT " and addr %s with failure %d", conn_fd, 604 + inet_ntoa(addr.sin_addr), ret); 593 605 #endif 594 606 socket_close(conn_fd); 595 607 goto cleanup;