1
0
mirror of https://github.com/pumpitupdev/pumptools.git synced 2024-11-23 22:50:56 +01:00

Code format

This commit is contained in:
icex2 2023-03-02 19:09:18 +01:00
parent e25d52c293
commit 94529e1e04
26 changed files with 166 additions and 143 deletions

View File

@ -202,7 +202,7 @@ enum cnh_result cnh_iobuf_write_be16(struct cnh_iobuf *dest, uint16_t value)
return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER;
}
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
dest->bytes[dest->pos++] = (uint8_t) value;
return CNH_RESULT_SUCCESS;
@ -216,9 +216,9 @@ enum cnh_result cnh_iobuf_write_be32(struct cnh_iobuf *dest, uint32_t value)
return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER;
}
dest->bytes[dest->pos++] = (uint8_t)(value >> 24);
dest->bytes[dest->pos++] = (uint8_t)(value >> 16);
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
dest->bytes[dest->pos++] = (uint8_t) (value >> 24);
dest->bytes[dest->pos++] = (uint8_t) (value >> 16);
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
dest->bytes[dest->pos++] = (uint8_t) value;
return CNH_RESULT_SUCCESS;
@ -233,7 +233,7 @@ enum cnh_result cnh_iobuf_write_le16(struct cnh_iobuf *dest, uint16_t value)
}
dest->bytes[dest->pos++] = (uint8_t) value;
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
return CNH_RESULT_SUCCESS;
}
@ -247,9 +247,9 @@ enum cnh_result cnh_iobuf_write_le32(struct cnh_iobuf *dest, uint32_t value)
}
dest->bytes[dest->pos++] = (uint8_t) value;
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
dest->bytes[dest->pos++] = (uint8_t)(value >> 16);
dest->bytes[dest->pos++] = (uint8_t)(value >> 24);
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
dest->bytes[dest->pos++] = (uint8_t) (value >> 16);
dest->bytes[dest->pos++] = (uint8_t) (value >> 24);
return CNH_RESULT_SUCCESS;
}

View File

