Skip to content

Commit

Permalink
killed all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alama committed Jan 22, 2010
1 parent 98f3436 commit 0103e7c
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 31 deletions.
1 change: 1 addition & 0 deletions Makefile
@@ -1,5 +1,6 @@
include broadway.mk

CFLAGS += -Werror
DEFINES = -DLACKS_SYS_TYPES_H -DLACKS_ERRNO_H -DLACKS_STDLIB_H -DLACKS_STRING_H -DLACKS_STRINGS_H -DLACKS_UNISTD_H
LDSCRIPT = mini.ld
LIBS = -lgcc
Expand Down
7 changes: 5 additions & 2 deletions aes.c
Expand Up @@ -12,6 +12,7 @@
#include "bootmii_ppc.h"
#include "string.h"
#include "aes.h"
#include "malloc.h"

#if !HARDWARE_AES

Expand All @@ -28,8 +29,9 @@ void aes_set_key(u8 *key)
}
void aes_decrypt(u8 *src, u8 *dst, u32 blocks, u8 keep_iv)
{
(void)keep_iv;
if(src == dst) {
u8 *p = 0x92000000;//malloc(16*blocks);
u8 *p = (void *)0x92000000;//malloc(16*blocks);
my_aes_decrypt(aes_iv, src, p, 16*blocks);
memcpy(dst, p, 16*blocks);
//free(p);
Expand All @@ -38,8 +40,9 @@ void aes_decrypt(u8 *src, u8 *dst, u32 blocks, u8 keep_iv)
}
void aes_encrypt(u8 *src, u8 *dst, u32 blocks, u8 keep_iv)
{
(void)keep_iv;
if(src == dst) {
u8 *p = 0x92000000;//malloc(16*blocks);
u8 *p = (void *)92000000;//malloc(16*blocks);
my_aes_encrypt(aes_iv, src, p, 16*blocks);
memcpy(dst, p, 16*blocks);
//free(p);
Expand Down
2 changes: 1 addition & 1 deletion console.h
Expand Up @@ -17,7 +17,7 @@ void print_str(const char *str, size_t len);
void print_str_noscroll(int x, int y, char *str);
int console_printf(const char *fmt, ...);
u32 *get_xfb(void);

int gfx_printf(const char *fmt, ...);
extern unsigned char console_font_8x16[];

#endif
Expand Down
9 changes: 5 additions & 4 deletions es.c
Expand Up @@ -15,6 +15,7 @@
#include "string.h"
#include "sha1.h"
#include "es.h"
#include "main.h"

#define ASSERT(x) do { if(!(x)) { printf("ASSERT failure: %s in %s:%d\n", #x, __FILE__, __LINE__); return -1; } } while(0)

Expand Down Expand Up @@ -74,8 +75,8 @@ static u32 get_shared_path(char *path, u8 hash[20])

sprintf(path, "/shared1/content.map");
ASSERT(!nandfs_open(&fp, path));
while(sizeof(struct content_map) == nandfs_read(&map, sizeof(struct content_map), 1, &fp)) {
temp = my_atoi_hex(map.path, 8);
while(sizeof(struct content_map) == nandfs_read((u8 *)&map, sizeof(struct content_map), 1, &fp)) {
temp = my_atoi_hex((char *)map.path, 8);
if(0 == memcmp(hash, map.hash, 20)) {
// It already exists, no need to write it
*path = 0;
Expand All @@ -86,9 +87,9 @@ static u32 get_shared_path(char *path, u8 hash[20])
}
// Make a new one
num++;
sprintf(map.path, "%08x", num);
sprintf((char *)map.path, "%08x", num);
memcpy(map.hash, hash, 20);
ASSERT(sizeof(struct content_map) == nandfs_write(&map, sizeof(struct content_map), 1, &fp));
ASSERT(sizeof(struct content_map) == nandfs_write((const u8 *)&map, sizeof(struct content_map), 1, &fp));
sprintf(path, "/shared1/%08x.app", num);
printf("*** %s\n", path);
return 0;
Expand Down
5 changes: 2 additions & 3 deletions fs_hmac.c
Expand Up @@ -68,10 +68,9 @@ void fs_hmac_set_key(const char *key, int key_size)

void fs_hmac_generic(const unsigned char *data, int size, const unsigned char *extra, int extra_size, unsigned char *hmac)
{
int i;
hmac_ctx ctx;

hmac_init(&ctx,hmac_key,0x14);
hmac_init(&ctx,(const char *)hmac_key,0x14);

hmac_update(&ctx,extra,extra_size);
hmac_update(&ctx,data,size);
Expand All @@ -91,7 +90,7 @@ void fs_hmac_meta(const unsigned char *super_data, short super_blk, unsigned cha

void fs_hmac_data(const unsigned char *data, int uid, const unsigned char *name, int entry_n, int x3, short blk, unsigned char *hmac)
{
int i,j;
//int i,j;
unsigned char extra[0x40];

memset(extra,0,0x40);
Expand Down
4 changes: 2 additions & 2 deletions gecko.c
Expand Up @@ -139,7 +139,7 @@ static int gecko_recvbuffer(void *buffer, u32 size) {
}
#endif

static int gecko_sendbuffer(const void *buffer, u32 size) {
static inline int gecko_sendbuffer(const void *buffer, u32 size) {
u32 left = size;
char *ptr = (char*)buffer;

Expand Down Expand Up @@ -168,7 +168,7 @@ static int gecko_recvbuffer_safe(void *buffer, u32 size) {
return (size - left);
}
#endif
static int gecko_sendbuffer_safe(const void *buffer, u32 size) {
static inline int gecko_sendbuffer_safe(const void *buffer, u32 size) {
u32 left = size;
char *ptr = (char*)buffer;

Expand Down
16 changes: 8 additions & 8 deletions main.c
Expand Up @@ -133,6 +133,7 @@ u32 lolcrypt(u8 *stuff)
stuff++;
key = ((key<<1) | (key>>31));
}
return key;
}

int main(void)
Expand Down Expand Up @@ -171,7 +172,7 @@ int main(void)
print_str_noscroll(112, 112, "ohai, world!\n");

testOTP();

hexdump(otp.nand_hmac, 20);
hexdump(otp.nand_key, 16);

Expand All @@ -190,7 +191,7 @@ int main(void)
hexdump(stuff, fp.size);
return 0;
#endif

FATFS fs;
f_mount(0, NULL);
disk_initialize(0);
Expand All @@ -203,7 +204,7 @@ int main(void)

nandfs_walk();

static u8 pathname[1024];
static char pathname[1024];
printf("diropen: %d\n", f_opendir(&fatd, "wad"));
while(1) {
printf("readdir: %d\n", f_readdir(&fatd, &fati));
Expand All @@ -219,20 +220,19 @@ int main(void)
}

printf("create: %d\n", nandfs_create("/title/00000001/00000002/data/setting.txt", 0, 0, NANDFS_ATTR_FILE, 3, 3, 3));
lol:
1 + 1;
//lol:
s32 ret = nandfs_open(&fp, "/title/00000001/00000002/data/setting.txt");
printf("open 2: %d\n", ret);

u8 settingTxt[0x100] __attribute__((aligned(32)));
char settingTxt[0x100] __attribute__((aligned(32)));
memset(settingTxt, 0, 0x100);

u32 serno = 104170609;
sprintf(settingTxt, "AREA=USA\r\nMODEL=RVL-001(USA)\r\nDVD=0\r\nMPCH=0x7FFE\r\nCODE=LU\r\nSERNO=%d\r\nVIDEO=NTSC\r\nGAME=US\r\n", serno);

lolcrypt(settingTxt);
lolcrypt((u8 *)settingTxt);

nandfs_write(settingTxt, sizeof(settingTxt), 1, &fp);
nandfs_write((u8 *)settingTxt, sizeof(settingTxt), 1, &fp);

printf("iplsave: %d\n", nandfs_create("/title/00000001/00000002/data/iplsave.bin", 0, 0, NANDFS_ATTR_FILE, 3, 3, 3));

Expand Down
1 change: 1 addition & 0 deletions main.h
@@ -0,0 +1 @@
void hexdump(void *d, int len);
1 change: 1 addition & 0 deletions mini_ipc.c
Expand Up @@ -145,6 +145,7 @@ int nand_read(u32 pageno, void *data, void *ecc)
hexdump(ecc, 0x40);
}
#endif
return res;
}

void nand_write(u32 pageno, void *data, void *ecc)
Expand Down
11 changes: 6 additions & 5 deletions nandfs.c
Expand Up @@ -18,6 +18,7 @@ Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com>
#include "string.h"
#include "otp.h"
#include "aes.h"
#include "main.h"

#define PAGE_SIZE 2048
#define NANDFS_CLUSTER_LAST 0xFFFB // cluster_map[last cluster in
Expand Down Expand Up @@ -146,7 +147,7 @@ static void nand_lazy_write(u32 pageno, void *data, void *ecc)
}
#endif
if(myblock != blockno) {
#ifdef NANDFS_VERBOSE >= 2
#if NANDFS_VERBOSE >= 2
printf("Switching from block %x to block %x\n", blockno, myblock);
#endif
if(blockno != ((u32) -1)) {
Expand Down Expand Up @@ -230,7 +231,7 @@ void nand_write_decrypted_cluster(u32 pageno, u8 *buffer, struct nandfs_fp *fp)
fs_hmac_data(
buffer,
fp->node->uid,
fp->node->name,
(const unsigned char *)fp->node->name,
fp->idx,
fp->node->dummy,
fp->cluster_idx,
Expand Down Expand Up @@ -288,7 +289,7 @@ s32 nandfs_initialize(void)

initialized = 1;

fs_hmac_set_key(otp.nand_hmac, 20);
fs_hmac_set_key((char *)otp.nand_hmac, 20);
return 0;
}

Expand Down Expand Up @@ -592,7 +593,7 @@ s32 nandfs_read(u8 *ptr, u32 size, u32 nmemb, struct nandfs_fp *fp)
if(fp->cur_cluster > 0xfff0) {
return size*nmemb - total;
}
if(fp->offset / (PAGE_SIZE * 8) == fp->cluster_idx) {
if(fp->offset / (PAGE_SIZE * 8) == (size_t)fp->cluster_idx) {
copy_offset = fp->offset % (PAGE_SIZE * 8);
copy_len = (PAGE_SIZE * 8) - copy_offset;
if(copy_len > total)
Expand Down Expand Up @@ -684,7 +685,7 @@ s32 nandfs_write(const u8 *ptr, u32 size, u32 nmemb, struct nandfs_fp *fp)
}
}

if(fp->offset / (PAGE_SIZE * 8) == fp->cluster_idx) {
if(fp->offset / (PAGE_SIZE * 8) == (size_t)fp->cluster_idx) {
copy_offset = fp->offset % (PAGE_SIZE * 8);
copy_len = (PAGE_SIZE * 8) - copy_offset;
if(copy_len > total)
Expand Down
1 change: 1 addition & 0 deletions nandfs.h
Expand Up @@ -49,5 +49,6 @@ s32 nandfs_read(u8 *ptr, u32 size, u32 nmemb, struct nandfs_fp *fp);
s32 nandfs_write(const u8 *ptr, u32 size, u32 nmemb, struct nandfs_fp *fp);
s32 nandfs_seek(struct nandfs_fp *fp, s32 offset, u32 whence);
s32 nandfs_delete(struct nandfs_fp *fp);
void nandfs_writemeta(void);
#endif

9 changes: 4 additions & 5 deletions rijndael.c
Expand Up @@ -9,8 +9,7 @@
*/

#include <stdio.h>
#include <string.h>
#include "string.h"

#define u8 unsigned char /* 8 bits */
#define u32 unsigned long /* 32 bits */
Expand Down Expand Up @@ -334,7 +333,7 @@ void decrypt(char *buff)

void my_aes_set_key(u8 *key) {
gentables();
gkey(4, 4, key);
gkey(4, 4, (char *)key);
}

// CBC mode decryption
Expand All @@ -354,7 +353,7 @@ void my_aes_decrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len) {

// debug_printf("block %d: fraction = %d\n", blockno, fraction);
memcpy(block, inbuf + blockno * sizeof(block), fraction);
decrypt(block);
decrypt((char *)block);
u8 *ctext_ptr;
if (blockno == 0) ctext_ptr = iv;
else ctext_ptr = inbuf + (blockno-1) * sizeof(block);
Expand Down Expand Up @@ -388,7 +387,7 @@ void my_aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len) {
for(i=0; i < fraction; i++)
block[i] = inbuf[blockno * sizeof(block) + i] ^ iv[i];

encrypt(block);
encrypt((char*)block);
memcpy(iv, block, sizeof(block));
memcpy(outbuf + blockno * sizeof(block), block, sizeof(block));
// debug_printf("Block %d output: ", blockno);
Expand Down
3 changes: 2 additions & 1 deletion wad.c
Expand Up @@ -20,6 +20,7 @@
#include "es.h"
#include "aes.h"
#include "malloc.h"
#include "main.h"

#define ASSERT(x) do { if(!(x)) { printf("Assert failure: %s in %s:%d\n", #x, __FILE__, __LINE__); return -1; } } while(0)

Expand Down Expand Up @@ -83,7 +84,7 @@ s32 wad_install(FIL *fil)
printf("num contents: %d\n", tmd->num_contents);
printf("%08x %08x\n", tmd, tik);
for(i = 0; i < tmd->num_contents; i++) {
u8 *content = 0x91000000;//memalign(32, ALIGN(tmd->contents[i].size, 0x40));
u8 *content = (void *)0x91000000;//memalign(32, ALIGN(tmd->contents[i].size, 0x40));
ASSERT(content);

f_lseek(fil, offset);
Expand Down

0 comments on commit 0103e7c

Please sign in to comment.