Skip to content

Commit

Permalink
Simplify server info initialization
Browse files Browse the repository at this point in the history
Use sc_read16be() to read 16-bit integer fields.
  • Loading branch information
rom1v committed Feb 3, 2023
1 parent 87972e2 commit f70f6cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <SDL2/SDL_platform.h>

#include "adb/adb.h"
#include "util/binary.h"
#include "util/file.h"
#include "util/log.h"
#include "util/net_intr.h"
Expand Down Expand Up @@ -398,10 +399,9 @@ device_read_info(struct sc_intr *intr, sc_socket device_socket,
buf[SC_DEVICE_NAME_FIELD_LENGTH - 1] = '\0';
memcpy(info->device_name, (char *) buf, sizeof(info->device_name));

info->frame_size.width = (buf[SC_DEVICE_NAME_FIELD_LENGTH] << 8)
| buf[SC_DEVICE_NAME_FIELD_LENGTH + 1];
info->frame_size.height = (buf[SC_DEVICE_NAME_FIELD_LENGTH + 2] << 8)
| buf[SC_DEVICE_NAME_FIELD_LENGTH + 3];
unsigned char *fields = &buf[SC_DEVICE_NAME_FIELD_LENGTH];
info->frame_size.width = sc_read16be(fields);
info->frame_size.height = sc_read16be(&fields[2]);
return true;
}

Expand Down

0 comments on commit f70f6cd

Please sign in to comment.