@ -27,7 +27,7 @@
#define LIB_MAIN_TRAP_MAIN(func_before_main, func_after_main) \
typedef int (*func_libc_start_main_t)( \
int *(main)(int, char **, char **), \
int *(main) (int, char **, char **), \
int argc, \
char **ubp_av, \
void (*init)(void), \
@ -58,7 +58,7 @@
} \
\
int __libc_start_main( \
int *(main)(int, char **, char **), \
int *(main) (int, char **, char **), \
int argc, \
char **ubp_av, \
void (*init)(void), \

View File

@ -69,25 +69,25 @@ Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) \
{ \
(a) += F((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) += F((b), (c), (d)) + (x) + (uint32_t) (ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) \
{ \
(a) += G((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) += G((b), (c), (d)) + (x) + (uint32_t) (ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) \
{ \
(a) += H((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) += H((b), (c), (d)) + (x) + (uint32_t) (ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) \
{ \
(a) += I((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) += I((b), (c), (d)) + (x) + (uint32_t) (ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}

View File

@ -570,15 +570,15 @@ static const u32 rcon[] = {
};
#define GETU32(plaintext) \
(((u32)(plaintext)[0] << 24) ^ ((u32)(plaintext)[1] << 16) ^ \
((u32)(plaintext)[2] << 8) ^ ((u32)(plaintext)[3]))
(((u32) (plaintext)[0] << 24) ^ ((u32) (plaintext)[1] << 16) ^ \
((u32) (plaintext)[2] << 8) ^ ((u32) (plaintext)[3]))
#define PUTU32(ciphertext, st) \
{ \
(ciphertext)[0] = (u8)((st) >> 24); \
(ciphertext)[1] = (u8)((st) >> 16); \
(ciphertext)[2] = (u8)((st) >> 8); \
(ciphertext)[3] = (u8)(st); \
(ciphertext)[0] = (u8) ((st) >> 24); \
(ciphertext)[1] = (u8) ((st) >> 16); \
(ciphertext)[2] = (u8) ((st) >> 8); \
(ciphertext)[3] = (u8) (st); \
}
/**

View File

@ -34,10 +34,10 @@ exchook_lockchip_dec_chunk(uint8_t len, const uint8_t *src, uint8_t *dest)
for (size_t i = 1; i < len; i++) {
uint8_t result = sec_lockchip_step(src[i] ^ 0xFF);
dest[i - 1] = (uint8_t)((last_res >> 3) ^ (result << 5));
dest[i - 1] = (uint8_t) ((last_res >> 3) ^ (result << 5));
last_res = result;
}
uint8_t last_byte = sec_lockchip_step(0);
dest[len - 1] = (uint8_t)((last_res >> 3) ^ (last_byte << 5));
dest[len - 1] = (uint8_t) ((last_res >> 3) ^ (last_byte << 5));
}

View File

@ -45,7 +45,10 @@ static const struct util_options_def exchook_options_def[] = {
},
{
.name = EXCHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -36,7 +36,10 @@ const struct util_options_def f2hook_options_def[] = {
},
{
.name = F2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -36,7 +36,10 @@ const struct util_options_def fexhook_options_def[] = {
},
{
.name = FEXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -36,7 +36,10 @@ const struct util_options_def fsthook_options_def[] = {
},
{
.name = FSTHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -35,7 +35,10 @@ static const struct util_options_def nxhook_options_def[] = {
},
{
.name = NXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -40,7 +40,10 @@ const struct util_options_def nx2hook_options_def[] = {
},
{
.name = NX2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -40,7 +40,10 @@ const struct util_options_def nxahook_options_def[] = {
},
{
.name = NXAHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -1,8 +1,8 @@
#define LOG_MODULE "patch-gfx"
#include <GL/gl.h>
#include <X11/Xutil.h>
#include <stdbool.h>
#include <GL/gl.h>
// OpenGL 3.x+
#include <GL/glx.h>
@ -165,8 +165,11 @@ void patch_gfx_init()
log_info("Initialized");
}
// Note, consider improving scaling, see http://www.david-amador.com/2013/04/opengl-2d-independent-resolution-rendering/
// Note, consider improving scaling, see
// http://www.david-amador.com/2013/04/opengl-2d-independent-resolution-rendering/
void patch_gfx_scale(enum patch_gfx_scale_mode scale_mode)
{
log_error("GFX scaling enabled but will not work. Temporarily removed due to issues with loading libGL.so");
log_error(
"GFX scaling enabled but will not work. Temporarily removed due to "
"issues with loading libGL.so");
}

View File

@ -468,9 +468,7 @@ static bool _patch_net_profile_download_profile_file(
virtual_file->buffer,
virtual_file->file_info->file_size)) {
log_error(
"Downloading file player %d, file_type %d, failed",
player,
file_type);
"Downloading file player %d, file_type %d, failed", player, file_type);
return false;
}
@ -536,16 +534,12 @@ static bool _patch_net_profile_upload_profile_file(
virtual_file->buffer,
virtual_file->file_info->file_size)) {
log_error(
"Uploading file player %d, file_type %d, failed",
player,
file_type);
"Uploading file player %d, file_type %d, failed", player, file_type);
return false;
}
log_info(
"Uploading file player %d, file_type %d, successful",
player,
file_type);
"Uploading file player %d, file_type %d, successful", player, file_type);
return true;
}
@ -641,10 +635,7 @@ void patch_net_profile_init(
pthread_mutex_init(&_patch_net_profile_mutex, NULL);
log_info(
"Initialized: game %d, server %s",
game,
pumpnet_server_addr);
log_info("Initialized: game %d, server %s", game, pumpnet_server_addr);
}
void patch_net_profile_shutdown()

View File

@ -34,7 +34,10 @@ const struct util_options_def prihook_options_def[] = {
},
{
.name = PRIHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -43,7 +43,10 @@ static const struct util_options_def x2hook_options_def[] = {
},
{
.name = X2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -43,7 +43,10 @@ static const struct util_options_def zerohook_options_def[] = {
},
{
.name = ZEROHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.description =
"Set a scaling mode for the rendered output. Available modes: 0 = "
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
.param = 'z',
.type = UTIL_OPTIONS_TYPE_INT,
.is_secret_data = false,

View File

@ -182,18 +182,13 @@ int32_t io_usb_control_transfer(
}
int32_t io_usb_interrupt_transfer(
void *handle,
int ep,
uint8_t *data,
uint16_t len,
uint32_t timeout)
void *handle, int ep, uint8_t *data, uint16_t len, uint32_t timeout)
{
struct usb_io_ctx *dev = (struct usb_io_ctx *) handle;
int32_t ret, transferred;
ret =
libusb_interrupt_transfer(
dev->dev, ep, data, len, &transferred, timeout);
libusb_interrupt_transfer(dev->dev, ep, data, len, &transferred, timeout);
if (transferred != len) {
log_error(

View File

@ -54,11 +54,7 @@ int32_t io_usb_control_transfer(
* @return Number of bytes read/written or -1 on error
*/
int32_t io_usb_interrupt_transfer(
void *handle,
int ep,
uint8_t *data,
uint16_t len,
uint32_t timeout);
void *handle, int ep, uint8_t *data, uint16_t len, uint32_t timeout);
/**
* Close a opened usb device
*

View File

@ -1,7 +1,8 @@
/**
* Communicate with the Andamiro "lxio" or ATMEGAPUMP or PIU HID.
* This device hosts all data in two address, and interrupt in and out.
* Device needs to be written then read in that order. Every read needs a preceding write.
* Device needs to be written then read in that order. Every read needs a
* preceding write.
*/
#define LOG_MODULE "ptapi-io-piuio-lxio"
@ -13,8 +14,8 @@
#include "util/log.h"
#include "ptapi/io/piuio.h"
#include "ptapi/io/piubtn.h"
#include "ptapi/io/piuio.h"
// Data going to/from lxio
uint8_t lxio_btn_state_buffer[LXIO_MSG_SIZE];
@ -95,19 +96,19 @@ void convert_output_to_lxio()
/* Menu Buttons */
for (uint8_t i = 0; i < 2; i++) {
//both UR and UL are mapped to "back"
// both UR and UL are mapped to "back"
if (ptapi_piubtn_out[i].back) {
lxio_light_state_buffer[i+4] |= (1 << 0);
lxio_light_state_buffer[i+4] |= (1 << 1);
lxio_light_state_buffer[i + 4] |= (1 << 0);
lxio_light_state_buffer[i + 4] |= (1 << 1);
}
if (ptapi_piubtn_out[i].start) {
lxio_light_state_buffer[i+4] |= (1 << 2);
lxio_light_state_buffer[i + 4] |= (1 << 2);
}
if (ptapi_piubtn_out[i].left) {
lxio_light_state_buffer[i+4] |= (1 << 3);
lxio_light_state_buffer[i + 4] |= (1 << 3);
}
if (ptapi_piubtn_out[i].right) {
lxio_light_state_buffer[i+4] |= (1 << 4);
lxio_light_state_buffer[i + 4] |= (1 << 4);
}
}
}
@ -135,7 +136,6 @@ static void convert_input_to_piuio()
ptapi_piuio_sys.clear = lxio_btn_state_buffer[8] & (1 << 7);
ptapi_piuio_sys.coin = lxio_btn_state_buffer[8] & (1 << 2);
ptapi_piuio_sys.coin2 = lxio_btn_state_buffer[9] & (1 << 2);
}
bool ptapi_io_piuio_recv(void)
@ -208,20 +208,20 @@ void ptapi_io_piuio_set_output_cab(
&ptapi_piuio_cab_out, outputs, sizeof(struct ptapi_io_piuio_cab_outputs));
}
const char* ptapi_io_piubtn_ident(void)
const char *ptapi_io_piubtn_ident(void)
{
return "lxio";
}
bool ptapi_io_piubtn_open(void)
{
//taken care of by piuio_open
// taken care of by piuio_open
return true;
}
void ptapi_io_piubtn_close(void)
{
//handled by piuio_close
// handled by piuio_close
}
bool ptapi_io_piubtn_recv(void)
@ -236,11 +236,12 @@ bool ptapi_io_piubtn_send(void)
return true;
}
void ptapi_io_piubtn_get_input(uint8_t player, struct ptapi_io_piubtn_inputs* inputs)
void ptapi_io_piubtn_get_input(
uint8_t player, struct ptapi_io_piubtn_inputs *inputs)
{
// Note: There could be consistancy issues if the two IOs are threaded by seperate threads
// Decided to take the risk of potentially lost button inputs. Testing has yielded
// good results.
// Note: There could be consistancy issues if the two IOs are threaded by
// seperate threads Decided to take the risk of potentially lost button
// inputs. Testing has yielded good results.
// Set all inputs to off
if (player == 0) {
@ -248,7 +249,7 @@ void ptapi_io_piubtn_get_input(uint8_t player, struct ptapi_io_piubtn_inputs* in
inputs->right = lxio_btn_state_buffer[10] & (1 << 4);
inputs->start = lxio_btn_state_buffer[10] & (1 << 2);
//map both UR and UL to "back" as this is how kpump maps it.
// map both UR and UL to "back" as this is how kpump maps it.
inputs->back = (lxio_btn_state_buffer[10] & (1 << 0)) |
(lxio_btn_state_buffer[10] & (1 << 1));
} else {
@ -256,13 +257,17 @@ void ptapi_io_piubtn_get_input(uint8_t player, struct ptapi_io_piubtn_inputs* in
inputs->right = lxio_btn_state_buffer[11] & (1 << 4);
inputs->start = lxio_btn_state_buffer[11] & (1 << 2);
//map both UR and UL to "back" as this is how kpump maps it.
// map both UR and UL to "back" as this is how kpump maps it.
inputs->back = (lxio_btn_state_buffer[11] & (1 << 0)) |
(lxio_btn_state_buffer[11] & (1 << 1));
}
}
void ptapi_io_piubtn_set_output(uint8_t player, const struct ptapi_io_piubtn_outputs* outputs)
void ptapi_io_piubtn_set_output(
uint8_t player, const struct ptapi_io_piubtn_outputs *outputs)
{
memcpy(&ptapi_piubtn_out[player], outputs, sizeof(struct ptapi_io_piubtn_outputs));
memcpy(
&ptapi_piubtn_out[player],
outputs,
sizeof(struct ptapi_io_piubtn_outputs));
}

View File

@ -472,18 +472,18 @@ sec_hasp_asn1_encode_int(uint32_t val, uint8_t *buffer, size_t *offset)
tmp[tmp_pos++] = (uint8_t) val;
} else if (val <= 0xFFFF) {
/* Big endian */
tmp[tmp_pos++] = (uint8_t)(val >> 8);
tmp[tmp_pos++] = (uint8_t) (val >> 8);
tmp[tmp_pos++] = (uint8_t) val;
} else if (val <= 0xFFFFFF) {
/* Big endian */
tmp[tmp_pos++] = (uint8_t)(val >> 16);
tmp[tmp_pos++] = (uint8_t)(val >> 8);
tmp[tmp_pos++] = (uint8_t) (val >> 16);
tmp[tmp_pos++] = (uint8_t) (val >> 8);
tmp[tmp_pos++] = (uint8_t) val;
} else if (val <= 0xFFFFFFFF) {
/* Big endian */
tmp[tmp_pos++] = (uint8_t)(val >> 24);
tmp[tmp_pos++] = (uint8_t)(val >> 16);
tmp[tmp_pos++] = (uint8_t)(val >> 8);
tmp[tmp_pos++] = (uint8_t) (val >> 24);
tmp[tmp_pos++] = (uint8_t) (val >> 16);
tmp[tmp_pos++] = (uint8_t) (val >> 8);
tmp[tmp_pos++] = (uint8_t) val;
} else if (val <= 0xFFFFFFFFFFFFFFFF) {
// TODO quad words not supported in decode?
@ -528,20 +528,20 @@ sec_hasp_asn1_encode_length(uint32_t len, uint8_t *buffer, size_t *offset)
} else if (len <= 0xFFFF) {
buffer[(*offset)++] = 0x82;
/* Big endian */
buffer[(*offset)++] = (uint8_t)(len >> 8);
buffer[(*offset)++] = (uint8_t) (len >> 8);
buffer[(*offset)++] = (uint8_t) len;
} else if (len <= 0xFFFF) {
buffer[(*offset)++] = 0x82;
/* Big endian */
buffer[(*offset)++] = (uint8_t)(len >> 16);
buffer[(*offset)++] = (uint8_t)(len >> 8);
buffer[(*offset)++] = (uint8_t) (len >> 16);
buffer[(*offset)++] = (uint8_t) (len >> 8);
buffer[(*offset)++] = (uint8_t) len;
} else if (len <= 0xFFFFFFFF) {
buffer[(*offset)++] = 0x84;
/* Big endian */
buffer[(*offset)++] = (uint8_t)(len >> 24);
buffer[(*offset)++] = (uint8_t)(len >> 16);
buffer[(*offset)++] = (uint8_t)(len >> 8);
buffer[(*offset)++] = (uint8_t) (len >> 24);
buffer[(*offset)++] = (uint8_t) (len >> 16);
buffer[(*offset)++] = (uint8_t) (len >> 8);
buffer[(*offset)++] = (uint8_t) len;
}
}
@ -551,9 +551,9 @@ sec_hasp_asn1_encode_tag(uint16_t tag, uint8_t *buffer, size_t *offset)
{
if (tag > 0xFF) {
/* Big endian */
buffer[(*offset)++] = (uint8_t)(tag >> 8);
buffer[(*offset)++] = (uint8_t)(tag);
buffer[(*offset)++] = (uint8_t) (tag >> 8);
buffer[(*offset)++] = (uint8_t) (tag);
} else {
buffer[(*offset)++] = (uint8_t)(tag);
buffer[(*offset)++] = (uint8_t) (tag);
}
}

View File

@ -648,7 +648,10 @@ static bool util_options_init_from_file(
options->defs->defs[j].param,
options->defs->defs[j].name,
options->defs->defs[j].type,
val ? (options->defs->defs[j].is_secret_data ? "[REDACTED-SECRET]" : val) : "NULL");
val ?
(options->defs->defs[j].is_secret_data ? "[REDACTED-SECRET]" :
val) :
"NULL");
options->values[j].avail = true;
break;

View File

@ -36,7 +36,7 @@ void util_patch_function(uintptr_t func_addr, void *detour_func)
offset += 4;
}
uintptr_t call = (uintptr_t)(((uintptr_t) detour_func) - func_addr - offset);
uintptr_t call = (uintptr_t) (((uintptr_t) detour_func) - func_addr - offset);
if (UNPROTECT(func_addr, 4096) != 0) {
log_die("Unprotecting memory %p, len %d failed", func_addr);

View File

@ -63,8 +63,8 @@ bool util_sock_tcp_is_connectable3(
FD_ZERO(&fdset);
FD_SET(handle, &fdset);
tv.tv_sec = (__time_t)(timeout_ms / 1000);
tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000);
tv.tv_sec = (__time_t) (timeout_ms / 1000);
tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000);
if (select(handle + 1, NULL, &fdset, NULL, &tv) == 1) {
int so_error;
@ -142,8 +142,8 @@ ssize_t
util_sock_tcp_send(int handle, void *buffer, size_t size, uint32_t timeout_ms)
{
struct timeval tv;
tv.tv_sec = (__time_t)(timeout_ms / 1000);
tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000);
tv.tv_sec = (__time_t) (timeout_ms / 1000);
tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000);
setsockopt(handle, SOL_SOCKET, SO_SNDTIMEO, (const char *) &tv, sizeof(tv));
@ -166,8 +166,8 @@ ssize_t
util_sock_tcp_recv(int handle, void *buffer, size_t size, uint32_t timeout_ms)
{
struct timeval tv;
tv.tv_sec = (__time_t)(timeout_ms / 1000);
tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000);
tv.tv_sec = (__time_t) (timeout_ms / 1000);
tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000);
setsockopt(handle, SOL_SOCKET, SO_RCVTIMEO, (const char *) &tv, sizeof(tv));

