Simplify server info initialization

Use sc_read16be() to read 16-bit integer fields.
This commit is contained in:
Romain Vimont 2023-02-02 21:32:17 +01:00
parent 87972e2022
commit f70f6cdd3e

View file

@ -8,6 +8,7 @@
#include <SDL2/SDL_platform.h> #include <SDL2/SDL_platform.h>
#include "adb/adb.h" #include "adb/adb.h"
#include "util/binary.h"
#include "util/file.h" #include "util/file.h"
#include "util/log.h" #include "util/log.h"
#include "util/net_intr.h" #include "util/net_intr.h"
@ -398,10 +399,9 @@ device_read_info(struct sc_intr *intr, sc_socket device_socket,
buf[SC_DEVICE_NAME_FIELD_LENGTH - 1] = '\0'; buf[SC_DEVICE_NAME_FIELD_LENGTH - 1] = '\0';
memcpy(info->device_name, (char *) buf, sizeof(info->device_name)); memcpy(info->device_name, (char *) buf, sizeof(info->device_name));
info->frame_size.width = (buf[SC_DEVICE_NAME_FIELD_LENGTH] << 8) unsigned char *fields = &buf[SC_DEVICE_NAME_FIELD_LENGTH];
| buf[SC_DEVICE_NAME_FIELD_LENGTH + 1]; info->frame_size.width = sc_read16be(fields);
info->frame_size.height = (buf[SC_DEVICE_NAME_FIELD_LENGTH + 2] << 8) info->frame_size.height = sc_read16be(&fields[2]);
| buf[SC_DEVICE_NAME_FIELD_LENGTH + 3];
return true; return true;
} }