Skip to content

Commit 4e055ed

Browse files
author
jmccrohan
committed
Replace non-portable datatypes with C99 versions
Found during OpenWrt's migration from uClibc to musl. Signed-off-by: Jonathan McCrohan <[email protected]> git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1203 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
1 parent d38b3dc commit 4e055ed

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

drv_TeakLCM.c

+15-14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "config.h"
3838

3939
#include <stdlib.h>
40+
#include <stdint.h>
4041
#include <stdio.h>
4142
#include <unistd.h>
4243
#include <string.h>
@@ -67,14 +68,14 @@ static char Name[] = "TeakLCM";
6768
static int global_reset_rx_flag = 0;
6869

6970

70-
#define HI8(value) ((u_int8_t)(((value)>>8) & 0xff))
71-
#define LO8(value) ((u_int8_t)((value) & 0xff))
71+
#define HI8(value) ((uint8_t)(((value)>>8) & 0xff))
72+
#define LO8(value) ((uint8_t)((value) & 0xff))
7273

7374

74-
static u_int16_t CRC16(u_int8_t value, u_int16_t crcin)
75+
static uint16_t CRC16(uint8_t value, uint16_t crcin)
7576
{
76-
u_int16_t k = (((crcin >> 8) ^ value) & 255) << 8;
77-
u_int16_t crc = 0;
77+
uint16_t k = (((crcin >> 8) ^ value) & 255) << 8;
78+
uint16_t crc = 0;
7879
int bits;
7980
for (bits = 8; bits; --bits) {
8081
if ((crc ^ k) & 0x8000)
@@ -100,7 +101,7 @@ static char printable(const char ch)
100101

101102
static void debug_data_int(const char *prefix, const void *data, const size_t size, const unsigned int delta)
102103
{
103-
const u_int8_t *b = (const u_int8_t *) data;
104+
const uint8_t *b = (const uint8_t *) data;
104105
size_t y;
105106
assert(delta <= 24);
106107
for (y = 0; y < size; y += delta) {
@@ -284,7 +285,7 @@ static
284285
void fsm_handle_cmd(lcm_fsm_t * fsm, const lcm_cmd_t cmd);
285286

286287
static
287-
void fsm_handle_datacmd(lcm_fsm_t * fsm, const lcm_cmd_t cmd, const u_int8_t * payload, const unsigned int payload_len);
288+
void fsm_handle_datacmd(lcm_fsm_t * fsm, const lcm_cmd_t cmd, const uint8_t * payload, const unsigned int payload_len);
288289

289290
static
290291
void try_reset(void);
@@ -304,7 +305,7 @@ void fsm_trans_data(lcm_fsm_t * fsm,
304305

305306

306307
static
307-
void fsm_handle_bytes(lcm_fsm_t * fsm, u_int8_t * rxbuf, const unsigned int buflen)
308+
void fsm_handle_bytes(lcm_fsm_t * fsm, uint8_t * rxbuf, const unsigned int buflen)
308309
{
309310
if ((buflen >= 3) && (rxbuf[0] == LCM_FRAME_MASK) && (rxbuf[2] == LCM_FRAME_MASK)) {
310311
const lcm_cmd_t cmd = rxbuf[1];
@@ -322,7 +323,7 @@ void fsm_handle_bytes(lcm_fsm_t * fsm, u_int8_t * rxbuf, const unsigned int bufl
322323
debug("%s Received possible data frame", __FUNCTION__);
323324

324325
/* unescape rxframe data in place */
325-
u_int16_t crc0 = 0, crc1 = 0, crc2 = 0, crc3 = 0;
326+
uint16_t crc0 = 0, crc1 = 0, crc2 = 0, crc3 = 0;
326327
for (ri = 1, ci = 1; ri < buflen; ri++) {
327328
switch (rxbuf[ri]) {
328329
case LCM_ESC:
@@ -339,7 +340,7 @@ void fsm_handle_bytes(lcm_fsm_t * fsm, u_int8_t * rxbuf, const unsigned int bufl
339340
if ((rxbuf[ci - 1] == LCM_FRAME_MASK) && (rxbuf[ci - 2] == LO8(crc3)) && (rxbuf[ci - 3] == HI8(crc3))) {
340341
/* looks like a complete data frame */
341342
lcm_cmd_t cmd = rxbuf[1];
342-
u_int16_t len = (rxbuf[3] << 8) + rxbuf[2];
343+
uint16_t len = (rxbuf[3] << 8) + rxbuf[2];
343344
assert(ci == (unsigned int) (1 + 1 + 2 + len + 2 + 1));
344345
fsm_handle_datacmd(fsm, cmd, &rxbuf[4], len);
345346
if (ri + 1 < buflen) {
@@ -420,7 +421,7 @@ static void fsm_handle_cmd(lcm_fsm_t * fsm, lcm_cmd_t cmd)
420421

421422

422423
static
423-
void fsm_handle_datacmd(lcm_fsm_t * fsm, const lcm_cmd_t cmd, const u_int8_t * payload, unsigned int payload_len)
424+
void fsm_handle_datacmd(lcm_fsm_t * fsm, const lcm_cmd_t cmd, const uint8_t * payload, unsigned int payload_len)
424425
{
425426
const lcm_state_t old_state = fsm_get_state(fsm);
426427
debug("fsm_handle_datacmd: old state 0x%02x %s", old_state, state2str(old_state));
@@ -677,7 +678,7 @@ void raw_send_data_frame(lcm_cmd_t cmd, const char *data, const unsigned int len
677678
unsigned int di; /* data index */
678679
unsigned int fi; /* frame index */
679680
static char frame[32];
680-
u_int16_t crc = 0;
681+
uint16_t crc = 0;
681682

682683
frame[0] = LCM_FRAME_MASK;
683684

@@ -740,7 +741,7 @@ void lcm_event_callback(event_flags_t flags, void *data)
740741
lcm_fsm_t *fsm = (lcm_fsm_t *) data;
741742
debug("%s: flags=%d, data=%p", __FUNCTION__, flags, data);
742743
if (flags & EVENT_READ) {
743-
static u_int8_t rxbuf[32];
744+
static uint8_t rxbuf[32];
744745
const int readlen = drv_generic_serial_poll((void *) rxbuf, sizeof(rxbuf));
745746
if (readlen <= 0) {
746747
debug("%s Received no data", __FUNCTION__);
@@ -901,7 +902,7 @@ static int drv_TeakLCM_start(const char *section)
901902
debug("%s: %s opened", Name, __FUNCTION__);
902903

903904
/* read initial garbage data */
904-
static u_int8_t rxbuf[32];
905+
static uint8_t rxbuf[32];
905906
const int readlen = drv_generic_serial_poll((void *) rxbuf, sizeof(rxbuf));
906907
if (readlen >= 0) {
907908
debug_data(" initial RX garbage ", rxbuf, readlen);

drv_USBHUB.c

+10-9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*/
3636

3737
#include "config.h"
38+
#include <stdint.h>
3839

3940
#ifdef HAVE_USB_H
4041
#include <usb.h>
@@ -68,15 +69,15 @@ static unsigned int hubProduct = 0x0058;
6869
static usb_dev_handle *hub = NULL;
6970

7071
typedef struct _usb_hub_descriptor {
71-
u_int8_t bLength;
72-
u_int8_t bDescriptorType;
73-
u_int8_t nNbrPorts;
74-
u_int8_t wHubCharacteristicLow;
75-
u_int8_t wHubCharacteristicHigh;
76-
u_int8_t bPwrOn2PwrGood;
77-
u_int8_t bHubContrCurrent;
78-
u_int8_t deviceRemovable;
79-
u_int8_t PortPwrCtrlMask[8];
72+
uint8_t bLength;
73+
uint8_t bDescriptorType;
74+
uint8_t nNbrPorts;
75+
uint8_t wHubCharacteristicLow;
76+
uint8_t wHubCharacteristicHigh;
77+
uint8_t bPwrOn2PwrGood;
78+
uint8_t bHubContrCurrent;
79+
uint8_t deviceRemovable;
80+
uint8_t PortPwrCtrlMask[8];
8081
} usb_hub_descriptor;
8182

8283
/****************************************/

0 commit comments

Comments
 (0)