View File

@ -12,7 +12,7 @@
void util_time_sleep_ns(uint64_t time_ns)
{
struct timespec t;
t.tv_sec = (__time_t)(time_ns / (1000 * 1000 * 1000));
t.tv_sec = (__time_t) (time_ns / (1000 * 1000 * 1000));
t.tv_nsec = (__syscall_slong_t) time_ns % (1000 * 1000 * 1000);
nanosleep(&t, NULL);
@ -21,8 +21,8 @@ void util_time_sleep_ns(uint64_t time_ns)
void util_time_sleep_us(uint64_t time_us)
{
struct timespec t;
t.tv_sec = (__time_t)(time_us / (1000 * 1000));
t.tv_nsec = (__syscall_slong_t)(time_us % (1000 * 1000)) * 1000;
t.tv_sec = (__time_t) (time_us / (1000 * 1000));
t.tv_nsec = (__syscall_slong_t) (time_us % (1000 * 1000)) * 1000;
nanosleep(&t, NULL);
}
@ -30,8 +30,8 @@ void util_time_sleep_us(uint64_t time_us)
void util_time_sleep_ms(uint64_t time_ms)
{
struct timespec t;
t.tv_sec = (__time_t)(time_ms / 1000);
t.tv_nsec = (__syscall_slong_t)(time_ms % 1000) * 1000 * 1000;
t.tv_sec = (__time_t) (time_ms / 1000);
t.tv_nsec = (__syscall_slong_t) (time_ms % 1000) * 1000 * 1000;
nanosleep(&t, NULL);
}