mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-21 03:55:06 +00:00
firmware-utils: fix -Wpointer-sign warnings
Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: maurerr <mariusd84@gmail.com>
This commit is contained in:
parent
5cdc6ee3ce
commit
ba160eaa66
@ -65,7 +65,7 @@ static uint32_t crc32buf(unsigned char *buf, size_t len)
|
||||
}
|
||||
|
||||
struct header {
|
||||
unsigned char model[16];
|
||||
char model[16];
|
||||
uint32_t crc;
|
||||
};
|
||||
|
||||
|
@ -74,34 +74,34 @@ typedef uint16_t cyg_uint16;
|
||||
// Compute a CRC, using the POSIX 1003 definition
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_posix_crc32(unsigned char *s, int len);
|
||||
cyg_posix_crc32(void *s, int len);
|
||||
|
||||
// Gary S. Brown's 32 bit CRC
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_crc32(unsigned char *s, int len);
|
||||
cyg_crc32(void *s, int len);
|
||||
|
||||
// Gary S. Brown's 32 bit CRC, but accumulate the result from a
|
||||
// previous CRC calculation
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
|
||||
cyg_crc32_accumulate(cyg_uint32 crc, void *s, int len);
|
||||
|
||||
// Ethernet FCS Algorithm
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_ether_crc32(unsigned char *s, int len);
|
||||
cyg_ether_crc32(void *s, int len);
|
||||
|
||||
// Ethernet FCS algorithm, but accumulate the result from a previous
|
||||
// CRC calculation.
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
|
||||
cyg_ether_crc32_accumulate(cyg_uint32 crc, void *s, int len);
|
||||
|
||||
// 16 bit CRC with polynomial x^16+x^12+x^5+1
|
||||
|
||||
__externC cyg_uint16
|
||||
cyg_crc16(unsigned char *s, int len);
|
||||
cyg_crc16(void *s, int len);
|
||||
|
||||
#endif // _SERVICES_CRC_CRC_H_
|
||||
|
||||
|
@ -96,8 +96,9 @@ static const cyg_uint16 crc16_tab[] = {
|
||||
};
|
||||
|
||||
cyg_uint16
|
||||
cyg_crc16(unsigned char *buf, int len)
|
||||
cyg_crc16(void *ptr, int len)
|
||||
{
|
||||
unsigned char *buf = ptr;
|
||||
int i;
|
||||
cyg_uint16 cksum;
|
||||
|
||||
|
@ -127,8 +127,9 @@ static const cyg_uint32 crc32_tab[] = {
|
||||
/* This is the standard Gary S. Brown's 32 bit CRC algorithm, but
|
||||
accumulate the CRC into the result of a previous CRC. */
|
||||
cyg_uint32
|
||||
cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
|
||||
cyg_crc32_accumulate(cyg_uint32 crc32val, void *ptr, int len)
|
||||
{
|
||||
unsigned char *s = ptr;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
@ -139,7 +140,7 @@ cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
|
||||
|
||||
/* This is the standard Gary S. Brown's 32 bit CRC algorithm */
|
||||
cyg_uint32
|
||||
cyg_crc32(unsigned char *s, int len)
|
||||
cyg_crc32(void *s, int len)
|
||||
{
|
||||
return (cyg_crc32_accumulate(0,s,len));
|
||||
}
|
||||
@ -148,8 +149,9 @@ cyg_crc32(unsigned char *s, int len)
|
||||
result from a previous CRC calculation. This uses the Ethernet FCS
|
||||
algorithm.*/
|
||||
cyg_uint32
|
||||
cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
|
||||
cyg_ether_crc32_accumulate(cyg_uint32 crc32val, void *ptr, int len)
|
||||
{
|
||||
unsigned char *s = ptr;
|
||||
int i;
|
||||
|
||||
if (s == 0) return 0L;
|
||||
@ -164,7 +166,7 @@ cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
|
||||
/* Return a 32-bit CRC of the contents of the buffer, using the
|
||||
Ethernet FCS algorithm. */
|
||||
cyg_uint32
|
||||
cyg_ether_crc32(unsigned char *s, int len)
|
||||
cyg_ether_crc32(void *s, int len)
|
||||
{
|
||||
return cyg_ether_crc32_accumulate(0,s,len);
|
||||
}
|
||||
|
@ -102,9 +102,11 @@ static const uint32_t crc32_table[256] = {
|
||||
};
|
||||
|
||||
static uint32_t crc32(uint32_t crc,
|
||||
const unsigned char *buf,
|
||||
const void *data,
|
||||
unsigned int len)
|
||||
{
|
||||
const uint8_t *buf = data;
|
||||
|
||||
crc = crc ^ 0xffffffffUL;
|
||||
do {
|
||||
crc = crc32_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
||||
@ -112,7 +114,7 @@ static uint32_t crc32(uint32_t crc,
|
||||
return crc ^ 0xffffffffUL;
|
||||
}
|
||||
|
||||
static void be_wr(unsigned char *buf, uint32_t val)
|
||||
static void be_wr(char *buf, uint32_t val)
|
||||
{
|
||||
buf[0] = (val >> 24) & 0xFFU;
|
||||
buf[1] = (val >> 16) & 0xFFU;
|
||||
@ -129,7 +131,7 @@ int main(int argc, char **argv)
|
||||
int ret = 0;
|
||||
const char *pathin;
|
||||
const char *pathout;
|
||||
unsigned char *buffer;
|
||||
char *buffer;
|
||||
uint32_t sum;
|
||||
size_t bufsize;
|
||||
size_t bytes;
|
||||
|
@ -31,15 +31,15 @@
|
||||
#define PART_NAME_LENGTH 16
|
||||
|
||||
typedef struct header {
|
||||
uint8_t magic[MAGIC_LENGTH];
|
||||
uint8_t version[256];
|
||||
char magic[MAGIC_LENGTH];
|
||||
char version[256];
|
||||
u_int32_t crc;
|
||||
u_int32_t pad;
|
||||
} __attribute__ ((packed)) header_t;
|
||||
|
||||
typedef struct part {
|
||||
uint8_t magic[MAGIC_LENGTH];
|
||||
uint8_t name[PART_NAME_LENGTH];
|
||||
char magic[MAGIC_LENGTH];
|
||||
char name[PART_NAME_LENGTH];
|
||||
uint8_t pad[12];
|
||||
u_int32_t memaddr;
|
||||
u_int32_t index;
|
||||
|
@ -52,12 +52,13 @@ static void init_crc32()
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t crc32buf(unsigned char *buf, size_t len)
|
||||
static uint32_t crc32buf(const void *buf, size_t len)
|
||||
{
|
||||
uint32_t crc = 0xFFFFFFFF;
|
||||
const uint8_t *in = buf;
|
||||
|
||||
for (; len; len--, buf++)
|
||||
crc = crc32[(uint8_t)crc ^ *buf] ^ (crc >> BPB);
|
||||
for (; len; len--, in++)
|
||||
crc = crc32[(uint8_t)crc ^ *in] ^ (crc >> BPB);
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
|
@ -463,8 +463,9 @@ csum8_get(struct csum_state *css)
|
||||
|
||||
|
||||
void
|
||||
csum16_update(uint8_t *p, uint32_t len, struct csum_state *css)
|
||||
csum16_update(void *data, uint32_t len, struct csum_state *css)
|
||||
{
|
||||
uint8_t *p = data;
|
||||
uint16_t t;
|
||||
|
||||
if (css->odd) {
|
||||
@ -524,8 +525,10 @@ csum_init(struct csum_state *css, int size)
|
||||
}
|
||||
|
||||
void
|
||||
csum_update(uint8_t *p, uint32_t len, struct csum_state *css)
|
||||
csum_update(void *data, uint32_t len, struct csum_state *css)
|
||||
{
|
||||
uint8_t *p = data;
|
||||
|
||||
switch (css->size) {
|
||||
case CSUM_TYPE_8:
|
||||
csum8_update(p,len,css);
|
||||
@ -568,19 +571,21 @@ csum_get(struct csum_state *css)
|
||||
* routines to write data to the output file
|
||||
*/
|
||||
int
|
||||
write_out_data(FILE *outfile, uint8_t *data, size_t len,
|
||||
write_out_data(FILE *outfile, void *data, size_t len,
|
||||
struct csum_state *css)
|
||||
{
|
||||
uint8_t *ptr = data;
|
||||
|
||||
errno = 0;
|
||||
|
||||
fwrite(data, len, 1, outfile);
|
||||
fwrite(ptr, len, 1, outfile);
|
||||
if (errno) {
|
||||
ERRS("unable to write output file");
|
||||
return ERR_FATAL;
|
||||
}
|
||||
|
||||
if (css) {
|
||||
csum_update(data, len, css);
|
||||
csum_update(ptr, len, css);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -423,8 +423,9 @@ csum8_get(struct csum_state *css)
|
||||
|
||||
|
||||
void
|
||||
csum16_update(uint8_t *p, uint32_t len, struct csum_state *css)
|
||||
csum16_update(void *data, uint32_t len, struct csum_state *css)
|
||||
{
|
||||
uint8_t *p = data;
|
||||
uint16_t t;
|
||||
|
||||
if (css->odd) {
|
||||
@ -468,8 +469,10 @@ csum_init(struct csum_state *css, int size)
|
||||
|
||||
|
||||
void
|
||||
csum_update(uint8_t *p, uint32_t len, struct csum_state *css)
|
||||
csum_update(void *data, uint32_t len, struct csum_state *css)
|
||||
{
|
||||
uint8_t *p = data;
|
||||
|
||||
switch (css->size) {
|
||||
case CSUM_SIZE_8:
|
||||
csum8_update(p,len,css);
|
||||
@ -506,19 +509,21 @@ csum_get(struct csum_state *css)
|
||||
* routines to write data to the output file
|
||||
*/
|
||||
int
|
||||
write_out_data(FILE *outfile, uint8_t *data, size_t len,
|
||||
write_out_data(FILE *outfile, void *data, size_t len,
|
||||
struct csum_state *css)
|
||||
{
|
||||
uint8_t *ptr = data;
|
||||
|
||||
errno = 0;
|
||||
|
||||
fwrite(data, len, 1, outfile);
|
||||
fwrite(ptr, len, 1, outfile);
|
||||
if (errno) {
|
||||
ERRS("unable to write output file");
|
||||
return ERR_FATAL;
|
||||
}
|
||||
|
||||
if (css) {
|
||||
csum_update(data, len, css);
|
||||
csum_update(ptr, len, css);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -478,18 +478,20 @@ process_partitions(void)
|
||||
* routines to write data to the output file
|
||||
*/
|
||||
int
|
||||
write_out_data(FILE *outfile, uint8_t *data, size_t len, uint32_t *crc)
|
||||
write_out_data(FILE *outfile, void *data, size_t len, uint32_t *crc)
|
||||
{
|
||||
uint8_t *ptr = data;
|
||||
|
||||
errno = 0;
|
||||
|
||||
fwrite(data, len, 1, outfile);
|
||||
fwrite(ptr, len, 1, outfile);
|
||||
if (errno) {
|
||||
errmsg(1,"unable to write output file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (crc) {
|
||||
update_crc(data, len, crc);
|
||||
update_crc(ptr, len, crc);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -67,7 +67,7 @@ typedef struct image_header {
|
||||
uint8_t ih_type;
|
||||
uint8_t ih_comp;
|
||||
union {
|
||||
uint8_t ih_name[IH_NMLEN];
|
||||
char ih_name[IH_NMLEN];
|
||||
asus_t asus;
|
||||
} tail;
|
||||
} image_header_t;
|
||||
|
@ -114,7 +114,7 @@ static void get_digest(struct wrgg03_header *header, char *data, int size)
|
||||
MD5_Update(&ctx, (char *)&header->devname, sizeof(header->devname));
|
||||
MD5_Update(&ctx, data, size);
|
||||
|
||||
MD5_Final(header->digest, &ctx);
|
||||
MD5_Final((unsigned char *)header->digest, &ctx);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -100,7 +100,7 @@ static void get_digest(struct wrg_header *header, char *data, int size)
|
||||
MD5_Update(&ctx, (char *)&header->devname, sizeof(header->devname));
|
||||
MD5_Update(&ctx, data, size);
|
||||
|
||||
MD5_Final(header->digest, &ctx);
|
||||
MD5_Final((unsigned char *)header->digest, &ctx);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -444,8 +444,10 @@ csum_init(struct csum_state *css)
|
||||
|
||||
|
||||
void
|
||||
csum_update(uint8_t *p, uint32_t len, struct csum_state *css)
|
||||
csum_update(void *data, uint32_t len, struct csum_state *css)
|
||||
{
|
||||
uint8_t *p = data;
|
||||
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
@ -499,19 +501,21 @@ csum_buf(uint8_t *p, uint32_t len)
|
||||
* routines to write data to the output file
|
||||
*/
|
||||
int
|
||||
write_out_data(FILE *outfile, uint8_t *data, size_t len,
|
||||
write_out_data(FILE *outfile, void *data, size_t len,
|
||||
struct csum_state *css)
|
||||
{
|
||||
uint8_t *ptr = data;
|
||||
|
||||
errno = 0;
|
||||
|
||||
fwrite(data, len, 1, outfile);
|
||||
fwrite(ptr, len, 1, outfile);
|
||||
if (errno) {
|
||||
ERR("unable to write output file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (css) {
|
||||
csum_update(data, len, css);
|
||||
csum_update(ptr, len, css);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -541,7 +545,7 @@ write_out_padding(FILE *outfile, size_t len, uint8_t padc,
|
||||
|
||||
|
||||
int
|
||||
write_out_data_align(FILE *outfile, uint8_t *data, size_t len, size_t align,
|
||||
write_out_data_align(FILE *outfile, void *data, size_t len, size_t align,
|
||||
struct csum_state *css)
|
||||
{
|
||||
size_t padlen;
|
||||
@ -611,7 +615,7 @@ write_out_mmap(FILE *outfile, struct fw_mmap *mmap, struct csum_state *css)
|
||||
mh->count=0;
|
||||
|
||||
/* Build user data section */
|
||||
data = buf+sizeof(*mh);
|
||||
data = (char *)buf + sizeof(*mh);
|
||||
data += sprintf(data, "Vendor 1 %d", board->vendor);
|
||||
*data++ = '\0';
|
||||
data += sprintf(data, "Model 1 %d", BE16_TO_HOST(board->model));
|
||||
|
@ -225,8 +225,9 @@ void sha1_process( sha1_context *ctx, uchar data[64] )
|
||||
ctx->state[4] += E;
|
||||
}
|
||||
|
||||
void sha1_update( sha1_context *ctx, uchar *input, uint length )
|
||||
void sha1_update( sha1_context *ctx, void *data, uint length )
|
||||
{
|
||||
uchar *input = data;
|
||||
ulong left, fill;
|
||||
|
||||
if( ! length ) return;
|
||||
|
@ -26,7 +26,7 @@ sha1_context;
|
||||
* Core SHA-1 functions
|
||||
*/
|
||||
void sha1_starts( sha1_context *ctx );
|
||||
void sha1_update( sha1_context *ctx, uchar *input, uint length );
|
||||
void sha1_update( sha1_context *ctx, void *input, uint length );
|
||||
void sha1_finish( sha1_context *ctx, uchar digest[20] );
|
||||
|
||||
/*
|
||||
|
@ -117,10 +117,12 @@ static char fake_data[] = {
|
||||
};
|
||||
|
||||
|
||||
uint32_t crc32(uint32_t crc, uint8_t *data, size_t len)
|
||||
uint32_t crc32(uint32_t crc, const void *data, size_t len)
|
||||
{
|
||||
const uint8_t *in = data;
|
||||
|
||||
while (len--)
|
||||
crc = (crc >> 8) ^ crc32tab[(crc ^ *data++) & 0xFF];
|
||||
crc = (crc >> 8) ^ crc32tab[(crc ^ *in++) & 0xFF];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
@ -29,15 +29,17 @@ static char default_pattern[] = "12345678";
|
||||
static int is_hex_pattern;
|
||||
|
||||
|
||||
int xor_data(uint8_t *data, size_t len, const uint8_t *pattern, int p_len, int p_off)
|
||||
int xor_data(void *data, size_t len, const void *pattern, int p_len, int p_off)
|
||||
{
|
||||
int offset = p_off;
|
||||
const uint8_t *key = pattern;
|
||||
uint8_t *d = data;
|
||||
|
||||
while (len--) {
|
||||
*data ^= pattern[offset];
|
||||
data++;
|
||||
offset = (offset + 1) % p_len;
|
||||
*d ^= key[p_off];
|
||||
d++;
|
||||
p_off = (p_off + 1) % p_len;
|
||||
}
|
||||
return offset;
|
||||
return p_off;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user