diff --git a/common/sbus/src/iop_sif2.c b/common/sbus/src/iop_sif2.c index 502bff4fb4cf..0fb10a1f4940 100644 --- a/common/sbus/src/iop_sif2.c +++ b/common/sbus/src/iop_sif2.c @@ -61,9 +61,7 @@ int SIF2_RestartDma(void) _sif2_xfer_chunk_size = (_sif2_xfer_size > SIF2_XFER_CHUNK_SIZE) ? SIF2_XFER_CHUNK_SIZE : _sif2_xfer_size; bs = ((_sif2_xfer_chunk_size + 3) / 4); - if (bs > 32) { - bs = 32; - } + bs = (bs > 32) ? 32 : bs; bc = (_sif2_xfer_chunk_size + ((bs * 4) - 1)) / (bs * 4); @@ -86,9 +84,7 @@ int SIF2_set_dma(u32 addr, u32 size, u32 attr) _sif2_xfer_addr = addr; _sif2_xfer_size = size; - if (!(attr & PS2_DMA_FROM_MEM)) { - attr |= IOP_CHCR_30; - } + attr |= (!(attr & PS2_DMA_FROM_MEM)) ? IOP_CHCR_30 : 0; _sif2_xfer_attr = IOP_CHCR_TR | attr; diff --git a/common/sbus/src/ps2_dbg.c b/common/sbus/src/ps2_dbg.c index 5ab62de74b7c..af46fbdf6cbe 100644 --- a/common/sbus/src/ps2_dbg.c +++ b/common/sbus/src/ps2_dbg.c @@ -33,10 +33,7 @@ void _sif2_cmd_puts(SIF2_CmdPkt *cmd, void *param) while (left > 0) { int toget; - toget = left; - if (toget > sizeof(_dbg_cmd_dma_buf)) { - toget = sizeof(_dbg_cmd_dma_buf); - } + toget = (left > sizeof(_dbg_cmd_dma_buf)) ? sizeof(_dbg_cmd_dma_buf) : left; // sio_printf("getting %d of %d bytes left\n", toget, left); diff --git a/ee/debug/src/scr_printf.c b/ee/debug/src/scr_printf.c index 29a39746dbd8..cb4c5b10c002 100644 --- a/ee/debug/src/scr_printf.c +++ b/ee/debug/src/scr_printf.c @@ -271,10 +271,8 @@ void scr_vprintf(const char *format, va_list opt) void scr_setXY(int x, int y) { - if (x < MX && x >= 0) - X = x; - if (y < MY && y >= 0) - Y = y; + X = (x < MX && x >= 0) ? x : X; + Y = (y < MY && y >= 0) ? y : Y; } int scr_getX() diff --git a/ee/debug/src/screenshot.c b/ee/debug/src/screenshot.c index b7d9c0db035b..3c0a40a8b45f 100644 --- a/ee/debug/src/screenshot.c +++ b/ee/debug/src/screenshot.c @@ -198,12 +198,7 @@ int ps2_screenshot( void *pDest, unsigned int VramAdress, unsigned int x, // Calc size depending on Psm - if( Psm == PS2SS_GSPSMCT16 ) - uQSize = ((Width*Height*2)/16); - else if( Psm == PS2SS_GSPSMCT24 ) - uQSize = ((Width*Height*3)/16); - else - uQSize = (Width*Height*4)/16; + uQSize = ( Psm == PS2SS_GSPSMCT16 ) ? ((Width*Height*2)/16) : (( Psm == PS2SS_GSPSMCT24 ) ? ((Width*Height*3)/16) : ((Width*Height*4)/16)); // Setup transfer texture back to memory diff --git a/ee/dma/src/dma.c b/ee/dma/src/dma.c index 6fb6d44820a9..f9394d2fe473 100644 --- a/ee/dma/src/dma.c +++ b/ee/dma/src/dma.c @@ -85,14 +85,7 @@ int dma_channel_initialize(int channel, void *handler, int flags) dma_handler_id[channel] = AddDmacHandler(channel, handler, 0); // Enable the channel interrupt. - if (flags & DMA_FLAG_INTERRUPTSAFE) - { - iEnableDmac(channel); - } - else - { - EnableDmac(channel); - } + ((flags & DMA_FLAG_INTERRUPTSAFE) ? iEnableDmac : EnableDmac)(channel); } @@ -189,14 +182,7 @@ int dma_channel_send_chain(int channel, void *data, int data_size, int flags, in // clear channel status *DMA_REG_STAT = DMA_SET_STAT(1 << channel,0,0,0,0,0,0); - if (flags & DMA_FLAG_INTERRUPTSAFE) - { - iSyncDCache(data, (void *)((u8 *)data + (data_size<<4))); - } - else - { - SyncDCache(data, (void *)((u8 *)data + (data_size<<4))); - } + ((flags & DMA_FLAG_INTERRUPTSAFE) ? iSyncDCache : SyncDCache)(data, (void *)((u8 *)data + (data_size<<4))); // Set the size of the data, in quadwords. *(vu32 *)dma_qwc[channel] = DMA_SET_QWC(0); @@ -245,14 +231,7 @@ int dma_channel_send_normal(int channel, void *data, int qwc, int flags, int spr *DMA_REG_STAT = DMA_SET_STAT(1 << channel,0,0,0,0,0,0); // Not sure if this should be here. - if (flags & DMA_FLAG_INTERRUPTSAFE) - { - iSyncDCache(data, (void *)((u8 *)data + (qwc<<4))); - } - else - { - SyncDCache(data, (void *)((u8 *)data + (qwc<<4))); - } + ((flags & DMA_FLAG_INTERRUPTSAFE) ? iSyncDCache : SyncDCache)(data, (void *)((u8 *)data + (qwc<<4))); // Set the size of the data, in quadwords. *(vu32 *)dma_qwc[channel] = DMA_SET_QWC(qwc); @@ -274,14 +253,7 @@ int dma_channel_send_normal_ucab(int channel, void *data, int qwc, int flags) *DMA_REG_STAT = DMA_SET_STAT(1 << channel,0,0,0,0,0,0); // Not sure if this should be here. - if (flags & DMA_FLAG_INTERRUPTSAFE) - { - iSyncDCache(data, (void *)((u8 *)data + (qwc<<4))); - } - else - { - SyncDCache(data, (void *)((u8 *)data + (qwc<<4))); - } + ((flags & DMA_FLAG_INTERRUPTSAFE) ? iSyncDCache : SyncDCache)(data, (void *)((u8 *)data + (qwc<<4))); // Set the size of the data, in quadwords. *(vu32 *)dma_qwc[channel] = DMA_SET_QWC(qwc); @@ -368,14 +340,7 @@ int dma_channel_shutdown(int channel, int flags) { // Disable the channel. - if (flags & DMA_FLAG_INTERRUPTSAFE) - { - iDisableDmac(channel); - } - else - { - DisableDmac(channel); - } + ((flags & DMA_FLAG_INTERRUPTSAFE) ? iDisableDmac : DisableDmac)(channel); // Remove the handler. RemoveDmacHandler(channel, dma_handler_id[channel]); diff --git a/ee/draw/src/draw.c b/ee/draw/src/draw.c index fba86612abc8..7ee8278f1c7e 100644 --- a/ee/draw/src/draw.c +++ b/ee/draw/src/draw.c @@ -29,17 +29,12 @@ qword_t *draw_setup_environment(qword_t *q, int context, framebuffer_t *frame, z dtest.pass = DRAW_DISABLE; // Enable or Disable ZBuffer - if (z->enable) - { - ztest.enable = DRAW_ENABLE; - ztest.method = z->method; - } - else + if (!z->enable) { z->mask = 1; - ztest.enable = DRAW_ENABLE; - ztest.method = ZTEST_METHOD_ALLPASS; } + ztest.enable = DRAW_ENABLE; + ztest.method = z->enable ? z->method : ZTEST_METHOD_ALLPASS; // Setup alpha blending blend.color1 = BLEND_COLOR_SOURCE; @@ -96,16 +91,8 @@ qword_t *draw_setup_environment(qword_t *q, int context, framebuffer_t *frame, z PACK_GIFTAG(q,GS_SET_COLCLAMP(GS_ENABLE),GS_REG_COLCLAMP); q++; // Alpha Correction - if ((frame->psm == GS_PSM_16) || (frame->psm == GS_PSM_16S)) - { - PACK_GIFTAG(q,GS_SET_FBA(ALPHA_CORRECT_RGBA16),GS_REG_FBA + context); - q++; - } - else - { - PACK_GIFTAG(q,GS_SET_FBA(ALPHA_CORRECT_RGBA32),GS_REG_FBA + context); - q++; - } + PACK_GIFTAG(q,GS_SET_FBA((((frame->psm == GS_PSM_16) || (frame->psm == GS_PSM_16S)) ? ALPHA_CORRECT_RGBA16 : ALPHA_CORRECT_RGBA32)),GS_REG_FBA + context); + q++; // Texture wrapping/clamping PACK_GIFTAG(q, GS_SET_CLAMP(wrap.horizontal,wrap.vertical,wrap.minu, wrap.maxu,wrap.minv,wrap.maxv), GS_REG_CLAMP + context); diff --git a/ee/elf-loader2/src/elf.c b/ee/elf-loader2/src/elf.c index 12d361160d6d..1a0baf031af3 100644 --- a/ee/elf-loader2/src/elf.c +++ b/ee/elf-loader2/src/elf.c @@ -112,17 +112,7 @@ int elf_loader_is_elf_valid_for_loading(const void *buf, size_t buf_size) ph_count += 1; } } - if ( !ph_count || ph_count > ELF_LOADER_MAX_PROGRAM_HEADERS ) - { - return -21; - } - if ( !entrypoint_in_ph ) - { - return -22; - } - if ( buf_size < highest_offset ) - return -32; - return 0; + return ( !ph_count || ph_count > ELF_LOADER_MAX_PROGRAM_HEADERS ) ? -21 : (( !entrypoint_in_ph ) ? -22 : (( buf_size < highest_offset ) ? -32 : 0)); } int elf_loader_exec_elf_prepare_loadinfo(elf_loader_execinfo_t *execinfo, const void *buf, size_t buf_size) diff --git a/ee/elf-loader2/src/elf_loader_reader.c b/ee/elf-loader2/src/elf_loader_reader.c index b56a100c95f1..81ec280a0835 100644 --- a/ee/elf-loader2/src/elf_loader_reader.c +++ b/ee/elf-loader2/src/elf_loader_reader.c @@ -48,8 +48,7 @@ void elf_loader_reader_read_elf_file(elf_loader_reader_info_t *info) int ret; ret = elf_loader_is_elf_ehdr_valid(ptr); - if ( ret ) - ptr = info->m_alloc_callback(info->m_userdata, ptr, cur_alloc_block_size, 0); + ptr = ret ? info->m_alloc_callback(info->m_userdata, ptr, cur_alloc_block_size, 0) : ptr; } if ( ptr ) { diff --git a/ee/erl/src/erl.c b/ee/erl/src/erl.c index 2bd1858611e8..57ce3de02010 100644 --- a/ee/erl/src/erl.c +++ b/ee/erl/src/erl.c @@ -382,10 +382,7 @@ static void destroy_erl_record(struct erl_record_t * erl) { erl_flush_symbols(erl); - if (erl->prev) - erl->prev->next = erl->next; - else - erl_record_root = erl->next; + *(erl->prev ? &(erl->prev->next) : &erl_record_root) = erl->next; if (erl->next) erl->next->prev = erl->prev; @@ -429,26 +426,15 @@ static int apply_reloc(u8 * reloc, int type, u32 addr) { } struct symbol_t * erl_find_local_symbol(const char * symbol, struct erl_record_t * erl) { - if (!erl) - return 0; - if (hfind(erl->symbols, symbol, strlen(symbol))) - return hstuff(erl->symbols); - return 0; + return (!erl) ? 0 : ((hfind(erl->symbols, symbol, strlen(symbol))) ? hstuff(erl->symbols) : 0); } static struct symbol_t * r_find_symbol(const char * symbol, struct erl_record_t * erl) { - if (!erl) - return 0; - if (hfind(erl->symbols, symbol, strlen(symbol))) - return hstuff(erl->symbols); - return r_find_symbol(symbol, erl->next); + return (!erl) ? 0 : ((hfind(erl->symbols, symbol, strlen(symbol))) ? hstuff(erl->symbols) : r_find_symbol(symbol, erl->next)); } struct symbol_t * erl_find_symbol(const char * symbol) { - if (global_symbols) - if (hfind(global_symbols, symbol, strlen(symbol))) - return hstuff(global_symbols); - return r_find_symbol(symbol, erl_record_root); + return (global_symbols && hfind(global_symbols, symbol, strlen(symbol))) ? hstuff(global_symbols) : r_find_symbol(symbol, erl_record_root); } static struct dependancy_t * add_dependancy(struct erl_record_t * depender, struct erl_record_t * provider) { @@ -473,10 +459,7 @@ static struct dependancy_t * add_dependancy(struct erl_record_t * depender, stru } static void destroy_dependancy(struct dependancy_t * d) { - if (d->prev) - d->prev->next = d->next; - else - dependancy_root = d->next; + *(d->prev ? &(d->prev->next) : &dependancy_root) = d->next; if (d->next) d->next->prev = d->prev; @@ -550,13 +533,9 @@ static int is_local(const char * symbol) { static int add_symbol(struct erl_record_t * erl, const char * symbol, u32 address) { htab * symbols; - if (erl) { - symbols = erl->symbols; - } else { - if (!global_symbols) - global_symbols = hcreate(6); - symbols = global_symbols; - } + if (!erl && !global_symbols) + global_symbols = hcreate(6); + symbols = erl ? erl->symbols : global_symbols; if (!is_local(symbol) && erl_find_symbol(symbol)) return -1; @@ -664,10 +643,9 @@ return code } // **TODO** handle compession - if (elf_mem) { - sec = (struct elf_section_t *) (elf_mem + head.e_shoff); - } else { - if (!(sec = (struct elf_section_t *) malloc(sizeof(struct elf_section_t) * head.e_shnum))) { + sec = elf_mem ? (struct elf_section_t *) (elf_mem + head.e_shoff) : (struct elf_section_t *) malloc(sizeof(struct elf_section_t) * head.e_shnum); + if (!elf_mem) { + if (!sec) { dprintf("Not enough memory.\n"); free_and_return(-1); } @@ -677,10 +655,9 @@ return code // Reading the section names's table. // **TODO** handle compession - if (elf_mem) { - names = (char *) (elf_mem + sec[head.e_shstrndx].sh_offset); - } else { - if (!(names = (char *) malloc(sec[head.e_shstrndx].sh_size))) { + names = elf_mem ? (char *) (elf_mem + sec[head.e_shstrndx].sh_offset) : (char *) malloc(sec[head.e_shstrndx].sh_size); + if (!elf_mem) { + if (!names) { dprintf("Not enough memory.\n"); free_and_return(-1); } @@ -788,10 +765,9 @@ return code // Loading strtab. // **TODO** handle compession - if (elf_mem) { - strtab_names = (char *) (elf_mem + sec[strtab].sh_offset); - } else { - if (!(strtab_names = (char *) malloc(sec[strtab].sh_size))) { + strtab_names = elf_mem ? (char *) (elf_mem + sec[strtab].sh_offset) : (char *) malloc(sec[strtab].sh_size); + if (!elf_mem) { + if (!strtab_names) { dprintf("Not enough memory.\n"); free_and_return(-1); } @@ -802,10 +778,9 @@ return code // Loading symtab. // **TODO** handle compession - if (elf_mem) { - sym = (struct elf_symbol_t *) (elf_mem + sec[symtab].sh_offset); - } else { - if (!(sym = (struct elf_symbol_t *) malloc(sec[symtab].sh_size))) { + sym = elf_mem ? (struct elf_symbol_t *) (elf_mem + sec[symtab].sh_offset) : (struct elf_symbol_t *) malloc(sec[symtab].sh_size); + if (!elf_mem) { + if (!sym) { dprintf("Not enough memory.\n"); free_and_return(-1); } @@ -827,11 +802,9 @@ return code // Loading relocation section. // **TODO** handle compession - if (elf_mem) { - reloc_section = (char *)(elf_mem + sec[i].sh_offset); - } else { - lseek(elf_handle, sec[i].sh_offset, SEEK_SET); - if (!(reloc_section = (char *) malloc(sec[i].sh_size))) { + reloc_section = elf_mem ? (char *)(elf_mem + sec[i].sh_offset) : (char *) malloc(sec[i].sh_size); + if (!elf_mem) { + if (!reloc_section) { dprintf("Not enough memory.\n"); free_and_return(-1); } @@ -850,11 +823,10 @@ return code sym_n = reloc.r_info >> 8; - has_next_reloc = 0; - if ((u32)j+1 < (sec[i].sh_size / sec[i].sh_entsize)) { + has_next_reloc = ((u32)j+1 < (sec[i].sh_size / sec[i].sh_entsize)) ? 1 : 0; + if (has_next_reloc) { next_reloc = *((struct elf_reloc_t *) (reloc_section + ((j+1) * sec[i].sh_entsize))); next_sym_n = reloc.r_info >> 8; - has_next_reloc = 1; } dprintf("%6i: %08X %-14s %3i: ", j, reloc.r_offset, reloc_types[reloc.r_info & 255], sym_n); @@ -989,19 +961,11 @@ static struct erl_record_t * load_erl(const char * fname, u8 * elf_mem, u32 addr close(elf_handle); } - if ((s = erl_find_local_symbol("erl_id", r))) { - r->name = *(char **) s->address; - } else { - r->name = 0; - } + r->name = ((s = erl_find_local_symbol("erl_id", r))) ? *(char **) s->address : 0; dprintf("erl_id = %08X.\n", r->name); - if ((s = erl_find_local_symbol("erl_dependancies", r))) { - r->dependancies = (char **) s->address; - } else { - r->dependancies = 0; - } + r->dependancies = ((s = erl_find_local_symbol("erl_dependancies", r))) ? (char **) s->address : 0; dprintf("erl_dependancies = %08X.\n", r->dependancies); @@ -1193,11 +1157,7 @@ int main(int argc, char *argv[]) { erl_add_global_symbol("printf", (u32) printf); - if (argc == 2) { - fname = argv[1]; - } else { - fname = "host:hello-erl.erl"; - } + fname = (argc == 2) ? argv[1] : "host:hello-erl.erl"; if (!(erl = load_erl_from_file(fname))) { dprintf("Error while loading erl file.\n"); diff --git a/ee/font/src/fontx.c b/ee/font/src/fontx.c index 3a448cbcc699..a1ac5b3e7f4a 100644 --- a/ee/font/src/fontx.c +++ b/ee/font/src/fontx.c @@ -268,20 +268,9 @@ int fontx_load(const char *path, fontx_t* fontx, int type, int wmargin, int hmar if (!strcmp("rom0:KROM",path) || !strcmp("rom0:/KROM",path)) { - int ret = -1; + int ret; - if (type == SINGLE_BYTE) - { - - ret = fontx_load_single_krom(fontx); - - } - else - { - - ret = fontx_load_double_krom(fontx); - - } + ret = (type == SINGLE_BYTE) ? fontx_load_single_krom(fontx) : fontx_load_double_krom(fontx); if (ret < 0) { @@ -361,19 +350,8 @@ int fontx_load(const char *path, fontx_t* fontx, int type, int wmargin, int hmar fontx->bold = bold; // This is the offset that character data starts - if (fontx_header->type == SINGLE_BYTE) - { - - fontx->offset = 17; - - } - else - { - - // 17 + 1 + (number of tables * 4) bytes - fontx->offset = 18 + (fontx_header->table_num * 4); - - } + // 17 + 1 + (number of tables * 4) bytes + fontx->offset = (fontx_header->type == SINGLE_BYTE) ? 17 : (18 + (fontx_header->table_num * 4)); return 0; @@ -465,22 +443,9 @@ u64 *draw_fontx_row(u64 *dw, unsigned char byte, int x, int y, int z, int bold) { // if there's a bit - if (byte & mask) - { - + if (!(byte & mask) || (bold && px)) *dw++ = GS_SET_XYZ((x+(i<<4)) + 32768,y+32768,z); - px = 1; - - } - else - { - - if (bold && px) - *dw++ = GS_SET_XYZ((x+(i<<4)) + 32768,y+32768,z); - - px = 0; - - } + px = (byte & mask) ? 1 : 0; mask >>= 1; @@ -622,10 +587,7 @@ qword_t *fontx_print_ascii(qword_t *q, int context, const unsigned char *str, in while (str[i] == '\t' || str[i] == '\n') { - if (str[i] == '\t') - { - line_num[line] += 4; - } + line_num[line] += (str[i] == '\t') ? 4 : 0; if (str[i] == '\n') { @@ -659,10 +621,7 @@ qword_t *fontx_print_ascii(qword_t *q, int context, const unsigned char *str, in while (str[i] == '\t' || str[i] == '\n') { - if (str[i] == '\t') - { - line_num[line] += 4; - } + line_num[line] += (str[i] == '\t') ? 4 : 0; if (str[i] == '\n') { @@ -706,10 +665,7 @@ qword_t *fontx_print_ascii(qword_t *q, int context, const unsigned char *str, in v_pos.y += h + hm; v_pos.x = x_orig[line]; } - if (str[j] == '\t') - { - v_pos.x += w * 5.0f; - } + v_pos.x += (str[j] == '\t') ? (w * 5.0f) : 0; j++; } @@ -774,10 +730,7 @@ qword_t *fontx_print_sjis(qword_t *q, int context, const unsigned char *str, int while (str[i] == '\t'|| str[i] == '\n') { - if (str[i] == '\t') - { - halfwidth[line] += 4; - } + halfwidth[line] += (str[i] == '\t') ? 4 : 0; if (str[i] == '\n') { x_orig[line] = v_pos.x; @@ -806,10 +759,7 @@ qword_t *fontx_print_sjis(qword_t *q, int context, const unsigned char *str, int while (str[i] == '\t'|| str[i] == '\n') { - if (str[i] == '\t') - { - halfwidth[line] += 4; - } + halfwidth[line] += (str[i] == '\t') ? 4 : 0; if (str[i] == '\n') { x_orig[line] = v_pos.x - ((halfwidth[line] * (hw+wm)) + (fullwidth[line] * (fw + wm)));; @@ -854,10 +804,7 @@ qword_t *fontx_print_sjis(qword_t *q, int context, const unsigned char *str, int while (str[i] == '\t'|| str[i] == '\n') { - if (str[i] == '\t') - { - halfwidth[line] += 4; - } + halfwidth[line] += (str[i] == '\t') ? 4 : 0; if (str[i] == '\n') { x_orig[line] = v_pos.x - ((halfwidth[line] * (hw+wm)) + (fullwidth[line] * (fw + wm)))/2.0f; @@ -915,10 +862,7 @@ qword_t *fontx_print_sjis(qword_t *q, int context, const unsigned char *str, int v_pos.y += h + hm; v_pos.x = x_orig[line]; } - if (str[j] == '\t') - { - v_pos.x += hw * 5.0f; - } + v_pos.x += (str[j] == '\t') ? (hw * 5.0f) : 0; j++; } diff --git a/ee/font/src/fsfont.c b/ee/font/src/fsfont.c index 225ba1773281..715475fe8e7e 100644 --- a/ee/font/src/fsfont.c +++ b/ee/font/src/fsfont.c @@ -537,14 +537,8 @@ qword_t *fontstudio_print_string(qword_t *q, int context, const unsigned char *s line++; line_num[line] = 0; } - if (utf8[i] == TAB) - { - line_num[line] += font->spacewidth * 4; - } - if (utf8[i] == SPACE) - { - line_num[line] += font->spacewidth; - } + line_num[line] += (utf8[i] == TAB) ? (font->spacewidth * 4) : 0; + line_num[line] += (utf8[i] == SPACE) ? font->spacewidth : 0; i++; } @@ -574,14 +568,8 @@ qword_t *fontstudio_print_string(qword_t *q, int context, const unsigned char *s line++; line_num[line] = 0; } - if (utf8[i] == TAB) - { - line_num[line] += font->spacewidth * 4; - } - if (utf8[i] == SPACE) - { - line_num[line] += font->spacewidth; - } + line_num[line] += (utf8[i] == TAB) ? (font->spacewidth * 4) : 0; + line_num[line] += (utf8[i] == SPACE) ? font->spacewidth : 0; i++; } @@ -617,14 +605,8 @@ qword_t *fontstudio_print_string(qword_t *q, int context, const unsigned char *s v_pos.y += font->height*font->scale; v_pos.x = x_orig[line]; } - if (utf8[j] == TAB) - { - v_pos.x += font->spacewidth*font->scale * 4.0f; - } - if (utf8[j] == SPACE) - { - v_pos.x += font->spacewidth*font->scale; - } + v_pos.x += (utf8[j] == TAB) ? (font->spacewidth*font->scale * 4.0f) : 0; + v_pos.x += (utf8[j] == SPACE) ? (font->spacewidth*font->scale) : 0; j++; } diff --git a/ee/graph/src/graph_mode.c b/ee/graph/src/graph_mode.c index 6755136138b9..6641f4a82cac 100644 --- a/ee/graph/src/graph_mode.c +++ b/ee/graph/src/graph_mode.c @@ -254,22 +254,9 @@ int graph_set_screen(int x, int y, int width, int height) } // Set the display attributes but use the user defined height. - if (graph_filter) - { - - // For flicker filter, we need to get add an extra line. - *GS_REG_DISPLAY1 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-1); - *GS_REG_DISPLAY2 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-2); - - } - else - { - - *GS_REG_DISPLAY1 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-1); - *GS_REG_DISPLAY2 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-1); - - } - + // For flicker filter, we need to get add an extra line. + *GS_REG_DISPLAY1 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-1); + *GS_REG_DISPLAY2 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-(graph_filter ? 2 : 1)); return 0; } @@ -286,21 +273,8 @@ void graph_set_framebuffer_filtered(int fbp, int width, int psm, int x, int y) void graph_set_framebuffer(int context, int fbp, int width, int psm, int x, int y) { - - if (context == 0) - { - - *GS_REG_DISPFB1 = GS_SET_DISPFB(fbp>>11,width>>6,psm,x,y); - - } - else - { - - // For flicker filter, we need to offset the lines by 1 for the other read circuit. - *GS_REG_DISPFB2 = GS_SET_DISPFB(fbp>>11,width>>6,psm,x,y); - - } - + // For flicker filter, we need to offset the lines by 1 for the other read circuit. + *((context == 0) ? GS_REG_DISPFB1 : GS_REG_DISPFB2) = GS_SET_DISPFB(fbp>>11,width>>6,psm,x,y); } void graph_set_bgcolor(unsigned char r, unsigned char g, unsigned char b) @@ -323,20 +297,7 @@ void graph_set_output(int rc1, int rc2, int alpha_select, int alpha_output, int // numbered lines are more biased against the even lines, producing less jitter. void graph_enable_output(void) { - - if (graph_filter) - { - - graph_set_output(GRAPH_ENABLE,GRAPH_ENABLE,GRAPH_VALUE_ALPHA,GRAPH_RC1_ALPHA,GRAPH_BLEND_RC2,0x70); - - } - else - { - - graph_set_output(0,1,0,1,0,0x80); - - } - + graph_set_output(graph_filter ? GRAPH_ENABLE : GRAPH_DISABLE,GRAPH_ENABLE, graph_filter ? GRAPH_VALUE_ALPHA : GRAPH_VALUE_RC1, graph_filter ? GRAPH_RC1_ALPHA : GRAPH_RC2_ALPHA, GRAPH_BLEND_RC2, graph_filter ? 0x70 : 0x80); } void graph_disable_output(void) @@ -413,18 +374,7 @@ float graph_aspect_ratio(void) float graph_aspect; // Get the tv screen type as defined in the osd configuration. - if (configGetTvScreenType() == TV_SCREEN_169) - { - - graph_aspect = 1.78f; - - } - else - { - - graph_aspect = 1.33f; - - } + graph_aspect = (configGetTvScreenType() == TV_SCREEN_169) ? 1.78f : 1.33f; // Return the current aspect ratio return graph_aspect * (graph_height / graph_width); diff --git a/ee/input/src/input.c b/ee/input/src/input.c index 6d5c585d6393..7ef0e096a008 100644 --- a/ee/input/src/input.c +++ b/ee/input/src/input.c @@ -217,14 +217,7 @@ void pad_set_mode(pad_t *pad, int mode, int lock) int status = 0; - if (lock == PAD_MMODE_LOCK) - { - pad->lock = lock; - } - else - { - pad->lock = PAD_MMODE_UNLOCK; - } + pad->lock = (lock == PAD_MMODE_LOCK) ? lock : PAD_MMODE_UNLOCK; if ((mode == PAD_MMODE_DUALSHOCK) || (mode == PAD_TYPE_DUALSHOCK)) { @@ -273,15 +266,7 @@ void pad_set_sensitivity(pad_t *pad, int enable) return; } - if (enable) - { - padEnterPressMode(pad->port,pad->slot); - } - else - { - padExitPressMode(pad->port,pad->slot); - } - + (enable ? padEnterPressMode : padExitPressMode)(pad->port,pad->slot); } @@ -326,14 +311,7 @@ void pad_init_actuators(pad_t *pad) void pad_set_actuators(pad_t *pad, int small, unsigned char large) { - if (!small) - { - pad->actuator->small = small; - } - else - { - pad->actuator->small = 0x01; - } + pad->actuator->small = (!small) ? small : 0x01; pad->actuator->large = large; diff --git a/ee/kernel/src/fileio.c b/ee/kernel/src/fileio.c index a2d957b1fbeb..f0de1755de99 100644 --- a/ee/kernel/src/fileio.c +++ b/ee/kernel/src/fileio.c @@ -293,12 +293,8 @@ int fioWrite(int fd, const void *ptr, int size) arg.size = size; /* Copy the unaligned (16-byte) portion into the argument */ - mis = 0; - if ((u32)ptr & 0xf) { - mis = 16 - ((u32)ptr & 0xf); - if (mis > size) - mis = size; - } + mis = ((u32)ptr & 0xf) ? (16 - ((u32)ptr & 0xf)) : 0; + mis = (mis > size) ? size : mis; arg.mis = mis; if (mis) diff --git a/ee/kernel/src/kernel_util.c b/ee/kernel/src/kernel_util.c index df3d7e61de12..ef8d347338ae 100644 --- a/ee/kernel/src/kernel_util.c +++ b/ee/kernel/src/kernel_util.c @@ -40,11 +40,7 @@ s32 WaitSemaEx(s32 semaid, int signal, u64 *timeout) if (timeout != NULL && *timeout == 0) { ret = PollSema(semaid); - if (ret < 0) - { - return ret; - } - return semaid; + return (ret < 0) ? ret : semaid; } if (timeout != NULL) diff --git a/ee/kernel/src/loadfile.c b/ee/kernel/src/loadfile.c index 8fea1224c580..e334ba0c34e9 100644 --- a/ee/kernel/src/loadfile.c +++ b/ee/kernel/src/loadfile.c @@ -78,12 +78,8 @@ int _SifLoadModule(const char *path, int arg_len, const char *args, int *modres, strncpy(arg.path, path, LF_PATH_MAX - 1); arg.path[LF_PATH_MAX - 1] = 0; - if (args && arg_len) { - arg.p.arg_len = arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len; - memcpy(arg.args, args, arg.p.arg_len); - } else { - arg.p.arg_len = 0; - } + arg.p.arg_len = (args && arg_len) ? (arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len) : 0; + memcpy(arg.args, args, arg.p.arg_len); if (sceSifCallRpc(&_lf_cd, fno, dontwait, &arg, sizeof arg, &arg, 8, NULL, NULL) < 0) return -SCE_ECALLMISS; @@ -126,12 +122,8 @@ int SifStopModule(int id, int arg_len, const char *args, int *mod_res) arg.p.id = id; - if (args && arg_len) { - arg.q.arg_len = arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len; - memcpy(arg.args, args, arg.q.arg_len); - } else { - arg.q.arg_len = 0; - } + arg.q.arg_len = (args && arg_len) ? (arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len) : 0; + memcpy(arg.args, args, arg.q.arg_len); if (sceSifCallRpc(&_lf_cd, LF_F_MOD_STOP, 0, &arg, sizeof arg, &arg, 8, NULL, NULL) < 0) return -SCE_ECALLMISS; @@ -320,12 +312,8 @@ int _SifLoadModuleBuffer(void *ptr, int arg_len, const char *args, int *modres) memset(&arg, 0, sizeof arg); arg.p.ptr = ptr; - if (args && arg_len) { - arg.q.arg_len = arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len; - memcpy(arg.args, args, arg.q.arg_len); - } else { - arg.q.arg_len = 0; - } + arg.q.arg_len = (args && arg_len) ? (arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len) : 0; + memcpy(arg.args, args, arg.q.arg_len); if (sceSifCallRpc(&_lf_cd, LF_F_MOD_BUF_LOAD, 0, &arg, sizeof arg, &arg, 8, NULL, NULL) < 0) diff --git a/ee/kernel/src/osd_config.c b/ee/kernel/src/osd_config.c index 43ea09633eb6..e36c1f6ff941 100644 --- a/ee/kernel/src/osd_config.c +++ b/ee/kernel/src/osd_config.c @@ -207,9 +207,7 @@ int configGetLanguage(void) return g_t10KConfig.language; GetOsdConfigParam(&config); - if (IsEarlyJap(config)) - return config.japLanguage; - return config.language; + return (IsEarlyJap(config)) ? config.japLanguage : config.language; } #endif diff --git a/ee/kernel/src/osdsrc/src/osd.c b/ee/kernel/src/osdsrc/src/osd.c index 618f2814e81f..956e0ddc5a22 100644 --- a/ee/kernel/src/osdsrc/src/osd.c +++ b/ee/kernel/src/osdsrc/src/osd.c @@ -66,17 +66,9 @@ void SetOsdConfigParam2(void *config, int size, int offset) u8 *ptr; ptr = config; - if ((WriteEnd = offset + size) >= 0x81) { - unsigned int AmountToWrite; - if (offset < 0x80) { - AmountToWrite = 0x80 - offset; - } else { - offset = 0x80; - AmountToWrite = 0; - } - - WriteEnd = AmountToWrite + offset; - } + WriteEnd = offset + size; + offset = (WriteEnd >= 0x81 && offset >= 0x80) ? 0x80 : offset; + WriteEnd = (WriteEnd >= 0x81) ? 0x80 : WriteEnd; for (i = 0; offset < WriteEnd; i++, offset++) { OSDConfig2[offset] = ptr[i]; @@ -89,15 +81,9 @@ int GetOsdConfigParam2(void *config, int size, int offset) u8 *ptr; ptr = config; - if ((ReadEnd = offset + size) >= 0x81) { - if (offset < 0x80) { - AmountToRead = 0x80 - offset; - } else { - offset = 0x80; - AmountToRead = 0; - } - } else - AmountToRead = size; + ReadEnd = offset + size; + offset = (ReadEnd >= 0x81 && offset >= 0x80) ? 0x80 : offset; + AmountToRead = (ReadEnd >= 0x81) ? (0x80 - offset) : size; ReadEnd = AmountToRead + offset; for (i = 0; offset < ReadEnd; i++, offset++) { diff --git a/ee/kernel/src/osdsrc/src/osdsrc.c b/ee/kernel/src/osdsrc/src/osdsrc.c index 29dcce95634c..8a2a8b7430b0 100644 --- a/ee/kernel/src/osdsrc/src/osdsrc.c +++ b/ee/kernel/src/osdsrc/src/osdsrc.c @@ -34,18 +34,12 @@ int _start(int syscall) __attribute__((section(".start"))); int _start(int syscall) { unsigned int i; - int result; InitSystemConfig(&SystemConfiguration, 0x26); for (i = 0; i < 5; i++) { if (SyscallPatchData[i].syscall == syscall) { - if (syscall == 0xFFFFC402) { - result = ((unsigned int)SyscallPatchData[i].function >> 2 & 0x03FFFFFF) | 0x0C000000; // Creates a JAL instruction to the function. - } else - result = (unsigned int)SyscallPatchData[i].function; - - return result; + return (syscall == 0xFFFFC402) ? ((unsigned int)SyscallPatchData[i].function >> 2 & 0x03FFFFFF) | 0x0C000000 /* Creates a JAL instruction to the function. */ : (unsigned int)SyscallPatchData[i].function; } } diff --git a/ee/kernel/src/sifcmd.c b/ee/kernel/src/sifcmd.c index 05554f682caf..5ffc6f805fbb 100644 --- a/ee/kernel/src/sifcmd.c +++ b/ee/kernel/src/sifcmd.c @@ -96,10 +96,7 @@ unsigned int _SifSendCmd(int cid, int mode, void *pkt, int pktsize, void *src, sceSifWriteBackDCache(pkt, pktsize); - if (mode & SIF_CMD_M_INTR) /* INTERRUPT DMA TRANSFER */ - return isceSifSetDma(dmat, count); - else - return sceSifSetDma(dmat, count); + return ((mode & SIF_CMD_M_INTR) /* INTERRUPT DMA TRANSFER */ ? isceSifSetDma : sceSifSetDma)(dmat, count); } #endif @@ -313,16 +310,8 @@ void sceSifAddCmdHandler(int cid, SifCmdHandler_t handler, void *harg) { u32 id = cid & ~SIF_CMD_ID_SYSTEM; - if (cid & SIF_CMD_ID_SYSTEM) - { - _sif_cmd_data.sys_cmd_handlers[id].handler = handler; - _sif_cmd_data.sys_cmd_handlers[id].harg = harg; - } - else - { - _sif_cmd_data.usr_cmd_handlers[id].handler = handler; - _sif_cmd_data.usr_cmd_handlers[id].harg = harg; - } + *((cid & SIF_CMD_ID_SYSTEM) ? &(_sif_cmd_data.sys_cmd_handlers[id].handler) : &(_sif_cmd_data.usr_cmd_handlers[id].handler)) = handler; + *((cid & SIF_CMD_ID_SYSTEM) ? &(_sif_cmd_data.sys_cmd_handlers[id].harg) : &(_sif_cmd_data.usr_cmd_handlers[id].harg)) = harg; } #endif @@ -331,10 +320,7 @@ void sceSifRemoveCmdHandler(int cid) { u32 id = cid & ~SIF_CMD_ID_SYSTEM; - if (cid & SIF_CMD_ID_SYSTEM) - _sif_cmd_data.sys_cmd_handlers[id].handler = NULL; - else - _sif_cmd_data.usr_cmd_handlers[id].handler = NULL; + *((cid & SIF_CMD_ID_SYSTEM) ? &(_sif_cmd_data.sys_cmd_handlers[id].handler) : &(_sif_cmd_data.usr_cmd_handlers[id].handler)) = NULL; } #endif diff --git a/ee/kernel/src/sifrpc.c b/ee/kernel/src/sifrpc.c index 22e67da102dc..93fadd085c50 100644 --- a/ee/kernel/src/sifrpc.c +++ b/ee/kernel/src/sifrpc.c @@ -345,15 +345,9 @@ static void _request_bind(SifRpcBindPkt_t *bind, void *data) rend->cid = SIF_CMD_RPC_BIND; sd = search_svdata(bind->sid, data); - if (!sd) { - rend->sd = NULL; - rend->buf = NULL; - rend->cbuf = NULL; - } else { - rend->sd = sd; - rend->buf = sd->buf; - rend->cbuf = sd->cbuf; - } + rend->sd = sd ? sd : NULL; + rend->buf = sd ? sd->buf : NULL; + rend->cbuf = sd ? sd->cbuf : NULL; isceSifSendCmd(SIF_CMD_RPC_END, rend, RPC_PACKET_SIZE, NULL, NULL, 0); } @@ -366,10 +360,7 @@ static void _request_call(SifRpcCallPkt_t *request, void *data) (void)data; - if (base->start) - base->end->next = sd; - else - base->start = sd; + *(base->start ? &(base->end->next) : &(base->start)) = sd; base->end = sd; sd->pkt_addr = request->pkt_addr; @@ -584,12 +575,9 @@ SifRpcServerData_t *sceSifGetNextRequest(SifRpcDataQueue_t *qd) DI(); sd = qd->start; - if (sd != NULL) { - qd->active = 1; + qd->active = sd ? 1 : 0; + if (sd) qd->start = sd->next; - } else { - qd->active = 0; - } EI(); @@ -600,10 +588,7 @@ SifRpcServerData_t *sceSifGetNextRequest(SifRpcDataQueue_t *qd) #ifdef F_sceSifExecRequest static void *_rpc_get_fpacket2(struct rpc_data *rpc_data, int rid) { - if (rid < 0 || rid < rpc_data->client_table_len) - return _rpc_get_fpacket(rpc_data); - else - return rpc_data->client_table + (rid * RPC_PACKET_SIZE); + return (rid < 0 || rid < rpc_data->client_table_len) ? _rpc_get_fpacket(rpc_data) : (rpc_data->client_table + (rid * RPC_PACKET_SIZE)); } void sceSifExecRequest(SifRpcServerData_t *sd) { @@ -621,12 +606,7 @@ void sceSifExecRequest(SifRpcServerData_t *sd) DI(); - if (sd->rid & 4) - rend = (SifRpcRendPkt_t *) - _rpc_get_fpacket2(&_sif_rpc_data, (sd->rid >> 16) & 0xffff); - else - rend = (SifRpcRendPkt_t *) - _rpc_get_fpacket(&_sif_rpc_data); + rend = (sd->rid & 4) ? (SifRpcRendPkt_t *) _rpc_get_fpacket2(&_sif_rpc_data, (sd->rid >> 16) & 0xffff) : (SifRpcRendPkt_t *)_rpc_get_fpacket(&_sif_rpc_data); EI(); @@ -642,17 +622,10 @@ void sceSifExecRequest(SifRpcServerData_t *sd) rend->rpc_id = 0; rend->rec_id = 0; - if (sd->rsize) { - dmat.src = rec; - dmat.dest = sd->recvbuf; - dmat.size = sd->rsize; - dmat.attr = 0; - } else { - dmat.src = rend; - dmat.dest = sd->pkt_addr; - dmat.size = 64; - dmat.attr = 0; - } + dmat.src = sd->rsize ? rec : rend; + dmat.dest = sd->rsize ? sd->recvbuf : sd->pkt_addr; + dmat.size = sd->rsize ? sd->rsize : 64; + dmat.attr = 0; while (!sceSifSetDma(&dmat, 1)) nopdelay(); diff --git a/ee/kernel/src/timer.c b/ee/kernel/src/timer.c index ecae59f1b98c..cd3eb7ca6932 100644 --- a/ee/kernel/src/timer.c +++ b/ee/kernel/src/timer.c @@ -209,11 +209,7 @@ __attribute__((weak)) s32 EndTimer(void) #ifdef F_GetTimerPreScaleFactor s32 GetTimerPreScaleFactor(void) { - if (g_Timer.intc_handler < 0) - { - return 0x80008001; // EINIT - } - return (*T2_MODE) & 3; + return (g_Timer.intc_handler < 0) ? 0x80008001 /* EINIT */ : ((*T2_MODE) & 3); } #endif @@ -790,15 +786,7 @@ u64 iGetTimerBaseTime(s32 id) counter_struct_t *timer_current; timer_current = TIMER_ID_TO_PTR(id); - if (!TIMER_ID_IS_VALID(id)) - { - return -1; - } - if ((timer_current->timer_mode & TIMER_MODE_START) == 0) - { - return 0; - } - return timer_current->timer_base_time - timer_current->timer_base_count; + return (!TIMER_ID_IS_VALID(id)) ? -1 : (((timer_current->timer_mode & TIMER_MODE_START) == 0) ? 0 : (timer_current->timer_base_time - timer_current->timer_base_count)); } #endif @@ -830,10 +818,7 @@ u64 iGetTimerCount(s32 id) return -1; } ret = timer_current->timer_base_count; - if ((timer_current->timer_mode & TIMER_MODE_START) != 0) - { - ret += iGetTimerSystemTime() - timer_current->timer_base_time; - } + ret += ((timer_current->timer_mode & TIMER_MODE_START) != 0) ? (iGetTimerSystemTime() - timer_current->timer_base_time) : 0; return ret; } #endif diff --git a/ee/kernel/src/tlbfunc.c b/ee/kernel/src/tlbfunc.c index c80fc7bb7b60..7ea1da63b6f4 100644 --- a/ee/kernel/src/tlbfunc.c +++ b/ee/kernel/src/tlbfunc.c @@ -60,11 +60,7 @@ void InitTLBFunctions(void) __attribute__((weak)) void InitTLB(void) { - if (GetMemorySize() == 0x2000000) { - InitTLB32MB(); - } else { - _InitTLB(); - } + ((GetMemorySize() == 0x2000000) ? InitTLB32MB : _InitTLB)(); } struct TLBEntry diff --git a/ee/libcglue/src/cwd.c b/ee/libcglue/src/cwd.c index 6edd09a52fc7..f2398db58a27 100644 --- a/ee/libcglue/src/cwd.c +++ b/ee/libcglue/src/cwd.c @@ -224,7 +224,7 @@ int __path_absolute(const char *in, char *out, int len) memcpy(out, __cwd, __cwd_len); out[__cwd_len] = '\x00'; dr = __get_drive(out, &separatorType); - if(dr < 0) dr = 0; + dr = (dr < 0) ? 0 : dr; out[dr] = 0; strncat(out, in, len); } else { @@ -238,7 +238,7 @@ int __path_absolute(const char *in, char *out, int len) /* Now normalize the pathname portion */ dr = __get_drive(out, &separatorType); - if(dr < 0) dr = 0; + dr = (dr < 0) ? 0 : dr; return __path_normalize(out + dr, len - dr, separatorType == SeparatorTypePOSIX); } #endif diff --git a/ee/libcglue/src/glue.c b/ee/libcglue/src/glue.c index 0b8ea18d06e5..3827e3b3ff99 100644 --- a/ee/libcglue/src/glue.c +++ b/ee/libcglue/src/glue.c @@ -454,11 +454,7 @@ int getdents(int fd, void *dd_buf, int count) _libcglue_fdman_fd_info_t *fdinfo; fdinfo = &(__descriptormap[fd]->info); - rv = -ENOSYS; - if (fdinfo->ops != NULL && fdinfo->ops->dread != NULL) - { - rv = __transform_errno(fdinfo->ops->dread(fdinfo->userdata, dirp)); - } + rv = (fdinfo->ops != NULL && fdinfo->ops->dread != NULL) ? __transform_errno(fdinfo->ops->dread(fdinfo->userdata, dirp)) : -ENOSYS; } if (rv < 0) { return __transform_errno(rv); @@ -1290,15 +1286,7 @@ int ps2sdk_get_iop_fd(int fd) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->getfd == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->getfd(fdinfo->userdata); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->getfd == NULL) ? -ENOSYS : fdinfo->ops->getfd(fdinfo->userdata)); } #endif @@ -1307,15 +1295,7 @@ char *ps2sdk_get_iop_filename(int fd) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return NULL; - } - if (fdinfo->ops == NULL || fdinfo->ops->getfilename == NULL) - { - return NULL; - } - return fdinfo->ops->getfilename(fdinfo->userdata); + return (fdinfo == NULL || fdinfo->ops == NULL || fdinfo->ops->getfilename == NULL) ? NULL : fdinfo->ops->getfilename(fdinfo->userdata); } #endif @@ -1324,15 +1304,7 @@ int _ps2sdk_close(int fd) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->close == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->close(fdinfo->userdata); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->close == NULL) ? -ENOSYS : fdinfo->ops->close(fdinfo->userdata)); } #endif @@ -1348,15 +1320,7 @@ int _ps2sdk_read(int fd, void *buf, int nbytes) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->read == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->read(fdinfo->userdata, buf, nbytes); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->read == NULL) ? -ENOSYS : fdinfo->ops->read(fdinfo->userdata, buf, nbytes)); } #endif @@ -1365,15 +1329,7 @@ int _ps2sdk_lseek(int fd, int offset, int whence) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->lseek == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->lseek(fdinfo->userdata, offset, whence); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->lseek == NULL) ? -ENOSYS : fdinfo->ops->lseek(fdinfo->userdata, offset, whence)); } #endif @@ -1382,15 +1338,7 @@ int64_t _ps2sdk_lseek64(int fd, int64_t offset, int whence) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->lseek64 == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->lseek64(fdinfo->userdata, offset, whence); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->lseek64 == NULL) ? -ENOSYS : fdinfo->ops->lseek64(fdinfo->userdata, offset, whence)); } #endif @@ -1399,15 +1347,7 @@ int _ps2sdk_write(int fd, const void *buf, int nbytes) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->write == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->write(fdinfo->userdata, buf, nbytes); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->write == NULL) ? -ENOSYS : fdinfo->ops->write(fdinfo->userdata, buf, nbytes)); } #endif @@ -1416,15 +1356,7 @@ int _ps2sdk_ioctl(int fd, int request, void *data) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->ioctl == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->ioctl(fdinfo->userdata, request, data); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->ioctl == NULL) ? -ENOSYS : fdinfo->ops->ioctl(fdinfo->userdata, request, data)); } #endif @@ -1433,15 +1365,7 @@ int _ps2sdk_ioctl2(int fd, int request, void *arg, unsigned int arglen, void *bu { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->ioctl == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->ioctl2(fdinfo->userdata, request, arg, arglen, buf, buflen); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->ioctl == NULL) ? -ENOSYS : fdinfo->ops->ioctl2(fdinfo->userdata, request, arg, arglen, buf, buflen)); } #endif @@ -1450,15 +1374,7 @@ int _ps2sdk_dread(int fd, struct dirent *dir) { _libcglue_fdman_fd_info_t *fdinfo; fdinfo = libcglue_get_fd_info(fd); - if (fdinfo == NULL) - { - return -EBADF; - } - if (fdinfo->ops == NULL || fdinfo->ops->dread == NULL) - { - return -ENOSYS; - } - return fdinfo->ops->dread(fdinfo->userdata, dir); + return (fdinfo == NULL) ? -EBADF : ((fdinfo->ops == NULL || fdinfo->ops->dread == NULL) ? -ENOSYS : fdinfo->ops->dread(fdinfo->userdata, dir)); } #endif @@ -1559,12 +1475,7 @@ int unlinkat(int dirfd, const char *pathname, int flags) { // If flags contains AT_REMOVEDIR, then the path refers to a directory. // Otherwise, the path refers to a file. - if (flags & AT_REMOVEDIR) { - return rmdir(pathname); - } - else { - return unlink(pathname); - } + return ((flags & AT_REMOVEDIR) ? rmdir : unlink)(pathname); } #endif /* F_unlinkat */ diff --git a/ee/libcglue/src/ps2sdkapi.c b/ee/libcglue/src/ps2sdkapi.c index 3e8823e9d992..48f0fec71cfb 100644 --- a/ee/libcglue/src/ps2sdkapi.c +++ b/ee/libcglue/src/ps2sdkapi.c @@ -69,15 +69,15 @@ int __fioOpenHelper(_libcglue_fdman_fd_info_t *info, const char *buf, int flags, int iop_fd; // newlib flags differ from iop flags - if ((flags & 3) == O_RDONLY) iop_flags |= IOP_O_RDONLY; - if ((flags & 3) == O_WRONLY) iop_flags |= IOP_O_WRONLY; - if ((flags & 3) == O_RDWR ) iop_flags |= IOP_O_RDWR; - if (flags & O_NONBLOCK) iop_flags |= IOP_O_NBLOCK; - if (flags & O_APPEND) iop_flags |= IOP_O_APPEND; - if (flags & O_CREAT) iop_flags |= IOP_O_CREAT; - if (flags & O_TRUNC) iop_flags |= IOP_O_TRUNC; - if (flags & O_EXCL) iop_flags |= IOP_O_EXCL; - //if (flags & O_???) iop_flags |= IOP_O_NOWAIT; + iop_flags |= ((flags & 3) == O_RDONLY) ? IOP_O_RDONLY : 0; + iop_flags |= ((flags & 3) == O_WRONLY) ? IOP_O_WRONLY : 0; + iop_flags |= ((flags & 3) == O_RDWR ) ? IOP_O_RDWR : 0; + iop_flags |= (flags & O_NONBLOCK) ? IOP_O_NBLOCK : 0; + iop_flags |= (flags & O_APPEND) ? IOP_O_APPEND : 0; + iop_flags |= (flags & O_CREAT) ? IOP_O_CREAT : 0; + iop_flags |= (flags & O_TRUNC) ? IOP_O_TRUNC : 0; + iop_flags |= (flags & O_EXCL) ? IOP_O_EXCL : 0; + //iop_flags |= (flags & O_???) ? IOP_O_NOWAIT : 0; if (flags & O_DIRECTORY) { iop_flags |= IOP_O_DIROPEN; is_dir = 1; @@ -397,11 +397,11 @@ static time_t io_to_posix_time(const unsigned char *ps2time) static mode_t io_to_posix_mode(unsigned int ps2mode) { mode_t posixmode = 0; - if (ps2mode & FIO_SO_IFREG) posixmode |= S_IFREG; - if (ps2mode & FIO_SO_IFDIR) posixmode |= S_IFDIR; - if (ps2mode & FIO_SO_IROTH) posixmode |= S_IRUSR|S_IRGRP|S_IROTH; - if (ps2mode & FIO_SO_IWOTH) posixmode |= S_IWUSR|S_IWGRP|S_IWOTH; - if (ps2mode & FIO_SO_IXOTH) posixmode |= S_IXUSR|S_IXGRP|S_IXOTH; + posixmode |= (ps2mode & FIO_SO_IFREG) ? (S_IFREG) : 0; + posixmode |= (ps2mode & FIO_SO_IFDIR) ? (S_IFDIR) : 0; + posixmode |= (ps2mode & FIO_SO_IROTH) ? (S_IRUSR|S_IRGRP|S_IROTH) : 0; + posixmode |= (ps2mode & FIO_SO_IWOTH) ? (S_IWUSR|S_IWGRP|S_IWOTH) : 0; + posixmode |= (ps2mode & FIO_SO_IXOTH) ? (S_IXUSR|S_IXGRP|S_IXOTH) : 0; return posixmode; } diff --git a/ee/libgs/samples/libgs_doublebuffer/main.c b/ee/libgs/samples/libgs_doublebuffer/main.c index deb8c6c4f0ac..9e68d9020370 100644 --- a/ee/libgs/samples/libgs_doublebuffer/main.c +++ b/ee/libgs/samples/libgs_doublebuffer/main.c @@ -146,10 +146,7 @@ static void SelectDisplayContext(int context_id) static void ClearDrawingContext(int context_id) { - if(context_id==0) - GsClearDrawEnv1(&draw_env[0]); - else - GsClearDrawEnv2(&draw_env[1]); + ((context_id==0) ? GsClearDrawEnv1 : GsClearDrawEnv2)(&draw_env[0]); } static int point_x=100,point_y=100; @@ -214,11 +211,11 @@ static int DrawTriangles(GS_PACKET_TABLE *table, int context_index) static void MovePoint(void) { - if(dir_x==0)point_x -= 6; - if(dir_x==1)point_x += 6; + point_x -= (dir_x==0) ? 6 : 0; + point_x += (dir_x==1) ? 6 : 0; - if(dir_y==0)point_y -= 8; - if(dir_y==1)point_y += 8; + point_y -= (dir_y==0) ? 8 : 0; + point_y += (dir_y==1) ? 8 : 0; if(point_x >SCREEN_WIDTH) { diff --git a/ee/libgs/src/dma.c b/ee/libgs/src/dma.c index 9ac90d923919..cc0d125ad75a 100644 --- a/ee/libgs/src/dma.c +++ b/ee/libgs/src/dma.c @@ -81,14 +81,7 @@ void GsDmaSend(const void *addr, u32 qwords) DMA_CHCR chcr; static char spr; - if((u32)addr >= 0x70000000 && (u32)addr <= 0x70003fff) - { - spr = 1; - } - else - { - spr = 0; - } + spr = ((u32)addr >= 0x70000000 && (u32)addr <= 0x70003fff) ? 1 : 0; *((vu32 *)(gif_madr)) = ( u32 )((( u32 )addr) & 0x7FFFFFFF) << 0 | (u32)((spr) & 0x00000001) << 31;; @@ -116,14 +109,7 @@ void GsDmaSend_tag(const void *addr, u32 qwords, const GS_GIF_DMACHAIN_TAG *tag) DMA_CHCR chcr; static char spr; - if((u32)addr >= 0x70000000 && (u32)addr <= 0x70003fff) - { - spr = 1; - } - else - { - spr = 0; - } + spr = ((u32)addr >= 0x70000000 && (u32)addr <= 0x70003fff) ? 1 : 0; *((vu32 *)(gif_madr)) = ( u32 )((( u32 )addr) & 0x7FFFFFFF) << 0 | (u32)((spr) & 0x00000001) << 31; *((vu32 *)(gif_qwc)) = qwords; diff --git a/ee/libgs/src/draw.c b/ee/libgs/src/draw.c index da0b405a3360..c08c7bf89869 100644 --- a/ee/libgs/src/draw.c +++ b/ee/libgs/src/draw.c @@ -84,48 +84,20 @@ void GsSetDefaultDisplayEnv(GS_DISPENV *dispenv, u16 psm, u16 w, u16 h, u16 dx, switch(pGParams->omode) { case GS_MODE_NTSC: - if(pGParams->interlace) - { - dispenv->disp.display_y = dy+gs_DY+0x32; - dispenv->disp.display_x = (gs_DX+0x27C) + dx*((w+0x9FF)/w); - dispenv->disp.magnify_h = (w+0x9FF)/w - 1; - dispenv->disp.magnify_v = 0; - dispenv->disp.display_w = (w+0x9FF)/w*w - 1; - - if(pGParams->ffmode) - dispenv->disp.display_h = (h<<1) - 1; - else - dispenv->disp.display_h = h - 1; - } else { - dispenv->disp.display_h = h-1; - dispenv->disp.display_x = gs_DX+0x27C + dx*((w+0x9FF)/w); - dispenv->disp.display_y = gs_DY+dy+0x19; - dispenv->disp.magnify_h = (w+0x9FF)/w - 1; - dispenv->disp.magnify_v = 0; - dispenv->disp.display_w = (w+0x9FF)/w*w - 1; - } + dispenv->disp.display_h = (pGParams->interlace) ? ((pGParams->ffmode) ? ((h<<1) - 1) : (h - 1)) : (h-1); + dispenv->disp.display_y = (pGParams->interlace) ? (gs_DY+dy+0x32) : (gs_DY+dy+0x19); + dispenv->disp.display_x = gs_DX+0x27C + dx*((w+0x9FF)/w); + dispenv->disp.magnify_h = (w+0x9FF)/w - 1; + dispenv->disp.magnify_v = 0; + dispenv->disp.display_w = (w+0x9FF)/w*w - 1; break; case GS_MODE_PAL: - if(pGParams->interlace) - { - dispenv->disp.display_y = gs_DY+dy+0x48; - dispenv->disp.display_x = gs_DX+0x290 + dx*((w+0x9FF)/w); - dispenv->disp.magnify_h = (w+0x9FF)/w - 1; - dispenv->disp.magnify_v = 0; - dispenv->disp.display_w = (w+0x9FF)/w*w - 1; - - if(pGParams->ffmode) - dispenv->disp.display_h = (h<<1) - 1; - else - dispenv->disp.display_h = h - 1; - } else { - dispenv->disp.display_h = h-1; - dispenv->disp.display_x = gs_DX+0x290 + dx*((w+0x9FF)/w); - dispenv->disp.display_y = dy+gs_DY+0x48; - dispenv->disp.magnify_h = (w+0x9FF)/w - 1; - dispenv->disp.magnify_v = 0; - dispenv->disp.display_w = (w+0x9FF)/w*w - 1; - } + dispenv->disp.display_h = (pGParams->interlace) ? ((pGParams->ffmode) ? ((h<<1) - 1) : (h - 1)) : (h-1); + dispenv->disp.display_x = gs_DX+0x290 + dx*((w+0x9FF)/w); + dispenv->disp.display_y = gs_DY+dy+0x48; + dispenv->disp.magnify_h = (w+0x9FF)/w - 1; + dispenv->disp.magnify_v = 0; + dispenv->disp.display_w = (w+0x9FF)/w*w - 1; break; case GS_MODE_DTV_480P: dispenv->disp.display_x = gs_DX+((0x2D0-w) + ((0x2D0-w)>>31))/2*2 + (dx<<1)+0xE8; diff --git a/ee/libgs/src/primitives.c b/ee/libgs/src/primitives.c index 0506f7b7ec3d..896a936a590c 100644 --- a/ee/libgs/src/primitives.c +++ b/ee/libgs/src/primitives.c @@ -28,14 +28,7 @@ void GsOverridePrimAttributes(s8 override, s8 iip, s8 tme, s8 fge, s8 abe, s8 aa gs_setGIF_TAG(((GS_GIF_TAG *)&p[0]), 2,1,0,0,GS_GIF_PACKED,1,gif_rd_ad); //override. (0 = use PRIM)(1 = use PRMODE) - if(override) - { - gs_setR_PRMODECONT(((GS_R_PRMODECONT *)&p[1]), 0); - } - else - { - gs_setR_PRMODECONT(((GS_R_PRMODECONT *)&p[1]), 1); - } + gs_setR_PRMODECONT(((GS_R_PRMODECONT *)&p[1]), override ? 0 : 1); gs_setR_PRMODE(((GS_R_PRMODE *)&p[2]), iip,tme,fge,abe,aa1,fst,ctxt,fix); @@ -50,23 +43,18 @@ void GsEnableDithering(u8 enable, int mode) (void)mode; p=UNCACHED_SEG(GsPrimWorkArea); + gs_setGIF_TAG(((GS_GIF_TAG *)&p[0]), enable ? 3 : 2,1,0,0,GS_GIF_PACKED,1,gif_rd_ad); + gs_setR_DTHE(((GS_R_DTHE *)&p[1]), enable ? 1 : 0); if(enable) { - gs_setGIF_TAG(((GS_GIF_TAG *)&p[0]), 3,1,0,0,GS_GIF_PACKED,1,gif_rd_ad); - gs_setR_DTHE(((GS_R_DTHE *)&p[1]), 1); gs_setR_DIMX(((GS_R_DIMX *)&p[2]), 4,2,5,3,0,6,1,7,5,3,4,2,1,7,0,6); //thanks to:"Maximus32" on ps2dev.org gs_setR_COLCLAMP(((GS_R_COLCLAMP *)&p[3]), 1); - - GsDmaSend(GsPrimWorkArea, 4); } else { - gs_setGIF_TAG(((GS_GIF_TAG *)&p[0]), 2,1,0,0,GS_GIF_PACKED,1,gif_rd_ad); - gs_setR_DTHE(((GS_R_DTHE *)&p[1]), 0); gs_setR_DIMX(((GS_R_DIMX *)&p[2]), 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); - - GsDmaSend(GsPrimWorkArea, 3); } + GsDmaSend(GsPrimWorkArea, enable ? 4 : 3); GsDmaWait(); } @@ -143,14 +131,7 @@ void GsEnableAlphaBlending1(u16 enable) p=UNCACHED_SEG(GsPrimWorkArea); gs_setGIF_TAG(((GS_GIF_TAG *)&p[0]), 4,1,0,0,GS_GIF_PACKED,1,gif_rd_ad); - if(enable) - { - gs_setR_ALPHA_1(((GS_R_ALPHA *)&p[1]), 0,1,0,1,0x00); //last arg(0x00) is not used bceause of other settings - } - else - { - gs_setR_ALPHA_1(((GS_R_ALPHA *)&p[1]), 0,0,0,0,0x80); - } + gs_setR_ALPHA_1(((GS_R_ALPHA *)&p[1]), 0,enable ? 1 : 0,0,enable ? 1 : 0,enable ? 0x00 : 0x80); //last arg(0x00) is not used bceause of other settings gs_setR_PABE(((GS_R_PABE *)&p[2]), 0); gs_setR_FBA_1(((GS_R_FBA *)&p[3]), 0); gs_setR_TEXA(((GS_R_TEXA *)&p[4]), 0x80, 0, 0x00); @@ -166,14 +147,7 @@ void GsEnableAlphaBlending2(u16 enable) p=UNCACHED_SEG(GsPrimWorkArea); gs_setGIF_TAG(((GS_GIF_TAG*)&p[0]), 4,1,0,0,GS_GIF_PACKED,1,gif_rd_ad); - if(enable) - { - gs_setR_ALPHA_2(((GS_R_ALPHA*)&p[1]), 0,1,0,1,0x00); //last arg(0x00) is not used bceause of other settings - } - else - { - gs_setR_ALPHA_2(((GS_R_ALPHA *)&p[1]), 0,0,0,0,0x80); - } + gs_setR_ALPHA_2(((GS_R_ALPHA*)&p[1]), 0,enable ? 1 : 0,0,enable ? 1 : 0,enable ? 0x00 : 0x80); //last arg(0x00) is not used bceause of other settings gs_setR_PABE(((GS_R_PABE *)&p[2]), 0); gs_setR_FBA_2(((GS_R_FBA *)&p[3]), 0); gs_setR_TEXA(((GS_R_TEXA *)&p[4]), 0x80, 0, 0x00); diff --git a/ee/libgs/src/texture.c b/ee/libgs/src/texture.c index f76f4851858b..000f9ceefc7a 100644 --- a/ee/libgs/src/texture.c +++ b/ee/libgs/src/texture.c @@ -132,19 +132,12 @@ int GsVramAllocFrameBuffer(s16 w, s16 h, s16 psm) return -EINVAL; } - if(byte_pp > 0) // 8 to 32 bit - { - size = ((w*h)*byte_pp)/4; - } - else // 4 bit - { - size = (w*h)/2; - } + // 8 to 32 bit, or 4 bit + size = (byte_pp > 0) ? (((w*h)*byte_pp)/4) : ((w*h)/2); remainder = (vr_addr % (2048)); - if(remainder) - vr_addr += ((2048)-remainder); + vr_addr += (remainder) ? ((2048)-remainder) : 0; ret = vr_addr/(2048); vr_addr += size; @@ -180,22 +173,15 @@ int GsVramAllocTextureBuffer(s16 w, s16 h, s16 psm) return -EINVAL; } - if(byte_pp > 0) // 8 to 32 bit - { - size = ((w*h)*byte_pp)/4; - } - else // 4 bit - { - size = (w*h)/2; - } + // 8 to 32 bit, or 4 bit + size = (byte_pp > 0) ? (((w*h)*byte_pp)/4) : ((w*h)/2); remainder = (vr_addr % (64)); //--- vr_2ndtolast_alloc = vr_addr; - if(remainder) - vr_addr += ((64)-remainder); + vr_addr += (remainder) ? ((64)-remainder) : 0; ret = vr_addr/(64); vr_addr += size; diff --git a/ee/libpthreadglue/src/osal.c b/ee/libpthreadglue/src/osal.c index 6bfdffe02829..f1a822df0441 100644 --- a/ee/libpthreadglue/src/osal.c +++ b/ee/libpthreadglue/src/osal.c @@ -438,11 +438,7 @@ pte_osResult pte_osThreadCancel(pte_osThreadHandle threadHandle) pThreadData = __getThreadData(threadHandle); osResult = SignalSema(pThreadData->cancelSem); - if (osResult == pThreadData->cancelSem) { - result = PTE_OS_OK; - } else { - result = PTE_OS_GENERAL_FAILURE; - } + result = (osResult == pThreadData->cancelSem) ? PTE_OS_OK : PTE_OS_GENERAL_FAILURE; return result; } @@ -460,16 +456,7 @@ pte_osResult pte_osThreadCheckCancel(pte_osThreadHandle threadHandle) if (pThreadData != NULL) { osResult = ReferSemaStatus(pThreadData->cancelSem, &semInfo); - if (osResult == pThreadData->cancelSem) { - if (semInfo.count > 0) { - result = PTE_OS_INTERRUPTED; - } else { - result = PTE_OS_OK; - } - } else { - /* sceKernelReferSemaStatus returned an error */ - result = PTE_OS_GENERAL_FAILURE; - } + result = (osResult == pThreadData->cancelSem) ? ((semInfo.count > 0) ? PTE_OS_INTERRUPTED : PTE_OS_OK) : /* sceKernelReferSemaStatus returned an error */ PTE_OS_GENERAL_FAILURE; } else { /* For some reason, we couldn't get thread data */ result = PTE_OS_GENERAL_FAILURE; @@ -568,13 +555,7 @@ pte_osResult pte_osMutexTimedLock(pte_osMutexHandle handle, unsigned int timeout pte_osResult result; int32_t timeout = timeoutMsecs * 1000; int status = SemWaitTimeout(handle, timeout); - if (status > 0) { - result = PTE_OS_OK; - } else if (status == -1) { - result = PTE_OS_TIMEOUT; - } else { - result = PTE_OS_GENERAL_FAILURE; - } + result = (status > 0) ? PTE_OS_OK : ((status == -1) ? PTE_OS_TIMEOUT : PTE_OS_GENERAL_FAILURE); return result; } @@ -644,20 +625,10 @@ pte_osResult pte_osSemaphorePend(pte_osSemaphoreHandle handle, unsigned int *pTi int32_t result; pte_osResult osResult; - if (pTimeoutMsecs == NULL) { - timeout = UINT32_MAX; - } else { - timeout = *pTimeoutMsecs * 1000; - } + timeout = (pTimeoutMsecs == NULL) ? UINT32_MAX : *pTimeoutMsecs * 1000; result = SemWaitTimeout(handle, timeout); - if (result > 0) { - osResult = PTE_OS_OK; - } else if (result == -1) { - osResult = PTE_OS_TIMEOUT; - } else { - osResult = PTE_OS_GENERAL_FAILURE; - } + osResult = (result > 0) ? PTE_OS_OK : ((result == -1) ? PTE_OS_TIMEOUT : PTE_OS_GENERAL_FAILURE); return osResult; } @@ -684,11 +655,7 @@ pte_osResult pte_osSemaphoreCancellablePend(pte_osSemaphoreHandle semHandle, uns start_time = clock(); // clock() is in microseconds, timeout as passed in was in milliseconds - if (pTimeout == NULL) { - timeout = 0; - } else { - timeout = *pTimeout * 1000; - } + timeout = (pTimeout == NULL) ? 0 : (*pTimeout * 1000); while (1) { int32_t status; diff --git a/ee/libpthreadglue/src/tls-helper.c b/ee/libpthreadglue/src/tls-helper.c index 690ba93a8b87..12f61a861a83 100644 --- a/ee/libpthreadglue/src/tls-helper.c +++ b/ee/libpthreadglue/src/tls-helper.c @@ -108,11 +108,7 @@ void *pteTlsGetValue(void *pTlsThreadStruct, unsigned int index) { void **pTls = (void **)pTlsThreadStruct; - if (__keysUsed[index - 1] && pTls != NULL) { - return pTls[index - 1]; - } else { - return NULL; - } + return (__keysUsed[index - 1] && pTls != NULL) ? pTls[index - 1] : NULL; } #else void *pteTlsGetValue(void *pTlsThreadStruct, unsigned int index); @@ -147,11 +143,7 @@ void *__getTlsStructFromThread(s32 thid) * was created. Otherwise, we were called from a non-pthread, so use the * "global". This is a pretty bad hack, but necessary due to lack of TLS on PS2. */ - if (threadInfo->tlsPtr) { - pTls = threadInfo->tlsPtr; - } else { - pTls = __globalTls; - } + pTls = (threadInfo->tlsPtr) ? threadInfo->tlsPtr : __globalTls; return pTls; } diff --git a/ee/math3d/src/math3d.c b/ee/math3d/src/math3d.c index e31e1b60b414..0655e04808ab 100644 --- a/ee/math3d/src/math3d.c +++ b/ee/math3d/src/math3d.c @@ -67,16 +67,16 @@ vector_copy(work, input0); // Clamp the minimum values. - if (work[0] < min) { work[0] = min; } - if (work[1] < min) { work[1] = min; } - if (work[2] < min) { work[2] = min; } - if (work[3] < min) { work[3] = min; } + work[0] = (work[0] < min) ? min : work[0]; + work[1] = (work[1] < min) ? min : work[1]; + work[2] = (work[2] < min) ? min : work[2]; + work[3] = (work[3] < min) ? min : work[3]; // Clamp the maximum values. - if (work[0] > max) { work[0] = max; } - if (work[1] > max) { work[1] = max; } - if (work[2] > max) { work[2] = max; } - if (work[3] > max) { work[3] = max; } + work[0] = (work[0] > max) ? max : work[0]; + work[1] = (work[1] > max) ? max : work[1]; + work[2] = (work[2] > max) ? max : work[2]; + work[3] = (work[3] > max) ? max : work[3]; // Output the result. vector_copy(output, work); diff --git a/ee/mpeg/src/libmpeg.c b/ee/mpeg/src/libmpeg.c index 1e69f9eb81e4..6033f0b6f525 100644 --- a/ee/mpeg/src/libmpeg.c +++ b/ee/mpeg/src/libmpeg.c @@ -130,11 +130,7 @@ static void *_init_seq(void) } lMBWidth = (s_MPEG12Ctx.m_SI.m_Width + 15) / 16; - if (s_MPEG12Ctx.m_fMPEG2 && !s_MPEG12Ctx.m_fProgSeq) { - lMBHeight = 2 * ((s_MPEG12Ctx.m_SI.m_Height + 31) / 32); - } else { - lMBHeight = (s_MPEG12Ctx.m_SI.m_Height + 15) / 16; - } + lMBHeight = (s_MPEG12Ctx.m_fMPEG2 && !s_MPEG12Ctx.m_fProgSeq) ? (2 * ((s_MPEG12Ctx.m_SI.m_Height + 31) / 32)) : ((s_MPEG12Ctx.m_SI.m_Height + 15) / 16); if (lMBWidth != s_MPEG12Ctx.m_MBWidth || lMBHeight != s_MPEG12Ctx.m_MBHeight) { unsigned int lAllocSize; @@ -232,15 +228,8 @@ static void _seq_header(void) _MPEG_GetBits(10); /* vbv_buffer_size */ _MPEG_GetBits(1); /* constrained_parameters_flag */ - if (_MPEG_GetBits(1)) - _MPEG_SetQM(0); - else - _MPEG_SetDefQM(0); - - if (_MPEG_GetBits(1)) - _MPEG_SetQM(1); - else - _MPEG_SetDefQM(1); + (_MPEG_GetBits(1) ? _MPEG_SetQM : _MPEG_SetDefQM)(0); + (_MPEG_GetBits(1) ? _MPEG_SetQM : _MPEG_SetDefQM)(1); _ext_and_ud(); } @@ -372,17 +361,8 @@ static void _ext_seq(void) #endif /* _DEBUG */ s_MPEG12Ctx.m_SI.m_MSPerFrame = (int)((1000.0F / (s_FrameRate[s_MPEG12Ctx.m_FRCode] * ((lFRXn + 1.0F) / (lFRXd + 1.0F)))) + 0.5F); - if ((lProfLevel >> 7) & 1) { - if ((lProfLevel & 15) == 5) { - s_MPEG12Ctx.m_SI.m_Profile = MPEG_PROFILE_422; - s_MPEG12Ctx.m_SI.m_Level = MPEG_LEVEL_MAIN; - } else { - s_MPEG12Ctx.m_SI.m_Profile = s_MPEG12Ctx.m_SI.m_Level = -1; - } - } else { - s_MPEG12Ctx.m_SI.m_Profile = lProfLevel >> 4; - s_MPEG12Ctx.m_SI.m_Level = lProfLevel & 0xF; - } + s_MPEG12Ctx.m_SI.m_Profile = ((lProfLevel >> 7) & 1) ? (((lProfLevel & 15) == 5) ? MPEG_PROFILE_422 : -1) : (lProfLevel >> 4); + s_MPEG12Ctx.m_SI.m_Level = ((lProfLevel >> 7) & 1) ? (((lProfLevel & 15) == 5) ? MPEG_LEVEL_MAIN : -1) : (lProfLevel & 0xF); s_MPEG12Ctx.m_SI.m_Width = (lHSzX << 12) | (s_MPEG12Ctx.m_SI.m_Width & 0x0FFF); s_MPEG12Ctx.m_SI.m_Height = (lVSzX << 12) | (s_MPEG12Ctx.m_SI.m_Height & 0x0FFF); @@ -459,18 +439,7 @@ static void _ext_pic_dsp(void) int i; int lnFCO; - if (s_MPEG12Ctx.m_fProgSeq) { - if (s_MPEG12Ctx.m_fRepFF) - lnFCO = s_MPEG12Ctx.m_fTopFF ? 3 : 2; - else - lnFCO = 1; - } else { - if (s_MPEG12Ctx.m_PictStruct != _MPEG_PS_FRAME) - lnFCO = 1; - else - lnFCO = s_MPEG12Ctx.m_fRepFF ? 3 : 2; - } - + lnFCO = s_MPEG12Ctx.m_fProgSeq ? ((s_MPEG12Ctx.m_fRepFF) ? (s_MPEG12Ctx.m_fTopFF ? 3 : 2) : 1) : (s_MPEG12Ctx.m_PictStruct != _MPEG_PS_FRAME) ? 1 : (s_MPEG12Ctx.m_fRepFF ? 3 : 2); for (i = 0; i < lnFCO; ++i) { _MPEG_GetBits(16); /* frame_center_horizontal_offset[ i ] */ @@ -561,13 +530,8 @@ static int _get_next_picture(void *apData, s64 *apPTS) if ((s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME || s_MPEG12Ctx.m_fSecField) && s_MPEG12Ctx.m_SI.m_FrameCnt) { void *lpData; - if (s_MPEG12Ctx.m_PictCodingType == _MPEG_PT_B) { - lpData = s_MPEG12Ctx.m_pAuxFrame; - *apPTS = s_MPEG12Ctx.m_AuxPTS; - } else { - lpData = s_MPEG12Ctx.m_pFwdFrame; - *apPTS = s_MPEG12Ctx.m_FwdPTS; - } + lpData = (s_MPEG12Ctx.m_PictCodingType == _MPEG_PT_B) ? s_MPEG12Ctx.m_pAuxFrame : s_MPEG12Ctx.m_pFwdFrame; + *apPTS = (s_MPEG12Ctx.m_PictCodingType == _MPEG_PT_B) ? s_MPEG12Ctx.m_AuxPTS : s_MPEG12Ctx.m_FwdPTS; lfPic = _MPEG_CSCImage(lpData, apData, s_MPEG12Ctx.m_MBCount); } @@ -666,14 +630,12 @@ static void _mpeg12_decode_motion_vector(int *apPred, int aRSize, int aMotionCod if (aMotionCode > 0) { lVec += ((aMotionCode - 1) << aRSize) + aMotionResidual + 1; - if (lVec >= lLim) - lVec -= lLim + lLim; + lVec -= (lVec >= lLim) ? (lLim + lLim) : 0; } else if (aMotionCode < 0) { lVec -= ((-aMotionCode - 1) << aRSize) + aMotionResidual + 1; - if (lVec < -lLim) - lVec += lLim + lLim; + lVec += (lVec < -lLim) ? (lLim + lLim) : 0; } *apPred = aFullPelVector ? lVec << 1 : lVec; @@ -683,19 +645,11 @@ static void _mpeg12_decode_motion_vector(int *apPred, int aRSize, int aMotionCod static void _mpeg12_dual_prime_vector(int aDMV[][2], const int *apDMVector, int aMVX, int aMVY) { if (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) { - if (s_MPEG12Ctx.m_fTopFF) { - aDMV[0][0] = ((aMVX + (aMVX > 0)) >> 1) + apDMVector[0]; - aDMV[0][1] = ((aMVY + (aMVY > 0)) >> 1) + apDMVector[1] - 1; + aDMV[0][0] = s_MPEG12Ctx.m_fTopFF ? (((aMVX + (aMVX > 0)) >> 1) + apDMVector[0]) : (((3 * aMVX + (aMVX > 0)) >> 1) + apDMVector[0]); + aDMV[0][1] = s_MPEG12Ctx.m_fTopFF ? (((aMVY + (aMVY > 0)) >> 1) + apDMVector[1] - 1) : (((3 * aMVY + (aMVY > 0)) >> 1) + apDMVector[1] - 1); - aDMV[1][0] = ((3 * aMVX + (aMVX > 0)) >> 1) + apDMVector[0]; - aDMV[1][1] = ((3 * aMVY + (aMVY > 0)) >> 1) + apDMVector[1] + 1; - } else { - aDMV[0][0] = ((3 * aMVX + (aMVX > 0)) >> 1) + apDMVector[0]; - aDMV[0][1] = ((3 * aMVY + (aMVY > 0)) >> 1) + apDMVector[1] - 1; - - aDMV[1][0] = ((aMVX + (aMVX > 0)) >> 1) + apDMVector[0]; - aDMV[1][1] = ((aMVY + (aMVY > 0)) >> 1) + apDMVector[1] + 1; - } + aDMV[1][0] = s_MPEG12Ctx.m_fTopFF ? (((3 * aMVX + (aMVX > 0)) >> 1) + apDMVector[0]) : (((aMVX + (aMVX > 0)) >> 1) + apDMVector[0]); + aDMV[1][1] = s_MPEG12Ctx.m_fTopFF ? (((3 * aMVY + (aMVY > 0)) >> 1) + apDMVector[1] + 1) : (((aMVY + (aMVY > 0)) >> 1) + apDMVector[1] + 1); } else { aDMV[0][0] = ((aMVX + (aMVX > 0)) >> 1) + apDMVector[0]; aDMV[0][1] = ((aMVY + (aMVY > 0)) >> 1) + apDMVector[1]; @@ -789,21 +743,13 @@ static int _mpeg12_dec_mb( if (lMBType & (_MPEG_MBT_MOTION_FORWARD | _MPEG_MBT_MOTION_BACKWARD)) { - if (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) - lMotionType = s_MPEG12Ctx.m_fFPFrmDCT ? _MPEG_MC_FRAME : _MPEG_GetBits(2); - else - lMotionType = _MPEG_GetBits(2); + lMotionType = (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) ? (s_MPEG12Ctx.m_fFPFrmDCT ? _MPEG_MC_FRAME : _MPEG_GetBits(2)) : _MPEG_GetBits(2); } else if (lfIntra && s_MPEG12Ctx.m_fConsMV) lMotionType = (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) ? _MPEG_MC_FRAME : _MPEG_MC_FIELD; - if (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) { - lnMV = lMotionType == _MPEG_MC_FIELD ? 2 : 1; - lMVFmt = lMotionType == _MPEG_MC_FRAME ? _MPEG_MV_FRAME : _MPEG_MV_FIELD; - } else { - lnMV = (lMotionType == _MPEG_MC_16X8) ? 2 : 1; - lMVFmt = _MPEG_MV_FIELD; - } + lnMV = (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) ? (lMotionType == _MPEG_MC_FIELD ? 2 : 1) : ((lMotionType == _MPEG_MC_16X8) ? 2 : 1); + lMVFmt = (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) ? (lMotionType == _MPEG_MC_FRAME ? _MPEG_MV_FRAME : _MPEG_MV_FIELD) : _MPEG_MV_FIELD; lDMV = lMotionType == _MPEG_MC_DMV; lMVScale = lMVFmt == _MPEG_MV_FIELD && s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME; @@ -857,10 +803,8 @@ static int _mpeg12_dec_mb( aPMV[1][0][0] = 0; aPMV[1][0][1] = 0; - if (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) { - lMotionType = _MPEG_MC_FRAME; - } else { - lMotionType = _MPEG_MC_FIELD; + lMotionType = (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) ? _MPEG_MC_FRAME : _MPEG_MC_FIELD; + if (s_MPEG12Ctx.m_PictStruct != _MPEG_PS_FRAME) { aMVFS[0][0] = s_MPEG12Ctx.m_PictStruct == _MPEG_PS_BOTTOM_FIELD; } } @@ -1137,10 +1081,8 @@ static int _mpeg12_slice(int aMBAMax) lPMV[1][0][1] = 0; } - if (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) { - lMotionType = _MPEG_MC_FRAME; - } else { - lMotionType = _MPEG_MC_FIELD; + lMotionType = (s_MPEG12Ctx.m_PictStruct == _MPEG_PS_FRAME) ? _MPEG_MC_FRAME : _MPEG_MC_FIELD; + if (s_MPEG12Ctx.m_PictStruct != _MPEG_PS_FRAME) { lMVFS[0][0] = s_MPEG12Ctx.m_PictStruct == _MPEG_PS_BOTTOM_FIELD; lMVFS[0][1] = s_MPEG12Ctx.m_PictStruct == _MPEG_PS_BOTTOM_FIELD; } diff --git a/ee/mpeg/src/libmpeg_core.c b/ee/mpeg/src/libmpeg_core.c index 78e3380a9795..1937cf748aaa 100644 --- a/ee/mpeg/src/libmpeg_core.c +++ b/ee/mpeg/src/libmpeg_core.c @@ -253,10 +253,8 @@ s32 _mpeg_dmac_handler(s32 channel, void *arg, void *addr) return -1; } - u32 mbc = cp->blocks; - if (mbc > 0x3ff) { - mbc = 0x3ff; - } + u32 mbc; + mbc = (cp->blocks > 0x3ff) ? 0x3ff : cp->blocks; *R_EE_D3_MADR = cp->dest; *R_EE_D4_MADR = cp->source; cp->source += mbc * sizeof(_MPEGMacroBlock8); @@ -277,10 +275,8 @@ int _MPEG_CSCImage(void *source, void *dest, int mbcount) _ipu_suspend(); *R_EE_IPU_CMD = IPU_COMMAND_BCLR; *R_EE_D_STAT = 8; // ack ch3 - int mbc = mbcount; - if (mbc > 0x3ff) { - mbc = 0x3ff; - } + int mbc; + mbc = (mbcount > 0x3ff) ? 0x3ff : mbcount; *R_EE_D3_MADR = (u32)dest; *R_EE_D4_MADR = (u32)source; @@ -533,9 +529,7 @@ int _MPEG_GetMBAI(void) } // MB escape - if (ret == 0x23) { - mbai += 0x21; - } + mbai += (ret == 0x23) ? 0x21 : 0; if (ret < 0x22) { mbai += ret; diff --git a/ee/network/netman/src/netman.c b/ee/network/netman/src/netman.c index aead589d0a04..b4e511548a51 100644 --- a/ee/network/netman/src/netman.c +++ b/ee/network/netman/src/netman.c @@ -33,10 +33,7 @@ void NetManUpdateStackNIFLinkState(void) { if(IsNetStackInitialized) { - if(NIFLinkState) - MainNetProtStack.LinkStateUp(); - else - MainNetProtStack.LinkStateDown(); + (NIFLinkState ? MainNetProtStack.LinkStateUp : MainNetProtStack.LinkStateDown)(); } } diff --git a/ee/network/netman/src/rpc_server.c b/ee/network/netman/src/rpc_server.c index 4a27fa2c7bc1..e45b2abdd09e 100644 --- a/ee/network/netman/src/rpc_server.c +++ b/ee/network/netman/src/rpc_server.c @@ -184,13 +184,8 @@ static void NETMAN_RxThread(void *arg) do { DI(); PacketLength = bd->length; - if (PacketLength > 0) - { - run = 1; - } else { - run = 0; - IsProcessingRx = 0; - } + run = (PacketLength > 0) ? 1 : 0; + IsProcessingRx = (PacketLength > 0) ? IsProcessingRx : 0; EI(); if(!run) diff --git a/ee/network/tcpip/samples/tcpip_basic/ps2ip.c b/ee/network/tcpip/samples/tcpip_basic/ps2ip.c index 5ef8040583f2..4a8eac2c9c8c 100644 --- a/ee/network/tcpip/samples/tcpip_basic/ps2ip.c +++ b/ee/network/tcpip/samples/tcpip_basic/ps2ip.c @@ -99,17 +99,12 @@ static int ethApplyIPConfig(int use_dhcp, const struct ip4_addr *ip, const struc !ip_addr_cmp(gateway, (struct ip4_addr *)&ip_info.gw) || !ip_addr_cmp(dns, dns_curr)))) { - if (use_dhcp) - { - ip_info.dhcp_enabled = 1; - } - else + ip_info.dhcp_enabled = use_dhcp ? 1 : 0; + if (!use_dhcp) { //Copy over new settings if DHCP is not used. ip_addr_set((struct ip4_addr *)&ip_info.ipaddr, ip); ip_addr_set((struct ip4_addr *)&ip_info.netmask, netmask); ip_addr_set((struct ip4_addr *)&ip_info.gw, gateway); - - ip_info.dhcp_enabled = 0; } //Update settings. @@ -178,10 +173,7 @@ static void ethPrintLinkStatus(void) //SMAP is registered as the "sm0" device to the TCP/IP stack. scr_printf("Link:\t"); - if (NetManIoctl(NETMAN_NETIF_IOCTL_GET_LINK_STATUS, NULL, 0, NULL, 0) == NETMAN_NETIF_ETH_LINK_STATE_UP) - scr_printf("Up\n"); - else - scr_printf("Down\n"); + scr_printf((NetManIoctl(NETMAN_NETIF_IOCTL_GET_LINK_STATUS, NULL, 0, NULL, 0) == NETMAN_NETIF_ETH_LINK_STATE_UP) ? "Up\n" : "Down\n"); scr_printf("Mode:\t"); mode = NetManIoctl(NETMAN_NETIF_IOCTL_ETH_GET_LINK_MODE, NULL, 0, NULL, 0); @@ -205,10 +197,7 @@ static void ethPrintLinkStatus(void) default: scr_printf("Unknown"); } - if(!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE)) - scr_printf(" with "); - else - scr_printf(" without "); + scr_printf((!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE)) ? " with " : " without "); scr_printf("Flow Control\n"); } diff --git a/ee/network/tcpip/samples/tcpip_dhcp/ps2ip.c b/ee/network/tcpip/samples/tcpip_dhcp/ps2ip.c index bc188dcf56e5..161583a99906 100644 --- a/ee/network/tcpip/samples/tcpip_dhcp/ps2ip.c +++ b/ee/network/tcpip/samples/tcpip_dhcp/ps2ip.c @@ -85,10 +85,7 @@ static int ethGetDHCPStatus(void) if ((result = ps2ip_getconfig("sm0", &ip_info)) >= 0) { //Check for a successful state if DHCP is enabled. - if (ip_info.dhcp_enabled) - result = (ip_info.dhcp_status == DHCP_STATE_BOUND || (ip_info.dhcp_status == DHCP_STATE_OFF)); - else - result = -1; + result = ip_info.dhcp_enabled ? (ip_info.dhcp_status == DHCP_STATE_BOUND || (ip_info.dhcp_status == DHCP_STATE_OFF)) : -1; } return result; @@ -120,17 +117,12 @@ static int ethApplyIPConfig(int use_dhcp, const struct ip4_addr *ip, const struc !ip_addr_cmp(gateway, (struct ip4_addr *)&ip_info.gw) || !ip_addr_cmp(dns, dns_curr)))) { - if (use_dhcp) - { - ip_info.dhcp_enabled = 1; - } - else + ip_info.dhcp_enabled = use_dhcp ? 1 : 0; + if (!use_dhcp) { //Copy over new settings if DHCP is not used. ip_addr_set((struct ip4_addr *)&ip_info.ipaddr, ip); ip_addr_set((struct ip4_addr *)&ip_info.netmask, netmask); ip_addr_set((struct ip4_addr *)&ip_info.gw, gateway); - - ip_info.dhcp_enabled = 0; } //Update settings. @@ -199,10 +191,7 @@ static void ethPrintLinkStatus(void) //SMAP is registered as the "sm0" device to the TCP/IP stack. scr_printf("Link:\t"); - if (NetManIoctl(NETMAN_NETIF_IOCTL_GET_LINK_STATUS, NULL, 0, NULL, 0) == NETMAN_NETIF_ETH_LINK_STATE_UP) - scr_printf("Up\n"); - else - scr_printf("Down\n"); + scr_printf(NetManIoctl(NETMAN_NETIF_IOCTL_GET_LINK_STATUS, NULL, 0, NULL, 0) == NETMAN_NETIF_ETH_LINK_STATE_UP ? "Up\n" : "Down\n"); scr_printf("Mode:\t"); mode = NetManIoctl(NETMAN_NETIF_IOCTL_ETH_GET_LINK_MODE, NULL, 0, NULL, 0); @@ -226,10 +215,7 @@ static void ethPrintLinkStatus(void) default: scr_printf("Unknown"); } - if(!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE)) - scr_printf(" with "); - else - scr_printf(" without "); + scr_printf(!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE) ? " with " : " without "); scr_printf("Flow Control\n"); } diff --git a/ee/network/tcpip/src/ps2ip.c b/ee/network/tcpip/src/ps2ip.c index dd16fd45ac89..d7b248bd3b7e 100644 --- a/ee/network/tcpip/src/ps2ip.c +++ b/ee/network/tcpip/src/ps2ip.c @@ -56,16 +56,8 @@ int ps2ip_getconfig(char* pszName, t_ip_info* pInfo) #if LWIP_DHCP struct dhcp *dhcp = netif_dhcp_data(pNetIF); - if ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) - { - pInfo->dhcp_enabled=1; - pInfo->dhcp_status=dhcp->state; - } - else - { - pInfo->dhcp_enabled=0; - pInfo->dhcp_status=DHCP_STATE_OFF; - } + pInfo->dhcp_enabled = ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) ? 1 : 0; + pInfo->dhcp_status = (dhcp != NULL) ? dhcp->state : DHCP_STATE_OFF; #else pInfo->dhcp_enabled=0; @@ -208,12 +200,9 @@ static int NextTxPacket(void **payload) { int len; - if(TxTail != NULL) - { + len = TxTail ? TxTail->len : 0; + if(TxTail) *payload = TxTail->payload; - len = TxTail->len; - } else - len = 0; return len; } @@ -250,12 +239,9 @@ static int AfterTxPacket(void **payload) { int len; + len = (TxTail != NULL && TxTail->next != NULL) ? TxTail->next->len : 0; if(TxTail != NULL && TxTail->next != NULL) - { *payload = TxTail->next->payload; - len = TxTail->next->len; - } else - len = 0; return len; } diff --git a/ee/network/tcpip/src/ps2ip_ps2sdk.c b/ee/network/tcpip/src/ps2ip_ps2sdk.c index a2c0ccd23021..8a4496d46725 100644 --- a/ee/network/tcpip/src/ps2ip_ps2sdk.c +++ b/ee/network/tcpip/src/ps2ip_ps2sdk.c @@ -60,11 +60,7 @@ int __ps2ipeeFcntlfsetflHelper(void *userdata, int newfl) val = (newfl & O_NONBLOCK) ? 1 : 0; res = lwip_ioctl(fd, FIONBIO, &val); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipeeAcceptHelper(void *userdata, _libcglue_fdman_fd_info_t *info, struct sockaddr *addr, int *addrlen) @@ -100,11 +96,7 @@ int __ps2ipeeBindHelper(void *userdata, const struct sockaddr *name, int namelen } res = lwip_bind(fd, name, namelen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeCloseHelper(void *userdata) @@ -119,11 +111,7 @@ int __ps2ipeeCloseHelper(void *userdata) } res = lwip_close(fd); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeConnectHelper(void *userdata, const struct sockaddr *name, int namelen) @@ -138,11 +126,7 @@ int __ps2ipeeConnectHelper(void *userdata, const struct sockaddr *name, int name } res = lwip_connect(fd, name, namelen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeListenHelper(void *userdata, int backlog) @@ -157,11 +141,7 @@ int __ps2ipeeListenHelper(void *userdata, int backlog) } res = lwip_listen(fd, backlog); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeRecvHelper(void *userdata, void *mem, size_t len, int flags) @@ -176,11 +156,7 @@ int __ps2ipeeRecvHelper(void *userdata, void *mem, size_t len, int flags) } res = lwip_recv(fd, mem, len, flags); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeRecvfromHelper(void *userdata, void *mem, size_t len, int flags, struct sockaddr *from, int *fromlen) @@ -195,11 +171,7 @@ int __ps2ipeeRecvfromHelper(void *userdata, void *mem, size_t len, int flags, st } res = lwip_recvfrom(fd, mem, len, flags, from, fromlen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeRecvmsgHelper(void *userdata, struct msghdr *msg, int flags) @@ -220,11 +192,7 @@ int __ps2ipeeSendHelper(void *userdata, const void *dataptr, size_t size, int fl } res = lwip_send(fd, dataptr, size, flags); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeSendtoHelper(void *userdata, const void *dataptr, size_t size, int flags, const struct sockaddr *to, int tolen) @@ -239,11 +207,7 @@ int __ps2ipeeSendtoHelper(void *userdata, const void *dataptr, size_t size, int } res = lwip_sendto(fd, dataptr, size, flags, to, tolen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeSendmsgHelper(void *userdata, const struct msghdr *msg, int flags) { @@ -263,11 +227,7 @@ int __ps2ipeeIoctlHelper(void *userdata, int cmd, void *argp) } res = lwip_ioctl(fd, cmd, argp); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeGetsocknameHelper(void *userdata, struct sockaddr* name, int* namelen) @@ -282,11 +242,7 @@ int __ps2ipeeGetsocknameHelper(void *userdata, struct sockaddr* name, int* namel } res = lwip_getsockname(fd, name, namelen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeGetpeernameHelper(void *userdata, struct sockaddr *name, int *namelen) @@ -301,11 +257,7 @@ int __ps2ipeeGetpeernameHelper(void *userdata, struct sockaddr *name, int *namel } res = lwip_getpeername(fd, name, namelen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeGetsockoptHelper(void *userdata, int level, int optname, void* optval, socklen_t* optlen) @@ -320,11 +272,7 @@ int __ps2ipeeGetsockoptHelper(void *userdata, int level, int optname, void* optv } res = lwip_getsockopt(fd, level, optname, optval, optlen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeSetsockoptHelper(void *userdata, int level, int optname, const void *optval, socklen_t optlen) @@ -339,11 +287,7 @@ int __ps2ipeeSetsockoptHelper(void *userdata, int level, int optname, const void } res = lwip_setsockopt(fd, level, optname, optval, optlen); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeShutdownHelper(void *userdata, int how) @@ -358,11 +302,7 @@ int __ps2ipeeShutdownHelper(void *userdata, int how) } res = lwip_shutdown(fd, how); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeReadHelper(void *userdata, void *mem, int len) @@ -377,11 +317,7 @@ int __ps2ipeeReadHelper(void *userdata, void *mem, int len) } res = lwip_read(fd, mem, len); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } int __ps2ipeeWriteHelper(void *userdata, const void *mem, int len) @@ -396,11 +332,7 @@ int __ps2ipeeWriteHelper(void *userdata, const void *mem, int len) } res = lwip_write(fd, mem, len); - if (res < 0) - { - return -errno; - } - return res; + return (res < 0) ? -errno : res; } struct hostent *ps2ip_gethostbyaddr(const void *addr, int len, int type) { diff --git a/ee/network/tcpip/src/sys_arch.c b/ee/network/tcpip/src/sys_arch.c index 7be61aa79d46..ec5e3a02660e 100644 --- a/ee/network/tcpip/src/sys_arch.c +++ b/ee/network/tcpip/src/sys_arch.c @@ -208,10 +208,7 @@ static int WaitSemaTimeout(int sema, unsigned int msec) u64 *timeoutPtr; if (msec == 0) { - if (PollSema(sema) < 0) { - return -1; - } - return sema; + return (PollSema(sema) < 0) ? -1 : sema; } timeoutPtr = NULL; @@ -223,20 +220,14 @@ static int WaitSemaTimeout(int sema, unsigned int msec) ret = WaitSemaEx(sema, 1, timeoutPtr); - if (ret < 0) - return -1; //Timed out. - return sema; //Wait condition satisfied. + return (ret < 0) ? -1 /* Timed out. */ : sema /* Wait condition satisfied. */; } static int ReceiveMbx(arch_message **message, sys_mbox_t mBox, u32_t timeout) { int result; - if(timeout > 0) { - result = WaitSemaTimeout(mBox->MessageCountSema, timeout); - } else { - result = WaitSema(mBox->MessageCountSema); - } + result = (timeout > 0) ? WaitSemaTimeout(mBox->MessageCountSema, timeout) : WaitSema(mBox->MessageCountSema); if(result == mBox->MessageCountSema) { diff --git a/ee/packet2/include/packet2_chain.h b/ee/packet2/include/packet2_chain.h index b742520ca44e..e732b30f9644 100644 --- a/ee/packet2/include/packet2_chain.h +++ b/ee/packet2/include/packet2_chain.h @@ -76,20 +76,9 @@ extern "C" assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly. assert(packet2->tag_opened_at == NULL); // All previous tags are closed. - if (qwc == PACKET2_COUNT_QWC) - { - packet2_chain_set_dma_tag((dma_tag_t *)packet2->next, 0, pce, id, irq, addr, spr); // placeholder - packet2->tag_opened_at = (dma_tag_t *)packet2->next; - } - else - { - packet2_chain_set_dma_tag((dma_tag_t *)packet2->next, qwc, pce, id, irq, addr, spr); - packet2->tag_opened_at = (dma_tag_t *)NULL; - } - if (!packet2->tte) - packet2_advance_next(packet2, sizeof(dma_tag_t)); - else - packet2_advance_next(packet2, sizeof(u64)); + packet2_chain_set_dma_tag((dma_tag_t *)packet2->next, (qwc == PACKET2_COUNT_QWC) ? 0 : qwc, pce, id, irq, addr, spr); // placeholder + packet2->tag_opened_at = (qwc == PACKET2_COUNT_QWC) ? (dma_tag_t *)packet2->next : NULL; + packet2_advance_next(packet2, !packet2->tte ? sizeof(dma_tag_t) : sizeof(u64)); } /** diff --git a/ee/packet2/src/packet2_vif.c b/ee/packet2/src/packet2_vif.c index 71d454aa6608..46cc5bb73030 100644 --- a/ee/packet2/src/packet2_vif.c +++ b/ee/packet2/src/packet2_vif.c @@ -65,8 +65,7 @@ u32 packet2_vif_close_unpack_auto(packet2_t *packet2, u32 wl, u32 cl) { u32 wl_blocks_count = (quads_count / cl); u32 last_block_quads = quads_count - wl_blocks_count * cl; - if (last_block_quads == cl) - last_block_quads = wl; + last_block_quads = (last_block_quads == cl) ? wl : last_block_quads; quads_count = wl_blocks_count * wl + last_block_quads; } diff --git a/ee/rpc/camera/src/ps2cam_rpc.c b/ee/rpc/camera/src/ps2cam_rpc.c index 2654fd9025ee..4fca42b06e03 100644 --- a/ee/rpc/camera/src/ps2cam_rpc.c +++ b/ee/rpc/camera/src/ps2cam_rpc.c @@ -337,14 +337,7 @@ int PS2CamExtractFrame(int handle, char *buffer, int bufsize) pic_size = (int)(((head->Lo) + ((int)(head->Hi)<<8))<<3); - if(pos != pic_size) - { - return 0; - } - else - { - return pic_size; - } + return (pos != pic_size) ? 0 : pic_size; } else { diff --git a/ee/rpc/cdvd/src/ncmd.c b/ee/rpc/cdvd/src/ncmd.c index 8c667683c8c8..5e61b216ae11 100644 --- a/ee/rpc/cdvd/src/ncmd.c +++ b/ee/rpc/cdvd/src/ncmd.c @@ -199,12 +199,7 @@ int sceCdRead(u32 lbn, u32 sectors, void *buf, sceCdRMode *mode) readData[5] = (u32)&curReadPos; // work out buffer size - if (mode->datapattern == SCECdSecS2328) - bufSize = sectors * 2328; - else if (mode->datapattern == SCECdSecS2340) - bufSize = sectors * 2340; - else - bufSize = sectors * 2048; + bufSize = sectors * ((mode->datapattern == SCECdSecS2328) ? 2328 : (mode->datapattern == SCECdSecS2340) ? 2340 : 2048); curReadPos = 0; sceSifWriteBackDCache(buf, bufSize); @@ -313,8 +308,6 @@ int sceCdReadCDDA(u32 lbn, u32 nsectors, void *buf, sceCdRMode *rm) #ifdef F_sceCdGetToc int sceCdGetToc(u8 *toc) { - u8 *tocPtr, *tocEnd; - if (_CdCheckNCmd(CD_NCMD_GETTOC) == 0) return 0; @@ -326,25 +319,7 @@ int sceCdGetToc(u8 *toc) return 0; } - tocPtr = UNCACHED_SEG(tocBuff); - tocEnd = tocPtr + 1024; - if (*(u32 *)(nCmdRecvBuff + 4)) { - do { - memcpy(toc, tocPtr, 32); - tocPtr += 32; - toc += 32; - } while (tocPtr < tocEnd); - } else { - tocEnd = tocPtr + 2048; - - do { - memcpy(toc, tocPtr, 32); - tocPtr += 32; - toc += 32; - } while (tocPtr < tocEnd); - - memcpy(toc, tocPtr, 16); - } + memcpy(toc, UNCACHED_SEG(tocBuff), *(u32 *)(nCmdRecvBuff + 4) ? 1024 : 2064); SignalSema(nCmdSemaId); return *(int *)UNCACHED_SEG(nCmdRecvBuff); @@ -548,12 +523,7 @@ int sceCdReadChain(sceCdRChain *readChain, sceCdRMode *mode) readChainData[65].lbn = (mode->trycount) | (mode->spindlctrl << 8) | (mode->datapattern << 16); readChainData[65].sectors = (u32)&curReadPos; - if (mode->datapattern == SCECdSecS2328) - sectorType = 2328; - else if (mode->datapattern == SCECdSecS2340) - sectorType = 2340; - else - sectorType = 2048; + sectorType = (mode->datapattern == SCECdSecS2328) ? 2328 : ((mode->datapattern == SCECdSecS2340) ? 2340 : 2048); curReadPos = 0; if (CdDebug > 0) @@ -596,10 +566,7 @@ int sceCdReadChain(sceCdRChain *readChain, sceCdRMode *mode) #ifdef F_sceCdGetReadPos u32 sceCdGetReadPos(void) { - if (CdCallbackNum == CD_NCMD_READ) { - return *(u32 *)UNCACHED_SEG(curReadPos); - } - return 0; + return (CdCallbackNum == CD_NCMD_READ) ? *(u32 *)UNCACHED_SEG(curReadPos) : 0; } #endif @@ -744,10 +711,7 @@ int sceCdCddaStream(u32 lbn, u32 nsectors, void *buf, CdvdStCmd_t cmd, sceCdRMod if (_CdCheckNCmd(17) == 0) return cmd < CDVD_ST_CMD_INIT ? -1 : 0; - if (rm->datapattern == SCECdSecS2368) - sector_size = 2368; - else - sector_size = 2352; + sector_size = (rm->datapattern == SCECdSecS2368) ? 2368 : 2352; readStreamData[0] = lbn; readStreamData[1] = nsectors * sector_size; diff --git a/ee/rpc/filexio/src/fileXio_ps2sdk.c b/ee/rpc/filexio/src/fileXio_ps2sdk.c index 0f712292303b..6838f183544c 100644 --- a/ee/rpc/filexio/src/fileXio_ps2sdk.c +++ b/ee/rpc/filexio/src/fileXio_ps2sdk.c @@ -71,15 +71,15 @@ int __fileXioOpenHelper(_libcglue_fdman_fd_info_t *info, const char *buf, int fl int iop_fd; // newlib flags differ from iop flags - if ((flags & 3) == O_RDONLY) iop_flags |= IOP_O_RDONLY; - if ((flags & 3) == O_WRONLY) iop_flags |= IOP_O_WRONLY; - if ((flags & 3) == O_RDWR ) iop_flags |= IOP_O_RDWR; - if (flags & O_NONBLOCK) iop_flags |= IOP_O_NBLOCK; - if (flags & O_APPEND) iop_flags |= IOP_O_APPEND; - if (flags & O_CREAT) iop_flags |= IOP_O_CREAT; - if (flags & O_TRUNC) iop_flags |= IOP_O_TRUNC; - if (flags & O_EXCL) iop_flags |= IOP_O_EXCL; - //if (flags & O_???) iop_flags |= IOP_O_NOWAIT; + iop_flags |= ((flags & 3) == O_RDONLY) ? IOP_O_RDONLY : 0; + iop_flags |= ((flags & 3) == O_WRONLY) ? IOP_O_WRONLY : 0; + iop_flags |= ((flags & 3) == O_RDWR ) ? IOP_O_RDWR : 0; + iop_flags |= (flags & O_NONBLOCK) ? IOP_O_NBLOCK : 0; + iop_flags |= (flags & O_APPEND) ? IOP_O_APPEND : 0; + iop_flags |= (flags & O_CREAT) ? IOP_O_CREAT : 0; + iop_flags |= (flags & O_TRUNC) ? IOP_O_TRUNC : 0; + iop_flags |= (flags & O_EXCL) ? IOP_O_EXCL : 0; + //iop_flags |= (flags & O_???) ? IOP_O_NOWAIT : 0; if (flags & O_DIRECTORY) { iop_flags |= IOP_O_DIROPEN; is_dir = 1; @@ -159,17 +159,17 @@ static time_t io_to_posix_time(const unsigned char *ps2time) static mode_t iox_to_posix_mode(unsigned int ps2mode) { mode_t posixmode = 0; - if (ps2mode & FIO_S_IFREG) posixmode |= S_IFREG; - if (ps2mode & FIO_S_IFDIR) posixmode |= S_IFDIR; - if (ps2mode & FIO_S_IRUSR) posixmode |= S_IRUSR; - if (ps2mode & FIO_S_IWUSR) posixmode |= S_IWUSR; - if (ps2mode & FIO_S_IXUSR) posixmode |= S_IXUSR; - if (ps2mode & FIO_S_IRGRP) posixmode |= S_IRGRP; - if (ps2mode & FIO_S_IWGRP) posixmode |= S_IWGRP; - if (ps2mode & FIO_S_IXGRP) posixmode |= S_IXGRP; - if (ps2mode & FIO_S_IROTH) posixmode |= S_IROTH; - if (ps2mode & FIO_S_IWOTH) posixmode |= S_IWOTH; - if (ps2mode & FIO_S_IXOTH) posixmode |= S_IXOTH; + posixmode |= (ps2mode & FIO_S_IFREG) ? S_IFREG : 0; + posixmode |= (ps2mode & FIO_S_IFDIR) ? S_IFDIR : 0; + posixmode |= (ps2mode & FIO_S_IRUSR) ? S_IRUSR : 0; + posixmode |= (ps2mode & FIO_S_IWUSR) ? S_IWUSR : 0; + posixmode |= (ps2mode & FIO_S_IXUSR) ? S_IXUSR : 0; + posixmode |= (ps2mode & FIO_S_IRGRP) ? S_IRGRP : 0; + posixmode |= (ps2mode & FIO_S_IWGRP) ? S_IWGRP : 0; + posixmode |= (ps2mode & FIO_S_IXGRP) ? S_IXGRP : 0; + posixmode |= (ps2mode & FIO_S_IROTH) ? S_IROTH : 0; + posixmode |= (ps2mode & FIO_S_IWOTH) ? S_IWOTH : 0; + posixmode |= (ps2mode & FIO_S_IXOTH) ? S_IXOTH : 0; return posixmode; } diff --git a/ee/rpc/filexio/src/fileXio_rpc.c b/ee/rpc/filexio/src/fileXio_rpc.c index 1aa2e6885441..4f35f85f9d74 100644 --- a/ee/rpc/filexio/src/fileXio_rpc.c +++ b/ee/rpc/filexio/src/fileXio_rpc.c @@ -184,8 +184,7 @@ int fileXioGetDeviceList(struct fileXioDevice deviceEntry[], unsigned int req_en // This will get the directory contents, and fill dirEntry via DMA if((rv = sceSifCallRpc(&__cd0, FILEXIO_GETDEVICELIST, __fileXioBlockMode, __sbuff, sizeof(struct fxio_devlist_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -218,8 +217,7 @@ int fileXioGetdir(const char* pathname, struct fileXioDirEntry dirEntry[], unsig // This will get the directory contents, and fill dirEntry via DMA if((rv = sceSifCallRpc(&__cd0, FILEXIO_GETDIR, __fileXioBlockMode, __sbuff, sizeof(struct fxio_getdir_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -247,8 +245,7 @@ int fileXioMount(const char* mountpoint, const char* mountstring, int flag) if((rv = sceSifCallRpc(&__cd0, FILEXIO_MOUNT, __fileXioBlockMode, __sbuff, sizeof(struct fxio_mount_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -274,8 +271,7 @@ int fileXioUmount(const char* mountpoint) if((rv = sceSifCallRpc(&__cd0, FILEXIO_UMOUNT, __fileXioBlockMode, __sbuff, sizeof(struct fxio_unmount_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -303,8 +299,7 @@ int fileXioCopyfile(const char* source, const char* dest, int mode) if((rv = sceSifCallRpc(&__cd0, FILEXIO_COPYFILE, __fileXioBlockMode, __sbuff, sizeof(struct fxio_copyfile_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -331,8 +326,7 @@ int fileXioMkdir(const char* pathname, int mode) if((rv = sceSifCallRpc(&__cd0, FILEXIO_MKDIR, __fileXioBlockMode, __sbuff, sizeof(struct fxio_mkdir_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -358,8 +352,7 @@ int fileXioRmdir(const char* pathname) if((rv = sceSifCallRpc(&__cd0, FILEXIO_RMDIR, __fileXioBlockMode, __sbuff, sizeof(struct fxio_pathsel_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -385,8 +378,7 @@ int fileXioRemove(const char* pathname) if((rv = sceSifCallRpc(&__cd0, FILEXIO_REMOVE, __fileXioBlockMode, __sbuff, sizeof(struct fxio_pathsel_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -413,8 +405,7 @@ int fileXioRename(const char* source, const char* dest) if((rv = sceSifCallRpc(&__cd0, FILEXIO_RENAME, __fileXioBlockMode, __sbuff, sizeof(struct fxio_rename_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -441,8 +432,7 @@ int fileXioSymlink(const char* source, const char* dest) if((rv = sceSifCallRpc(&__cd0, FILEXIO_SYMLINK, __fileXioBlockMode, __sbuff, sizeof(struct fxio_rename_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -473,8 +463,7 @@ int fileXioReadlink(const char* source, char* buf, unsigned int buflen) if((rv = sceSifCallRpc(&__cd0, FILEXIO_READLINK, __fileXioBlockMode, __sbuff, sizeof(struct fxio_readlink_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -500,8 +489,7 @@ int fileXioChdir(const char* pathname) if((rv = sceSifCallRpc(&__cd0, FILEXIO_CHDIR, __fileXioBlockMode, __sbuff, sizeof(struct fxio_pathsel_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -533,8 +521,7 @@ int fileXioOpen(const char* source, int flags, ...) packet->mode = mode; if((rv = sceSifCallRpc(&__cd0, FILEXIO_OPEN, __fileXioBlockMode, __sbuff, sizeof(struct fxio_open_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -560,8 +547,7 @@ int fileXioClose(int fd) if((rv = sceSifCallRpc(&__cd0, FILEXIO_CLOSE, __fileXioBlockMode, __sbuff, sizeof(struct fxio_close_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -603,8 +589,7 @@ int fileXioRead(int fd, void *buf, int size) if((rv = sceSifCallRpc(&__cd0, FILEXIO_READ, __fileXioBlockMode, __sbuff, sizeof(struct fxio_read_packet), __sbuff, 4, &recv_intr, __intr_data)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -627,13 +612,8 @@ int fileXioWrite(int fd, const void *buf, int size) _lock(); WaitSema(__fileXioCompletionSema); - if((unsigned int)buf & 0x3F) - { - miss = 64 - ((unsigned int)buf & 0x3F); - if(miss > (unsigned int)size) miss = size; - } else { - miss = 0; - } + miss = ((unsigned int)buf & 0x3F) ? (64 - ((unsigned int)buf & 0x3F)) : 0; + if(miss > (unsigned int)size) miss = size; packet->fd = fd; packet->buffer = buf; @@ -647,8 +627,7 @@ int fileXioWrite(int fd, const void *buf, int size) if((rv = sceSifCallRpc(&__cd0, FILEXIO_WRITE, __fileXioBlockMode, __sbuff, sizeof(struct fxio_write_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -676,8 +655,7 @@ int fileXioLseek(int fd, int offset, int whence) if((rv = sceSifCallRpc(&__cd0, FILEXIO_LSEEK, __fileXioBlockMode, __sbuff, sizeof(struct fxio_lseek_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -710,12 +688,7 @@ s64 fileXioLseek64(int fd, s64 offset, int whence) if((rv = sceSifCallRpc(&__cd0, FILEXIO_LSEEK64, __fileXioBlockMode, __sbuff, sizeof(struct fxio_lseek64_packet), __sbuff, 8, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { - s64 rvHI = ret_packet->pos_hi; - rvHI = rvHI << 32; - rv = rvHI | ret_packet->pos_lo; - } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? (s64)0 : ((((s64)ret_packet->pos_hi) << 32) | (s64)ret_packet->pos_lo); } else SignalSema(__fileXioCompletionSema); @@ -747,8 +720,7 @@ int fileXioChStat(const char *name, iox_stat_t *stat, int mask) if((rv = sceSifCallRpc(&__cd0, FILEXIO_CHSTAT, __fileXioBlockMode, __sbuff, sizeof(struct fxio_chstat_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -778,8 +750,7 @@ int fileXioGetStat(const char *name, iox_stat_t *stat) if((rv = sceSifCallRpc(&__cd0, FILEXIO_GETSTAT, __fileXioBlockMode, __sbuff, sizeof(struct fxio_getstat_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -811,8 +782,7 @@ int fileXioFormat(const char *dev, const char *blockdev, const void *args, int a if((rv = sceSifCallRpc(&__cd0, FILEXIO_FORMAT, __fileXioBlockMode, __sbuff, sizeof(struct fxio_format_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -839,8 +809,7 @@ int fileXioSync(const char *devname, int flag) if((rv = sceSifCallRpc(&__cd0, FILEXIO_SYNC, __fileXioBlockMode, __sbuff, sizeof(struct fxio_sync_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -865,8 +834,7 @@ int fileXioDopen(const char *name) strncpy(packet->pathname, name, sizeof(packet->pathname)); if((rv = sceSifCallRpc(&__cd0, FILEXIO_DOPEN, __fileXioBlockMode, __sbuff, sizeof(struct fxio_pathsel_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -891,8 +859,7 @@ int fileXioDclose(int fd) packet->fd = fd; if((rv = sceSifCallRpc(&__cd0, FILEXIO_DCLOSE, __fileXioBlockMode, __sbuff, sizeof(struct fxio_close_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -922,8 +889,7 @@ int fileXioDread(int fd, iox_dirent_t *dirent) if((rv = sceSifCallRpc(&__cd0, FILEXIO_DREAD, __fileXioBlockMode, __sbuff, sizeof(struct fxio_dread_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -968,15 +934,11 @@ int fileXioDevctl(const char *name, int cmd, void *arg, unsigned int arglen, voi sceSifWriteBackDCache(buf, buflen); - if(buflen) - rv = sceSifCallRpc(&__cd0, FILEXIO_DEVCTL, __fileXioBlockMode, packet, sizeof(struct fxio_devctl_packet), __sbuff, 4, &fxio_ctl_intr, __intr_data); - else - rv = sceSifCallRpc(&__cd0, FILEXIO_DEVCTL, __fileXioBlockMode, packet, sizeof(struct fxio_devctl_packet), __sbuff, 4, (void *)&_fxio_intr, NULL); + rv = sceSifCallRpc(&__cd0, FILEXIO_DEVCTL, __fileXioBlockMode, packet, sizeof(struct fxio_devctl_packet), __sbuff, 4, buflen ? &fxio_ctl_intr : (void *)&_fxio_intr, buflen ? __intr_data : NULL); if(rv >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -1004,8 +966,7 @@ int fileXioIoctl(int fd, int cmd, void *arg){ if((rv = sceSifCallRpc(&__cd0, FILEXIO_IOCTL, __fileXioBlockMode, packet, sizeof(struct fxio_ioctl_packet), __sbuff, 4, (void *)&_fxio_intr, NULL)) >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); @@ -1040,15 +1001,11 @@ int fileXioIoctl2(int fd, int command, void *arg, unsigned int arglen, void *buf sceSifWriteBackDCache(buf, buflen); - if(buflen) - rv = sceSifCallRpc(&__cd0, FILEXIO_IOCTL2, __fileXioBlockMode, packet, sizeof(struct fxio_ioctl2_packet), __sbuff, 4, &fxio_ctl_intr, __intr_data); - else - rv = sceSifCallRpc(&__cd0, FILEXIO_IOCTL2, __fileXioBlockMode, packet, sizeof(struct fxio_ioctl2_packet), __sbuff, 4, (void *)&_fxio_intr, NULL); + rv = sceSifCallRpc(&__cd0, FILEXIO_IOCTL2, __fileXioBlockMode, packet, sizeof(struct fxio_ioctl2_packet), __sbuff, 4, buflen ? &fxio_ctl_intr : (void *)&_fxio_intr, buflen ? __intr_data : NULL); if(rv >= 0) { - if(__fileXioBlockMode == FXIO_NOWAIT) { rv = 0; } - else { rv = __sbuff[0]; } + rv = (__fileXioBlockMode == FXIO_NOWAIT) ? 0 : __sbuff[0]; } else SignalSema(__fileXioCompletionSema); diff --git a/ee/rpc/hdd/src/libhdd.c b/ee/rpc/hdd/src/libhdd.c index ce4680bc7f11..7e0c46f01d64 100644 --- a/ee/rpc/hdd/src/libhdd.c +++ b/ee/rpc/hdd/src/libhdd.c @@ -81,10 +81,7 @@ int hddCheckPresent() rv = fileXioDevctl("hdd0:", HDIOC_STATUS, NULL, 0, NULL, 0); - if((rv >= 3) || (rv < 0)) - return -1; - else - return 0; + return ((rv >= 3) || (rv < 0)) ? -1 : 0; } int hddCheckFormatted() @@ -95,10 +92,7 @@ int hddCheckFormatted() hddUpdateInfo(); rv = fileXioDevctl("hdd0:", HDIOC_STATUS, NULL, 0, NULL, 0); - if((rv >= 1) || (rv < 0)) - return -1; - else - return 0; + return ((rv >= 1) || (rv < 0)) ? -1 : 0; } @@ -279,8 +273,7 @@ static void hddUpdateInfo() rv = fileXioDread(hddFd, &infoDirEnt); while(rv > 0) { - if(infoDirEnt.stat.mode != FS_TYPE_EMPTY) - hddUsed += infoDirEnt.stat.size / 2048; //Equal to, but avoids overflows of: infoDirEnt.stat.size * 512 / 1024 / 1024; + hddUsed += (infoDirEnt.stat.mode != FS_TYPE_EMPTY) ? (infoDirEnt.stat.size / 2048) : 0; //Equal to, but avoids overflows of: infoDirEnt.stat.size * 512 / 1024 / 1024; rv = fileXioDread(hddFd, &infoDirEnt); } diff --git a/ee/rpc/keyboard/src/libkbd.c b/ee/rpc/keyboard/src/libkbd.c index 6cc4a5be9059..26c28eff0fd1 100644 --- a/ee/rpc/keyboard/src/libkbd.c +++ b/ee/rpc/keyboard/src/libkbd.c @@ -87,78 +87,46 @@ int PS2KbdSetBlockingMode(u32 blockmode) int PS2KbdSetRepeatRate(u32 repeat) { - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETREPEATRATE, &repeat); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETREPEATRATE, &repeat) : 0; } int PS2KbdSetLeds(u8 leds) { - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETLEDS, &leds); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETLEDS, &leds) : 0; } int PS2KbdSetKeymap(PS2KbdKeyMap *keymaps) { - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETKEYMAP, keymaps); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETKEYMAP, keymaps) : 0; } int PS2KbdSetCtrlmap(u8 *ctrlmap) { - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETCTRLMAP, ctrlmap); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETCTRLMAP, ctrlmap) : 0; } int PS2KbdSetAltmap(u8 *altmap) { - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETALTMAP, altmap); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETALTMAP, altmap) : 0; } int PS2KbdSetSpecialmap(u8 *special) { - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETSPECIALMAP, special); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_SETSPECIALMAP, special) : 0; } int PS2KbdFlushBuffer(void) { int dummy; - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_FLUSHBUFFER, &dummy); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_FLUSHBUFFER, &dummy) : 0; } int PS2KbdResetKeymap(void) { int dummy; - if(kbd_fd >= 0) - { - return _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_RESETKEYMAP, &dummy); - } - return 0; + return (kbd_fd >= 0) ? _ps2sdk_ioctl(kbd_fd, PS2KBD_IOCTL_RESETKEYMAP, &dummy) : 0; } int PS2KbdClose(void) diff --git a/ee/rpc/memorycard/src/libmc.c b/ee/rpc/memorycard/src/libmc.c index 18cab50511e8..944304d8b0e3 100644 --- a/ee/rpc/memorycard/src/libmc.c +++ b/ee/rpc/memorycard/src/libmc.c @@ -188,16 +188,7 @@ typedef struct libmc_target_desc_ static inline int libmc_pre_rpc_impl(const libmc_target_desc_t *target, int flags, int only_type) { - // check mc lib is inited - if (!target->m_interface_data->m_client_data.server) - return -1; - // If MCSERV version does not support a feature, return error - if ((flags & LIBMC_PRE_CHECK_FLAG_ONLY_TYPE) != 0 && target->m_interface_data->m_mc_rpc_type != only_type) - return -1; - // check nothing else is processing - if (target->m_interface_data->m_current_command != MC_FUNC_NONE) - return target->m_interface_data->m_current_command; - return 0; + return /* check mc lib is inited */ (!target->m_interface_data->m_client_data.server) || /* If MCSERV version does not support a feature, return error */((flags & LIBMC_PRE_CHECK_FLAG_ONLY_TYPE) != 0 && target->m_interface_data->m_mc_rpc_type != only_type) ? -1 : (/* check nothing else is processing */(target->m_interface_data->m_current_command != MC_FUNC_NONE) ? target->m_interface_data->m_current_command : 0); } #define LIBMC_PRE_RPC(target, flags, only_type) \ @@ -319,8 +310,7 @@ static void mcStoreDir(void* arg) int len; char *currentDir = ep->m_extra_send_recv_param->m_cur_dir; len = strlen(currentDir); - if (len >= 1024) - len = strlen(currentDir+1023); + len = (len >= 1024) ? strlen(currentDir+1023) : len; memcpy(ep->m_dst_cur_dir, currentDir, len); *(currentDir+len) = 0; } @@ -489,18 +479,9 @@ static int libmc_rpc_get_info(const libmc_target_desc_t *target, int* type, int* // set global variables target->m_interface_data->m_name_desc_param.m_desc_param.port = target->m_port; target->m_interface_data->m_name_desc_param.m_desc_param.slot = target->m_slot; - if (target->m_interface_data->m_mc_rpc_type == MC_TYPE_MC) - { - target->m_interface_data->m_name_desc_param.m_desc_param.size = (type) ? 1 : 0; - target->m_interface_data->m_name_desc_param.m_desc_param.offset = (free) ? 1 : 0; - target->m_interface_data->m_name_desc_param.m_desc_param.origin = (format) ? 1 : 0; - } - else - { - target->m_interface_data->m_name_desc_param.m_desc_param.size = (format) ? 1 : 0; - target->m_interface_data->m_name_desc_param.m_desc_param.offset = (free) ? 1 : 0; - target->m_interface_data->m_name_desc_param.m_desc_param.origin = (type) ? 1 : 0; - } + target->m_interface_data->m_name_desc_param.m_desc_param.size = (target->m_interface_data->m_mc_rpc_type == MC_TYPE_MC) ? ((type) ? 1 : 0) : ((format) ? 1 : 0); + target->m_interface_data->m_name_desc_param.m_desc_param.offset = (free) ? 1 : 0; + target->m_interface_data->m_name_desc_param.m_desc_param.origin = (target->m_interface_data->m_mc_rpc_type == MC_TYPE_MC) ? ((format) ? 1 : 0) : ((type) ? 1 : 0); target->m_interface_data->m_name_desc_param.m_desc_param.param = target->m_interface_data->m_extra_send_recv_param.m_end_parameter; target->m_interface_data->m_extra_end_param.m_p_type = type; target->m_interface_data->m_extra_end_param.m_p_free = free; @@ -572,18 +553,9 @@ static int libmc_rpc_write(const libmc_target_desc_t *target, const void *buffer // set global variables target->m_interface_data->m_name_desc_param.m_desc_param.fd = target->m_fd; - if (size < 17) - { - target->m_interface_data->m_name_desc_param.m_desc_param.size = 0; - target->m_interface_data->m_name_desc_param.m_desc_param.origin = size; - target->m_interface_data->m_name_desc_param.m_desc_param.buffer = 0; - } - else - { - target->m_interface_data->m_name_desc_param.m_desc_param.size = size - ( ((int)((const u8 *)buffer-1) & 0xFFFFFFF0) - (int)((const u8 *)buffer-16) ); - target->m_interface_data->m_name_desc_param.m_desc_param.origin = ( ((int)((const u8 *)buffer-1) & 0xFFFFFFF0) - (int)((const u8 *)buffer-16) ); - target->m_interface_data->m_name_desc_param.m_desc_param.buffer = (void*)((int)(const u8 *)buffer + ( ((int)((const u8 *)buffer-1) & 0xFFFFFFF0) - (int)((const u8 *)buffer-16) )); - } + target->m_interface_data->m_name_desc_param.m_desc_param.size = (size >= 17) ? (size - ( ((int)((const u8 *)buffer-1) & 0xFFFFFFF0) - (int)((const u8 *)buffer-16) )) : 0; + target->m_interface_data->m_name_desc_param.m_desc_param.origin = (size >= 17) ? ( ( ((int)((const u8 *)buffer-1) & 0xFFFFFFF0) - (int)((const u8 *)buffer-16) )) : size; + target->m_interface_data->m_name_desc_param.m_desc_param.buffer = (size >= 17) ? ((void*)((int)(const u8 *)buffer + ( ((int)((const u8 *)buffer-1) & 0xFFFFFFF0) - (int)((const u8 *)buffer-16) ))) : 0; for (i = 0; i < target->m_interface_data->m_name_desc_param.m_desc_param.origin; i++) { target->m_interface_data->m_name_desc_param.m_desc_param.data[i] = *(char*)((const u8 *)buffer+i); diff --git a/ee/rpc/multitap/samples/mtap_sample.c b/ee/rpc/multitap/samples/mtap_sample.c index cddec6b5b4d3..bea98fed605a 100644 --- a/ee/rpc/multitap/samples/mtap_sample.c +++ b/ee/rpc/multitap/samples/mtap_sample.c @@ -130,10 +130,7 @@ void find_controllers() mtapConnected[port] = mtapcon; // Check for multitap - if(mtapConnected[port] == 1) - maxslot[port] = 4; - else - maxslot[port] = 1; + maxslot[port] = (mtapConnected[port] == 1) ? 4 : 1; // Find any connected controllers for(slot=0; slot < maxslot[port]; slot++) diff --git a/ee/rpc/pad/src/libpad.c b/ee/rpc/pad/src/libpad.c index d933820df867..32e7ea49eb8c 100644 --- a/ee/rpc/pad/src/libpad.c +++ b/ee/rpc/pad/src/libpad.c @@ -662,9 +662,7 @@ padGetState(int port, int slot) pdata = padGetDmaStrOld(port, slot); state = pdata->state; - if (state == PAD_STATE_STABLE && padGetReqState(port, slot) == PAD_RSTAT_BUSY) // Ok - return PAD_STATE_EXECCMD; - return state; + return (state == PAD_STATE_STABLE && padGetReqState(port, slot) == PAD_RSTAT_BUSY) /* Ok */ ? PAD_STATE_EXECCMD : state; } case 2: { @@ -674,12 +672,7 @@ padGetState(int port, int slot) pdata = padGetDmaStrNew(port, slot); state = pdata->state; - if (state == PAD_STATE_ERROR && pdata->findPadRetries) - return PAD_STATE_FINDPAD; - - if (state == PAD_STATE_STABLE && padGetReqState(port, slot) == PAD_RSTAT_BUSY) // Ok - return PAD_STATE_EXECCMD; - return state; + return (state == PAD_STATE_ERROR && pdata->findPadRetries) ? PAD_STATE_FINDPAD : ((state == PAD_STATE_STABLE && padGetReqState(port, slot) == PAD_RSTAT_BUSY) /* Ok */ ? PAD_STATE_EXECCMD : state); } default: return 0; @@ -759,10 +752,7 @@ padGetPortMax(void) return -1; } - if (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) - return -1; - - return buffer.padResult.result; + return (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) ? -1 : buffer.padResult.result; } int @@ -785,10 +775,7 @@ padGetSlotMax(int port) } buffer.padSlotMaxArgs.port = port; - if (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) - return -1; - - return buffer.padResult.result; + return (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) ? -1 : buffer.padResult.result; } int @@ -798,10 +785,7 @@ padGetModVersion() return 1; // Well.. return a low version # buffer.command = PAD_RPCCMD_GET_MODVER; - if (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) - return -1; - - return buffer.padResult.result; + return (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) ? -1 : buffer.padResult.result; } int @@ -849,13 +833,7 @@ padInfoMode(int port, int slot, int infoMode, int index) case PAD_MODECUROFFS: return (pdata->modeConfig == 0) ? 0 : pdata->modeCurOffs; case PAD_MODETABLE: - if (pdata->modeConfig != 0) { - if (index == -1) - return pdata->nrOfModes; - else if (index < pdata->nrOfModes && ((unsigned int)index <= (sizeof(pdata->modeTable)/sizeof(pdata->modeTable[0])))) - return pdata->modeTable[index]; - } - return 0; + return (pdata->modeConfig != 0) ? ((index == -1) ? pdata->nrOfModes : ((index < pdata->nrOfModes && ((unsigned int)index <= (sizeof(pdata->modeTable)/sizeof(pdata->modeTable[0])))) ? pdata->modeTable[index] : 0)) : 0; default: return 0; } @@ -935,10 +913,7 @@ padGetButtonMask(int port, int slot) buffer.padGetButtonMaskArgs.port = port; buffer.padGetButtonMaskArgs.slot = slot; - if (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) - return 0; - - return buffer.padResult.result; + return (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) ? 0 : buffer.padResult.result; } int @@ -1078,10 +1053,7 @@ padSetActDirect(int port, int slot, const char actAlign[6]) memcpy(buffer.padActDirAlignArgs.align, actAlign, sizeof(buffer.padActDirAlignArgs.align)); - if (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) - return 0; - - return buffer.padModeResult.result; + return (sceSifCallRpc(&padsif[0], 1, 0, &buffer, sizeof(buffer), &buffer, sizeof(buffer), NULL, NULL) < 0) ? 0 : buffer.padModeResult.result; } /* @@ -1095,7 +1067,5 @@ padGetConnection(int port, int slot) if (padInitialised != 2) return 1; oslt = padGetConnDmaStr(); - if ((unsigned int)slot >= (sizeof(oslt->openSlots)/sizeof(oslt->openSlots[0]))) - return 1; - return ((oslt->openSlots[port] >> slot) & 0x1); + return ((unsigned int)slot >= (sizeof(oslt->openSlots)/sizeof(oslt->openSlots[0]))) ? 1 : ((oslt->openSlots[port] >> slot) & 0x1); } diff --git a/ee/rpc/remote/src/librm.c b/ee/rpc/remote/src/librm.c index fcc329a2b16e..6e1a10774b46 100644 --- a/ee/rpc/remote/src/librm.c +++ b/ee/rpc/remote/src/librm.c @@ -42,14 +42,7 @@ static struct rmEEData *rmGetDmaStr(int port, int slot) pdata = ports[port].rmData; SyncDCache(pdata, (u8 *)pdata + 256); - if (pdata[0].frame < pdata[1].frame) - { - return &pdata[1]; - } - else - { - return &pdata[0]; - } + return (pdata[0].frame < pdata[1].frame) ? &pdata[1] : &pdata[0]; } static void RMMan_Cleanup(void) @@ -321,17 +314,8 @@ void RMMan_Read(int port, int slot, struct remote_data *data) if (rmman_type == 2) { - int status; - int button; - status = RM_READY; - button = 0; - if (pdata->data[0] == 0x14) - { - status = RM_KEYPRESSED; - button = pdata->data[1] | (pdata->data[2] << 8) | (pdata->data[3] << 16); - } - data->status = status; - data->button = button; + data->status = (pdata->data[0] == 0x14) ? RM_KEYPRESSED : RM_READY; + data->button = (data->status == RM_KEYPRESSED) ? (pdata->data[1] | (pdata->data[2] << 8) | (pdata->data[3] << 16)) : 0; } else { diff --git a/ee/rpc/secr/src/libsecr.c b/ee/rpc/secr/src/libsecr.c index 7bbfcddd30ae..8acddd57a625 100644 --- a/ee/rpc/secr/src/libsecr.c +++ b/ee/rpc/secr/src/libsecr.c @@ -213,12 +213,9 @@ static void store_kbit(void *buffer, const void *kbit) const SecrKELFHeader_t *header = buffer; int offset = 0x20, kbit_offset; - if (header->BIT_count > 0) - offset += header->BIT_count * sizeof(SecrBitBlockData_t); - if (((header->flags) & 1) != 0) - offset += ((unsigned char *)buffer)[offset] + 1; - if (((header->flags) & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * sizeof(SecrBitBlockData_t)) : 0; + offset += (((header->flags) & 1) != 0) ? (((unsigned char *)buffer)[offset] + 1) : 0; + offset += (((header->flags) & 0xF000) == 0) ? (8) : 0; kbit_offset = (unsigned int)buffer + offset; memcpy((void *)kbit_offset, kbit, 16); @@ -230,12 +227,9 @@ static void store_kc(void *buffer, const void *kc) const SecrKELFHeader_t *header = buffer; int offset = 0x20, kc_offset; - if (header->BIT_count > 0) - offset += header->BIT_count * sizeof(SecrBitBlockData_t); - if (((header->flags) & 1) != 0) - offset += ((unsigned char *)buffer)[offset] + 1; - if (((header->flags) & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * sizeof(SecrBitBlockData_t)) : 0; + offset += (((header->flags) & 1) != 0) ? (((unsigned char *)buffer)[offset] + 1) : 0; + offset += (((header->flags) & 0xF000) == 0) ? (8) : 0; kc_offset = (unsigned int)buffer + offset + 0x10; // Goes after Kbit. memcpy((void *)kc_offset, kc, 16); @@ -261,12 +255,9 @@ static unsigned int get_BitTableOffset(const void *buffer) const SecrKELFHeader_t *header = buffer; int offset = sizeof(SecrKELFHeader_t); - if (header->BIT_count > 0) - offset += header->BIT_count * sizeof(SecrBitBlockData_t); // They used a loop for this. D: - if ((header->flags & 1) != 0) - offset += ((const unsigned char *)buffer)[offset] + 1; - if ((header->flags & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * sizeof(SecrBitBlockData_t)) : 0; // They used a loop for this. D: + offset += ((header->flags & 1) != 0) ? (((const unsigned char *)buffer)[offset] + 1) : 0; + offset += ((header->flags & 0xF000) == 0) ? (8) : 0; return (offset + 0x20); // Goes after Kbit and Kc. } diff --git a/ee/rpc/tcpips/src/ps2ipc.c b/ee/rpc/tcpips/src/ps2ipc.c index d51b9b25ce3b..a9136e861a93 100644 --- a/ee/rpc/tcpips/src/ps2ipc.c +++ b/ee/rpc/tcpips/src/ps2ipc.c @@ -331,15 +331,8 @@ int ps2ipc_send(int s, const void *dataptr, int size, unsigned int flags) pkt->flags = flags; pkt->ee_addr = (void *)dataptr; - if((u32)dataptr & 0x3f) - { - miss = 64 - ((u32)dataptr & 0x3f); - if(miss > size) miss = size; - - } else { - - miss = 0; - } + miss = ((u32)dataptr & 0x3f) ? (64 - ((u32)dataptr & 0x3f)) : 0; + if(miss > size) miss = size; pkt->malign = miss; @@ -379,15 +372,8 @@ int ps2ipc_sendto(int s, const void *dataptr, int size, unsigned int flags, pkt->ee_addr = (void *)dataptr; memcpy((void *)&pkt->sockaddr, (void *)to, sizeof(struct sockaddr)); - if((u32)dataptr & 0x3f) - { - miss = 64 - ((u32)dataptr & 0x3f); - if(miss > size) miss = size; - - } else { - - miss = 0; - } + miss = ((u32)dataptr & 0x3f) ? (64 - ((u32)dataptr & 0x3f)) : 0; + if(miss > size) miss = size; pkt->malign = miss; @@ -493,12 +479,9 @@ static void ps2ipc_pack_fdset(ps2ip_rpc_fd_set *dst, struct fd_set *src, int max int i; memset(dst, 0, sizeof(*dst)); if (src == NULL) return; - if (maxfdp1 > (int)(sizeof(dst->fd_bits) * 8)) - maxfdp1 = (int)(sizeof(dst->fd_bits) * 8); + maxfdp1 = (maxfdp1 > (int)(sizeof(dst->fd_bits) * 8)) ? (int)(sizeof(dst->fd_bits) * 8) : maxfdp1; for (i = 0; i < maxfdp1; i++) { - if (FD_ISSET(i, src)) { - dst->fd_bits[i >> 3] |= (unsigned char)(1U << (i & 7)); - } + dst->fd_bits[i >> 3] |= (FD_ISSET(i, src)) ? (unsigned char)(1U << (i & 7)) : 0; } } diff --git a/ee/rpc/tcpips/src/ps2ipc_ps2sdk.c b/ee/rpc/tcpips/src/ps2ipc_ps2sdk.c index 65780f6fe38c..916504d6b475 100644 --- a/ee/rpc/tcpips/src/ps2ipc_ps2sdk.c +++ b/ee/rpc/tcpips/src/ps2ipc_ps2sdk.c @@ -59,11 +59,7 @@ int __ps2ipcFcntlfsetflHelper(void *userdata, int newfl) val = (newfl & O_NONBLOCK) ? 1 : 0; res = ps2ipc_ioctl(fd, FIONBIO, &val); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcAcceptHelper(void *userdata, _libcglue_fdman_fd_info_t *info, struct sockaddr *addr, int *addrlen) @@ -99,11 +95,7 @@ int __ps2ipcBindHelper(void *userdata, const struct sockaddr *name, int namelen) } res = ps2ipc_bind(fd, name, namelen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcCloseHelper(void *userdata) @@ -118,11 +110,7 @@ int __ps2ipcCloseHelper(void *userdata) } res = ps2ipc_disconnect(fd); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcConnectHelper(void *userdata, const struct sockaddr *name, int namelen) @@ -137,11 +125,7 @@ int __ps2ipcConnectHelper(void *userdata, const struct sockaddr *name, int namel } res = ps2ipc_connect(fd, name, namelen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcListenHelper(void *userdata, int backlog) @@ -156,11 +140,7 @@ int __ps2ipcListenHelper(void *userdata, int backlog) } res = ps2ipc_listen(fd, backlog); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcRecvHelper(void *userdata, void *mem, size_t len, int flags) @@ -175,11 +155,7 @@ int __ps2ipcRecvHelper(void *userdata, void *mem, size_t len, int flags) } res = ps2ipc_recv(fd, mem, len, flags); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcRecvfromHelper(void *userdata, void *mem, size_t len, int flags, struct sockaddr *from, int *fromlen) @@ -194,11 +170,7 @@ int __ps2ipcRecvfromHelper(void *userdata, void *mem, size_t len, int flags, str } res = ps2ipc_recvfrom(fd, mem, len, flags, from, fromlen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcRecvmsgHelper(void *userdata, struct msghdr *msg, int flags) @@ -219,11 +191,7 @@ int __ps2ipcSendHelper(void *userdata, const void *dataptr, size_t len, int flag } res = ps2ipc_send(fd, dataptr, len, flags); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcSendtoHelper(void *userdata, const void *dataptr, size_t len, int flags, const struct sockaddr *to, int tolen) @@ -238,11 +206,7 @@ int __ps2ipcSendtoHelper(void *userdata, const void *dataptr, size_t len, int fl } res = ps2ipc_sendto(fd, dataptr, len, flags, to, tolen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcSendmsgHelper(void *userdata, const struct msghdr *msg, int flags) { @@ -263,11 +227,7 @@ int __ps2ipcIoctlHelper(void *userdata, int cmd, void *argp) } res = ps2ipc_ioctl(fd, cmd, argp); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcGetsocknameHelper(void *userdata, struct sockaddr* name, int* namelen) @@ -282,11 +242,7 @@ int __ps2ipcGetsocknameHelper(void *userdata, struct sockaddr* name, int* namele } res = ps2ipc_getsockname(fd, name, namelen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcGetpeernameHelper(void *userdata, struct sockaddr *name, int *namelen) @@ -301,11 +257,7 @@ int __ps2ipcGetpeernameHelper(void *userdata, struct sockaddr *name, int *namele } res = ps2ipc_getpeername(fd, name, namelen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcGetsockoptHelper(void *userdata, int level, int optname, void* optval, socklen_t* optlen) @@ -320,11 +272,7 @@ int __ps2ipcGetsockoptHelper(void *userdata, int level, int optname, void* optva } res = ps2ipc_getsockopt(fd, level, optname, optval, optlen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } int __ps2ipcSetsockoptHelper(void *userdata, int level, int optname, const void *optval, socklen_t optlen) @@ -339,11 +287,7 @@ int __ps2ipcSetsockoptHelper(void *userdata, int level, int optname, const void } res = ps2ipc_setsockopt(fd, level, optname, optval, optlen); - if (res < 0) - { - return -ENFILE; - } - return res; + return (res < 0) ? -ENFILE : res; } struct hostent *ps2ipc_gethostbyaddr(const void *addr, int len, int type) { diff --git a/ee/sbv/src/smod.c b/ee/sbv/src/smod.c index c7e53ef903fc..bb93d5cc1c01 100644 --- a/ee/sbv/src/smod.c +++ b/ee/sbv/src/smod.c @@ -33,14 +33,9 @@ int smod_get_next_mod(smod_mod_info_t *cur_mod, smod_mod_info_t *next_mod) void *addr; /* If cur_mod is 0, return the head of the list (typically IOP address 0x800). */ - if (!cur_mod) { - addr = (void *)0x800; - } else { - if (!cur_mod->next) - return 0; - else - addr = cur_mod->next; - } + addr = (!cur_mod) ? (void *)0x800 : cur_mod->next; + if (!addr) + return 0; SyncDCache(&smem_buf, smem_buf.bytes+sizeof(smod_mod_info_t)); if(sceSifGetOtherData(&RData, addr, &smem_buf, sizeof(smod_mod_info_t), 0)>=0){ diff --git a/ee/startup/src/crt0.c b/ee/startup/src/crt0.c index cc8430fca8ff..d14c97ee2025 100644 --- a/ee/startup/src/crt0.c +++ b/ee/startup/src/crt0.c @@ -102,9 +102,7 @@ static void _main() _InitSys(); // Use arguments sent through start if sent (by ps2link for instance) - pa = &args; - if (args.argc == 0 && args_start != NULL && args_start->args.argc != 0) - pa = &args_start->args; + pa = (args.argc == 0 && args_start != NULL && args_start->args.argc != 0) ? &args_start->args : &args; // call libcglue argument parsing _libcglue_args_parse(pa->argc, pa->argv); diff --git a/iop/arcade/acata/src/acata-entry.c b/iop/arcade/acata/src/acata-entry.c index 3ef73f78951e..bb4ea9d34fb2 100644 --- a/iop/arcade/acata/src/acata-entry.c +++ b/iop/arcade/acata/src/acata-entry.c @@ -30,11 +30,5 @@ int acAtaEntry(int argc, char **argv) int ret; ret = acAtaModuleStart(argc, argv); - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_acata) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_acata) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/acata/src/ata.c b/iop/arcade/acata/src/ata.c index 7d3105a05638..525014c6cb2e 100644 --- a/iop/arcade/acata/src/ata.c +++ b/iop/arcade/acata/src/ata.c @@ -67,10 +67,8 @@ static void ata_thread(void *arg) CpuResumeIntr(state); if ( atah ) { - tmout = atah->a_tmout; a_ops = atah->a_ops; - if ( !tmout ) - tmout = 5000000; + tmout = ( !atah->a_tmout ) ? 5000000 : atah->a_tmout; atah->a_state = 3; acTimerAdd(&argt->timer, (acTimerDone)ata_timer_done, argt, tmout); v10 = a_ops->ao_command(atah, 32, 78); @@ -116,9 +114,7 @@ int ata_request(struct ac_ata_h *atah, int (*wakeup)(int thid)) acSpl state; CpuSuspendIntr(&state); - unit = 1; - if ( (atah->a_flag & 0x10) != 0 ) - unit = 2; + unit = ( (atah->a_flag & 0x10) != 0 ) ? 2 : 1; thid = Atac.thid; if ( (Atac.active & unit) == 0 ) { @@ -146,10 +142,7 @@ int ata_request(struct ac_ata_h *atah, int (*wakeup)(int thid)) atah->a_chain.q_prev = q_prev; q_prev->q_next = &atah->a_chain; Atac.requestq.q_prev = &atah->a_chain; - if ( wakeup ) - atah->a_state = 3; - else - atah->a_state = 1; + atah->a_state = wakeup ? 3 : 1; } } CpuResumeIntr(state); @@ -215,8 +208,7 @@ int ata_probe(acAtaReg atareg) break; ++count; } - if ( count ) - active |= 1 << unit; + active |= ( count ) ? (1 << unit) : 0; ++unit; count = 0; } @@ -229,9 +221,7 @@ static int ata_module_optarg(const char *str, int default_value) char *next; result = strtol(str, &next, 0); - if ( next == str ) - return default_value; - return result; + return ( next == str ) ? default_value : result; } int acAtaModuleStart(int argc, char **argv) @@ -252,17 +242,10 @@ int acAtaModuleStart(int argc, char **argv) { return -16; } - cmdprio = Atac.cprio; - prio = Atac.prio; - delay = 2000000; - if ( !Atac.cprio ) - cmdprio = 32; + cmdprio = ( !Atac.cprio ) ? 32 : Atac.cprio; index = 1; - if ( !Atac.prio ) - { - delay = 1000000; - prio = 78; - } + delay = ( !Atac.prio ) ? 1000000 : 2000000; + prio = ( !Atac.prio ) ? 78 : Atac.prio; v11 = argv + 1; while ( index < argc ) { @@ -416,13 +399,7 @@ int acAtaModuleStatus() int state; CpuSuspendIntr(&state); - ret = 0; - if ( Atac.thid ) - { - ret = 2; - if ( !Atac.requestq.q_next ) - ret = 1; - } + ret = ( Atac.thid ) ? (( !Atac.requestq.q_next ) ? 1 : 2) : 0; CpuResumeIntr(state); return ret; } diff --git a/iop/arcade/acata/src/atacmd.c b/iop/arcade/acata/src/atacmd.c index 6d743e187a2e..2905bc7edf4e 100644 --- a/iop/arcade/acata/src/atacmd.c +++ b/iop/arcade/acata/src/atacmd.c @@ -33,10 +33,7 @@ static int ata_dma_xfer(acDmaT dma, int intr, acDmaOp op) } thid = dmatmp->ad_thid; dmatmp->ad_state = 3; - if ( intr ) - iWakeupThread(thid); - else - WakeupThread(thid); + (intr ? iWakeupThread : WakeupThread)(thid); return 0; } @@ -64,10 +61,7 @@ static void ata_dma_error(acDmaT dma, int intr, acDmaState state, int result) dmatmp->ad_result = result; if ( thid ) { - if ( intr ) - iWakeupThread(thid); - else - WakeupThread(thid); + (intr ? iWakeupThread : WakeupThread)(thid); } Kprintf("acata:A:dma_error: state=%d ret=%d\n", state, result); } @@ -125,9 +119,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) { printf("acata:A:dma_wait: TIMEDOUT %d\n", ret_v5); acDmaCancel(&dma_data.ad_dma, -116); - ret = ret_v5; - if ( ret_v5 >= 0 ) - ret = -116; + ret = ( ret_v5 >= 0 ) ? -116 : ret_v5; if ( ret < 0 ) { return ret; @@ -193,23 +185,13 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) int sr; int ret_v20; - xlen = 512; - if ( a_size < 513 ) - xlen = a_size; + xlen = ( a_size < 513 ) ? a_size : 512; a_size -= xlen; xlen_v15 = (unsigned int)xlen >> 1; xlen_v16 = xlen_v15 - 1; while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 ) { - int ret_v17; - - ret_v17 = 0; - if ( xlen_v16 >= 0 ) - { - ret_v17 = *a_buf; - a_buf++; - } - *((volatile acUint16 *)0xB6000000) = ret_v17; + *((volatile acUint16 *)0xB6000000) = ( xlen_v16 >= 0 ) ? *a_buf++ : 0; --xlen_v16; } if ( (flag_v8 & 2) != 0 ) @@ -277,13 +259,9 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) } if ( sr_v25 < 0 ) break; - xlen_v27 = 512; - if ( rest < 513 ) - xlen_v27 = rest; + xlen_v27 = ( rest < 513 ) ? rest : 512; rest -= xlen_v27; - xlen_v28 = (unsigned int)xlen_v27 >> 1; - if ( (sr_v25 & 1) != 0 ) - xlen_v28 = 0; + xlen_v28 = ( (sr_v25 & 1) != 0 ) ? 0 : ((unsigned int)xlen_v27 >> 1); (void)(*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY); xlen_v30 = xlen_v28 - 1; while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 ) @@ -323,9 +301,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) *((volatile acUint16 *)0xB6010000)); if ( state < 1023 ) acDmaCancel(&dma_data.ad_dma, -116); - ret = 0; - if ( !v38 ) - ret = -116; + ret = ( !v38 ) ? -116 : 0; break; } state = dma_data.ad_state; @@ -336,9 +312,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) } if ( SleepThread() ) { - state = 511; - if ( dma_data.ad_state == 31 ) - state = 1023; + state = ( dma_data.ad_state == 31 ) ? 1023 : 511; } } } @@ -383,14 +357,10 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) sr_v34 = *((volatile acUint16 *)0xB6070000); if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) != 0 ) return -((sr_v34 << 8) + *((volatile acUint16 *)0xB6010000)); + ret_v35 = ( atah->a_state < 0x1FFu ) ? 0 : -116; if ( atah->a_state < 0x1FFu ) { atah->a_state = 127; - ret_v35 = 0; - } - else - { - ret_v35 = -116; } cmd_v36 = ata->ac_command; if ( ret_v35 < 0 ) @@ -436,9 +406,7 @@ acAtaT acAtaSetup(acAtaData *ata, acAtaDone done, void *arg, unsigned int tmout) acAtaCommandData *acAtaReply(acAtaT ata) { - if ( ata == 0 ) - return 0; - return ata->ac_command; + return ( ata == 0 ) ? 0 : ata->ac_command; } int acAtaRequest(acAtaT ata, int flag, acAtaCommandData *cmd, int item, void *buf, int size) @@ -510,11 +478,5 @@ int acAtaStatus(acAtaT ata) return -22; } state = ata->ac_h.a_state; - if ( (unsigned int)(state - 1) >= 0x7E ) - { - return 0; - } - if ( state != 1 ) - return 2; - return 1; + return ( (unsigned int)(state - 1) >= 0x7E ) ? 0 : (( state != 1 ) ? 2 : 1); } diff --git a/iop/arcade/acata/src/atapicmd.c b/iop/arcade/acata/src/atapicmd.c index 7fefe2c3e331..be967336b9fb 100644 --- a/iop/arcade/acata/src/atapicmd.c +++ b/iop/arcade/acata/src/atapicmd.c @@ -35,10 +35,7 @@ static int atapi_dma_xfer(acDmaT dma, int intr, acDmaOp op) } thid = dmatmp->ad_thid; dmatmp->ad_state = 3; - if ( intr ) - iWakeupThread(thid); - else - WakeupThread(thid); + (intr ? iWakeupThread : WakeupThread)(thid); return 0; } @@ -65,10 +62,7 @@ static void atapi_dma_error(acDmaT dma, int intr, acDmaState state, int result) dmatmp->ad_result = result; if ( thid ) { - if ( intr ) - iWakeupThread(thid); - else - WakeupThread(thid); + (intr ? iWakeupThread : WakeupThread)(thid); } Kprintf("acata:P:dma_error: state=%d ret=%d\n", state, result); } @@ -164,11 +158,8 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag) if ( (sr_v5 & 8) == 0 ) break; xlen_v6 = (*((volatile acUint16 *)0xB6050000) << 8) + *((volatile acUint16 *)0xB6040000); - drop = xlen_v6 - rest; - if ( rest >= xlen_v6 ) - drop = 0; - else - xlen_v6 = rest; + drop = ( rest >= xlen_v6 ) ? 0 : (xlen_v6 - rest); + xlen_v6 = ( rest < xlen_v6 ) ? rest : xlen_v6; rest -= xlen_v6; xlen_v8 = (xlen_v6 + 1) / 2 - 1; while ( xlen_v8 >= 0 ) @@ -261,14 +252,10 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) if ( ret_v5 >= 0 ) { int v12; + v12 = ( atah->a_state < 0x1FFu ) ? 0 : -116; if ( atah->a_state < 0x1FFu ) { atah->a_state = 31; - v12 = 0; - } - else - { - v12 = -116; } ret_v5 = -116; if ( v12 >= 0 ) @@ -343,11 +330,8 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) break; } xlen_v15 = (*((volatile acUint16 *)0xB6050000) << 8) + *((volatile acUint16 *)0xB6040000); - drop = xlen_v15 - a_size; - if ( a_size >= xlen_v15 ) - drop = 0; - else - xlen_v15 = a_size; + drop = ( a_size >= xlen_v15 ) ? 0 : (xlen_v15 - a_size); + xlen_v15 = ( a_size < xlen_v15 ) ? a_size : xlen_v15; a_size -= xlen_v15; xlen_v17 = (xlen_v15 + 1) / 2 - 1; for ( sr_v18 = drop + 1; xlen_v17 >= 0; sr_v18 = drop + 1 ) @@ -372,14 +356,10 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) ChangeThreadPriority(0, pri); if ( ret_v5 < 0 ) return ret_v5; + v28 = ( atah->a_state < 0x1FFu ) ? 0 : -116;; if ( atah->a_state < 0x1FFu ) { atah->a_state = 63; - v28 = 0; - } - else - { - v28 = -116; } if ( v28 < 0 ) return -116; @@ -440,9 +420,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) *((volatile acUint16 *)0xB6010000)); if ( ret_v23 < 1023 ) acDmaCancel(&dma_data.ad_dma, -116); - ad_result = 0; - if ( !v30 ) - ad_result = -116; + ad_result = ( !v30 ) ? -116 : 0; break; } ret_v23 = dma_data.ad_state; @@ -453,9 +431,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) } if ( SleepThread() ) { - ret_v23 = 511; - if ( dma_data.ad_state == 31 ) - ret_v23 = 1023; + ret_v23 = ( dma_data.ad_state == 31 ) ? 1023 : 511; } } ret_v5 = ad_result; @@ -563,9 +539,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) printf("acata:C:io_done: TIMEDOUT\n"); v6 = -116; } - v3 = v5; - if ( v6 < 0 ) - v3 = -116; + v3 = ( v6 < 0 ) ? -116 : v5; ret = v3; } else @@ -578,11 +552,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) } } } - if ( ret > 0 ) - return -((sense.s_key << 16) | (sense.s_asc << 8) | sense.s_ascq); - if ( !ret ) - return -5; - return ret; + return ( ret > 0 ) ? (-((sense.s_key << 16) | (sense.s_asc << 8) | sense.s_ascq)) : (( !ret ) ? -5 : ret); } acAtapiT acAtapiSetup(acAtapiData *atapi, acAtapiDone done, void *arg, unsigned int tmout) @@ -640,11 +610,5 @@ int acAtapiStatus(acAtapiT atapi) return -22; } state = atapi->ap_h.a_state; - if ( (unsigned int)(state - 1) >= 0x7E ) - { - return 0; - } - if ( state != 1 ) - return 2; - return 1; + return ( (unsigned int)(state - 1) >= 0x7E ) ? 0 : (( state != 1 ) ? 2 : 1); } diff --git a/iop/arcade/acatad/src/acatad.c b/iop/arcade/acatad/src/acatad.c index 5b92c107cefd..fe462e07c4f7 100644 --- a/iop/arcade/acatad/src/acatad.c +++ b/iop/arcade/acatad/src/acatad.c @@ -266,10 +266,7 @@ int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir) { int err; - if ( dir == 1 ) - err = do_dma_xfer_write(device, lba, buf, nsectors); - else - err = do_dma_xfer_read(device, lba, buf, nsectors); + err = (( dir == 1 ) ? do_dma_xfer_write : do_dma_xfer_read)(device, lba, buf, nsectors); if ( err != 1 ) { printf("dma error\n"); diff --git a/iop/arcade/accdvd/src/accdvdi-entry.c b/iop/arcade/accdvd/src/accdvdi-entry.c index e053df19fb22..254df52e03c3 100644 --- a/iop/arcade/accdvd/src/accdvdi-entry.c +++ b/iop/arcade/accdvd/src/accdvdi-entry.c @@ -131,9 +131,5 @@ int acCdvdEntry(int argc, char **argv) ret = acCdvdModuleStart(argc, argv); DelayThread(1000); - if ( ret < 0 ) - return ret; - if ( RegisterLibraryEntries(&_exp_accdvd) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_accdvd) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/accdvd/src/acd.c b/iop/arcade/accdvd/src/acd.c index 44972e83a36f..0a43bc81a498 100644 --- a/iop/arcade/accdvd/src/acd.c +++ b/iop/arcade/accdvd/src/acd.c @@ -25,9 +25,7 @@ static void acd_done(struct acd *acd, struct acd_softc *arg, int ret) tmout = arg->active; arg->sense = ret; tmout--; - arg->active = tmout; - if ( tmout < 0 ) - arg->active = 0; + arg->active = ( tmout < 0 ) ? 0 : tmout; CpuResumeIntr(state); thid = acd->c_thid; tmout_v2 = acd->c_tmout; @@ -66,15 +64,11 @@ acd_request_in(struct acd *acd, int flag, acAtapiPacketT packet, void *buffer, i if ( (Acdc.status & 1) == 0 ) return -6; ret = acd->c_tmout; + acd->c_thid = ( ret <= 0 ) ? 0 : GetThreadId(); if ( ret <= 0 ) { - acd->c_thid = 0; ret = -ret; } - else - { - acd->c_thid = GetThreadId(); - } acAtapiSetup(&acd->c_atapi, done ? done : acd_atapi_done, &Acdc, ret); CpuSuspendIntr(&state); ret_v10 = Acdc.drive; @@ -163,9 +157,7 @@ int acd_read(struct acd *acd, acd_lsn_t lsn, void *buf, int sectors) return 0; } memset(&u, 0, sizeof(u)); - flag = 2; - if ( Acdc.dma ) - flag = 3; + flag = ( Acdc.dma ) ? 3 : 2; u.opcode = 40; u.lun = 0; u.lba[0] = (lsn & 0xFF000000) >> 24; @@ -271,9 +263,7 @@ int acd_ioctl(struct acd *acd, int cmd) u.op = cmd & 3; if ( (cmd & 2) != 0 ) { - done = (acAtapiDone)acd_opentray_done; - if ( (cmd & 1) != 0 ) - done = (acAtapiDone)acd_closetray_done; + done = ( (cmd & 1) != 0 ) ? (acAtapiDone)acd_closetray_done : (acAtapiDone)acd_opentray_done; } name = "ioctl:startstop"; } @@ -323,10 +313,7 @@ static void acd_getmedium_done(acAtapiT atapi, struct acd_softc *arg, int ret) h_mtype = arg->retry.me_h.h_mtype; status = arg->status | 6; arg->medium = h_mtype; - if ( h_mtype == 113 ) - v7 = status ^ 4; - else - v7 = status ^ 2; + v7 = status ^ (( h_mtype == 113 ) ? 4 : 2); arg->status = v7 | 0xA00; CpuResumeIntr(state); } @@ -341,9 +328,7 @@ int acd_getmedium(struct acd *acd) if ( acd ) return acd_mode_sense(acd, 1, &Acdc.retry, 20, (acAtapiDone)acd_getmedium_done, "getmedium"); CpuSuspendIntr(&state); - ret = -61; - if ( (Acdc.status & 0x800) != 0 ) - ret = Acdc.medium; + ret = ( (Acdc.status & 0x800) != 0 ) ? Acdc.medium : -61; CpuResumeIntr(state); return ret; } @@ -364,10 +349,7 @@ static void acd_retry_done(acAtapiT atapi, struct acd_softc *arg, int ret) h_mtype = arg->retry.me_h.h_mtype; status = arg->status | 6; arg->medium = h_mtype; - if ( h_mtype == 113 ) - v8 = status ^ 4; - else - v8 = status ^ 2; + v8 = status ^ (( h_mtype == 113 ) ? 4 : 2); arg->status = v8 | 0xA00; me_rretry = arg->retry.me_rretry; CpuResumeIntr(state); @@ -377,9 +359,7 @@ static void acd_retry_done(acAtapiT atapi, struct acd_softc *arg, int ret) int acd_getretry(struct acd *acd) { - if ( !acd ) - return -22; - return acd_mode_sense(acd, 1, &Acdc.retry, 20, (acAtapiDone)acd_retry_done, "getretry"); + return ( !acd ) ? -22 : acd_mode_sense(acd, 1, &Acdc.retry, 20, (acAtapiDone)acd_retry_done, "getretry"); } int acd_setretry(struct acd *acd, int rretry) @@ -403,9 +383,7 @@ int acd_setretry(struct acd *acd, int rretry) size = (Acdc.retry.me_h.h_len[0] << 8) + Acdc.retry.me_h.h_len[1] + 2; } CpuResumeIntr(state); - if ( !size ) - return rretry; - return acd_mode_select(acd, &Acdc.retry, size, (acAtapiDone)acd_retry_done, "setretry"); + return ( !size ) ? rretry : acd_mode_select(acd, &Acdc.retry, size, (acAtapiDone)acd_retry_done, "setretry"); } static void acd_getspeed_done(acAtapiT atapi, struct acd_softc *arg, int ret) @@ -425,10 +403,7 @@ static void acd_getspeed_done(acAtapiT atapi, struct acd_softc *arg, int ret) v4 = (arg->speed.mc_speed[0] << 8) + arg->speed.mc_speed[1]; status = arg->status | 6; arg->medium = speed; - if ( speed == 113 ) - v8 = status ^ 4; - else - v8 = status ^ 2; + v8 = status ^ (( speed == 113 ) ? 4 : 2); arg->status = v8 | 0xC00; CpuResumeIntr(state); } @@ -452,10 +427,7 @@ static void acd_getmaxspeed_done(acAtapiT atapi, struct acd_softc *arg, int ret) v4 = (arg->speed.mc_maxspeed[0] << 8) + arg->speed.mc_maxspeed[1]; status = arg->status | 6; arg->medium = speed; - if ( speed == 113 ) - v8 = status ^ 4; - else - v8 = status ^ 2; + v8 = status ^ (( speed == 113 ) ? 4 : 2); arg->status = v8 | 0xC00; CpuResumeIntr(state); } @@ -470,9 +442,7 @@ int acd_getspeed(struct acd *acd, int maxspeed) { return -22; } - done = (acAtapiDone)acd_getspeed_done; - if ( maxspeed ) - done = (acAtapiDone)acd_getmaxspeed_done; + done = ( maxspeed ) ? (acAtapiDone)acd_getmaxspeed_done : (acAtapiDone)acd_getspeed_done; return acd_mode_sense(acd, 42, &Acdc.speed, 28, done, "getspeed"); } @@ -498,10 +468,7 @@ int acd_setspeed(struct acd *acd, int speed) if ( speed < 0 ) return -22; CpuSuspendIntr(&state); - if ( (Acdc.status & 0x400) != 0 ) - ospeed = (Acdc.speed.mc_speed[0] << 8) + Acdc.speed.mc_speed[1]; - else - ospeed = -1; + ospeed = ( (Acdc.status & 0x400) != 0 ) ? ((Acdc.speed.mc_speed[0] << 8) + Acdc.speed.mc_speed[1]) : -1; CpuResumeIntr(state); if ( v3 > 0xFFFF ) v3 = 0xFFFF; @@ -531,10 +498,7 @@ static void acd_timer_done(acAtapiT atapi, struct acd_softc *arg, int ret) h_mtype = arg->timer.md_h.h_mtype; status = arg->status | 6; arg->medium = h_mtype; - if ( h_mtype == 113 ) - status_v3 = status ^ 4; - else - status_v3 = status ^ 2; + status_v3 = status ^ (( h_mtype == 113 ) ? 4 : 2); arg->status = status_v3 | 0x900; v4 = arg->timer.md_timer & 0xF; CpuResumeIntr(state); @@ -544,9 +508,7 @@ static void acd_timer_done(acAtapiT atapi, struct acd_softc *arg, int ret) int acd_gettimer(struct acd *acd) { - if ( !acd ) - return -22; - return acd_mode_sense(acd, 13, &Acdc.timer, 16, (acAtapiDone)acd_timer_done, "gettimer"); + return ( !acd ) ? -22 : acd_mode_sense(acd, 13, &Acdc.timer, 16, (acAtapiDone)acd_timer_done, "gettimer"); } int acd_settimer(struct acd *acd, int time) @@ -621,9 +583,7 @@ int acd_delay() GetSystemTime(&t); SysClock2USec(&t, &s, &us); - if ( s >= 0xD ) - return 0; - return 1000000 * (13 - s) - us; + return ( s >= 0xD ) ? 0 : (1000000 * (13 - s) - us); } int acd_getsense() @@ -633,11 +593,7 @@ int acd_getsense() acCdvdsifId acd_gettray() { - if ( (Acdc.status & 8) != 0 ) - return 3; - if ( (Acdc.status & 2) != 0 ) - return 1; - return (Acdc.status >> 1) & 2; + return ( (Acdc.status & 8) != 0 ) ? 3 : (( (Acdc.status & 2) != 0 ) ? 1 : ((Acdc.status >> 1) & 2)); } struct acd *acd_setup(struct acd *acd, acd_done_t done, void *arg, int tmout) @@ -647,9 +603,7 @@ struct acd *acd_setup(struct acd *acd, acd_done_t done, void *arg, int tmout) acd->c_done = done; acd->c_arg = arg; acd->c_thid = 0; - acd->c_tmout = tmout; - if ( !tmout ) - acd->c_tmout = 5000000; + acd->c_tmout = ( !tmout ) ? 5000000 : tmout; } return acd; } @@ -845,13 +799,7 @@ static int acd_identify(int drive) SleepThread(); ret = acdata.a_result; } - if ( ret < 0 ) - { - return ret; - } - if ( (ident[0] & 0xFF00) != 0x8500 ) - return -6; - return ((ident[62] & 0xFF) << 8) | ((ident[63] & 0xFF) << 16) | ((ident[88] & 0xFF) << 24); + return ( ret < 0 ) ? ret : (( (ident[0] & 0xFF00) != 0x8500 ) ? -6 : (((ident[62] & 0xFF) << 8) | ((ident[63] & 0xFF) << 16) | ((ident[88] & 0xFF) << 24))); } static int acd_softreset(int drive) @@ -867,13 +815,7 @@ int acd_module_status() int state; CpuSuspendIntr(&state); - ret = 0; - if ( (Acdc.status & 1) != 0 ) - { - ret = 1; - if ( Acdc.active > 0 ) - ret = 2; - } + ret = ( (Acdc.status & 1) != 0 ) ? (( Acdc.active > 0 ) ? 2 : 1) : 0; CpuResumeIntr(state); return ret; } @@ -903,10 +845,7 @@ int acd_module_start(int argc, char **argv) if ( drive >= 2 ) return ret; } - if ( drive ) - Acdc.drive = 16; - else - Acdc.drive = 0; + Acdc.drive = drive ? 16 : 0; Acdc.status = 1; Acdc.medium = -1; Acdc.dmamap = ret_v2; diff --git a/iop/arcade/accdvd/src/cdc.c b/iop/arcade/accdvd/src/cdc.c index 64be8aade48e..c5f8e93ada71 100644 --- a/iop/arcade/accdvd/src/cdc.c +++ b/iop/arcade/accdvd/src/cdc.c @@ -32,9 +32,7 @@ static int cdc_errno_set(struct cdc_softc *cdcc, int ret) int asc; asc = ret & 0xFFFF; - ret = 48; - if ( asc == 8448 ) - ret = 50; + ret = ( asc == 8448 ) ? 50 : 48; } } else @@ -107,9 +105,7 @@ static int cdc_unlock(struct cdc_softc *cdcc, int ret, acCdvdsifId fno) int v6; int eveid; - v6 = 0; - if ( ret < 0 ) - v6 = -ret; + v6 = ( ret < 0 ) ? -ret : 0; cdc_errno_set(cdcc, v6); eveid = cdcc->syncid; cdcc->stat = 0; @@ -148,9 +144,7 @@ static void cdc_done(struct acd *acd, struct cdc_softc *arg, int ret) int eveid; (void)acd; - v3 = 0; - if ( ret < 0 ) - v3 = -ret; + v3 = ( ret < 0 ) ? -ret : 0; cdc_errno_set(arg, v3); done = arg->done; arg->done = 0; @@ -200,9 +194,7 @@ int cdc_sync(int nonblocking) { return 1; } - bits = 1; - if ( nonblocking < 0 ) - bits = 3; + bits = ( nonblocking < 0 ) ? 3 : 1; if ( Cdcc.syncid > 0 ) WaitEventFlag(Cdcc.syncid, bits, 1, &bits); return ((bits & 0xFF) ^ 1) & 1; @@ -229,8 +221,7 @@ int cdc_ready(int nonblocking) if ( ret >= 0 ) { v4 = acd_readcapacity(); - if ( v4 < 0 ) - v4 = 0; + v4 = ( v4 < 0 ) ? 0 : v4; Cdcc.cdsize = v4; ret = 2; } @@ -254,9 +245,7 @@ int cdc_ready(int nonblocking) } else { - delay = 0; - if ( asc == 10496 ) - delay = acd_delay(); + delay = ( asc == 10496 ) ? acd_delay() : 0; } } else @@ -294,9 +283,7 @@ int cdc_medium() v0 = acd_setup(&acd_data, 0, 0, 5000000); v1 = acd_getmedium(v0); ret = v1; - v3 = 0; - if ( v1 < 0 ) - v3 = -v1; + v3 = ( v1 < 0 ) ? -v1 : 0; cdc_errno_set(&Cdcc, v3); switch ( ret ) { @@ -350,30 +337,19 @@ int cdc_stat() return Cdcc.stat; } v2 = acd_getstatus(); - if ( v2 < 0 ) - return 32; - return (v2 != 0) ? 2 : 0; + return ( v2 < 0 ) ? 32 : ((v2 != 0) ? 2 : 0); } int cdc_readtoc(unsigned char *toc, cdc_xfer_t xfer) { - acInt32 ret; + acInt32 err; int v7; int ret_v3; - if ( Cdcc.lockid ) - { - ret = 0; - if ( WaitSema(Cdcc.lockid) ) - ret = 19; - } - else + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - ret = 17; - } - if ( ret ) - { - Cdcc.error = ret; + Cdcc.error = err; return 0; } v7 = -16; @@ -401,24 +377,15 @@ int cdc_readtoc(unsigned char *toc, cdc_xfer_t xfer) int cdc_lookup(sceCdlFILE *fp, const char *name, int namlen, cdc_xfer_t xfer) { - acInt32 ret; + acInt32 err; int ret_v2; int ret_v3; struct cdfs_dirent dirent; - if ( Cdcc.lockid ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - ret = 0; - if ( WaitSema(Cdcc.lockid) ) - ret = 19; - } - else - { - ret = 17; - } - if ( ret ) - { - Cdcc.error = ret; + Cdcc.error = err; return 0; } ret_v2 = -16; @@ -468,12 +435,8 @@ int cdc_lookup(sceCdlFILE *fp, const char *name, int namlen, cdc_xfer_t xfer) fp->name[d_namlen + 1] = (dirent.d_vol & 0xFF) + 48; fp->name[d_namlen + 2] = 0; memcpy(fp->name, dirent.d_name, d_namlen); - ret_v3 = 0; - } - else - { - ret_v3 = cdfs_recover(ret_v4); } + ret_v3 = ( ret_v4 >= 0 ) ? 0 : cdfs_recover(ret_v4); } } return cdc_unlock(&Cdcc, ret_v3, AC_CDVDSIF_ID_LOOKUP); @@ -482,24 +445,15 @@ int cdc_lookup(sceCdlFILE *fp, const char *name, int namlen, cdc_xfer_t xfer) int cdc_seek(unsigned int lsn, cdc_done_t done) { acCdvdsifId fno; - acInt32 v5; + acInt32 err; int v8; int ret_v4; fno = AC_CDVDSIF_ID_SEEK; - if ( Cdcc.lockid ) - { - v5 = 0; - if ( WaitSema(Cdcc.lockid) ) - v5 = 19; - } - else - { - v5 = 17; - } - if ( v5 ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - Cdcc.error = v5; + Cdcc.error = err; return 0; } v8 = -16; @@ -532,49 +486,18 @@ int cdc_seek(unsigned int lsn, cdc_done_t done) static int cdc_ioctl(acCdvdsifId fno, int state, int tmout, cdc_done_t done) { - acInt32 ret; + acInt32 err; int ret_v2; acCdvdsifId v12; int ret_v4; - if ( Cdcc.lockid ) - { - ret = 0; - if ( WaitSema(Cdcc.lockid) ) - ret = 19; - } - else + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - ret = 17; - } - if ( ret ) - { - Cdcc.error = ret; + Cdcc.error = err; return 0; } - if ( state == 4 ) - { - ret_v2 = 0; - } - else if ( state >= 5 ) - { - if ( state == 6 ) - { - ret_v2 = 1; - } - else - { - ret_v2 = 10; - if ( state == 16 ) - ret_v2 = 18; - } - } - else - { - ret_v2 = 10; - if ( state == 1 ) - ret_v2 = 2; - } + ret_v2 = ( state == 4 ) ? 0 : (( state >= 5 ) ? (( state == 6 ) ? 1 : (( state == 16 ) ? 18 : 10)) : (( state == 1 ) ? 2 : 10)); if ( fno ) { v12 = -16; @@ -644,9 +567,7 @@ int cdc_tray(int mode, u32 *traycnt) { int ret; - ret = 134; - if ( mode ) - ret = 131; + ret = ( mode ) ? 131 : 134; v5 = cdc_ioctl(AC_CDVDSIF_ID_TRAY, ret, 5000000, 0); } v8 = acd_gettray(); @@ -657,31 +578,21 @@ int cdc_tray(int mode, u32 *traycnt) int cdc_getpos() { - acInt32 v0; + acInt32 err; int ret; - v0 = 17; - if ( Cdcc.lockid ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - v0 = 0; - if ( WaitSema(Cdcc.lockid) ) - v0 = 19; - } - if ( v0 ) - { - Cdcc.error = v0; + Cdcc.error = err; return 0; } if ( Cdcc.fno ) { - if ( Cdcc.fno == AC_CDVDSIF_ID_READ ) - { - ret = Cdcc.rd.pos << 11; - } - else + ret = ( Cdcc.fno == AC_CDVDSIF_ID_READ ) ? (Cdcc.rd.pos << 11) : 0; + if ( Cdcc.fno != AC_CDVDSIF_ID_READ ) { Cdcc.error = 19; - ret = 0; } } else @@ -723,17 +634,14 @@ static int cdc_rmode(struct cdc_softc *cdcc, const sceCdRMode *mode) int v9; v9 = 3 * (speed - 1); - speed = v9 >> 2; - if ( v9 < 0 ) - speed = (v9 + 3) >> 2; + speed = ( v9 < 0 ) ? ((v9 + 3) >> 2) : (v9 >> 2); } if ( acd_setspeed(acd, speed) >= 0 ) cdcc->rd.spindle = spindlctrl; } - trycount = mode->trycount - 1; acd_v7 = acd_setup(&cdcc->acd, 0, 0, 5000000); - if ( trycount < 0 ) - trycount = 254; + trycount = mode->trycount - 1; + trycount = ( trycount < 0 ) ? 254 : trycount; while ( acd_setretry(acd_v7, trycount) == -61 && acd_getretry(acd_v7) >= 0 ) ; return 0; @@ -758,17 +666,11 @@ static void cdc_read_done(struct acd *acd, struct cdc_softc *arg, int ret) cpos = arg->rd.pos; size = arg->rd.size; xfer = arg->rd.xfer; - npos = cpos + ret; - xlen = size - cpos; buf = &arg->rd.buf[2048 * cpos]; bsize = arg->rd.bsize; - rlen = size - (cpos + ret); - if ( size < cpos + ret ) - npos = arg->rd.size; - if ( bsize < rlen ) - rlen = arg->rd.bsize; - if ( bsize < xlen ) - xlen = arg->rd.bsize; + npos = ( size < (cpos + ret) ) ? size : (cpos + ret); + rlen = ( bsize < (size - (cpos + ret)) ) ? bsize : (size - (cpos + ret)); + xlen = ( bsize < (size - cpos) ) ? bsize : (size - cpos); arg->rd.pos = npos; if ( xfer ) { @@ -825,25 +727,16 @@ static void cdc_read_done(struct acd *acd, struct cdc_softc *arg, int ret) int cdc_read(unsigned int lsn, void *buf, int sectors, const sceCdRMode *mode, cdc_xfer_t xfer, cdc_done_t done) { acCdvdsifId fno; - acInt32 v11; + acInt32 err; int v14; int ret_v4; unsigned int n; fno = AC_CDVDSIF_ID_READ; - if ( Cdcc.lockid ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - v11 = 0; - if ( WaitSema(Cdcc.lockid) ) - v11 = 19; - } - else - { - v11 = 17; - } - if ( v11 ) - { - Cdcc.error = v11; + Cdcc.error = err; return 0; } v14 = -16; @@ -861,15 +754,13 @@ int cdc_read(unsigned int lsn, void *buf, int sectors, const sceCdRMode *mode, c fno = AC_CDVDSIF_ID_NOP; return cdc_unlock(&Cdcc, ret_v4, fno); } - n = 16; if ( lsn >= Cdcc.cdsize ) { ret_v4 = -34; } else { - if ( lsn + sectors >= Cdcc.cdsize ) - sectors = Cdcc.cdsize - lsn; + sectors = ( lsn + sectors >= Cdcc.cdsize ) ? (Cdcc.cdsize - lsn) : sectors; Cdcc.rd.buf = (acUint8 *)buf; Cdcc.done = done; Cdcc.rd.size = sectors; @@ -878,10 +769,8 @@ int cdc_read(unsigned int lsn, void *buf, int sectors, const sceCdRMode *mode, c Cdcc.rd.xfer = xfer; Cdcc.rd.pos = 0; Cdcc.rd.bank = 0; - if ( xfer ) - buf = Cdcc.buf; - if ( (unsigned int)sectors < 0x10 ) - n = sectors; + buf = xfer ? Cdcc.buf : Cdcc.rd.buf; + n = ( (unsigned int)sectors < 0x10 ) ? sectors : 16; ret_v4 = cdc_rmode(&Cdcc, mode); // cppcheck-suppress knownConditionTrueFalse if ( ret_v4 < 0 ) @@ -961,9 +850,7 @@ static void cdc_stream_done(struct acd *acd, struct cdc_softc *arg, int ret) size = arg->st.size; bsize = arg->st.bsize; cdsize = arg->cdsize; - head = arg->st.head + v4; - if ( head >= size ) - head = 0; + head = ( (arg->st.head + v4) >= size ) ? 0 : (arg->st.head + v4); lsn = arg->st.lsn + v4; if ( (flag & 0x10) != 0 ) { @@ -980,34 +867,13 @@ static void cdc_stream_done(struct acd *acd, struct cdc_softc *arg, int ret) flag = (flag | 6) ^ 2; } } - xlen = tail - head; - if ( head >= tail ) - xlen = size - head; + xlen = ( head >= tail ) ? (size - head) : (tail - head); + xlen = ( bsize < xlen ) ? bsize : xlen; v15 = lsn + xlen; - if ( bsize < xlen ) - { - xlen = bsize; - v15 = lsn + bsize; - } - if ( v15 >= cdsize ) - xlen = cdsize - lsn; + xlen = ( v15 >= cdsize ) ? (cdsize - lsn) : xlen; buf = &arg->st.buf[2048 * head]; size_v12 = flag & 0x28; - if ( size_v12 == 32 ) - { - arg->st.flag = flag & 0xFFFFFFFD; - } - else - { - if ( ((flag & 0x28) >= 0x21) ? (size_v12 != 40) : (size_v12 != 8) ) - { - arg->st.flag = flag; - } - else - { - arg->st.flag = flag & 4; - } - } + arg->st.flag = ( size_v12 == 32 ) ? (flag & 0xFFFFFFFD) : (( ((flag & 0x28) >= 0x21) ? (size_v12 != 40) : (size_v12 != 8) ) ? flag : (flag & 4)); arg->st.head = head; arg->st.lsn = lsn; CpuResumeIntr(state); @@ -1088,15 +954,11 @@ static int cdc_stream(struct cdc_softc *cdcc) CpuSuspendIntr(&state); head = cdcc->st.head; tail = cdcc->st.tail; - xlen = tail - head; - if ( head >= tail ) - xlen = cdcc->st.size - head; flag = cdcc->st.flag; - if ( cdcc->st.bsize < xlen ) - xlen = cdcc->st.bsize; + xlen = ( head >= tail ) ? (cdcc->st.size - head) : (tail - head); + xlen = ( cdcc->st.bsize < xlen ) ? cdcc->st.bsize : xlen; + xlen = ( (flag & 6) != 0 || (flag & 0x28) != 0 || (flag & 1) == 0 ) ? 0 : xlen; buf = &cdcc->st.buf[2048 * head]; - if ( (flag & 6) != 0 || (flag & 0x28) != 0 || (flag & 1) == 0 ) - xlen = 0; lsn = 0; if ( xlen ) { @@ -1142,7 +1004,6 @@ static int cdc_stream(struct cdc_softc *cdcc) int cdc_reads(void *buf, int sectors, int mode, int *errp, cdc_xfer_t xfer) { int v5; - int v7; unsigned char *v11; acInt32 rlen; int ret_v8; @@ -1170,21 +1031,14 @@ int cdc_reads(void *buf, int sectors, int mode, int *errp, cdc_xfer_t xfer) resbits = (u32 *)&v33; while ( v5 > 0 ) { - acInt32 v6; + acInt32 err; acInt32 ret; int len; - v6 = 17; - if ( Cdcc.lockid ) - { - v7 = WaitSema(Cdcc.lockid); - v6 = 0; - if ( v7 ) - v6 = 19; - } - if ( v6 ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - Cdcc.error = v6; + Cdcc.error = err; break; } ret = 27; @@ -1220,9 +1074,7 @@ int cdc_reads(void *buf, int sectors, int mode, int *errp, cdc_xfer_t xfer) } if ( ((ret_v8 & 4) == 0) && (head == rlen) ) { - v17 = 0; - if ( rlen_v10 ) - v17 = -34; + v17 = ( rlen_v10 ) ? -34 : 0; ret = v17; } else @@ -1233,10 +1085,8 @@ int cdc_reads(void *buf, int sectors, int mode, int *errp, cdc_xfer_t xfer) rlen_v13 = 0; if ( rlen >= head ) { - xlen = Cdcc.st.size - rlen; tmp = v11; - if ( v5 < Cdcc.st.size - rlen ) - xlen = v5; + xlen = ( v5 < Cdcc.st.size - rlen ) ? v5 : (Cdcc.st.size - rlen); len = v5 - xlen; v11 += 2048 * xlen; rlen_v13 = xlen; @@ -1247,9 +1097,7 @@ int cdc_reads(void *buf, int sectors, int mode, int *errp, cdc_xfer_t xfer) if ( v21 >= 0 ) { CpuSuspendIntr(&state_2); - ret_v17 = rlen + rlen_v13; - if ( rlen + rlen_v13 >= Cdcc.st.size ) - ret_v17 = 0; + ret_v17 = ( rlen + rlen_v13 >= Cdcc.st.size ) ? 0 : (rlen + rlen_v13); Cdcc.st.tail = ret_v17; Cdcc.st.flag &= ~4u; CpuResumeIntr(state_2); @@ -1337,24 +1185,15 @@ int cdc_reads(void *buf, int sectors, int mode, int *errp, cdc_xfer_t xfer) int cdc_starts(unsigned int lsn, const sceCdRMode *mode) { - acInt32 v4; + acInt32 err; int v7; int ret; acSpl state; - if ( Cdcc.lockid ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - v4 = 0; - if ( WaitSema(Cdcc.lockid) ) - v4 = 19; - } - else - { - v4 = 17; - } - if ( v4 ) - { - Cdcc.error = v4; + Cdcc.error = err; return 0; } v7 = 27; @@ -1405,7 +1244,7 @@ int cdc_starts(unsigned int lsn, const sceCdRMode *mode) int cdc_stops() { - acInt32 v0; + acInt32 err; int sync; int ret; int sync_v5; @@ -1413,16 +1252,10 @@ int cdc_stops() int state; u32 pattern; - v0 = 17; - if ( Cdcc.lockid ) - { - v0 = 0; - if ( WaitSema(Cdcc.lockid) ) - v0 = 19; - } - if ( v0 ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - Cdcc.error = v0; + Cdcc.error = err; return 0; } sync = 27; @@ -1463,7 +1296,7 @@ int cdc_stops() int cdc_pauses() { - acInt32 v0; + acInt32 err; int sync; int ret; int sync_v5; @@ -1471,16 +1304,10 @@ int cdc_pauses() int state; u32 pattern; - v0 = 17; - if ( Cdcc.lockid ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - v0 = 0; - if ( WaitSema(Cdcc.lockid) ) - v0 = 19; - } - if ( v0 ) - { - Cdcc.error = v0; + Cdcc.error = err; return 0; } sync = 27; @@ -1523,21 +1350,15 @@ int cdc_pauses() int cdc_resumes() { - acInt32 v0; + acInt32 err; int ret_v2; int ret_v3; acSpl state; - v0 = 17; - if ( Cdcc.lockid ) - { - v0 = 0; - if ( WaitSema(Cdcc.lockid) ) - v0 = 19; - } - if ( v0 ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - Cdcc.error = v0; + Cdcc.error = err; return 0; } ret_v2 = 27; @@ -1573,32 +1394,21 @@ int cdc_resumes() if ( (Cdcc.st.flag & 2) == 0 && (Cdcc.st.flag & 0x20) != 0 ) Cdcc.st.flag ^= 0x20u; CpuResumeIntr(state); - ret_v3 = 0; - if ( (flag & 0x20) != 0 ) - ret_v3 = cdc_stream(&Cdcc); + ret_v3 = ( (flag & 0x20) != 0 ) ? cdc_stream(&Cdcc) : 0; } return cdc_unlocks(&Cdcc, ret_v3, AC_CDVDSIF_ID_RESUMES); } int cdc_inits(void *buf, unsigned int size, unsigned int bsize) { - acInt32 ret; + acInt32 err; int v9; int ret_v3; - if ( Cdcc.lockid ) - { - ret = 0; - if ( WaitSema(Cdcc.lockid) ) - ret = 19; - } - else - { - ret = 17; - } - if ( ret ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - Cdcc.error = ret; + Cdcc.error = err; return 0; } v9 = -16; @@ -1628,21 +1438,15 @@ int cdc_inits(void *buf, unsigned int size, unsigned int bsize) int cdc_seeks(unsigned int lsn) { - acInt32 v2; + acInt32 err; int v5; int ret; acSpl state; - v2 = 17; - if ( Cdcc.lockid ) - { - v2 = 0; - if ( WaitSema(Cdcc.lockid) ) - v2 = 19; - } - if ( v2 ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - Cdcc.error = v2; + Cdcc.error = err; return 0; } v5 = 27; @@ -1671,20 +1475,14 @@ int cdc_seeks(unsigned int lsn) int cdc_stats() { - acInt32 v0; + acInt32 err; int ret; acSpl state; - v0 = 17; - if ( Cdcc.lockid ) + err = Cdcc.lockid ? (WaitSema(Cdcc.lockid) ? 19 : 0) : 17; + if ( err ) { - v0 = 0; - if ( WaitSema(Cdcc.lockid) ) - v0 = 19; - } - if ( v0 ) - { - Cdcc.error = v0; + Cdcc.error = err; return 0; } ret = 27; @@ -1702,20 +1500,7 @@ int cdc_stats() if ( ret > 0 ) { CpuSuspendIntr(&state); - ret = Cdcc.st.size; - if ( Cdcc.st.head == Cdcc.st.tail ) - { - if ( (Cdcc.st.flag & 4) == 0 ) - ret = 0; - } - else if ( Cdcc.st.head < Cdcc.st.tail ) - { - ret = Cdcc.st.size + Cdcc.st.head - Cdcc.st.tail; - } - else - { - ret = Cdcc.st.head - Cdcc.st.tail; - } + ret = ( Cdcc.st.head == Cdcc.st.tail ) ? (( (Cdcc.st.flag & 4) == 0 ) ? 0 : Cdcc.st.size) : (( Cdcc.st.head < Cdcc.st.tail ) ? (Cdcc.st.size + Cdcc.st.head - Cdcc.st.tail) : (Cdcc.st.head - Cdcc.st.tail)); CpuResumeIntr(state); } if ( Cdcc.fno == AC_CDVDSIF_ID_STATS ) @@ -1728,9 +1513,7 @@ int cdc_stats() { SignalSema(Cdcc.lockid); } - if ( ret < 0 ) - return 0; - return ret; + return ( ret < 0 ) ? 0 : ret; } int cdc_module_status() @@ -1739,10 +1522,7 @@ int cdc_module_status() int state; CpuSuspendIntr(&state); - if ( Cdcc.fno ) - ret = 2; - else - ret = Cdcc.lockid > 0; + ret = ( Cdcc.fno ) ? 2 : (Cdcc.lockid > 0); CpuResumeIntr(state); return ret; } @@ -1774,16 +1554,7 @@ int cdc_module_start(int argc, char **argv) int ret_v3; ret_v3 = mods_120[v6].status(); - ret_v4 = ret_v3; - if ( ret_v3 <= 0 ) - { - if ( !ret_v3 ) - ret_v4 = mods_120[v6].start(argc, argv); - } - else - { - ret_v4 = 0; - } + ret_v4 = ( ret_v3 <= 0 ) ? ((!ret_v3) ? mods_120[v6].start(argc, argv) : ret_v3) : 0; if ( ret_v4 < 0 ) { printf("cdc:init_modules:S:%d: error %d\n", index, ret_v4); @@ -1860,11 +1631,7 @@ int cdc_module_stop() int ret_v5; ret_v5 = mods_120[i].status(); - lockid_v6 = ret_v5; - if ( ret_v5 < 0 ) - { - lockid_v6 = 0; - } + lockid_v6 = ( ret_v5 < 0 ) ? 0 : ret_v5; if ( ret_v5 > 0 ) { lockid_v6 = mods_120[i].stop(); diff --git a/iop/arcade/accdvd/src/cddrv.c b/iop/arcade/accdvd/src/cddrv.c index 8ccd4c9ff288..3469239b4e73 100644 --- a/iop/arcade/accdvd/src/cddrv.c +++ b/iop/arcade/accdvd/src/cddrv.c @@ -116,9 +116,7 @@ static int cddrv_close(iop_file_t *io) static int cddrv_read(iop_file_t *io, void *buf, int cnt) { - if ( !buf || !cnt ) - return 0; - return cdfs_read((struct cdfs_file *)io->privdata, buf, cnt); + return ( !buf || !cnt ) ? 0 : cdfs_read((struct cdfs_file *)io->privdata, buf, cnt); } static int cddrv_write(iop_file_t *io, void *buf, int cnt) @@ -137,16 +135,9 @@ static int cddrv_lseek(iop_file_t *io, int offset, int whence) file = (struct cdfs_file *)io->privdata; size = file->f_size; - if ( whence == 1 ) - { - offset += file->f_pos; - } - else if ( whence == 2 ) - { - offset += size; - } - if ( size < (unsigned int)offset ) - offset = file->f_size; + offset += ( whence == 1 ) ? file->f_pos : 0; + offset += ( whence == 2 ) ? size : 0; + offset = ( size < (unsigned int)offset ) ? file->f_size : offset; file->f_pos = offset; return offset; } @@ -162,28 +153,14 @@ static int cddrv_ioctl(iop_file_t *io, int cmd, void *arg) int cddrv_module_start(int argc, char **argv) { - int v2; - int v3; - (void)argc; (void)argv; - v2 = AddDrv(&Cddrv); - v3 = 0; - if ( v2 < 0 ) - return -16; - return v3; + return ( AddDrv(&Cddrv) < 0 ) ? -16 : 0; } int cddrv_module_stop() { - int v0; - int v1; - - v0 = DelDrv(Cddrv.name); - v1 = 0; - if ( v0 < 0 ) - return -16; - return v1; + return ( DelDrv(Cddrv.name) < 0 ) ? -16 : 0; } int cddrv_module_restart(int argc, char **argv) diff --git a/iop/arcade/accdvd/src/cdfs.c b/iop/arcade/accdvd/src/cdfs.c index 07316c6c89b5..62513a34d1ad 100644 --- a/iop/arcade/accdvd/src/cdfs.c +++ b/iop/arcade/accdvd/src/cdfs.c @@ -63,18 +63,7 @@ static void cdfs_ready_done(struct acd *acd, const struct cdfs_softc *arg, int r int delay; asc = (acUint16) - (ret & 0xFFFF); - if ( -ret >> 16 == 6 ) - { - delay = 0; - if ( asc == 10496 ) - delay = acd_delay(); - } - else - { - delay = -1; - if ( asc == 1025 ) - delay = 1000000; - } + delay = ( -ret >> 16 == 6 ) ? (( asc == 10496 ) ? acd_delay() : 0) : (( asc == 1025 ) ? 1000000 : -1); if ( delay < 0 ) flg = 1; else @@ -123,10 +112,7 @@ static int cdfs_attach(struct cdfs_softc *cdfsc, struct acd *acd, int remount) struct cdfs_ptable *ptable_v19; semid = cdfsc->semid; - if ( semid <= 0 ) - active = -9; - else - active = WaitSema(semid); + active = ( semid <= 0 ) ? -9 : WaitSema(semid); if ( active >= 0 ) { acd_setup((struct acd *)cdfsc->buf, (acd_done_t)cdfs_ready_done, cdfsc, -5000000); @@ -136,9 +122,7 @@ static int cdfs_attach(struct cdfs_softc *cdfsc, struct acd *acd, int remount) SignalSema(cdfsc->semid); } } - active_v3 = -9; - if ( cdfsc->semid > 0 ) - active_v3 = WaitSema(cdfsc->semid); + active_v3 = ( cdfsc->semid > 0 ) ? WaitSema(cdfsc->semid) : -9; if ( active_v3 < 0 ) { return -6; @@ -210,13 +194,8 @@ static int cdfs_attach(struct cdfs_softc *cdfsc, struct acd *acd, int remount) FlushDcache(); pcache_v17 = (struct iso9660_path *)AllocSysMemory(0, ret_v16 << 11, 0); cdfsc->pcache = pcache_v17; - if ( pcache_v17 == 0 ) - { - ret = -12; - } - else + ret = ( pcache_v17 == 0 ) ? -12 : acd_read(acd, lsn, pcache_v17, ret_v16); { - ret = acd_read(acd, lsn, pcache_v17, ret_v16); if ( ret >= 0 ) { int active_v18; @@ -377,9 +356,7 @@ int cdfs_lookup(struct cdfs_dirent *result, const char *path, int pathlen) int v6; int v8; - v6 = -9; - if ( Cdfsc.semid > 0 ) - v6 = WaitSema(Cdfsc.semid); + v6 = ( Cdfsc.semid > 0 ) ? WaitSema(Cdfsc.semid) : -9; if ( v6 < 0 ) return -6; if ( Cdfsc.all ) @@ -465,10 +442,7 @@ int cdfs_lookup(struct cdfs_dirent *result, const char *path, int pathlen) path_v36 = (struct iso9660_path *)AllocSysMemory(0, n << 11, 0); dirent_v37 = path_v36; Cdfsc.dcache = (struct iso9660_dirent *)path_v36; - if ( path_v36 ) - Cdfsc.dcsize = n; - else - Cdfsc.dcsize = 0; + Cdfsc.dcsize = path_v36 ? n : 0; if ( !path_v36 ) lsn = 0; } @@ -562,9 +536,7 @@ int cdfs_lookup(struct cdfs_dirent *result, const char *path, int pathlen) break; } dirent_v38 = Cdfsc.dcache; - v55 = size_v29 + 2047; - if ( size_v29 + 2047 < 0 ) - v55 = size_v29 + 4094; + v55 = ( size_v29 + 2047 < 0 ) ? (size_v29 + 4094) : (size_v29 + 2047); n_v39 = v55 >> 11; } } @@ -625,8 +597,7 @@ int cdfs_lookup(struct cdfs_dirent *result, const char *path, int pathlen) { len_v19 = path_v16->name_len[0] | (path_v16->name_len[1] << 8); s2 = path_v16->name; - if ( namlen_v9 < len_v19 ) - len_v19 = namlen_v9; + len_v19 = ( namlen_v9 < len_v19 ) ? namlen_v9 : len_v19; idx_v21 = len_v19 - 1; dirent_v22 = name_v8; while ( idx_v21 >= 0 ) @@ -736,9 +707,7 @@ int cdfs_read(struct cdfs_file *file, void *buf, int size) { int ret_v8; - ret_v8 = -9; - if ( Cdfsc.semid > 0 ) - ret_v8 = WaitSema(Cdfsc.semid); + ret_v8 = ( Cdfsc.semid > 0 ) ? WaitSema(Cdfsc.semid) : -9; ret = -6; if ( ret_v8 >= 0 ) { @@ -781,9 +750,7 @@ int cdfs_read(struct cdfs_file *file, void *buf, int size) return ret; rest = size - ret; cpos_v14 = file->f_pos; - npos_v15 = cpos_v14 + rest; - if ( file->f_size < cpos_v14 + rest ) - npos_v15 = file->f_size; + npos_v15 = ( file->f_size < cpos_v14 + rest ) ? file->f_size : (cpos_v14 + rest); npos_v16 = npos_v15 - (npos_v15 & 0x7FF); lsn_v17 = file->f_lsn + (cpos_v14 >> 11); len_v18 = npos_v16 - cpos_v14; @@ -824,9 +791,7 @@ int cdfs_read(struct cdfs_file *file, void *buf, int size) flg = 1; break; } - ret_v21 = -9; - if ( Cdfsc.semid > 0 ) - ret_v21 = WaitSema(Cdfsc.semid); + ret_v21 = ( Cdfsc.semid > 0 ) ? WaitSema(Cdfsc.semid) : -9; ret = -6; if ( ret_v21 < 0 ) break; @@ -872,9 +837,7 @@ int cdfs_read(struct cdfs_file *file, void *buf, int size) return ret; rest_v34 = rest - ret; cpos_v35 = file->f_pos; - npos_v36 = cpos_v35 + rest_v34; - if ( file->f_size < cpos_v35 + rest_v34 ) - npos_v36 = file->f_size; + npos_v36 = ( file->f_size < cpos_v35 + rest_v34 ) ? file->f_size : (cpos_v35 + rest_v34); len_v37 = npos_v36 - cpos_v35; lsn_v38 = file->f_lsn + (cpos_v35 >> 11); ret = len_v37; @@ -882,9 +845,7 @@ int cdfs_read(struct cdfs_file *file, void *buf, int size) { int ret_v39; - ret_v39 = -9; - if ( Cdfsc.semid > 0 ) - ret_v39 = WaitSema(Cdfsc.semid); + ret_v39 = ( Cdfsc.semid > 0 ) ? WaitSema(Cdfsc.semid) : -9; if ( ret_v39 < 0 ) { ret = -6; @@ -925,9 +886,7 @@ int cdfs_read(struct cdfs_file *file, void *buf, int size) } } rest_v42 = rest_v34 - ret; - if ( ret >= 0 ) - return size - rest_v42; - return ret; + return ( ret >= 0 ) ? (size - rest_v42) : ret; } int cdfs_module_status() diff --git a/iop/arcade/accdvd/src/cdi.c b/iop/arcade/accdvd/src/cdi.c index 68c2c6dfdc7c..2ce6c237cd15 100644 --- a/iop/arcade/accdvd/src/cdi.c +++ b/iop/arcade/accdvd/src/cdi.c @@ -56,9 +56,7 @@ static int cdi_xfer(void *dst, void *src, int len, enum cdc_xfer_dir dir) int sceCdGetToc(unsigned char *toc) { - if ( !toc ) - return cdc_seterrno(34); - return cdc_readtoc(toc, cdi_xfer); + return ( !toc ) ? cdc_seterrno(34) : cdc_readtoc(toc, cdi_xfer); } int sceCdInit(int mode) @@ -97,13 +95,7 @@ int sceCdPause() int sceCdRead(u32 lbn, u32 sectors, void *buffer, sceCdRMode *mode) { - if ( !mode || !buffer || ((uiptr)buffer & 3) != 0 ) - { - return cdc_seterrno(34); - } - if ( !sectors ) - return cdc_seterrno(0); - return cdc_read(lbn, buffer, sectors, mode, 0, Cdic.done); + return ( !mode || !buffer || ((uiptr)buffer & 3) != 0 ) ? cdc_seterrno(34) : (( !sectors ) ? cdc_seterrno(0) : cdc_read(lbn, buffer, sectors, mode, 0, Cdic.done)); } int sceCdSync(int mode) @@ -134,9 +126,7 @@ int sceCdSearchFile(sceCdlFILE *file, const char *name) if ( namlen >= 1024 ) namlen = 0; } - if ( !namlen ) - return cdc_seterrno(34); - return cdc_lookup(file, name, namlen, cdi_xfer); + return ( !namlen ) ? cdc_seterrno(34) : cdc_lookup(file, name, namlen, cdi_xfer); } int sceCdSeek(u32 lbn) @@ -170,9 +160,7 @@ int sceCdStInit(u32 bufmax, u32 bankmax, void *buffer) if ( !bufmax || !bankmax || !buffer || ((uiptr)buffer & 3) != 0 ) return cdc_seterrno(34); - v4 = bufmax / bankmax; - if ( !(bufmax / bankmax) ) - v4 = 1; + v4 = ( !(bufmax / bankmax) ) ? 1 : (bufmax / bankmax); return cdc_inits((void *)buffer, bufmax, v4); } @@ -201,9 +189,7 @@ int sceCdStSeek(u32 lbn) int sceCdStStart(u32 lbn, sceCdRMode *mode) { - if ( !mode ) - return cdc_seterrno(34); - return cdc_starts(lbn, mode); + return ( !mode ) ? cdc_seterrno(34) : cdc_starts(lbn, mode); } int sceCdStStat() diff --git a/iop/arcade/accdvde/src/accdvde-entry.c b/iop/arcade/accdvde/src/accdvde-entry.c index bc3f8d89e210..703d5452ec46 100644 --- a/iop/arcade/accdvde/src/accdvde-entry.c +++ b/iop/arcade/accdvde/src/accdvde-entry.c @@ -32,11 +32,5 @@ int acCdvdeEntry(int argc, char **argv) int ret; ret = acCdvdeModuleStart(argc, argv); - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_accdvde) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_accdvde) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/accdvde/src/cde.c b/iop/arcade/accdvde/src/cde.c index 30fe93a66160..635ab2c64b27 100644 --- a/iop/arcade/accdvde/src/cde.c +++ b/iop/arcade/accdvde/src/cde.c @@ -267,10 +267,7 @@ static int cde_op_sync(void *arg) argr->fno = cdc_getfno(); v3 = cdc_sync(mode); argr->result = v3; - if ( mode < 0 && v3 ) - argr->rpos = cdc_getpos(); - else - argr->rpos = 0; + argr->rpos = ( mode < 0 && v3 ) ? cdc_getpos() : 0; return 0; } @@ -381,12 +378,8 @@ static int cde_reads_xfer(void *dst, void *src, int len, enum cdc_xfer_dir dir) { int index_v3; - index_v3 = Cdec.st_index - 1; - if ( Cdec.st_index - 1 < 0 ) - index_v3 = 1; - if ( acMemWait(&Cdec.st_mem[index_v3], 100, 120) < 0 ) - return -116; - return 9; + index_v3 = ( Cdec.st_index - 1 < 0 ) ? 1 : (Cdec.st_index - 1); + return ( acMemWait(&Cdec.st_mem[index_v3], 100, 120) < 0 ) ? -116 : 9; } index = Cdec.st_index; mem = &Cdec.st_mem[Cdec.st_index]; @@ -520,14 +513,10 @@ static void *cde_request(unsigned int fno, struct cde_softc *data, int size) return rpl; } CpuSuspendIntr(&state); - if ( data->fno ) - { - ret = 1; - } - else + ret = data->fno ? 1 : 0; + if ( !data->fno ) { data->fno = fno; - ret = 0; } CpuResumeIntr(state); if ( ret ) @@ -543,10 +532,7 @@ static void *cde_request(unsigned int fno, struct cde_softc *data, int size) v11 = func(rpl); if ( v11 >= 0 ) { - if ( v11 ) - rpl->error = 0; - else - rpl->error = cdc_error(); + rpl->error = v11 ? 0 : cdc_error(); } data->fno = AC_CDVDSIF_ID_NOP; return rpl; @@ -629,10 +615,7 @@ int acCdvdeModuleStatus() int state; CpuSuspendIntr(&state); - if ( Cdec.fno ) - ret = 2; - else - ret = Cdec.thid != 0; + ret = Cdec.fno ? 2 : (Cdec.thid != 0); CpuResumeIntr(state); return ret; } @@ -646,7 +629,6 @@ int acCdvdeModuleStart(int argc, char **argv) int v10; const char *opt_v7; int value; - int inited; char *next; if ( acCdvdeModuleStatus() != 0 ) @@ -674,10 +656,7 @@ int acCdvdeModuleStart(int argc, char **argv) ++v8; } memset(&Cdec, 0, sizeof(Cdec)); - inited = cde_init_thread(&Cdec, prio); - if ( inited <= 0 ) - return -6; - return 0; + return ( cde_init_thread(&Cdec, prio) <= 0 ) ? -6 : 0; } int acCdvdeModuleStop() diff --git a/iop/arcade/accore/src/accore-entry.c b/iop/arcade/accore/src/accore-entry.c index 45fdd34acdec..60226bb9ae6e 100644 --- a/iop/arcade/accore/src/accore-entry.c +++ b/iop/arcade/accore/src/accore-entry.c @@ -61,11 +61,5 @@ int acCoreEntry(int argc, char **argv) break; } } - if ( ret_v4 < 0 ) - { - return ret_v4; - } - if ( RegisterLibraryEntries(&_exp_accore) != 0 ) - return -16; - return 0; + return ( ret_v4 < 0 ) ? ret_v4 : (( RegisterLibraryEntries(&_exp_accore) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/accore/src/dma.c b/iop/arcade/accore/src/dma.c index f56263f0b6c0..4f21c9db7427 100644 --- a/iop/arcade/accore/src/dma.c +++ b/iop/arcade/accore/src/dma.c @@ -65,16 +65,8 @@ static int dma_xfer(acDmaT dma, void *ioptr, void *buf, int count) int state; slice = dma->d_slice; - if ( count >= 4 << slice ) - { - ret = count >> (slice + 2); - slice_v2 = 1 << slice; - } - else - { - ret = count >> 2; - slice_v2 = 1; - } + ret = count >> (( count >= 4 << slice ) ? (slice + 2) : 2); + slice_v2 = 1 << (( count >= 4 << slice ) ? slice : 0); CpuSuspendIntr(&state); if ( dma == (acDmaT)Dmac.requestq.q_next && dma->d_state == 2 ) { @@ -375,12 +367,8 @@ int acDmaModuleStart(int argc, char **argv) return 0; } ReleaseIntrHandler(41); - msg = "dma_intr_enable"; - } - else - { - msg = "dma_intr_register"; } + msg = ( !ret || ret == -104 ) ? "dma_intr_enable" : "dma_intr_register"; printf("accore:dma_init:%s: error %d\n", msg, ret); return -6; } diff --git a/iop/arcade/accore/src/intr.c b/iop/arcade/accore/src/intr.c index 63eb24532101..bc86d9cf2b83 100644 --- a/iop/arcade/accore/src/intr.c +++ b/iop/arcade/accore/src/intr.c @@ -107,13 +107,7 @@ int acIntrDisable(acIntrNum inum) if ( Intrc.enable ) return 0; enable = DisableIntr(13, &old_status); - if ( enable != (acUint32)-103 ) - { - if ( !enable ) - return 0; - return -22; - } - return 1; + return ( enable != (acUint32)-103 ) ? (( !enable ) ? 0 : -22) : 1; } int acIntrRegister(acIntrNum inum, acIntrHandler func, void *arg) @@ -248,10 +242,7 @@ int acIntrModuleStatus() int state; CpuSuspendIntr(&state); - if ( Intrc.enable ) - ret = 2; - else - ret = Intrc.active != 0; + ret = Intrc.enable ? 2 : (Intrc.active != 0); CpuResumeIntr(state); return ret; } diff --git a/iop/arcade/acflash/src/acflash-entry.c b/iop/arcade/acflash/src/acflash-entry.c index b899dcb88d16..d32f1bda8755 100644 --- a/iop/arcade/acflash/src/acflash-entry.c +++ b/iop/arcade/acflash/src/acflash-entry.c @@ -31,11 +31,5 @@ int acFlashEntry(int argc, char **argv) int ret; ret = acFlashModuleStart(argc, argv); - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries((struct irx_export_table *)&_exp_acflash) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_acflash) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/acflash/src/flash.c b/iop/arcade/acflash/src/flash.c index dc4ccd2cc592..e72022a3d7b4 100644 --- a/iop/arcade/acflash/src/flash.c +++ b/iop/arcade/acflash/src/flash.c @@ -59,32 +59,12 @@ int acFlashStop() int acFlashErase(acFlashAddr addr) { - if ( Flashc.status == 1 ) - return -13; - if ( Flashc.status != 2 ) - { - return -6; - } - if ( addr >= (acUint32)Flashc.size ) - return -34; - return Flashc.ops->fo_erase(addr + 0xB0000000); + return ( Flashc.status == 1 ) ? -13 : (( Flashc.status != 2 ) ? -6 : (( addr >= (acUint32)Flashc.size ) ? -34 : Flashc.ops->fo_erase(addr + 0xB0000000))); } int acFlashProgram(acFlashAddr addr, void *buf, int count) { - if ( Flashc.status == 1 ) - return -13; - if ( Flashc.status != 2 ) - { - return -6; - } - if ( (addr & 1) != 0 ) - { - return -14; - } - if ( addr >= (acUint32)Flashc.size ) - return -34; - return Flashc.ops->fo_program(addr + 0xB0000000, (flash_data_t *)buf, count); + return ( Flashc.status == 1 ) ? -13 : (( Flashc.status != 2 ) ? -6 : (( (addr & 1) != 0 ) ? -14 : (( addr >= (acUint32)Flashc.size ) ? -34 : Flashc.ops->fo_program(addr + 0xB0000000, (flash_data_t *)buf, count)))); } int acFlashRead(acFlashAddr addr, void *buf, int count) @@ -171,15 +151,7 @@ int acFlashVerify(acFlashAddr addr, void *buf, int count) int acFlashStatus(acFlashAddr addr) { - if ( Flashc.status == 1 ) - return 1; - if ( Flashc.status == 2 ) - { - if ( addr >= (acUint32)Flashc.size ) - return -34; - return Flashc.ops->fo_status(addr + 0xB0000000); - } - return -6; + return ( Flashc.status == 1 ) ? 1 : (( Flashc.status == 2 ) ? (( addr >= (acUint32)Flashc.size ) ? -34 : Flashc.ops->fo_status(addr + 0xB0000000)) : -6); } int acFlashInfo(acFlashInfoData *info) diff --git a/iop/arcade/acflash/src/i28f640j5.c b/iop/arcade/acflash/src/i28f640j5.c index 72b21a5e351f..95e930044961 100644 --- a/iop/arcade/acflash/src/i28f640j5.c +++ b/iop/arcade/acflash/src/i28f640j5.c @@ -29,8 +29,7 @@ static int flash_wait(flash_ptr_t ptr, int tick, int count) *ptr = 0x70; sr = *ptr; - if ( (sr & 0x80) == 0 ) - sr = -116; + sr = ( (sr & 0x80) == 0 ) ? -116 : sr; if ( sr >= 0 ) return sr; threshold--; @@ -42,8 +41,7 @@ static int flash_wait(flash_ptr_t ptr, int tick, int count) DelayThread(tick); *ptr = 0x70; sr_v3 = *ptr; - if ( (sr_v3 & 0x80) == 0 ) - sr_v3 = -116; + sr_v3 = ( (sr_v3 & 0x80) == 0 ) ? -116 : sr_v3; if ( sr_v3 >= 0 ) return sr_v3; --count; @@ -76,18 +74,15 @@ static int flash_program(flash_addr_t addr, const flash_data_t *buf, int size) if ( rest <= 0 ) return size - rest; blen = 0x20000 - (addr & 0x1FFFF); - if ( rest < blen ) - blen = rest; + blen = ( rest < blen ) ? rest : blen; rest -= blen; while ( blen > 0 ) { flash_addr_t v8; v8 = addr & 0xF; - xlen = 16 - v8; count = 2; - if ( blen < (int)(16 - v8) ) - xlen = blen; + xlen = ( blen < (int)(16 - v8) ) ? blen : (16 - v8); threshold = 399; while ( 1 ) { @@ -148,16 +143,12 @@ flash_ops_t flash_probe_i28f640f5(flash_addr_t addr) device = *(volatile acUint16 *)(addr + 2); *(volatile acUint16 *)addr = 0xFF; // cppcheck-suppress knownConditionTrueFalse - if ( vendor != 0x89 || device != 0x15 ) - return 0; - return &ops_30; + return ( vendor != 0x89 || device != 0x15 ) ? 0 : &ops_30; } static int flash_status(flash_addr_t addr) { *(volatile acUint16 *)addr = 0x70; // cppcheck-suppress knownConditionTrueFalse - if ( (*(volatile acUint16 *)addr & 0x80) != 0 ) - return 1; - return 2; + return ( (*(volatile acUint16 *)addr & 0x80) != 0 ) ? 1 : 2; } diff --git a/iop/arcade/acflash/src/mbm29f033c.c b/iop/arcade/acflash/src/mbm29f033c.c index f2e91cb663e7..ea2a6549ea4f 100644 --- a/iop/arcade/acflash/src/mbm29f033c.c +++ b/iop/arcade/acflash/src/mbm29f033c.c @@ -69,12 +69,8 @@ static int flash_erase_0(flash_addr_t addr) ++pass; --i; } - v9 = -116; - if ( pass == 2 ) - v9 = count; - if ( v9 < 0 ) - return -116; - return 0x20000; + v9 = ( pass == 2 ) ? count : -116; + return ( v9 < 0 ) ? -116 : 0x20000; } static int flash_program_0(flash_addr_t addr, const flash_data_t *buf, int size) @@ -134,9 +130,7 @@ static int flash_program_0(flash_addr_t addr, const flash_data_t *buf, int size) ++pass; shift = 8 * --i; } - tmp_v12 = -116; - if ( pass == 2 ) - tmp_v12 = count; + tmp_v12 = ( pass == 2 ) ? count : -116; if ( tmp_v12 < 0 ) return rest - v4; ++buf; @@ -160,9 +154,7 @@ static int flash_status_0(flash_addr_t addr) pass = 0; for ( i = 1; i >= 0; --i ) ++pass; - if ( pass == 2 ) - return 1; - return 2; + return ( pass == 2 ) ? 1 : 2; } flash_ops_t flash_probe_mbm29f033c(flash_addr_t addr) @@ -179,9 +171,5 @@ flash_ops_t flash_probe_mbm29f033c(flash_addr_t addr) device = *(volatile acUint16 *)(addr + 2); flash_reset_0(addr); // cppcheck-suppress knownConditionTrueFalse - if ( vendor != 0x404 || device != 0xD4D4 ) - { - return 0; - } - return &ops_22; + return ( vendor != 0x404 || device != 0xD4D4 ) ? 0 : &ops_22; } diff --git a/iop/arcade/acfpgald/src/fpgald.c b/iop/arcade/acfpgald/src/fpgald.c index 67cc81588296..2bf1b6448bbd 100644 --- a/iop/arcade/acfpgald/src/fpgald.c +++ b/iop/arcade/acfpgald/src/fpgald.c @@ -72,9 +72,7 @@ static char *fpgald_path(char *name) char *str; str = strchr(name, ':'); - if ( str == 0 ) - return name; - return str + 1; + return ( str == 0 ) ? name : (str + 1); } static char *fpgald_basename(char *name) @@ -82,26 +80,14 @@ static char *fpgald_basename(char *name) char *str; char *str_v3; char *str_v4; - char *str_v5; - char *str_v6; str = strchr(name, ':'); if ( str == 0 ) return name; str_v3 = str + 1; str_v4 = strrchr(str_v3, '/'); - if ( str_v4 == 0 ) - { - str_v6 = strrchr(str_v3, '\\'); - if ( str_v6 == 0 ) - return str_v3; - str_v5 = str_v6 + 1; - } - else - { - str_v5 = str_v4 + 1; - } - return str_v5; + str_v4 = ( str_v4 == 0 ) ? strrchr(str_v3, '\\') : str_v4; + return ( str_v4 == 0 ) ? str_v3 : (str_v4 + 1); } #define acFpgaLoader _start @@ -113,9 +99,7 @@ int acFpgaLoader(int argc, char **argv) char *name; int fd; - prog = 0; - if ( argv ) - prog = *argv; + prog = ( argv ) ? *argv : 0; if ( argc < 2 ) return -22; name = argv[1]; @@ -228,7 +212,5 @@ int acFpgaLoader(int argc, char **argv) } close(fd); } - if ( ret >= 0 ) - return 1; - return ret; + return ( ret >= 0 ) ? 1 : ret; } diff --git a/iop/arcade/acjv/src/acjv-entry.c b/iop/arcade/acjv/src/acjv-entry.c index 0bd399797104..17a987a35697 100644 --- a/iop/arcade/acjv/src/acjv-entry.c +++ b/iop/arcade/acjv/src/acjv-entry.c @@ -31,11 +31,5 @@ int acJvEntry(int argc, char **argv) ret = acJvModuleStart(argc, argv); // cppcheck-suppress knownConditionTrueFalse - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_acjv) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_acjv) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/acjvld/src/jvld.c b/iop/arcade/acjvld/src/jvld.c index 7d727b0bfb73..dab001b5ce0b 100644 --- a/iop/arcade/acjvld/src/jvld.c +++ b/iop/arcade/acjvld/src/jvld.c @@ -49,9 +49,7 @@ static char *jvld_path(char *name) char *str; str = strchr(name, ':'); - if ( str == 0 ) - return name; - return str + 1; + return ( str == 0 ) ? name : (str + 1); } static char *jvld_basename(char *name) @@ -59,26 +57,14 @@ static char *jvld_basename(char *name) char *str; char *str_v3; char *str_v4; - char *str_v5; - char *str_v6; str = strchr(name, ':'); if ( str == 0 ) return name; str_v3 = str + 1; str_v4 = strrchr(str_v3, '/'); - if ( str_v4 == 0 ) - { - str_v6 = strrchr(str_v3, '\\'); - if ( str_v6 == 0 ) - return str_v3; - str_v5 = str_v6 + 1; - } - else - { - str_v5 = str_v4 + 1; - } - return str_v5; + str_v4 = ( str_v4 == 0 ) ? strrchr(str_v3, '\\') : str_v4; + return ( str_v4 == 0 ) ? str_v3 : (str_v4 + 1); } #define acJvLoader _start @@ -90,9 +76,7 @@ int acJvLoader(int argc, char **argv) char *name; int fd; - prog = 0; - if ( argv ) - prog = *argv; + prog = ( argv ) ? *argv : 0; if ( argc < 2 ) { ret = -22; @@ -161,21 +145,8 @@ int acJvLoader(int argc, char **argv) *ret_v10++ = *ptr++; } } - if ( sent != lseek(fd, 0, 2) ) - { - ret = -5; - } - else - { - ret = sent; - if ( !sent ) - { - ret = -8; - } - } + ret = ( sent != lseek(fd, 0, 2) ) ? -5 : (( !sent ) ? -8 : sent); close(fd); } - if ( ret >= 0 ) - return 1; - return 4 * ret + 1; + return ( ret >= 0 ) ? 1 : (4 * ret + 1); } diff --git a/iop/arcade/acmem/src/acmem-entry.c b/iop/arcade/acmem/src/acmem-entry.c index 82314e888de2..2f7d9937d1f8 100644 --- a/iop/arcade/acmem/src/acmem-entry.c +++ b/iop/arcade/acmem/src/acmem-entry.c @@ -34,11 +34,5 @@ int acMemEntry(int argc, char **argv) ret = acMemModuleStart(argc, argv); // cppcheck-suppress knownConditionTrueFalse - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_acmem) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_acmem) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/acmem/src/memi.c b/iop/arcade/acmem/src/memi.c index dfa78e8b1073..7ca8ed1855ca 100644 --- a/iop/arcade/acmem/src/memi.c +++ b/iop/arcade/acmem/src/memi.c @@ -111,9 +111,7 @@ int acMemReceive(acMemT mem, acMemEEaddr addr, int size) if ( size > 0 ) { mem->m_id = 0; - if ( sceSifGetOtherData(&recv_data, (void *)addr, m_buf, size, 0) < 0 ) - return -5; - return size; + return ( sceSifGetOtherData(&recv_data, (void *)addr, m_buf, size, 0) < 0 ) ? -5 : size; } return 0; } diff --git a/iop/arcade/acmeme/src/acmeme-entry.c b/iop/arcade/acmeme/src/acmeme-entry.c index de96bc0fbc1e..4e7b0ec06d5d 100644 --- a/iop/arcade/acmeme/src/acmeme-entry.c +++ b/iop/arcade/acmeme/src/acmeme-entry.c @@ -32,11 +32,5 @@ int acMemeEntry(int argc, char **argv) int ret; ret = acMemeModuleStart(argc, argv); - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_acmeme) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_acmeme) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/acmeme/src/meme.c b/iop/arcade/acmeme/src/meme.c index df3bd9431e5f..fb38195fcd4c 100644 --- a/iop/arcade/acmeme/src/meme.c +++ b/iop/arcade/acmeme/src/meme.c @@ -140,9 +140,7 @@ static int meme_xfer_ioptodev(struct meme_softc *memec, acMemVecT mvec, meme_xfe dst = mvec->mv_dst & 0xFFFFFFE; for ( src = (acUint8 *)(mvec->mv_src & 0xFFFFFFE); mv_size > 0; src += v9 ) { - v9 = 0x20000; - if ( mv_size <= 0x20000 ) - v9 = mv_size; + v9 = ( mv_size <= 0x20000 ) ? mv_size : 0x20000; ret = xfer(dst, src, v9); dst += v9; if ( ret <= 0 ) @@ -162,7 +160,6 @@ static int meme_op_xfer(struct meme_softc *memec, struct ac_memsif_reply *rpl, c meme_xfer_t xfer_src; acMemAddr v10; meme_xfer_t xfer_dst; - int v12; acMemAddr mv_dst; int v14; acUint8 *dst; @@ -217,56 +214,24 @@ static int meme_op_xfer(struct meme_softc *memec, struct ac_memsif_reply *rpl, c { mvec = &memec->mvec[pos_v35]; v8 = memec->mvec[pos_v35].mv_src & 0xF0000000; - if ( v8 == 1342177280 ) - { - xfer_src = meme_sram_read; - } - else if ( v8 > 0x50000000 ) - { - xfer_src = 0; - if ( v8 == 0x60000000 ) - xfer_src = meme_jv_read; - } - else - { - xfer_src = 0; - if ( v8 == 0x40000000 ) - xfer_src = meme_ram_read; - } + xfer_src = ( v8 == 1342177280 ) ? meme_sram_read : (( v8 > 0x50000000 ) ? (( v8 == 0x60000000 ) ? meme_jv_read : 0) : (( v8 == 0x40000000 ) ? meme_ram_read : 0)); v10 = memec->mvec[pos_v35].mv_dst & 0xF0000000; - if ( v10 == 0x50000000 ) - { - xfer_dst = meme_sram_write; - } - else if ( v10 > 0x50000000 ) - { - xfer_dst = 0; - if ( v10 == 0x60000000 ) - xfer_dst = meme_jv_write; - } - else - { - xfer_dst = 0; - if ( v10 == 0x40000000 ) - xfer_dst = meme_ram_write; - } + xfer_dst = ( v10 == 0x50000000 ) ? meme_sram_write : (( v10 > 0x50000000 ) ? (( v10 == 0x60000000 ) ? meme_jv_write : 0) : (( v10 == 0x40000000 ) ? meme_ram_write : 0)); ret = 0; if ( xfer_src ) { - v12 = -134; if ( xfer_dst ) { mvec->mv_result = -134; - ret = v12; + ret = -134; } } else { - v12 = -134; if ( !xfer_dst ) { mvec->mv_result = -134; - ret = v12; + ret = -134; } } if ( ret >= 0 ) @@ -287,9 +252,7 @@ static int meme_op_xfer(struct meme_softc *memec, struct ac_memsif_reply *rpl, c mv_size = memec->mvec[pos_v35].mv_size; for ( src = memec->mvec[pos_v35].mv_src & v40; mv_size > 0; src += ret_v14 ) { - ret_v14 = 0x20000; - if ( mv_size <= 0x20000 ) - ret_v14 = mv_size; + ret_v14 = ( mv_size <= 0x20000 ) ? mv_size : 0x20000; v14 = xfer_src(src, dst, ret_v14); dst += ret_v14; if ( v14 <= 0 ) @@ -311,21 +274,15 @@ static int meme_op_xfer(struct meme_softc *memec, struct ac_memsif_reply *rpl, c v23 = mvec->mv_size; for ( ret = 0; v23 > 0; dst_v15 += v27 ) { - xlen = v23; - if ( bsize < v23 ) - xlen = bsize; + xlen = ( bsize < v23 ) ? bsize : v23; ret = xfer_src(src_v16, &buf[pos], xlen); if ( ret <= 0 ) break; - v25 = mem_data_v29; - if ( !pos ) - v25 = &mem_data_v29[1]; + v25 = ( !pos ) ? &mem_data_v29[1] : mem_data_v29; ret = acMemWait(v25, 100, 110); if ( ret < 0 ) break; - size_v22 = mem_data_v29; - if ( pos ) - size_v22 = &mem_data_v29[1]; + size_v22 = ( pos ) ? &mem_data_v29[1] : mem_data_v29; v27 = acMemSend(size_v22, dst_v15, xlen, 10); ret = v27; if ( v27 <= 0 ) @@ -334,24 +291,14 @@ static int meme_op_xfer(struct meme_softc *memec, struct ac_memsif_reply *rpl, c src_v16 += v27; v23 -= v27; } - size_v24 = mem_data_v29; - if ( !pos ) - size_v24 = &mem_data_v29[1]; + size_v24 = ( !pos ) ? &mem_data_v29[1] : mem_data_v29; acMemWait(size_v24, 100, 110); mvec->mv_result = mvec->mv_size - v23; } } else { - if ( (memec->mvec[pos_v35].mv_src & 1) != 0 ) - { - ret = meme_xfer_ioptodev(memec, &memec->mvec[pos_v35], xfer_dst); - } - else - { - v12 = meme_xfer_eetodev(memec, &memec->mvec[pos_v35], xfer_dst); - ret = v12; - } + ret = (( (memec->mvec[pos_v35].mv_src & 1) != 0 ) ? meme_xfer_ioptodev : meme_xfer_eetodev)(memec, &memec->mvec[pos_v35], xfer_dst); } } } @@ -380,9 +327,7 @@ static int meme_op_xfer(struct meme_softc *memec, struct ac_memsif_reply *rpl, c break; v5 = v37; } - v31 = ret; - if ( v31 > 0 ) - v31 = 0; + v31 = ( ret > 0 ) ? 0 : ret; rpl->error = v31; return v36 - v37; } @@ -410,9 +355,7 @@ static int meme_op_init(struct meme_softc *memec, struct ac_memsif_reply *rpl, c } if ( v4 == 0 ) { - if ( memec->buf == 0 ) - return -6; - return memec->size; + return ( memec->buf == 0 ) ? -6 : memec->size; } buf_v3 = AllocSysMemory(0, argt->size, 0); if ( buf_v3 == 0 ) @@ -434,17 +377,7 @@ static void *meme_request(unsigned int fno, struct meme_softc *data, int size) data->status = 2; data->pkt.rpl.error = 0; - if ( size != 16 ) - { - v5 = -122; - } - else - { - if ( fno >= 3 || (op = ops_48[fno]) == 0 ) - v5 = -88; - else - v5 = op(data, &data->pkt.rpl, data, 16); - } + v5 = ( size != 16 ) ? -122 : (( fno >= 3 || (op = ops_48[fno]) == 0 ) ? -88 : op(data, &data->pkt.rpl, data, 16)); if ( v5 < 0 ) { data->pkt.rpl.error = -v5; diff --git a/iop/arcade/acram/src/acram-entry.c b/iop/arcade/acram/src/acram-entry.c index 806736569bba..c4386aa0ab1b 100644 --- a/iop/arcade/acram/src/acram-entry.c +++ b/iop/arcade/acram/src/acram-entry.c @@ -31,11 +31,5 @@ int acRamEntry(int argc, char **argv) int ret; ret = acRamModuleStart(argc, argv); - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_acram) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_acram) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/acram/src/ram.c b/iop/arcade/acram/src/ram.c index 29e7252b3450..e47cbb8e8daf 100644 --- a/iop/arcade/acram/src/ram.c +++ b/iop/arcade/acram/src/ram.c @@ -50,14 +50,12 @@ static int ram_dma_xfer(acDmaT dma, int intr, acDmaOp op) break; } } - size = dmatmp->size; output = dmatmp->addr & 1; addr = dmatmp->addr - output; if ( bank < 0 ) return -34; v10 = Ram_limits[bank]; - if ( addr + size >= v10 ) - size = v10 - addr; + size = ( addr + dmatmp->size >= v10 ) ? (v10 - addr) : dmatmp->size; v11 = bank << 21; if ( size <= 0 ) return -34; @@ -66,12 +64,8 @@ static int ram_dma_xfer(acDmaT dma, int intr, acDmaOp op) buf = dmatmp->buf; *(acUint16 *)((size & 0x7FC) + v11 + 0xB4000000 + 0x20000) = size >> 11; ioaddr = (void *)(v11 + 0xB4000000 + 0x100000); - if ( bank > 0 ) - addr -= Ram_limits[bank - 1]; - if ( output ) - v16 = 0x70000; - else - v16 = 0x60000; + addr -= ( bank > 0 ) ? Ram_limits[bank - 1] : 0; + v16 = output ? 0x70000 : 0x60000; *(acRamReg)((char *)ramreg + (addr & 0x7FC) + v16) = addr >> 11; return op(dma, ioaddr, buf, size); } @@ -99,10 +93,7 @@ static void ram_dma_error(acDmaT dma, int intr, acDmaState state, int result) dmatmp->size = 0; if ( thid ) { - if ( intr ) - iWakeupThread(thid); - else - WakeupThread(thid); + (intr ? iWakeupThread : WakeupThread)(thid); } Kprintf("acram:dma_error: state=%d ret=%d\n", state, result); } @@ -167,9 +158,7 @@ static void ram_thread(void *arg) while ( 1 ) { CpuSuspendIntr(&state); - ram = 0; - if ( qh != qh->q_next ) - ram = (acRamT)qh->q_next; + ram = ( qh != qh->q_next ) ? (acRamT)qh->q_next : 0; CpuResumeIntr(state); if ( ram ) { @@ -413,9 +402,7 @@ int acRamModuleStop() } } ret_v3 = CancelAlarm(ram_refresh, &Ramc); - if ( ret_v3 != 0 ) - return -6; - return 0; + return ( ret_v3 != 0 ) ? -6 : 0; } int acRamModuleRestart(int argc, char **argv) @@ -432,16 +419,7 @@ int acRamModuleStatus() int state; CpuSuspendIntr(&state); - if ( Ramc.thid ) - { - ret = 2; - if ( Ramc.requestq.q_next == &Ramc.requestq ) - ret = 1; - } - else - { - ret = 0; - } + ret = Ramc.thid ? (( Ramc.requestq.q_next == &Ramc.requestq ) ? 1 : 2) : 0; CpuResumeIntr(state); return ret; } diff --git a/iop/arcade/acsram/src/acsram-entry.c b/iop/arcade/acsram/src/acsram-entry.c index 6659fc4b22ed..728f5f82aa9c 100644 --- a/iop/arcade/acsram/src/acsram-entry.c +++ b/iop/arcade/acsram/src/acsram-entry.c @@ -33,11 +33,5 @@ int acSramEntry(int argc, char **argv) ret = acSramModuleStart(argc, argv); // cppcheck-suppress knownConditionTrueFalse - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_acsram) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_acsram) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/actimer/src/actimer-entry.c b/iop/arcade/actimer/src/actimer-entry.c index bd1e820dbef0..62aefb995f03 100644 --- a/iop/arcade/actimer/src/actimer-entry.c +++ b/iop/arcade/actimer/src/actimer-entry.c @@ -32,11 +32,5 @@ int acTimerEntry(int argc, char **argv) int ret; ret = acTimerModuleStart(argc, argv); - if ( ret < 0 ) - { - return ret; - } - if ( RegisterLibraryEntries(&_exp_actimer) != 0 ) - return -16; - return 0; + return ( ret < 0 ) ? ret : (( RegisterLibraryEntries(&_exp_actimer) != 0 ) ? -16 : 0); } diff --git a/iop/arcade/actimer/src/timer.c b/iop/arcade/actimer/src/timer.c index 19311673079d..a2ec8aedca2c 100644 --- a/iop/arcade/actimer/src/timer.c +++ b/iop/arcade/actimer/src/timer.c @@ -119,14 +119,7 @@ int acTimerModuleStart(int argc, char **argv) if ( argc >= 2 ) { tick = strtol(argv[1], &next, 10); - if ( next == argv[1] ) - { - tick = 1000000; - } - else if ( tick < 1000 ) - { - tick = 1000; - } + tick = ( next == argv[1] ) ? 1000000 : (( tick < 1000 ) ? 1000 : tick); } Timerc.tick = 0LL; Timerc.waitq.q_prev = (acQueueT)&Timerc; diff --git a/iop/arcade/acuart/src/uart.c b/iop/arcade/acuart/src/uart.c index 2567bd15f6f4..2c8ebe6b9b31 100644 --- a/iop/arcade/acuart/src/uart.c +++ b/iop/arcade/acuart/src/uart.c @@ -309,22 +309,7 @@ int acUartWait(acUartFlag rw, int usec) } result_v7 = 0; v7 = (usec > 0 ? WaitEventFlag : PollEventFlag)(Uartc.eve, rw, 17, &result_v7); - if ( v7 == -418 ) - { - ret = -116; - } - else if ( v7 >= -417 ) - { - ret = -5; - if ( !v7 ) - ret = 0; - } - else - { - ret = -5; - if ( v7 == -425 ) - ret = -6; - } + ret = ( v7 == -418 ) ? -116 : (( v7 >= -417 ) ? (!v7 ? 0 : -5) : ((v7 == -425) ? -6 : -5)); CancelAlarm(uart_timedout, (void *)thid); if ( !ret ) { @@ -403,17 +388,7 @@ static void uart_attr_set(struct uart_softc *uartc, acUartReg uartreg) v3 = 36864000 / (signed int)(16 * uartc->speed); trigger = uartc->fifo; - if ( trigger < 14 ) - { - if ( trigger < 8 ) - v6 = ((trigger >= 4) << 6 & 0xFFFF); - else - v6 = 128; - } - else - { - v6 = 192; - } + v6 = ( trigger < 14 ) ? (( trigger < 8 ) ? ((trigger >= 4) << 6 & 0xFFFF) : 128) : 192; v7 = 16 * (uartc->loopback != 0); uartreg[1] = 0; uartreg[2] = 6; @@ -448,23 +423,7 @@ int acUartSetAttr(const acUartAttrData *attr) fifo = attr->ua_fifo; Uartc.speed = attr->ua_speed; Uartc.loopback = attr->ua_loopback != 0; - if ( fifo < 14 ) - { - if ( fifo < 8 ) - { - fifo_v2 = 4; - if ( fifo < 4 ) - fifo_v2 = 1; - } - else - { - fifo_v2 = 8; - } - } - else - { - fifo_v2 = 14; - } + fifo_v2 = ( fifo < 14 ) ? (( fifo < 8 ) ? (( fifo < 4 ) ? 1 : 4) : 8) : 14; Uartc.fifo = fifo_v2; uart_attr_set(&Uartc, (acUartReg)0xB2418000); return 0; @@ -503,9 +462,7 @@ static int uart_optarg(const char *str, int default_value) char *next; result = strtol(str, &next, 0); - if ( next == str ) - return default_value; - return result; + return ( next == str ) ? default_value : result; } int acUartModuleStart(int argc, char **argv) @@ -524,15 +481,11 @@ int acUartModuleStart(int argc, char **argv) return -16; } Uartc.loopback = 0; - if ( !Uartc.speed ) - Uartc.speed = 9600; - if ( !Uartc.fifo ) - Uartc.fifo = 1; - if ( !Uartc.xmit.ub_size ) - Uartc.xmit.ub_size = 256; + Uartc.speed = ( !Uartc.speed ) ? 9600 : Uartc.speed; + Uartc.fifo = ( !Uartc.fifo ) ? 1 : Uartc.fifo; + Uartc.xmit.ub_size = ( !Uartc.xmit.ub_size ) ? 256 : Uartc.xmit.ub_size; index = 1; - if ( !Uartc.recv.ub_size ) - Uartc.recv.ub_size = 512; + Uartc.recv.ub_size = ( !Uartc.recv.ub_size ) ? 512 : Uartc.recv.ub_size; v7 = argv + 1; while ( index < argc ) { diff --git a/iop/arcade/romwrite/src/romwrite.c b/iop/arcade/romwrite/src/romwrite.c index 72037b208c74..44ea0e2ad91f 100644 --- a/iop/arcade/romwrite/src/romwrite.c +++ b/iop/arcade/romwrite/src/romwrite.c @@ -906,13 +906,7 @@ static int get_nand_partition_offset(int part, int abspart) if ( abspart == -1 && g_device_info->m_block_size == (int)0x80000000 ) __builtin_trap(); } - if ( !part ) - return get_nand_block_size_div_32_div_64(); - if ( abspart ) - return g_device_info->m_block_size / abspart * part; - if ( part != 1 ) - return -1; - return g_device_info->m_block_size / 4; + return ( !part ) ? get_nand_block_size_div_32_div_64() : (abspart ? (g_device_info->m_block_size / abspart * part) : (( part != 1 ) ? -1 : (g_device_info->m_block_size / 4))); } static int get_nand_partition_size(int part, int abspart) @@ -927,9 +921,7 @@ static int get_nand_partition_size(int part, int abspart) __builtin_trap(); return g_device_info->m_block_size / abspart - (part ? 0 : get_nand_block_size_div_32_div_64()); } - if ( part ) - return (part == 1) ? (3 * (g_device_info->m_block_size / 4)) : 0; - return g_device_info->m_block_size / 4 - get_nand_block_size_div_32_div_64(); + return ( part ) ? ((part == 1) ? (3 * (g_device_info->m_block_size / 4)) : 0) : (g_device_info->m_block_size / 4 - get_nand_block_size_div_32_div_64()); } static int get_nand_block_size_div_32_div_64(void) @@ -1054,8 +1046,7 @@ static const nand_id_desc_info_t *do_parse_device_info(const char *nandid) cmpval = 0; for ( j = 0; j < 5; j += 1 ) - if ( ((int)g_nand_type_info[i].m_id[j] == -1) || ((u8)g_nand_type_info[i].m_id[j] == (u8)nandid[j]) ) - cmpval += 1; + cmpval += ( ((int)g_nand_type_info[i].m_id[j] == -1) || ((u8)g_nand_type_info[i].m_id[j] == (u8)nandid[j]) ) ? 1 : 0; if ( cmpval == 5 ) return &g_nand_type_info[i]; } diff --git a/iop/arcade/s147link/src/s147link.c b/iop/arcade/s147link/src/s147link.c index 29bc2ff78bab..f5a13798afd7 100644 --- a/iop/arcade/s147link/src/s147link.c +++ b/iop/arcade/s147link/src/s147link.c @@ -63,14 +63,11 @@ int _start(int argc, char **argv) int priority; maxnode = (argc >= 2) ? strtol(argv[1], 0, 10) : 0; - if ( maxnode < 2 || maxnode >= 16 ) - maxnode = 2; + maxnode = ( maxnode < 2 || maxnode >= 16 ) ? 2 : maxnode; mynode = (argc >= 3) ? strtol(argv[2], 0, 10) : 0; - if ( mynode <= 0 || maxnode < mynode ) - mynode = 1; + mynode = ( mynode <= 0 || maxnode < mynode ) ? 1 : mynode; priority = (argc >= 4) ? strtol(argv[3], 0, 10) : 0; - if ( priority < 9 || priority >= 124 ) - priority = 28; + priority = ( priority < 9 || priority >= 124 ) ? 28 : priority; gbBRE = (argc >= 5 && toupper(*argv[4]) == 'N' && toupper(argv[4][1]) == 'B' && toupper(argv[4][2]) == 'R') ? 0 : 1; printf("== S147LINK (%d/%d)@%d ", mynode, maxnode, priority); if ( !gbBRE ) @@ -92,16 +89,14 @@ static void T_fix(CL_COM *io_pCommon) io_pCommon->T_out = 0; io_pCommon->T_in = io_pCommon->T_out; io_pCommon->rbfix += 1; - if ( !io_pCommon->rbfix ) - io_pCommon->rbfix -= 1; + io_pCommon->rbfix -= ( !io_pCommon->rbfix ) ? 1 : 0; } if ( io_pCommon->T_remain == 0x100 && io_pCommon->T_in != io_pCommon->T_out ) { io_pCommon->T_out = 0; io_pCommon->T_in = io_pCommon->T_out; io_pCommon->rbfix += 1; - if ( !io_pCommon->rbfix ) - io_pCommon->rbfix -= 1; + io_pCommon->rbfix -= ( !io_pCommon->rbfix ) ? 1 : 0; } } @@ -186,8 +181,7 @@ static int clink_InterruptHandler(void *userdata) else if ( io_pCommon->R_pd[i] ) { io_pCommon->R_lost[i] += 1; - if ( !io_pCommon->R_lost[i] ) - io_pCommon->R_lost[i] += 1; + io_pCommon->R_lost[i] += ( !io_pCommon->R_lost[i] ) ? 1 : 0; } else { @@ -226,8 +220,7 @@ static int clink_InterruptHandler(void *userdata) else if ( io_pCommon->R_pd[i] ) { io_pCommon->R_lost[i] += 1; - if ( !io_pCommon->R_lost[i] ) - io_pCommon->R_lost[i] += 1; + io_pCommon->R_lost[i] += ( !io_pCommon->R_lost[i] ) ? 1 : 0; } else { @@ -338,8 +331,7 @@ static int cl_mread(void *dstptr, int count) cl_info.R_out = 0; cl_info.R_in = 0; cl_info.rbfix += 1; - if ( !cl_info.rbfix ) - cl_info.rbfix -= 1; + cl_info.rbfix -= ( !cl_info.rbfix ) ? 1 : 0; count = 0; } if ( cl_info.R_remain == 512 && cl_info.R_in != cl_info.R_out ) @@ -347,8 +339,7 @@ static int cl_mread(void *dstptr, int count) cl_info.R_out = 0; cl_info.R_in = 0; cl_info.rbfix += 1; - if ( !cl_info.rbfix ) - cl_info.rbfix -= 1; + cl_info.rbfix -= ( !cl_info.rbfix ) ? 1 : 0; count = 0; } CpuResumeIntr(state); @@ -782,10 +773,8 @@ static void *dispatch(int fno, void *buf, int size) *(u32 *)buf |= (cl_info.online ? 0x10000 : 0); for ( i = 1; i < cl_info.maxnode; i += 1 ) { - if ( cl_info.T_error[i] ) - *(u32 *)buf |= 0x10000 << i; - if ( cl_info.R_lost[i] ) - *(u32 *)buf |= 0x10000 << i; + *(u32 *)buf |= ( cl_info.T_error[i] ) ? (0x10000 << i) : 0; + *(u32 *)buf |= ( cl_info.R_lost[i] ) ? (0x10000 << i) : 0; } FlushDcache(); return buf; diff --git a/iop/arcade/s147nand/src/s147nand.c b/iop/arcade/s147nand/src/s147nand.c index abe286aa1d35..a7a0c0348e74 100644 --- a/iop/arcade/s147nand/src/s147nand.c +++ b/iop/arcade/s147nand/src/s147nand.c @@ -679,11 +679,7 @@ int s147nand_8_multi_write_dma(void *ptr, int pageoffs, int pagecnt) int s147nand_9_get_nand_partition(int part) { - if ( part == 8 ) - return g_nand_header.m_nand_partition_8_info.m_offset; - if ( part >= 0 && part < 8 ) - return g_nand_header.m_nand_partition_info[part].m_offset; - return 0; + return ( part == 8 ) ? g_nand_header.m_nand_partition_8_info.m_offset : (( part >= 0 && part < 8 ) ? g_nand_header.m_nand_partition_info[part].m_offset : 0); } static int get_nand_partition_offset(int part) @@ -693,11 +689,7 @@ static int get_nand_partition_offset(int part) int s147nand_10_get_nand_partition_size(int part) { - if ( part == 8 ) - return g_nand_header.m_nand_partition_8_info.m_size; - if ( part >= 0 && part < 8 ) - return g_nand_header.m_nand_partition_info[part].m_size; - return 0; + return ( part == 8 ) ? g_nand_header.m_nand_partition_8_info.m_size : (( part >= 0 && part < 8 ) ? g_nand_header.m_nand_partition_info[part].m_size : 0); } static int nand_mdev_open_special(iop_file_t *f, const char *name) @@ -1230,11 +1222,7 @@ static int nand_lowlevel_write_dma(void *ptr, int pageoffs, int byteoffs, int by s147nand_dev9_io_mmio->m_nand_write_cmd_unlock = 0; if ( g_nand_watchdog_enabled == 1 ) s147_dev9_mem_mmio->m_watchdog_flag2 = 0; - if ( (flgtmp & 0x80) == 0 ) - return -1470030; - if ( (flgtmp & 1) != 0 ) - return -1470020; - return 0; + return ( (flgtmp & 0x80) == 0 ) ? -1470030 : (( (flgtmp & 1) != 0 ) ? -1470020 : 0); } static int nand_lowlevel_write_pio(void *ptr, int pageoffs, int byteoffs, int bytecnt) @@ -1269,11 +1257,7 @@ static int nand_lowlevel_write_pio(void *ptr, int pageoffs, int byteoffs, int by s147nand_dev9_io_mmio->m_nand_write_cmd_unlock = 0; if ( g_nand_watchdog_enabled == 1 ) s147_dev9_mem_mmio->m_watchdog_flag2 = 0; - if ( (flgtmp & 0x80) == 0 ) - return -1470030; - if ( (flgtmp & 1) != 0 ) - return -1470020; - return 0; + return ( (flgtmp & 0x80) == 0 ) ? -1470030 : (( (flgtmp & 1) != 0 ) ? -1470020 : 0); } static int nand_lowlevel_blockerase(int pageoffs) @@ -1299,11 +1283,7 @@ static int nand_lowlevel_blockerase(int pageoffs) s147nand_dev9_io_mmio->m_nand_write_cmd_unlock = 0; if ( g_nand_watchdog_enabled == 1 ) s147_dev9_mem_mmio->m_watchdog_flag2 = 0; - if ( (flgtmp & 0x80) == 0 ) - return -1470030; - if ( (flgtmp & 1) != 0 ) - return -1470020; - return 0; + return ( (flgtmp & 0x80) == 0 ) ? -1470030 : (( (flgtmp & 1) != 0 ) ? -1470020 : 0); } static int nand_lowlevel_readid(void *ptr) diff --git a/iop/cdvd/cdfs/src/cdfs_iop.c b/iop/cdvd/cdfs/src/cdfs_iop.c index f2fe9916d735..70995c3dcb6b 100755 --- a/iop/cdvd/cdfs/src/cdfs_iop.c +++ b/iop/cdvd/cdfs/src/cdfs_iop.c @@ -440,10 +440,7 @@ static enum PathMatch comparePath(const char *path) { // if requested path is longer, and next char is a dir seperator // then report sub-dir match - if ((path[length] == '/') || (path[length] == '\\')) - return SUBDIR; - else - return NOT_MATCH; + return ((path[length] == '/') || (path[length] == '\\')) ? SUBDIR : NOT_MATCH; } // Find, and cache, the requested directory, for use by GetDir or (and thus open) @@ -538,9 +535,7 @@ static int cdfs_cacheDir(const char *pathname, enum Cache_getMode getMode) { // then we will need to re-load it before starting search if (cacheInfoDir.cache_offset != 0) { cacheInfoDir.cache_offset = 0; - cacheInfoDir.cache_size = cacheInfoDir.sector_num; - if (cacheInfoDir.cache_size > MAX_DIR_CACHE_SECTORS) - cacheInfoDir.cache_size = MAX_DIR_CACHE_SECTORS; + cacheInfoDir.cache_size = (cacheInfoDir.sector_num > MAX_DIR_CACHE_SECTORS) ? MAX_DIR_CACHE_SECTORS : cacheInfoDir.sector_num; // Now fill the cache with the specified sectors if (!cdfs_readSect(cacheInfoDir.sector_start + cacheInfoDir.cache_offset, cacheInfoDir.cache_size, cacheInfoDir.cache)) { @@ -799,10 +794,7 @@ int cdfs_readSect(u32 lsn, u32 sectors, u8 *buf) { cdReadMode.trycount = 32; for (retry = 0; retry < 32; retry++) { // 32 retries - if (retry <= 8) - cdReadMode.spindlctrl = 1; // Try fast reads for first 8 tries - else - cdReadMode.spindlctrl = 0; // Then try slow reads + cdReadMode.spindlctrl = (retry <= 8) ? 1 /* Try fast reads for first 8 tries */ : 0 /* Then try slow reads */; if (!isValidDisc()) return FALSE; @@ -1040,9 +1032,7 @@ int cdfs_getDir(const char *pathname, struct TocEntry tocEntry[], unsigned int r int cdfs_checkDiskChanged(enum Cdvd_Changed_Index index) { u32 res = 0; sceCdTrayReq(SCECdTrayCheck, &res); - if (res) { - cdvdChangedMagic += 1; - } + cdvdChangedMagic += (res) ? 1 : 0; if (cdvdChangedMagic != cdvdChangedMagicLast[index]) { cdvdChangedMagicLast[index] = cdvdChangedMagic; return TRUE; diff --git a/iop/cdvd/cdvdfsv/src/cdvdfsv.c b/iop/cdvd/cdvdfsv/src/cdvdfsv.c index 808e2505fbf4..45334dd955b4 100644 --- a/iop/cdvd/cdvdfsv/src/cdvdfsv.c +++ b/iop/cdvd/cdvdfsv/src/cdvdfsv.c @@ -286,9 +286,7 @@ static void cdvdfsv_main_th(void *arg) int *cdvdfsv_dummyentry(int arg1) { VERBOSE_PRINTF(1, "Dummy Entry Called\n"); - if ( arg1 != 128 ) - return 0; - return &g_verbose_level; + return ( arg1 != 128 ) ? 0 : &g_verbose_level; } static void cdvdfsv_parseargs(int ac, char **av) @@ -1477,11 +1475,9 @@ static void cdvdfsv_rpc5_03_readdvdv(const cdvdfsv_rpc5_inpacket_t *inbuf, int b buf_align_remain = buf_1_toalign - buf_aligned; buf_offs_mod_sector_size = (buf_aligned - inbuf->m_pkt_03.m_buf) % 0x810; sector_count_in_bytes = (0x8100 >= buf_align_remain) ? buf_align_remain : 0x8100; - sectors = (0x8100 >= buf_align_remain) ? (buf_align_remain / 0x810 + (!!(buf_align_remain % 0x810))) : 16; - sectors += !!buf_offs_mod_sector_size; lbn = inbuf->m_pkt_03.m_lbn + (buf_aligned - inbuf->m_pkt_03.m_buf) / 0x810; - if ( sectors > (inbuf->m_pkt_03.m_lbn + inbuf->m_pkt_03.m_nsectors) - lbn ) - sectors = (inbuf->m_pkt_03.m_lbn + inbuf->m_pkt_03.m_nsectors) - lbn; + sectors = ((0x8100 >= buf_align_remain) ? (buf_align_remain / 0x810 + (!!(buf_align_remain % 0x810))) : 16) + (!!buf_offs_mod_sector_size); + sectors = ( sectors > (inbuf->m_pkt_03.m_lbn + inbuf->m_pkt_03.m_nsectors) - lbn ) ? ((inbuf->m_pkt_03.m_lbn + inbuf->m_pkt_03.m_nsectors) - lbn) : sectors; cmd_error = sceCdReadDVDV(lbn, sectors, g_cdvdfsv_fsvrbuf[readbuf], (sceCdRMode *)&inbuf->m_pkt_03.m_mode); if ( firstflag ) { diff --git a/iop/cdvd/cdvdman/src/cdvdman.c b/iop/cdvd/cdvdman/src/cdvdman.c index b3fb46de2e4c..1e216ca5e815 100644 --- a/iop/cdvd/cdvdman/src/cdvdman.c +++ b/iop/cdvd/cdvdman/src/cdvdman.c @@ -1110,10 +1110,7 @@ static int cdrom_internal_write_cache(const iop_file_t *f, unsigned int nbytes) return -EBUSY; } fh = &g_cdvdman_fhinfo[(uiptr)f->privdata]; - if ( nbytes > fh->m_file_size - fh->m_read_pos ) - { - nbytes = fh->m_file_size - fh->m_read_pos; - } + nbytes = ( nbytes > fh->m_file_size - fh->m_read_pos ) ? fh->m_file_size - fh->m_read_pos : nbytes; if ( !nbytes ) { return 0; @@ -1358,10 +1355,7 @@ static int cdrom_open(iop_file_t *f, const char *name, int mode, int arg4) if ( g_cache_path_fd != -1 ) { devready_tmp = cdvd_odcinit(fh, 1, (int)f->privdata); - if ( devready_tmp >= 0 ) - { - fh->m_fd_flags |= 4; - } + fh->m_fd_flags |= ( devready_tmp >= 0 ) ? 4 : 0; } } if ( devready_tmp < 0 ) @@ -1518,10 +1512,7 @@ static int cdrom_internal_read(const iop_file_t *f, char *addr, int nbytes) } } buf = g_cdvdman_temp_buffer_ptr; - if ( (unsigned int)(sectors) > filesize_bsr_11 - lbn ) - { - sectors = filesize_bsr_11 - lbn; - } + sectors = ( (unsigned int)(sectors) > filesize_bsr_11 - lbn ) ? (filesize_bsr_11 - lbn) : sectors; VERBOSE_PRINTF(1, "sce_Read LBN= %d sectors= %d\n", (int)lbn, (int)sectors); if ( g_cdvdman_iocache && (lbn >= g_cdvdman_lcn_offset) @@ -1532,10 +1523,7 @@ static int cdrom_internal_read(const iop_file_t *f, char *addr, int nbytes) else if ( ((uiptr)(addr + i) & 3) || pos_extra || (nbytes_segment != 0x4000) ) { sec = (sectors >= 8) ? sectors : 8; - if ( sec > filesize_bsr_11 - lbn ) - { - sec = filesize_bsr_11 - lbn; - } + sec = ( sec > filesize_bsr_11 - lbn ) ? (filesize_bsr_11 - lbn) : sec; VERBOSE_PRINTF(1, "FIO Cache LSN:%d SEC:%d ADDR:%08x\n", (int)lbn, (int)sec, (unsigned int)(uiptr)buf); sectors_count = (sec >= 9) ? (sec - 8) : 0; if ( sectors_count ) @@ -2368,10 +2356,7 @@ int sceCdStatus(void) if ( !g_cdvdman_istruct.m_tray_is_open && cdvdman_scmd_sender_03_30(&rdata_tmp, &status_tmp) == 1 && !status_tmp ) { reg_00A_tmp &= ~SCECdStatShellOpen; - if ( (rdata_tmp & 8) ) - { - reg_00A_tmp |= SCECdStatShellOpen; - } + reg_00A_tmp |= ( (rdata_tmp & 8) ) ? SCECdStatShellOpen : 0; } if ( (reg_00A_tmp & 0x1E) ) { @@ -2383,11 +2368,7 @@ int sceCdStatus(void) { reg_00A_tmp &= ~SCECdStatShellOpen; } - if ( g_cdvdman_istruct.m_power_flag ) - { - return -1; - } - return reg_00A_tmp; + return ( g_cdvdman_istruct.m_power_flag ) ? -1 : reg_00A_tmp; } #ifdef CDVD_VARIANT_OSD @@ -3766,14 +3747,7 @@ static int get_cdvd_register(int regnr) { if ( g_cd_atapi_evfid != -1 ) { - if ( IntrContext ) - { - iReferEventFlagStatus(g_cd_atapi_evfid, &efinfo); - } - else - { - ReferEventFlagStatus(g_cd_atapi_evfid, &efinfo); - } + (IntrContext ? iReferEventFlagStatus : ReferEventFlagStatus)(g_cd_atapi_evfid, &efinfo); if ( !(efinfo.currBits & 3) ) { return -1; @@ -3781,14 +3755,7 @@ static int get_cdvd_register(int regnr) } if ( g_adma_evfid != -1 ) { - if ( IntrContext ) - { - iReferEventFlagStatus(g_adma_evfid, &efinfo); - } - else - { - ReferEventFlagStatus(g_adma_evfid, &efinfo); - } + (IntrContext ? iReferEventFlagStatus : ReferEventFlagStatus)(g_adma_evfid, &efinfo); if ( !(efinfo.currBits & 1) ) { return -1; @@ -3796,14 +3763,7 @@ static int get_cdvd_register(int regnr) } if ( g_acmd_evfid != -1 ) { - if ( IntrContext ) - { - iReferEventFlagStatus(g_acmd_evfid, &efinfo); - } - else - { - ReferEventFlagStatus(g_acmd_evfid, &efinfo); - } + (IntrContext ? iReferEventFlagStatus : ReferEventFlagStatus)(g_acmd_evfid, &efinfo); } if ( !(efinfo.currBits & 1) ) { @@ -6056,14 +6016,7 @@ cdvdman_send_ncmd(int ncmd, const void *ndata, int ndlen, int func, cdvdman_dma3 g_cdvdman_istruct.m_last_error = SCECdErNO; g_cdvdman_istruct.m_wait_flag = 0; g_cdvdman_istruct.m_thread_id = GetThreadId(); - if ( QueryIntrContext() ) - { - iClearEventFlag(g_cdvdman_intr_evfid, ~1); - } - else - { - ClearEventFlag(g_cdvdman_intr_evfid, ~1); - } + (QueryIntrContext() ? iClearEventFlag : ClearEventFlag)(g_cdvdman_intr_evfid, ~1); for ( i = 0; i < ndlen; i += 1 ) { dev5_mmio_hwport->m_dev5_reg_005 = ((u8 *)ndata)[i]; @@ -6389,23 +6342,7 @@ u32 sceCdGetReadPos(void) sector_sizes[0] = 0x800; sector_sizes[1] = 0x918; sector_sizes[2] = 0x924; - if ( g_cdvdman_istruct.m_recover_status && g_cdvdman_istruct.m_recover_status != 3 ) - { - return 0; - } - if ( g_cdvdman_cmdfunc == SCECdFuncReadCDDA || g_cdvdman_cmdfunc == 12 ) - { - return dmac_ch_get_madr(3) - (uiptr)g_cdvdman_readbuf; - } - if ( g_cdvdman_istruct.m_read2_flag ) - { - return g_cdvdman_readptr * sector_sizes[g_cdvdman_istruct.m_cdvdman_pattern]; - } - if ( g_cdvdman_cmdfunc == SCECdFuncRead ) - { - return dmac_ch_get_madr(3) - (uiptr)g_cdvdman_readbuf; - } - return 0; + return ( g_cdvdman_istruct.m_recover_status && g_cdvdman_istruct.m_recover_status != 3 ) ? 0 : (( g_cdvdman_cmdfunc == SCECdFuncReadCDDA || g_cdvdman_cmdfunc == 12 ) ? (dmac_ch_get_madr(3) - (uiptr)g_cdvdman_readbuf) : (( g_cdvdman_istruct.m_read2_flag ) ? (g_cdvdman_readptr * sector_sizes[g_cdvdman_istruct.m_cdvdman_pattern]) : (( g_cdvdman_cmdfunc == SCECdFuncRead ) ? (dmac_ch_get_madr(3) - (uiptr)g_cdvdman_readbuf) : 0))); } static int cdvdman_speedctl(u32 spindlctrl, int dvdflag, u32 maxlsn) diff --git a/iop/cdvd/xatapi/src/xatapi.c b/iop/cdvd/xatapi/src/xatapi.c index 2959509127a5..eddf9acb168a 100644 --- a/iop/cdvd/xatapi/src/xatapi.c +++ b/iop/cdvd/xatapi/src/xatapi.c @@ -1051,8 +1051,7 @@ static int xatapi_dev_devctl( break; case 0x4335: retres1 = sceCdAtapi_BC(); - if ( retres1 == 1 ) - retres1 = 0; + retres1 = ( retres1 == 1 ) ? 0 : retres1; break; case 0x4336: retres1 = sceCdAtapi_SC(); @@ -1554,10 +1553,7 @@ void xatapi_10_sceCdSpdAtaDmaEnd(void) dev5_speed_regs->r_spd_if_ctrl |= 0x80; dev5_speed_regs->r_spd_if_ctrl &= ~0x84; ata_pio_mode(0); - if ( g_dma_mode_value ) - ata_ultra_dma_mode(g_dma_speed_value); - else - ata_multiword_dma_mode(g_dma_speed_value); + (g_dma_mode_value ? ata_ultra_dma_mode : ata_multiword_dma_mode)(g_dma_speed_value); g_should_wait_for_dma_flag = 0; SetEventFlag(g_adma_evfid, 1); } @@ -3553,10 +3549,7 @@ static int Mpeg2CheckPadding(char *buf, unsigned int bufsize, int *retptr, int * { if ( !bufoffs1[15] && bufoffs1[16] == 1 && (u8)bufoffs1[17] == 0xBB ) bufoffs2 = bufoffs1 + 38; - if ( !*bufoffs2 && !bufoffs2[1] && bufoffs2[2] == 1 && (u8)bufoffs2[3] != 0xBF && (bufoffs2[6] & 0x60) ) - { - *pesscramblingpackptr += 1; - } + *pesscramblingpackptr += ( !*bufoffs2 && !bufoffs2[1] && bufoffs2[2] == 1 && (u8)bufoffs2[3] != 0xBF && (bufoffs2[6] & 0x60) ) ? 1 : 0; } } } diff --git a/iop/cdvd/xesdrv/src/xesdrv.c b/iop/cdvd/xesdrv/src/xesdrv.c index 3a1790cecab6..1c2f542d7221 100644 --- a/iop/cdvd/xesdrv/src/xesdrv.c +++ b/iop/cdvd/xesdrv/src/xesdrv.c @@ -262,10 +262,7 @@ IRX_ID(MODNAME, 1, 1); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if ( argc >= 0 ) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return (( argc >= 0 ) ? module_start : module_stop)(argc, argv, startaddr, mi); } static int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -292,9 +289,7 @@ static int module_stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi (void)startaddr; (void)mi; - if ( iomanX_DelDrv(ESDRV.name) != 0 ) - return MODULE_REMOVABLE_END; - return MODULE_NO_RESIDENT_END; + return ( iomanX_DelDrv(ESDRV.name) != 0 ) ? MODULE_REMOVABLE_END : MODULE_NO_RESIDENT_END; } static int esdrv_df_init(iomanX_iop_device_t *dev) @@ -319,9 +314,7 @@ static int esdrv_df_exit(iomanX_iop_device_t *dev) { (void)dev; - if ( DeleteSema(sema_id) != 0 ) - return -1; - return 0; + return ( DeleteSema(sema_id) != 0 ) ? -1 : 0; } static int esdrv_df_ioctl(iomanX_iop_file_t *f, int cmd, void *param) @@ -1168,23 +1161,7 @@ static void EsAcsSetReg(u8 a1, u8 a2) static u8 EsDrvNnResultCheck(void) { - if ( EsAcsIsNnInvalid() != 0 ) - { - return 4; - } - if ( EsAcsIsNnRevoked() != 0 ) - { - return 3; - } - if ( EsAcsIsNnReplaced() != 0 ) - { - return 2; - } - if ( EsAcsIsNnComplete() != 0 ) - { - return 1; - } - return 0; + return ( EsAcsIsNnInvalid() != 0 ) ? 4 : (( EsAcsIsNnRevoked() != 0 ) ? 3 : (( EsAcsIsNnReplaced() != 0 ) ? 2 : (( EsAcsIsNnComplete() != 0 ) ? 1 : 0))); } static void EsDrvSoftReset(void) @@ -1266,9 +1243,7 @@ static void EsDrvCmpltInitProcess(void) static u8 EsDrvRndNnCheck(void) { - if ( EsAcsIsBbStatusIdle() == 0 ) - return -1; - return 0; + return ( EsAcsIsBbStatusIdle() == 0 ) ? -1 : 0; } static u8 EsDrvRandom(void) @@ -1635,11 +1610,7 @@ esioctl2_func_5(iomanX_iop_file_t *f, int cmd, void *arg, unsigned int arglen, v (void)buf; (void)buflen; - if ( EsDrvRndNnCheck() ) - return -EINTR; - if ( EsDrvRandom() != 0 ) - return -EIO; - return 0; + return ( EsDrvRndNnCheck() ) ? -EINTR : (( EsDrvRandom() != 0 ) ? -EIO : 0); } static int @@ -1764,9 +1735,7 @@ esioctl2_func_c(iomanX_iop_file_t *f, int cmd, void *arg, unsigned int arglen, v (void)buf; (void)buflen; - if ( EsDrvAaStop() != 0 ) - return -ECHILD; - return 0; + return ( EsDrvAaStop() != 0 ) ? -ECHILD : 0; } static int @@ -1807,7 +1776,5 @@ esioctl2_func_f(iomanX_iop_file_t *f, int cmd, void *arg, unsigned int arglen, v (void)buf; (void)buflen; - if ( EsDrvBbStop() != 0 ) - return -ECHILD; - return 0; + return ( EsDrvBbStop() != 0 ) ? -ECHILD : 0; } diff --git a/iop/debug/iop_sbusdbg/src/main.c b/iop/debug/iop_sbusdbg/src/main.c index 684199fa7887..019fa70bceaf 100644 --- a/iop/debug/iop_sbusdbg/src/main.c +++ b/iop/debug/iop_sbusdbg/src/main.c @@ -20,14 +20,7 @@ void _iop_ex_handler(IOP_RegFrame *frame) { int excode = M_IOP_GET_CAUSE_EXCODE(frame->cause); - if(excode == IOP_EXCEPTION_HDB) - { - _iop_exception_state = 2; - } - else - { - _iop_exception_state = 1; - } + _iop_exception_state = (excode == IOP_EXCEPTION_HDB) ? 2 : 1; _iop_controlled = 1; diff --git a/iop/debug/iop_sbusdbg/src/sbus_dbg.c b/iop/debug/iop_sbusdbg/src/sbus_dbg.c index 6b6db88251a4..e99e3bf13969 100644 --- a/iop/debug/iop_sbusdbg/src/sbus_dbg.c +++ b/iop/debug/iop_sbusdbg/src/sbus_dbg.c @@ -62,8 +62,7 @@ void _sif2_cmd_dbg_control(SIF2_CmdPkt *cmd, void *param) if(_iop_exception_state == 0) { return; } - if(_iop_exception_state == 1) { frame = _iop_ex_def_frame; } - else { frame = _iop_ex_dbg_frame; } + frame = (_iop_exception_state == 1) ? _iop_ex_def_frame : _iop_ex_dbg_frame; // update the register frame and release the CPU. memcpy(frame, ¶ms->reg_frame, sizeof(IOP_RegFrame)); diff --git a/iop/debug/iop_sbusdbg/src/sbus_tty.c b/iop/debug/iop_sbusdbg/src/sbus_tty.c index 514a921e3b51..6feebc9bfed1 100644 --- a/iop/debug/iop_sbusdbg/src/sbus_tty.c +++ b/iop/debug/iop_sbusdbg/src/sbus_tty.c @@ -80,9 +80,7 @@ static int ttyfs_write(iop_file_t *file, void *ptr, int size) { { int toWrite; - toWrite = (size - bCount); - if(toWrite > 64) - toWrite = 64; + toWrite = ((size - bCount) > 64) ? 64 : (size - bCount); memcpy(temp, &(((u8 *)ptr)[bCount]), toWrite); temp[toWrite] = '\0'; diff --git a/iop/debug/ioptrap/src/ioptrap.c b/iop/debug/ioptrap/src/ioptrap.c index bc680eb8b4a3..77660d81dc2c 100644 --- a/iop/debug/ioptrap/src/ioptrap.c +++ b/iop/debug/ioptrap/src/ioptrap.c @@ -64,11 +64,7 @@ jmp_buf dbg_jmp_buf; exception_type_t dbg_setjmp() { int v; - if (0 == (v = setjmp(dbg_jmp_buf))) { - dbg_jmp_buf_setup = 1; - } else { - dbg_jmp_buf_setup = 0; - } + dbg_jmp_buf_setup = (0 == (v = setjmp(dbg_jmp_buf))) ? 1 : 0; return v; } @@ -98,15 +94,7 @@ typedef struct _smod_mod_info smod_mod_info_t *smod_get_next_mod(smod_mod_info_t *cur_mod) { /* If cur_mod is 0, return the head of the list (IOP address 0x800). */ - if (!cur_mod) { - return (smod_mod_info_t *)0x800; - } else { - if (!cur_mod->next) - return 0; - else - return cur_mod->next; - } - return 0; + return (!cur_mod) ? ((smod_mod_info_t *)0x800) : ((!cur_mod->next) ? 0 : cur_mod->next); } char *ExceptionGetModuleName(u32 epc, u32 *r_epc) diff --git a/iop/debug/ppctty/src/tty.c b/iop/debug/ppctty/src/tty.c index 00d35d7c31c7..eb25a2dcbef4 100644 --- a/iop/debug/ppctty/src/tty.c +++ b/iop/debug/ppctty/src/tty.c @@ -59,9 +59,7 @@ static int ttyfs_write(iop_file_t *file, void *ptr, int size) { { int toWrite; - toWrite = (size - bCount); - if(toWrite > 64) - toWrite = 64; + toWrite = ((size - bCount) > 64) ? 64 : (size - bCount); memcpy(temp, &(((u8 *)ptr)[bCount]), toWrite); temp[toWrite] = '\0'; diff --git a/iop/debug/thmon/src/thmon.c b/iop/debug/thmon/src/thmon.c index 37d75799309b..da5c971cef23 100644 --- a/iop/debug/thmon/src/thmon.c +++ b/iop/debug/thmon/src/thmon.c @@ -444,9 +444,8 @@ static void do_rtlist_handle_priority(int is_flag_v_or_c, int int_value) curelem1 = g_rtlist_nondormant; list_for_each (thread, &g_ThbaseInternal->thread_list, thread_list) { - curelem1->m_thread_ptr = 0; - if (thread->status != 16) { - curelem1->m_thread_ptr = thread; + curelem1->m_thread_ptr = (thread->status != 16) ? thread : 0; + if (curelem1->m_thread_ptr) { curelem1->m_thread_id = thread->tag.id; curelem1->m_old_clocks.hi = thread->run_clocks_hi; curelem1->m_old_clocks.lo = thread->run_clocks_lo; @@ -522,10 +521,8 @@ static void rtlist_cmd_handler(char *cmdparam) *EndOfString = 0; EndOfString = RemoveLeadingWhitespaces(EndOfString + 1); } - if (!strcmp(cmdparam_cur, "-v")) - is_flag_v_or_c |= 1u; - if (!strcmp(cmdparam_cur, "-c")) - is_flag_v_or_c |= 2u; + is_flag_v_or_c |= (!strcmp(cmdparam_cur, "-v")) ? 1u : 0; + is_flag_v_or_c |= (!strcmp(cmdparam_cur, "-c")) ? 2u : 0; if (*cmdparam_cur != '-') int_value = strtol(cmdparam_cur, 0, 10); } diff --git a/iop/dev9/atad/src/ps2atad.c b/iop/dev9/atad/src/ps2atad.c index 757aa93b6487..81b61fda803b 100644 --- a/iop/dev9/atad/src/ps2atad.c +++ b/iop/dev9/atad/src/ps2atad.c @@ -311,11 +311,9 @@ int _start(int argc, char *argv[]) Official adaptors appear to have a 0x0001 set for this register, but not compatibles. While official I/O to this register are 8-bit, some compatibles have a 0x01 for the lower 8-bits, but the upper 8-bits contain some random value. Hence perform a 16-bit read instead. */ - if (SPD_REG16(0x20) != 1) { - ata_gamestar_workaround = 1; + ata_gamestar_workaround = (SPD_REG16(0x20) != 1) ? 1 : 0; + if (ata_gamestar_workaround) { M_PRINTF("Compatible adaptor detected.\n"); - } else { - ata_gamestar_workaround = 0; } #endif #endif @@ -917,9 +915,7 @@ static int ata_device_pkt_identify(int device, void *info) int res; res = sceAtaExecCmd(info, 1, 0, 0, 0, 0, 0, (device << 4) & 0xffff, ATA_C_IDENTIFY_PACKET_DEVICE); - if (!res) - return sceAtaWaitResult(); - return res; + return (!res) ? sceAtaWaitResult() : res; } /* Export 14 */ @@ -1289,11 +1285,7 @@ static int ata_init_devices(ata_devinfo_t *devinfo) /* Save the total sector counts before we overwrite ata_param with the value of Sony identify drive command. */ total_sectors_nonlba48 = (ata_param[ATA_ID_SECTOTAL_HI] << 16) | ata_param[ATA_ID_SECTOTAL_LO]; - if (ata_param[ATA_ID_48BIT_SECTOTAL_HI]) { - total_sectors_lba48 = 0xffffffff; - } else { - total_sectors_lba48 = (ata_param[ATA_ID_48BIT_SECTOTAL_MI] << 16) | ata_param[ATA_ID_48BIT_SECTOTAL_LO]; - } + total_sectors_lba48 = (ata_param[ATA_ID_48BIT_SECTOTAL_HI]) ? 0xffffffff : ((ata_param[ATA_ID_48BIT_SECTOTAL_MI] << 16) | ata_param[ATA_ID_48BIT_SECTOTAL_LO]); devinfo[i].security_status = ata_param[ATA_ID_SECURITY_STATUS]; @@ -1323,18 +1315,9 @@ static int ata_init_devices(ata_devinfo_t *devinfo) /* Set standby timer to 21min 15s. */ sceAtaIdle(i, 0xff); - if (devinfo[i].lba48) { - /* If this device is emulated through the DVRP, use the non-48-bit LBA size. */ - if (ata_dvrp_workaround) { - devinfo[i].total_sectors = total_sectors_nonlba48; - } else { - devinfo[i].total_sectors = total_sectors_lba48; - } - devinfo[i].total_sectors_lba48 = total_sectors_lba48; - } else { - devinfo[i].total_sectors = total_sectors_nonlba48; - devinfo[i].total_sectors_lba48 = total_sectors_nonlba48; - } + /* If this device is emulated through the DVRP, use the non-48-bit LBA size. */ + devinfo[i].total_sectors = devinfo[i].lba48 ? (ata_dvrp_workaround ? total_sectors_nonlba48 : total_sectors_lba48) : total_sectors_nonlba48; + devinfo[i].total_sectors_lba48 = devinfo[i].lba48 ? total_sectors_lba48 : total_sectors_nonlba48; /* Call the proprietary identify command. */ #ifdef ATA_SCE_AUTH_HDD diff --git a/iop/dev9/dev9/src/ps2dev9.c b/iop/dev9/dev9/src/ps2dev9.c index dc4f142b05dc..9f992fc45aaf 100644 --- a/iop/dev9/dev9/src/ps2dev9.c +++ b/iop/dev9/dev9/src/ps2dev9.c @@ -539,8 +539,7 @@ static int read_eeprom_data(void) SPD_REG8(SPD_R_PIO_DATA) = 0xc0; DelayThread(1); val = SPD_REG8(SPD_R_PIO_DATA); - if (val & 0x10) - eeprom_data[i + 1] |= (1 << j); + eeprom_data[i + 1] |= (val & 0x10) ? (1 << j) : 0; SPD_REG8(SPD_R_PIO_DATA) = 0x80; DelayThread(1); } @@ -719,12 +718,9 @@ static int dev9_smap_read_phy(volatile u8 *emac3_regbase, unsigned int address, i++; } while (i < 100); - if (i >= 100) { - return 1; - } else { + if (i < 100) *data = result; - return 0; - } + return (i >= 100) ? 1 : 0; } static int dev9_smap_write_phy(volatile u8 *emac3_regbase, unsigned char address, unsigned short int value) @@ -918,11 +914,7 @@ static int speed_device_init(void) /* Print out the SPEED chip revision. */ spdrev = SPD_REG16(SPD_R_REV_1); - idx = (spdrev & 0xffff) - 14; - if (spdrev == 9) - idx = 1; /* TS */ - else if (spdrev < 9 || (spdrev < 16 || spdrev > 17)) - idx = 0; /* Unknown revision */ + idx = (spdrev == 9) ? 1 /* TS */ : ((spdrev < 9 || (spdrev < 16 || spdrev > 17)) ? 0 /* Unknown revision */ : ((spdrev & 0xffff) - 14)); M_PRINTF("SPEED chip '%s', revision %0x\n", spdnames[idx], spdrev); return 0; @@ -933,11 +925,7 @@ static int pcic_get_cardtype(void) USE_DEV9_REGS; u16 val = DEV9_REG(DEV9_R_1462) & 0x03; - if (val == 0) - return PC_CARD_TYPE_PCMCIA; /* 16-bit */ - else if (val < 3) // If the bit pattern is either 10b or 01b - return PC_CARD_TYPE_CARDBUS; /* CardBus */ - return PC_CARD_TYPE_NONE; + return (val == 0) ? PC_CARD_TYPE_PCMCIA /* 16-bit */ : ((val < 3) /* If the bit pattern is either 10b or 01b */ ? PC_CARD_TYPE_CARDBUS : PC_CARD_TYPE_NONE); } static int pcic_get_voltage(void) @@ -945,13 +933,7 @@ static int pcic_get_voltage(void) USE_DEV9_REGS; u16 val = DEV9_REG(DEV9_R_1462) & 0x0c; - if (val == 0x04) - return PC_CARD_VOLTAGE_04h; - if (val == 0 || val == 0x08) - return PC_CARD_VOLTAGE_3V; - if (val == 0x0c) - return PC_CARD_VOLTAGE_5V; - return PC_CARD_VOLTAGE_INVALID; + return (val == 0x04) ? PC_CARD_VOLTAGE_04h : ((val == 0 || val == 0x08) ? PC_CARD_VOLTAGE_3V : ((val == 0x0c) ? PC_CARD_VOLTAGE_5V : PC_CARD_VOLTAGE_INVALID)); } static int pcic_power(int voltage, int flag) @@ -962,10 +944,8 @@ static int pcic_power(int voltage, int flag) DEV9_REG(DEV9_R_POWER) = 0; - if (voltage == 2) - val |= 0x08; - if (flag == 1) - val |= 0x10; + val |= (voltage == 2) ? 0x08 : 0; + val |= (flag == 1) ? 0x10 : 0; DEV9_REG(DEV9_R_POWER) = val; DelayThread(22000); @@ -986,22 +966,14 @@ static void pcmcia_set_stat(int stat) if (stat & 0x10) val = 1; - if (stat & 0x02) - val |= 0x02; - if (stat & 0x20) - val |= 0x02; - if (stat & 0x04) - val |= 0x08; - if (stat & 0x08) - val |= 0x10; - if (stat & 0x200) - val |= 0x20; - if (stat & 0x100) - val |= 0x40; - if (stat & 0x400) - val |= 0x80; - if (stat & 0x800) - val |= 0x04; + val |= (stat & 0x02) ? 0x02 : 0; + val |= (stat & 0x20) ? 0x02 : 0; + val |= (stat & 0x04) ? 0x08 : 0; + val |= (stat & 0x08) ? 0x10 : 0; + val |= (stat & 0x200) ? 0x20 : 0; + val |= (stat & 0x100) ? 0x40 : 0; + val |= (stat & 0x400) ? 0x80 : 0; + val |= (stat & 0x800) ? 0x04 : 0; DEV9_REG(DEV9_R_1476) = val & 0xff; } diff --git a/iop/dev9/extflash/src/extflash.c b/iop/dev9/extflash/src/extflash.c index 481cb0306c83..3116c0461029 100644 --- a/iop/dev9/extflash/src/extflash.c +++ b/iop/dev9/extflash/src/extflash.c @@ -251,13 +251,8 @@ int flash_page_read(flash_info_t *info, u32 page, u32 count, void *buf) SPD_REG16(0x480c) = func; - if (info->page_bytes == 16) { - SPD_REG16(0x4804) = SM_CMD_READ3; - byteofs = pageofs & 0x0f; - } else { - SPD_REG16(0x4804) = SM_CMD_READ1; - byteofs = pageofs & 0x1ff; - } + SPD_REG16(0x4804) = (info->page_bytes == 16) ? SM_CMD_READ3 : SM_CMD_READ1; + byteofs = pageofs & ((info->page_bytes == 16) ? 0x0f : 0x1ff); SPD_REG16(0x4808) = (byteofs & 0xff) | 0x100; /* Set the rest of the page info. */ diff --git a/iop/dev9/hdpro_atad/src/hdproatad.c b/iop/dev9/hdpro_atad/src/hdproatad.c index 52ea032c447d..3d45bc78480e 100644 --- a/iop/dev9/hdpro_atad/src/hdproatad.c +++ b/iop/dev9/hdpro_atad/src/hdproatad.c @@ -825,21 +825,9 @@ static int ata_init_devices(ata_devinfo_t *devinfo) /* This section is to detect whether the HDD supports 48-bit LBA (IDENITFY DEVICE bit 10 word 83) and get the total sectors from either words(61:60) for 28-bit or words(103:100) for 48-bit. */ - if (ata_param[ATA_ID_COMMAND_SETS_SUPPORTED] & 0x0400) { - atad_devinfo[i].lba48 = 1; - /* I don't think anyone would use a >2TB HDD but just in case. */ - if (ata_param[ATA_ID_48BIT_SECTOTAL_HI]) { - devinfo[i].total_sectors = 0xffffffff; - } else { - devinfo[i].total_sectors = - (ata_param[ATA_ID_48BIT_SECTOTAL_MI] << 16) | - ata_param[ATA_ID_48BIT_SECTOTAL_LO]; - } - } else { - atad_devinfo[i].lba48 = 0; - devinfo[i].total_sectors = (ata_param[ATA_ID_SECTOTAL_HI] << 16) | - ata_param[ATA_ID_SECTOTAL_LO]; - } + atad_devinfo[i].lba48 = (ata_param[ATA_ID_COMMAND_SETS_SUPPORTED] & 0x0400) ? 1 : 0; + /* I don't think anyone would use a >2TB HDD but just in case. */ + devinfo[i].total_sectors = atad_devinfo[i].lba48 ? (ata_param[ATA_ID_48BIT_SECTOTAL_HI] ? 0xffffffff : ((ata_param[ATA_ID_48BIT_SECTOTAL_MI] << 16) | ata_param[ATA_ID_48BIT_SECTOTAL_LO])) : ((ata_param[ATA_ID_SECTOTAL_HI] << 16) | ata_param[ATA_ID_SECTOTAL_LO]); devinfo[i].security_status = ata_param[ATA_ID_SECURITY_STATUS]; /* PIO mode 0 (flow control). */ diff --git a/iop/dev9/poweroff/src/poweroff.c b/iop/dev9/poweroff/src/poweroff.c index 88deeec73ca8..096463b7662f 100644 --- a/iop/dev9/poweroff/src/poweroff.c +++ b/iop/dev9/poweroff/src/poweroff.c @@ -216,10 +216,7 @@ void* poweroff_rpc_server(int fno, void *data, int size) InitPowerOffThread(); int* sbuff = data; - if (sbuff[0]) - SetPowerButtonHandler(Shutdown, 0); - else - SetPowerButtonHandler(SendCmd, 0); + SetPowerButtonHandler(sbuff[0] ? Shutdown : SendCmd, 0); sbuff[0] = 1; return sbuff; } diff --git a/iop/dev9/pvrdrv/src/dvrdrv.c b/iop/dev9/pvrdrv/src/dvrdrv.c index 06daa21bbc9b..9ee5b9a971c9 100644 --- a/iop/dev9/pvrdrv/src/dvrdrv.c +++ b/iop/dev9/pvrdrv/src/dvrdrv.c @@ -95,10 +95,7 @@ struct_itr_sema itr_sema_table[32]; int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return ((argc >= 0) ? module_start : module_stop)(argc, argv, startaddr, mi); } int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -128,9 +125,7 @@ int module_stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) (void)mi; ReleaseLibraryEntries(&_exp_pvrdrv); - if (DvrdrvEnd() != 0) - return MODULE_REMOVABLE_END; - return MODULE_NO_RESIDENT_END; + return (DvrdrvEnd() != 0) ? MODULE_REMOVABLE_END : MODULE_NO_RESIDENT_END; } int DvrdrvInit() @@ -310,9 +305,7 @@ int DvrdrvSendCmdAck(struct_itr_sema *itrsema, u16 command, u16 *input_word, s32 } } } - v25 = 64; - if ((SPD_REG16(0x4228) & 1) == 0) - v25 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2; + v25 = ((SPD_REG16(0x4228) & 1) == 0) ? ((u8)(SPD_REG16(0x4228) & 0xFC) >> 2) : 64; *status_4228 = v25; for (i = 0; (u32)i < *status_4228; ++ack_status) { ++i; @@ -472,10 +465,7 @@ int DvrdrvWaitDmaEnd(struct_itr_sema *itrsema, u16 command) int v7; v5 = 0; - if ((SPD_REG16(0x4228) & 1) != 0) - v6 = 64; - else - v6 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2; + v6 = ((SPD_REG16(0x4228) & 1) != 0) ? 64 : ((u8)(SPD_REG16(0x4228) & 0xFC) >> 2); v7 = 0; if (v6) { char *v8; @@ -558,10 +548,7 @@ int DvrdrvWaitCmdComp(struct_itr_sema *itrsema, u16 command, u16 *status_4220, u if ((v10 & 4) != 0) { int v11; v9 = 0; - if ((SPD_REG16(0x4228) & 1) != 0) - v11 = 64; - else - v11 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2; + v11 = ((SPD_REG16(0x4228) & 1) != 0) ? 64 : ((u8)(SPD_REG16(0x4228) & 0xFC) >> 2); *status_4228 = v11; v12 = 0; if (*status_4228 > 0) { @@ -759,9 +746,7 @@ void INTR_CMD_ACK_HANDLER(int a1, void *a2) Kprintf("ACK:GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220)); Kprintf("Clear \"Reply FIFO\"\n"); - v3 = 64; - if ((SPD_REG16(0x4228) & 1) == 0) - v3 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2; + v3 = ((SPD_REG16(0x4228) & 1) == 0) ? ((u8)(SPD_REG16(0x4228) & 0xFC) >> 2) : 64; v4 = 0; if (v3) { char *v5; @@ -817,9 +802,7 @@ void INTR_CMD_COMP_HANDLER(int a1, void *a2) Kprintf("COMP:GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220)); Kprintf("Clear \"Reply FIFO\"\n"); - v3 = 64; - if ((SPD_REG16(0x4228) & 1) == 0) - v3 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2; + v3 = ((SPD_REG16(0x4228) & 1) == 0) ? ((u8)(SPD_REG16(0x4228) & 0xFC) >> 2) : 64; v4 = 0; if (v3) { char *v5; @@ -1142,10 +1125,7 @@ int DvrdrvExecCmdAckDmaSendComp(drvdrv_exec_cmd_ack *a1) DvrdrvBlockPhase(); DvrdrvSetDmaDirection(1u); v8 = a1->input_buffer_length; - if ((v8 & 0x7F) != 0) - v18 = (v8 / 128 + 1) << 7; - else - v18 = a1->input_buffer_length; + v18 = ((v8 & 0x7F) != 0) ? ((v8 / 128 + 1) << 7) : a1->input_buffer_length; v9 = a1->command; input_word_count = 2; v12 = (v9 & 0xF0FF) | 0x200; diff --git a/iop/dvrp/dvr/src/dvr.c b/iop/dvrp/dvr/src/dvr.c index bc2b40fe67c2..a617a4a988c2 100644 --- a/iop/dvrp/dvr/src/dvr.c +++ b/iop/dvrp/dvr/src/dvr.c @@ -157,10 +157,7 @@ IRX_ID(MODNAME, 1, 1); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return ((argc >= 0) ? module_start : module_stop)(argc, argv, startaddr, mi); } int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -199,9 +196,7 @@ int module_stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) (void)startaddr; (void)mi; - if (iomanX_DelDrv(DVR.name) != 0) - return MODULE_REMOVABLE_END; - return MODULE_NO_RESIDENT_END; + return (iomanX_DelDrv(DVR.name) != 0) ? MODULE_REMOVABLE_END : MODULE_NO_RESIDENT_END; } int dvr_df_init(iomanX_iop_device_t *dev) @@ -226,9 +221,7 @@ int dvr_df_exit(iomanX_iop_device_t *dev) { (void)dev; - if (DeleteSema(sema_id) != 0) - return -1; - return 0; + return (DeleteSema(sema_id) != 0) ? -1 : 0; } int dvr_df_ioctl(iomanX_iop_file_t *f, int cmd, void *param) diff --git a/iop/dvrp/dvrav/src/dvrav.c b/iop/dvrp/dvrav/src/dvrav.c index bf6425467388..3c1a2b345ba6 100644 --- a/iop/dvrp/dvrav/src/dvrav.c +++ b/iop/dvrp/dvrav/src/dvrav.c @@ -153,10 +153,7 @@ IRX_ID(MODNAME, 1, 1); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return ((argc >= 0) ? module_start : module_stop)(argc, argv, startaddr, mi); } int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -195,9 +192,7 @@ int module_stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) (void)startaddr; (void)mi; - if (iomanX_DelDrv(DVRAV.name) != 0) - return MODULE_REMOVABLE_END; - return MODULE_NO_RESIDENT_END; + return (iomanX_DelDrv(DVRAV.name) != 0) ? MODULE_REMOVABLE_END : MODULE_NO_RESIDENT_END; } int dvrav_df_init(iomanX_iop_device_t *dev) @@ -222,9 +217,7 @@ int dvrav_df_exit(iomanX_iop_device_t *dev) { (void)dev; - if (DeleteSema(sema_id) != 0) - return -1; - return 0; + return (DeleteSema(sema_id) != 0) ? -1 : 0; } int dvrav_df_ioctl(iomanX_iop_file_t *f, int cmd, void *param) diff --git a/iop/dvrp/dvrdv/src/dvrdv.c b/iop/dvrp/dvrdv/src/dvrdv.c index 7a790e06c89e..e1086546e7de 100644 --- a/iop/dvrp/dvrdv/src/dvrdv.c +++ b/iop/dvrp/dvrdv/src/dvrdv.c @@ -98,10 +98,7 @@ IRX_ID(MODNAME, 1, 0); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return ((argc >= 0) ? module_start : module_stop)(argc, argv, startaddr, mi); } int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -140,9 +137,7 @@ int module_stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) (void)startaddr; (void)mi; - if (iomanX_DelDrv(DVR.name) != 0) - return MODULE_REMOVABLE_END; - return MODULE_NO_RESIDENT_END; + return (iomanX_DelDrv(DVR.name) != 0) ? MODULE_REMOVABLE_END : MODULE_NO_RESIDENT_END; } int dvrdv_df_init(iomanX_iop_device_t *dev) @@ -167,9 +162,7 @@ int dvrdv_df_exit(iomanX_iop_device_t *dev) { (void)dev; - if (DeleteSema(sema_id) != 0) - return -1; - return 0; + return (DeleteSema(sema_id) != 0) ? -1 : 0; } int dvrdv_df_ioctl(iomanX_iop_file_t *f, int cmd, void *param) diff --git a/iop/dvrp/dvrfile/src/dvrfile.c b/iop/dvrp/dvrfile/src/dvrfile.c index 3ceeddfba363..7078254d1f6b 100644 --- a/iop/dvrp/dvrfile/src/dvrfile.c +++ b/iop/dvrp/dvrfile/src/dvrfile.c @@ -257,10 +257,7 @@ IRX_ID(MODNAME, 1, 1); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return ((argc >= 0) ? module_start : module_stop)(argc, argv, startaddr, mi); } int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -504,13 +501,9 @@ int dvrf_df_devctl(iomanX_iop_file_t *f, const char *name, int cmd, void *arg, u retval = 0; WaitSema(sema_id); if (cmd == 0x5065) { - if ((*(u32 *)arg & 0x7F) != 0) { - retval = -EINVAL; - } else if (*(int *)arg <= 0x20000) { + retval = ((*(u32 *)arg & 0x7F) != 0) ? -EINVAL : ((*(int *)arg > 0x20000) ? -EDOM : 0); + if (!retval) current_chunk_size = *(u32 *)arg; - } else { - retval = -EDOM; - } goto finish; } argoffset = arglen + 16; @@ -877,10 +870,7 @@ int dvrf_df_read(iomanX_iop_file_t *f, void *ptr, int size) drvdrv_exec_cmd_ack cmdack; total_read = 0; - unaligned_size = 0; - if (((u32)ptr & 3) != 0) { - unaligned_size = 4 - ((u32)ptr & 3); - } + unaligned_size = (((u32)ptr & 3) != 0) ? (4 - ((u32)ptr & 3)) : 0; WaitSema(sema_id); out_buf = (char *)ptr; dvrp_fd = (int)f->privdata; @@ -895,20 +885,10 @@ int dvrf_df_read(iomanX_iop_file_t *f, void *ptr, int size) if (remain_size <= 0) { break; } - chunk_size = current_chunk_size; - if (remain_size < current_chunk_size) { - chunk_size = remain_size; - } - if (unaligned_size != 0) { - chunk_size = unaligned_size; - } + chunk_size = (unaligned_size != 0) ? unaligned_size : ((remain_size < current_chunk_size) ? remain_size : current_chunk_size); cmdack.input_word[2] = (chunk_size >> 16) & 0xFFFF; cmdack.input_word[3] = chunk_size; - if ((chunk_size & 0x7F) != 0 || unaligned_size != 0) { - cmdack.output_buffer = (char *)RBUF; - } else { - cmdack.output_buffer = out_buf; - } + cmdack.output_buffer = ((chunk_size & 0x7F) != 0 || unaligned_size != 0) ? (char *)RBUF : out_buf; if (check_cmdack_err(&DvrdrvExecCmdAckDmaRecvComp, &cmdack, &read_size, __func__)) { retval = read_size; goto finish; @@ -1116,11 +1096,8 @@ int dvrf_df_write(iomanX_iop_file_t *f, void *ptr, int size) total_write = 0; in_buffer = (char *)ptr; - unaligned_size = 0; - if (((u32)ptr & 3) != 0) { - unaligned_size = 4 - ((u32)ptr & 3); - memcpy(RBUF, ptr, unaligned_size); - } + unaligned_size = (((u32)ptr & 3) != 0) ? (4 - ((u32)ptr & 3)) : 0; + memcpy(RBUF, ptr, unaligned_size); WaitSema(sema_id); dvrp_fd = (int)f->privdata; remain_size = size; @@ -1131,21 +1108,11 @@ int dvrf_df_write(iomanX_iop_file_t *f, void *ptr, int size) cmdack.timeout = 10000000; while (remain_size > 0) { u32 chunk_size; - chunk_size = current_chunk_size; - if (remain_size < current_chunk_size) { - chunk_size = remain_size; - } - if (unaligned_size != 0) { - chunk_size = unaligned_size; - } + chunk_size = (unaligned_size != 0) ? unaligned_size : ((remain_size < current_chunk_size) ? remain_size : current_chunk_size); cmdack.input_word[2] = (chunk_size >> 16) & 0xFFFF; cmdack.input_word[3] = chunk_size; - if (unaligned_size != 0) { - cmdack.input_buffer = (char *)RBUF; - unaligned_size = 0; - } else { - cmdack.input_buffer = in_buffer; - } + cmdack.input_buffer = (unaligned_size != 0) ? (char *)RBUF : in_buffer; + unaligned_size = 0; cmdack.input_buffer_length = chunk_size; if (check_cmdack_err(&DvrdrvExecCmdAckDmaSendComp, &cmdack, &retval, __func__)) { goto finish; diff --git a/iop/dvrp/dvripl/src/dvripl.c b/iop/dvrp/dvripl/src/dvripl.c index bcbfbf08d959..631eb67cb766 100644 --- a/iop/dvrp/dvripl/src/dvripl.c +++ b/iop/dvrp/dvripl/src/dvripl.c @@ -84,10 +84,7 @@ IRX_ID(MODNAME, 1, 1); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return ((argc >= 0) ? module_start : module_stop)(argc, argv, startaddr, mi); } int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -114,9 +111,7 @@ int module_stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) (void)startaddr; (void)mi; - if (iomanX_DelDrv(DVRMAN.name) != 0) - return MODULE_REMOVABLE_END; - return MODULE_NO_RESIDENT_END; + return (iomanX_DelDrv(DVRMAN.name) != 0) ? MODULE_REMOVABLE_END : MODULE_NO_RESIDENT_END; } int dvripl_df_init(iomanX_iop_device_t *dev) @@ -143,9 +138,7 @@ int dvripl_df_exit(iomanX_iop_device_t *dev) (void)dev; DPRINTF("dvripl_df_exit\n"); - if (DeleteSema(sema_id) != 0) - return -1; - return 0; + return (DeleteSema(sema_id) != 0) ? -1 : 0; } int dvripl_df_ioctl(iomanX_iop_file_t *f, int cmd, void *param) @@ -178,9 +171,7 @@ int dvripl_df_devctl( DPRINTF("dvripl_df_devctl\n"); WaitSema(sema_id); - v11 = -EINVAL; - if (cmd == 0x5602) - v11 = iplioctl2_update(a1, 0x5602, arg); + v11 = (cmd == 0x5602) ? iplioctl2_update(a1, 0x5602, arg) : -EINVAL; SignalSema(sema_id); return v11; } diff --git a/iop/dvrp/dvrmisc/src/dvrmisc.c b/iop/dvrp/dvrmisc/src/dvrmisc.c index 8cc6b3151403..239622afaa33 100644 --- a/iop/dvrp/dvrmisc/src/dvrmisc.c +++ b/iop/dvrp/dvrmisc/src/dvrmisc.c @@ -139,10 +139,7 @@ IRX_ID(MODNAME, 1, 1); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return ((argc >= 0) ? module_start : module_stop)(argc, argv, startaddr, mi); } int module_start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) @@ -181,9 +178,7 @@ int module_stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) (void)startaddr; (void)mi; - if (iomanX_DelDrv(DVRMISC.name) != 0) - return MODULE_REMOVABLE_END; - return MODULE_NO_RESIDENT_END; + return (iomanX_DelDrv(DVRMISC.name) != 0) ? MODULE_REMOVABLE_END : MODULE_NO_RESIDENT_END; } int dvrmisc_df_init(iomanX_iop_device_t *dev) @@ -208,9 +203,7 @@ int dvrmisc_df_exit(iomanX_iop_device_t *dev) { (void)dev; - if (DeleteSema(sema_id) != 0) - return -1; - return 0; + return (DeleteSema(sema_id) != 0) ? -1 : 0; } int dvrmisc_df_ioctl(iomanX_iop_file_t *f, int cmd, void *param) @@ -743,13 +736,8 @@ int dvrioctl2_partition_free( return -EIO; } *(u64 *)buf = v10; - if (*(s64 *)buf <= 0x7FFFFFF) { - *(u32 *)buf = 0; - *((u32 *)buf + 1) = 0; - } else { - *(u32 *)buf = v10 - 0x8000000; - *((u32 *)buf + 1) = (v10 >> 32) - 1 + ((unsigned int)(v10 - 0x8000000) < 0xF8000000); - } + *(u32 *)buf = (*(s64 *)buf <= 0x7FFFFFF) ? 0 : (v10 - 0x8000000); + *((u32 *)buf + 1) = (*(s64 *)buf <= 0x7FFFFFF) ? 0 : ((v10 >> 32) - 1 + ((unsigned int)(v10 - 0x8000000) < 0xF8000000)); return 0; } @@ -1187,9 +1175,7 @@ int dvrioctl2_get_device_key( while (1) { int v21; int v22; - v21 = v18; - if (v20 >= 0x11) - v21 = 16; + v21 = (v20 >= 0x11) ? 16 : v18; cmdack.command = 0x511A; cmdack.input_word[0] = v17; cmdack.input_word[1] = v21; diff --git a/iop/fs/bdmfs_fatfs/src/fs_driver.c b/iop/fs/bdmfs_fatfs/src/fs_driver.c index 290cf6375999..0c4fc496f713 100644 --- a/iop/fs/bdmfs_fatfs/src/fs_driver.c +++ b/iop/fs/bdmfs_fatfs/src/fs_driver.c @@ -247,9 +247,7 @@ static int fs_driver_resolve_volume(const char *driver_name, int unit) int i, count; if (strcmp(driver_name, "mass") == 0) { - if (unit >= 0 && unit < FATFS_FS_DRIVER_MOUNT_INFO_MAX) - return unit; - return -1; + return (unit >= 0 && unit < FATFS_FS_DRIVER_MOUNT_INFO_MAX) ? unit : -1; } count = 0; @@ -363,16 +361,11 @@ static int fs_open(iop_file_t *fd, const char *name, int flags, int mode) } // translate mode - if (flags & O_RDONLY) - f_mode |= FA_READ; - if (flags & O_WRONLY) - f_mode |= FA_WRITE; - if (flags & O_CREAT) - f_mode |= FA_OPEN_ALWAYS; - if (flags & O_TRUNC) - f_mode |= FA_CREATE_ALWAYS; - if (flags & O_APPEND) - f_mode |= FA_OPEN_APPEND; + f_mode |= (flags & O_RDONLY) ? FA_READ : 0; + f_mode |= (flags & O_WRONLY) ? FA_WRITE : 0; + f_mode |= (flags & O_CREAT) ? FA_OPEN_ALWAYS : 0; + f_mode |= (flags & O_TRUNC) ? FA_CREATE_ALWAYS : 0; + f_mode |= (flags & O_APPEND) ? FA_OPEN_APPEND : 0; ret = f_open(fd->privdata, modified_name, f_mode); @@ -595,14 +588,8 @@ static void fileInfoToStat(FILINFO *fno, iox_stat_t *stat) stat->hisize = (unsigned int)(fno->fsize>>32); stat->mode = FIO_S_IROTH | FIO_S_IXOTH; - if (fno->fattrib & AM_DIR) { - stat->mode |= FIO_S_IFDIR; - } else { - stat->mode |= FIO_S_IFREG; - } - if (!(fno->fattrib & AM_RDO)) { - stat->mode |= FIO_S_IWOTH; - } + stat->mode |= (fno->fattrib & AM_DIR) ? FIO_S_IFDIR : FIO_S_IFREG; + stat->mode |= (!(fno->fattrib & AM_RDO)) ? FIO_S_IWOTH : 0; // Since the VFAT file system does not support timezones, the timezone offset will not be applied. // exFAT does support timezones, but the feature is not used/exposed in the FatFs library. diff --git a/iop/fs/devfs/src/devfs.c b/iop/fs/devfs/src/devfs.c index 54aa41b76b6b..4e2e678bd257 100644 --- a/iop/fs/devfs/src/devfs.c +++ b/iop/fs/devfs/src/devfs.c @@ -119,9 +119,7 @@ const char *devfs_subdev_to_str(int subdev) name[loop++] = 0; } - loop = 0; - if(name[0] == '0') loop = 1; - if((name[0] == '0') && (name[1] == '0')) loop = 2; + loop = (name[0] == '0') ? 1 : (((name[0] == '0') && (name[1] == '0')) ? 2 : 0); return &name[loop]; } @@ -165,14 +163,8 @@ int devfs_fill_dirent(iox_dirent_t *dirent, int devno) dirent->stat.size = dev_scan->subdevs[subdev_loop].extent.loc32[0]; dirent->stat.hisize = dev_scan->subdevs[subdev_loop].extent.loc32[1]; dirent->stat.mode = FIO_S_IFREG; - if(dev_scan->subdevs[subdev_loop].mode & DEVFS_MODE_R) - { - dirent->stat.mode |= FIO_S_IRUSR; - } - if(dev_scan->subdevs[subdev_loop].mode & DEVFS_MODE_W) - { - dirent->stat.mode |= FIO_S_IWUSR; - } + dirent->stat.mode |= (dev_scan->subdevs[subdev_loop].mode & DEVFS_MODE_R) ? FIO_S_IRUSR : 0; + dirent->stat.mode |= (dev_scan->subdevs[subdev_loop].mode & DEVFS_MODE_W) ? FIO_S_IWUSR : 0; dirent->name[0] = 0; strcpy(dirent->name, dev_scan->node.name); strcat(dirent->name, devfs_subdev_to_str(subdev_loop)); @@ -660,10 +652,7 @@ int devfs_read(iop_file_t *file, void *buf, int len) dev_info.mode = data->mode; dev_info.loc = data->loc; bytes_read = dev->node.read(&dev_info, buf, len); - if(bytes_read > 0) - { - data->loc.loc64 += (u64) bytes_read; - } + data->loc.loc64 += (bytes_read > 0) ? (u64) bytes_read : 0; return bytes_read; } } @@ -707,10 +696,7 @@ int devfs_write(iop_file_t *file, void *buf, int len) dev_info.mode = data->mode; dev_info.loc = data->loc; bytes_written = dev->node.write(&dev_info, buf, len); - if(bytes_written > 0) - { - data->loc.loc64 += (u64) bytes_written; - } + data->loc.loc64 += (bytes_written > 0) ? (u64) bytes_written : 0; return bytes_written; } } @@ -966,14 +952,8 @@ int devfs_getstat(iop_file_t *file, const char *name, iox_stat_t *stat) stat->size = dev->subdevs[subdev].extent.loc32[0]; stat->hisize = dev->subdevs[subdev].extent.loc32[1]; stat->mode = FIO_S_IFREG; - if(dev->subdevs[subdev].mode & DEVFS_MODE_R) - { - stat->mode |= FIO_S_IRUSR; - } - if(dev->subdevs[subdev].mode & DEVFS_MODE_W) - { - stat->mode |= FIO_S_IWUSR; - } + stat->mode |= (dev->subdevs[subdev].mode & DEVFS_MODE_R) ? FIO_S_IRUSR : 0; + stat->mode |= (dev->subdevs[subdev].mode & DEVFS_MODE_W) ? FIO_S_IWUSR : 0; } return 0; diff --git a/iop/fs/eromdrv/src/eromdrv.c b/iop/fs/eromdrv/src/eromdrv.c index e32512e19254..f33ffaf20ba8 100644 --- a/iop/fs/eromdrv/src/eromdrv.c +++ b/iop/fs/eromdrv/src/eromdrv.c @@ -263,21 +263,7 @@ static u32 get_string_hash(const char *name) int tmpval2; tmpval1 = (u8)nametmp[i]; - tmpval2 = tmpval1 - 64; - if ( (u32)(tmpval1 - 65) >= 0xD ) - { - tmpval2 = 14; - if ( tmpval1 ) - { - tmpval2 = (u8)tmpval1 - 63; - if ( (u8)tmpval1 < 0x4Eu ) - { - tmpval2 = 28; - if ( (u8)tmpval1 != 32 ) - tmpval2 = (u8)tmpval1 - 19; - } - } - } + tmpval2 = ( (u32)(tmpval1 - 65) >= 0xD ) ? (( tmpval1 ) ? (( (u8)tmpval1 < 0x4Eu ) ? (( (u8)tmpval1 != 32 ) ? ((u8)tmpval1 - 19) : 28) : ((u8)tmpval1 - 63)) : 14) : (tmpval1 - 64); ret = 40 * ret + tmpval2; } return ret; @@ -295,9 +281,7 @@ static int get_val_from_hash0(u32 obfval) int tmpval2; tmpval1 = obfval % 0x12; - tmpval2 = (tmpval1 - 1) << i; - if ( tmpval1 - 1 >= 0xA ) - tmpval2 = (tmpval1 - 2) << i; + tmpval2 = ( tmpval1 - 1 >= 0xA ) ? ((tmpval1 - 2) << i) : ((tmpval1 - 1) << i); ret |= tmpval2; obfval /= 0x12u; } @@ -314,9 +298,7 @@ static int get_val_from_hash1(u32 obfval) { u32 tmpval1; - tmpval1 = obfval % 0x13 + 9; - if ( obfval % 0x13 - 1 >= 6 ) - tmpval1 = obfval % 0x13 - 8; + tmpval1 = ( obfval % 0x13 - 1 >= 6 ) ? (obfval % 0x13 - 8) : (obfval % 0x13 + 9); ret |= tmpval1 << i; obfval /= 0x13u; } diff --git a/iop/fs/fileio/src/fileio.c b/iop/fs/fileio/src/fileio.c index 2c46cd4575af..bfa11d384305 100644 --- a/iop/fs/fileio/src/fileio.c +++ b/iop/fs/fileio/src/fileio.c @@ -154,11 +154,7 @@ static void fileio_rpc_read(struct _fio_read_arg *buffer, int length, int *outbu v6 = 0; #if 0 if (size >= 64) { - if ((ptr & 0x3F) != 0) { - v7 = (ptr >> 6 << 6) - (ptr - 64); - } else { - v7 = 0; - } + v7 = ((ptr & 0x3F) != 0) ? ((ptr >> 6 << 6) - (ptr - 64)) : 0; v21 = ptr; v8 = (char *)(ptr + v7); v9 = ((ptr + size) >> 6 << 6) - (ptr + v7); @@ -167,11 +163,7 @@ static void fileio_rpc_read(struct _fio_read_arg *buffer, int length, int *outbu } #else if (size >= 16) { - if ((ptr & 0xF) != 0) { - v7 = (ptr >> 4 << 4) - (ptr - 16); - } else { - v7 = 0; - } + v7 = ((ptr & 0xF) != 0) ? ((ptr >> 4 << 4) - (ptr - 16)) : 0; v21 = (void *)ptr; v8 = (char *)(ptr + v7); v9 = ((ptr + size) >> 4 << 4) - (ptr + v7); @@ -192,10 +184,7 @@ static void fileio_rpc_read(struct _fio_read_arg *buffer, int length, int *outbu if (v7 > 0) { v12 = io_read(fd, read_data_out.buf1, v7); if (v7 != v12) { - v7 = 0; - if (v12 > 0) { - v7 = v12; - } + v7 = (v12 > 0) ? v12 : 0; v6 = v7; goto LABEL_26; } @@ -206,18 +195,13 @@ static void fileio_rpc_read(struct _fio_read_arg *buffer, int length, int *outbu if (v10 > 0) { v16 = io_read(fd, read_data_out.buf2, v10); if (v10 != v16) { - v10 = 0; - if (v16 > 0) { - v10 = v16; - } + v10 = (v16 > 0) ? v16 : 0; } v6 += v10; } } else { for (;;) { - v13 = v9; - if (xfer_size < v9) - v13 = xfer_size; + v13 = (xfer_size < v9) ? xfer_size : v9; while (sceSifDmaStat(v11) >= 0) ; v14 = io_read(fd, xfer_buffer, v13); @@ -298,9 +282,7 @@ static void fileio_rpc_write(struct _fio_write_arg *buffer, int length, int *out v9 = io_write(fd, buffer->aligned, mis); if (v9 != mis) { - if (v9 > 0) { - v15 += v9; - } + v15 += (v9 > 0) ? v9 : 0; *outbuffer = v15; return; } @@ -315,10 +297,7 @@ static void fileio_rpc_write(struct _fio_write_arg *buffer, int length, int *out for (;;) { int v12; - v12 = v10; - if (xfer_size < v10) { - v12 = xfer_size; - } + v12 = (xfer_size < v10) ? xfer_size : v10; sceSifGetOtherData(&v14, v11, xfer_buffer, v12, 0); v13 = io_write(fd, xfer_buffer, v12); v10 -= v12; @@ -332,9 +311,7 @@ static void fileio_rpc_write(struct _fio_write_arg *buffer, int length, int *out return; } } - if (v13 > 0) { - v15 += v13; - } + v15 += (v13 > 0) ? v13 : 0; *outbuffer = v15; } diff --git a/iop/fs/filexio/src/fileXio_iop.c b/iop/fs/filexio/src/fileXio_iop.c index ce35588247dd..fab7996eee27 100644 --- a/iop/fs/filexio/src/fileXio_iop.c +++ b/iop/fs/filexio/src/fileXio_iop.c @@ -114,7 +114,7 @@ static void fileXio_Thread(void* param); int _start( int argc, char *argv[]) { struct _iop_thread param; - int th, result; + int th; (void)argc; (void)argv; @@ -130,11 +130,9 @@ int _start( int argc, char *argv[]) if (th > 0) { StartThread(th, NULL); - result=MODULE_RESIDENT_END; } - else result=MODULE_NO_RESIDENT_END; - return result; + return (th > 0) ? MODULE_RESIDENT_END : MODULE_NO_RESIDENT_END; } static int fileXio_GetDeviceList_RPC(struct fileXioDevice* ee_devices, int eecount) @@ -229,10 +227,7 @@ static int fileXio_Read_RPC(int infd, char *read_buf, int read_size, void *intr_ buffer = read_buf; aebuffer = 0; }else{ - if ((read_buf2 & 0x3F) == 0) - srest=0; - else - srest=(int)RDOWN_64(read_buf2) - read_buf2 + 64; + srest=((read_buf2 & 0x3F) == 0) ? 0 : ((int)RDOWN_64(read_buf2) - read_buf2 + 64); buffer = read_buf; abuffer = read_buf2 + srest; aebuffer=(void *)RDOWN_64(read_buf2 + read_size); @@ -317,8 +312,7 @@ static int fileXio_Write_RPC(int outfd, const char *write_buf, int write_size, i wlen=iomanX_write(outfd, misbuf, mis); if (wlen != mis) { - if (wlen > 0) - total += wlen; + total += (wlen > 0) ? wlen : 0; return (total); } total += wlen; @@ -332,8 +326,7 @@ static int fileXio_Write_RPC(int outfd, const char *write_buf, int write_size, i sceSifGetOtherData(&rdata, (void *)pos, rwbuf, writelen, 0); wlen=iomanX_write(outfd, rwbuf, writelen); if (wlen != writelen){ - if (wlen>0) - total+=wlen; + total += (wlen>0) ? wlen : 0; return (total); } left -=writelen; @@ -870,10 +863,7 @@ static void* fileXioRpc_Devctl(unsigned int* sbuff) ret_buf->dest = packet->buf; // EE is expecting data.. on error, simply use size of 0 so no data is copied. - if(ret >= 0) - ret_buf->len = packet->buflen; - else - ret_buf->len = 0; + ret_buf->len = (ret >= 0) ? packet->buflen : 0; CpuSuspendIntr(&intStatus); sceSifSetDma(&dmatrans, 1); @@ -922,10 +912,7 @@ static void* fileXioRpc_Ioctl2(unsigned int* sbuff) ret_buf->dest = packet->buf; // EE is expecting data.. on error, simply use size of 0 so no data is copied. - if(ret >= 0) - ret_buf->len = packet->buflen; - else - ret_buf->len = 0; + ret_buf->len = (ret >= 0) ? packet->buflen : 0; CpuSuspendIntr(&intStatus); sceSifSetDma(&dmatrans, 1); diff --git a/iop/fs/http/src/ps2http.c b/iop/fs/http/src/ps2http.c index 3312ec3400ab..fa335bb1d2d4 100644 --- a/iop/fs/http/src/ps2http.c +++ b/iop/fs/http/src/ps2http.c @@ -114,10 +114,7 @@ int isErrorHeader(char *mimeBuffer) line[i] = '\0'; code = (int)strtol(line,NULL, 10); - if( code == 200 ) - return 0; - else - return code; + return ( code == 200 ) ? 0 : code; } /** diff --git a/iop/fs/libbdm/src/bd_cache.c b/iop/fs/libbdm/src/bd_cache.c index cb3af3dec090..a5f30816267b 100644 --- a/iop/fs/libbdm/src/bd_cache.c +++ b/iop/fs/libbdm/src/bd_cache.c @@ -25,19 +25,13 @@ struct bd_cache /* cache overlaps with requested area ? */ static int _overlaps(u64 csector, u64 sector, u16 count) { - if ((sector < (csector + SECTORS_PER_BLOCK)) && ((sector + count) > csector)) - return 1; - else - return 0; + return ((sector < (csector + SECTORS_PER_BLOCK)) && ((sector + count) > csector)) ? 1 : 0; } /* cache contains requested area ? */ static int _contains(u64 csector, u64 sector, u16 count) { - if ((sector >= csector) && ((sector + count) <= (csector + SECTORS_PER_BLOCK))) - return 1; - else - return 0; + return ((sector >= csector) && ((sector + count) <= (csector + SECTORS_PER_BLOCK))) ? 1 : 0; } static void _invalidate(struct bd_cache *c, u64 sector, u16 count) diff --git a/iop/fs/netfs/src/ps2_fio.c b/iop/fs/netfs/src/ps2_fio.c index 3710ef22079a..f8cf87fed010 100644 --- a/iop/fs/netfs/src/ps2_fio.c +++ b/iop/fs/netfs/src/ps2_fio.c @@ -141,16 +141,13 @@ static inline int convmode_to_iomanx(int stat) { int mode = 0; - if (FIO_SO_ISLNK(stat)) mode |= FIO_S_IFLNK; // Symbolic link - if (FIO_SO_ISREG(stat)) mode |= FIO_S_IFREG; // regular file - if (FIO_SO_ISDIR(stat)) mode |= FIO_S_IFDIR; // directory + mode |= (FIO_SO_ISLNK(stat)) ? FIO_S_IFLNK : 0; // Symbolic link + mode |= (FIO_SO_ISREG(stat)) ? FIO_S_IFREG : 0; // regular file + mode |= (FIO_SO_ISDIR(stat)) ? FIO_S_IFDIR : 0; // directory - if (((stat) & FIO_SO_IROTH) == FIO_SO_IROTH) // read - mode |= FIO_S_IRUSR | FIO_S_IRGRP | FIO_S_IROTH; - if (((stat) & FIO_SO_IWOTH) == FIO_SO_IWOTH) // write - mode |= FIO_S_IWUSR | FIO_S_IWGRP | FIO_S_IWOTH; - if (((stat) & FIO_SO_IXOTH) == FIO_SO_IXOTH) // execute - mode |= FIO_S_IXUSR | FIO_S_IXGRP | FIO_S_IXOTH; + mode |= (((stat) & FIO_SO_IROTH) == FIO_SO_IROTH) /* read */ ? (FIO_S_IRUSR | FIO_S_IRGRP | FIO_S_IROTH) : 0; + mode |= (((stat) & FIO_SO_IWOTH) == FIO_SO_IWOTH) /* write */ ? (FIO_S_IWUSR | FIO_S_IWGRP | FIO_S_IWOTH) : 0; + mode |= (((stat) & FIO_SO_IXOTH) == FIO_SO_IXOTH) /* execute */ ? (FIO_S_IXUSR | FIO_S_IXGRP | FIO_S_IXOTH) : 0; return mode; } @@ -501,10 +498,7 @@ static int ps2netfs_op_open(char *buf, int len) devtype = devscan_gettype(cmd->path); if (devtype != IOPMGR_DEVTYPE_INVALID) { - if (devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_open(cmd->path,ntohl(cmd->flags)); - else if (devtype == IOPMGR_DEVTYPE_IOMANX) - retval = open(cmd->path,ntohl(cmd->flags),0644); + retval = (devtype == IOPMGR_DEVTYPE_IOMAN) ? io_open(cmd->path,ntohl(cmd->flags)) : ((devtype == IOPMGR_DEVTYPE_IOMANX) ? open(cmd->path,ntohl(cmd->flags),0644) : retval); if (retval > 0) retval = fdh_getfd(devtype,retval); } @@ -562,10 +556,7 @@ static int ps2netfs_op_close(char *buf, int len) fdptr = fdh_get(ntohl(cmd->fd)); if (fdptr != 0) { - if (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_close(fdptr->realfd); - else if (fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) - retval = close(fdptr->realfd); + retval = (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) ? io_close(fdptr->realfd) : ((fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) ? close(fdptr->realfd) : retval); fdh_freefd(ntohl(cmd->fd)); } @@ -626,10 +617,7 @@ static int ps2netfs_op_read(char *buf, int len) fdptr = fdh_get(ntohl(cmd->fd)); if (fdptr != 0) { - if (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_read(fdptr->realfd,ps2netfs_fiobuffer,nbytes); - else if (fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) - retval = read(fdptr->realfd,ps2netfs_fiobuffer,nbytes); + retval = (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) ? io_read(fdptr->realfd,ps2netfs_fiobuffer,nbytes) : ((fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) ? read(fdptr->realfd,ps2netfs_fiobuffer,nbytes) : retval); } // now build the response @@ -704,10 +692,7 @@ static int ps2netfs_op_write(char *buf, int len) return -1; } - if (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_write(fdptr->realfd,ps2netfs_fiobuffer,towrite); - else if (fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) - retval = write(fdptr->realfd,ps2netfs_fiobuffer,towrite); + retval = (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) ? io_write(fdptr->realfd,ps2netfs_fiobuffer,towrite) : ((fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) ? write(fdptr->realfd,ps2netfs_fiobuffer,towrite) : retval); if (retval > 0) { written += retval; left -= retval; } } @@ -767,10 +752,7 @@ static int ps2netfs_op_lseek(char *buf, int len) fdptr = fdh_get(ntohl(cmd->fd)); if (fdptr != 0) { - if (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_lseek(fdptr->realfd,ntohl(cmd->offset),ntohl(cmd->whence)); - else if (fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) - retval = lseek(fdptr->realfd,ntohl(cmd->offset),ntohl(cmd->whence)); + retval = (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) ? io_lseek(fdptr->realfd,ntohl(cmd->offset),ntohl(cmd->whence)) : ((fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) ? lseek(fdptr->realfd,ntohl(cmd->offset),ntohl(cmd->whence)) : retval); } // now build the response @@ -828,10 +810,7 @@ static int ps2netfs_op_ioctl(char *buf, int len) fdptr = fdh_get(ntohl(cmd->fd)); if (fdptr != 0) { - if (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_ioctl(fdptr->realfd,ntohl(cmd->command),(void *)ioctlrly->buf); - else if (fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) - retval = ioctl(fdptr->realfd,ntohl(cmd->command),(void *)ioctlrly->buf); + retval = (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) ? io_ioctl(fdptr->realfd,ntohl(cmd->command),(void *)ioctlrly->buf) : ((fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) ? ioctl(fdptr->realfd,ntohl(cmd->command),(void *)ioctlrly->buf) : retval); } // Build packet @@ -884,10 +863,7 @@ static int ps2netfs_op_remove(char *buf, int len) devtype = devscan_gettype(cmd->path); if (devtype != IOPMGR_DEVTYPE_INVALID) { - if (devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_remove(cmd->path); - else if (devtype == IOPMGR_DEVTYPE_IOMANX) - retval = remove(cmd->path); + retval = (devtype == IOPMGR_DEVTYPE_IOMAN) ? io_remove(cmd->path) : ((devtype == IOPMGR_DEVTYPE_IOMANX) ? remove(cmd->path) : retval); } // now build the response @@ -943,10 +919,7 @@ static int ps2netfs_op_mkdir(char *buf, int len) devtype = devscan_gettype(cmd->path); if (devtype != IOPMGR_DEVTYPE_INVALID) { - if (devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_mkdir(cmd->path); - else if (devtype == IOPMGR_DEVTYPE_IOMANX) - retval = mkdir(cmd->path,0644); + retval = (devtype == IOPMGR_DEVTYPE_IOMAN) ? io_mkdir(cmd->path) : ((devtype == IOPMGR_DEVTYPE_IOMANX) ? mkdir(cmd->path,0644) : retval); } // now build the response @@ -1002,10 +975,7 @@ static int ps2netfs_op_rmdir(char *buf, int len) devtype = devscan_gettype(cmd->path); if (devtype != IOPMGR_DEVTYPE_INVALID) { - if (devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_rmdir(cmd->path); - else if (devtype == IOPMGR_DEVTYPE_IOMANX) - retval = rmdir(cmd->path); + retval = (devtype == IOPMGR_DEVTYPE_IOMAN) ? io_rmdir(cmd->path) : ((devtype == IOPMGR_DEVTYPE_IOMANX) ? rmdir(cmd->path) : retval); } // now build the response @@ -1061,10 +1031,7 @@ static int ps2netfs_op_dopen(char *buf, int len) devtype = devscan_gettype(cmd->path); if (devtype != IOPMGR_DEVTYPE_INVALID) { - if (devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_dopen(cmd->path,0); - else if (devtype == IOPMGR_DEVTYPE_IOMANX) - retval = dopen(cmd->path); + retval = (devtype == IOPMGR_DEVTYPE_IOMAN) ? io_dopen(cmd->path,0) : ((devtype == IOPMGR_DEVTYPE_IOMANX) ? dopen(cmd->path) : retval); if (retval > 0) retval = fdh_getfd(devtype,retval); } @@ -1122,10 +1089,7 @@ static int ps2netfs_op_dclose(char *buf, int len) fdptr = fdh_get(ntohl(cmd->fd)); if (fdptr != 0) { - if (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) - retval = io_dclose(fdptr->realfd); - else if (fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) - retval = dclose(fdptr->realfd); + retval = (fdptr->devtype == IOPMGR_DEVTYPE_IOMAN) ? io_dclose(fdptr->realfd) : ((fdptr->devtype == IOPMGR_DEVTYPE_IOMANX) ? dclose(fdptr->realfd) : retval); if (retval == 0) fdh_freefd(ntohl(cmd->fd)); } @@ -1327,12 +1291,8 @@ static int ps2netfs_op_format(char *buf, int len) devtype = devscan_gettype(cmd->dev); if (devtype == IOPMGR_DEVTYPE_IOMANX) { // if other end has not set args, add some standard ones (hdd use only for mo) - if (ntohl(cmd->arglen) == 0) - { - int Arg[3] = { PFS_ZONE_SIZE, 0x2d66, PFS_FRAGMENT }; - retval = format(cmd->dev,cmd->blockdev,(char*)&Arg,sizeof(Arg)); - } - else retval = format(cmd->dev,cmd->blockdev,cmd->arg,ntohl(cmd->arglen)); + int Arg[3] = { PFS_ZONE_SIZE, 0x2d66, PFS_FRAGMENT }; + retval = (ntohl(cmd->arglen) == 0) ? format(cmd->dev,cmd->blockdev,(char*)&Arg,sizeof(Arg)) : format(cmd->dev,cmd->blockdev,cmd->arg,ntohl(cmd->arglen)); } // now build the response @@ -1391,9 +1351,7 @@ static int ps2netfs_op_rename(char *buf, int len) if (devtype == IOPMGR_DEVTYPE_IOMANX) { devtype = devscan_gettype(cmd->newpath); - if (devtype == IOPMGR_DEVTYPE_IOMANX) - retval = rename(cmd->oldpath,cmd->newpath); - else retval = -1; + retval = (devtype == IOPMGR_DEVTYPE_IOMANX) ? rename(cmd->oldpath,cmd->newpath) : -1; } // now build the response renamerly = (ps2netfs_pkt_file_rly *)&ps2netfs_send_packet[0]; @@ -1713,9 +1671,7 @@ static int ps2netfs_op_symlink(char *buf, int len) if (devtype == IOPMGR_DEVTYPE_IOMANX) { devtype = devscan_gettype(cmd->newpath); - if (devtype == IOPMGR_DEVTYPE_IOMANX) - retval = symlink(cmd->oldpath,cmd->newpath); - else retval = -1; + retval = (devtype == IOPMGR_DEVTYPE_IOMANX) ? symlink(cmd->oldpath,cmd->newpath) : -1; } // now build the response symlinkrly = (ps2netfs_pkt_file_rly *)&ps2netfs_send_packet[0]; diff --git a/iop/fs/subfile/src/subfile.c b/iop/fs/subfile/src/subfile.c index bd6aa4a2cf28..760e27293453 100644 --- a/iop/fs/subfile/src/subfile.c +++ b/iop/fs/subfile/src/subfile.c @@ -75,9 +75,7 @@ int _start(int ac, char *av[]) CpuSuspendIntr(&state); tmpbuf = AllocSysMemory(ALLOC_LAST, 0x4000, NULL); CpuResumeIntr(state); - if ( tmpbuf == NULL ) - return MODULE_NO_RESIDENT_END; - return (AddDrv(&subfile_dev) < 0) ? MODULE_NO_RESIDENT_END : MODULE_RESIDENT_END; + return ( tmpbuf == NULL ) ? MODULE_NO_RESIDENT_END : ((AddDrv(&subfile_dev) < 0) ? MODULE_NO_RESIDENT_END : MODULE_RESIDENT_END); } static int subfile_op_open(iop_file_t *f, const char *name, int mode) @@ -103,10 +101,7 @@ static int subfile_op_open(iop_file_t *f, const char *name, int mode) case 0: { curfilename[i] = (name[i] != ',') ? name[i] : '\x00'; - if ( curfilename[i] == '\x00' ) - { - arrind += 1; - } + arrind += ( curfilename[i] == '\x00' ) ? 1 : 0; break; } case 1: @@ -207,21 +202,12 @@ static int subfile_op_read(iop_file_t *f, void *ptr, int size) baseoffs_plus_curpos = privdata->m_baseoffset + privdata->m_curpos + i; baseoffs_plus_curpos_chunk = baseoffs_plus_curpos & ~0x1FF; baseoffs_plus_curpos_sub = privdata->m_baseoffset + privdata->m_totalsize - baseoffs_plus_curpos_chunk; + baseoffs_plus_curpos_sub = ( (u32)(size_tmp + 0x400) < baseoffs_plus_curpos_sub ) ? (size_tmp + 0x400) : baseoffs_plus_curpos_sub; baseoffs_plus_curpos_mask = baseoffs_plus_curpos_sub & 0x1FF; - if ( (u32)(size_tmp + 0x400) < baseoffs_plus_curpos_sub ) - { - baseoffs_plus_curpos_sub = size_tmp + 0x400; - baseoffs_plus_curpos_mask = baseoffs_plus_curpos_sub & 0x1FF; - } - if ( baseoffs_plus_curpos_mask ) - baseoffs_plus_curpos_sub = (baseoffs_plus_curpos_sub + 0x1FF) & ~0x1FF; - if ( baseoffs_plus_curpos_sub > 0x4000 ) - { - baseoffs_plus_curpos_sub = 0x4000; - } + baseoffs_plus_curpos_sub = baseoffs_plus_curpos_mask ? ((baseoffs_plus_curpos_sub + 0x1FF) & ~0x1FF) : baseoffs_plus_curpos_sub; + baseoffs_plus_curpos_sub = ( baseoffs_plus_curpos_sub > 0x4000 ) ? 0x4000 : baseoffs_plus_curpos_sub; baseoffs_plus_curpos_size = (baseoffs_plus_curpos_chunk + baseoffs_plus_curpos_sub) - baseoffs_plus_curpos; - if ( size_tmp < baseoffs_plus_curpos_size ) - baseoffs_plus_curpos_size = size_tmp; + baseoffs_plus_curpos_size = ( size_tmp < baseoffs_plus_curpos_size ) ? size_tmp : baseoffs_plus_curpos_size; lseek(privdata->m_fd, baseoffs_plus_curpos_chunk, FIO_SEEK_SET); read(privdata->m_fd, tmpbuf, baseoffs_plus_curpos_sub); memcpy((u8 *)ptr + i, (u8 *)tmpbuf + (baseoffs_plus_curpos & 0x1FF), baseoffs_plus_curpos_size); @@ -256,12 +242,7 @@ static int subfile_op_lseek(iop_file_t *f, int pos, int mode) } m_totalsize = privdata->m_totalsize; pos_plus_curpos = pos + offs_relative; - if ( (int)m_totalsize >= pos_plus_curpos ) - { - m_totalsize = 0; - if ( pos_plus_curpos >= 0 ) - m_totalsize = pos_plus_curpos; - } + m_totalsize = ( (int)m_totalsize >= pos_plus_curpos ) ? (( pos_plus_curpos >= 0 ) ? pos_plus_curpos : 0) : m_totalsize; privdata->m_curpos = m_totalsize; return m_totalsize; } diff --git a/iop/fs/vfat/src/fat_driver.c b/iop/fs/vfat/src/fat_driver.c index 9a03049623e0..e76951e37eb6 100644 --- a/iop/fs/vfat/src/fat_driver.c +++ b/iop/fs/vfat/src/fat_driver.c @@ -73,10 +73,8 @@ int strEqual(const char *s1, const char *s2) u1 = *s1++; u2 = *s2++; - if (u1 > 64 && u1 < 91) - u1 += 32; - if (u2 > 64 && u2 < 91) - u2 += 32; + u1 += (u1 > 64 && u1 < 91) ? 32 : 0; + u2 += (u2 > 64 && u2 < 91) ? 32 : 0; if (u1 != u2) { return -1; @@ -103,11 +101,7 @@ unsigned int fat_getClusterRecord12(const unsigned char *buf, int type) { M_DEBUG("%s\n", __func__); - if (type) { // 1 - return ((buf[1] << 4) + (buf[0] >> 4)); - } else { // 0 - return (((buf[1] & 0x0F) << 8) + buf[0]); - } + return type ? ((buf[1] << 4) + (buf[0] >> 4)) : (((buf[1] & 0x0F) << 8) + buf[0]); } //--------------------------------------------------------------------------- @@ -143,10 +137,7 @@ static int fat_getClusterChain12(fat_driver *fatd, unsigned int cluster, unsigne recordOffset = (cluster * 3) / 2; // offset of the cluster record (in bytes) from the FAT start fatSector = recordOffset / fatd->partBpb.sectorSize; - sectorSpan = 0; - if ((recordOffset % fatd->partBpb.sectorSize) == (fatd->partBpb.sectorSize - 1)) { - sectorSpan = 1; - } + sectorSpan = ((recordOffset % fatd->partBpb.sectorSize) == (fatd->partBpb.sectorSize - 1)) ? 1 : 0; if (lastFatSector != fatSector || sectorSpan) { ret = READ_SECTOR(DEV_ACCESSOR(fatd), fatd->partBpb.partStart + fatd->partBpb.resSectors + fatSector, sbuf); if (ret < 0) { @@ -167,11 +158,7 @@ static int fat_getClusterChain12(fat_driver *fatd, unsigned int cluster, unsigne xbuf[3] = sbuf[1]; } } - if (sectorSpan) { // use xbuf as source buffer - cluster = fat_getClusterRecord12(xbuf + (recordOffset % fatd->partBpb.sectorSize) - (fatd->partBpb.sectorSize - 2), cluster % 2); - } else { // use sector buffer as source buffer - cluster = fat_getClusterRecord12(sbuf + (recordOffset % fatd->partBpb.sectorSize), cluster % 2); - } + cluster = fat_getClusterRecord12(sectorSpan ? (xbuf + (recordOffset % fatd->partBpb.sectorSize) - (fatd->partBpb.sectorSize - 2)) /* use xbuf as source buffer */ : (sbuf + (recordOffset % fatd->partBpb.sectorSize)) /* use sector buffer as source buffer */, cluster % 2); if ((cluster & 0xFFF) >= 0xFF8) { cont = 0; // continue = false @@ -347,13 +334,7 @@ static void fat_determineFatType(fat_bpb *partBpb) clusterCount = sector / partBpb->clusterSize; // XPRINTF("Data cluster count = %u \n", clusterCount); - if (clusterCount < 4085) { - partBpb->fatType = FAT12; - } else if (clusterCount < 65525) { - partBpb->fatType = FAT16; - } else { - partBpb->fatType = FAT32; - } + partBpb->fatType = (clusterCount < 4085) ? FAT12 : ((clusterCount < 65525) ? FAT16 : FAT32); } //--------------------------------------------------------------------------- @@ -408,9 +389,7 @@ static int fat_getPartitionBootSector(struct block_device *bd, unsigned int sect partBpb->trackSize = getUI16(bpb_raw->trackSize); partBpb->headCount = getUI16(bpb_raw->headCount); partBpb->sectorCount = getUI16(bpb_raw->sectorCountO); - if (partBpb->sectorCount == 0) { - partBpb->sectorCount = getUI32(bpb_raw->sectorCount); // large partition - } + partBpb->sectorCount = (partBpb->sectorCount == 0) ? getUI32(bpb_raw->sectorCount) : partBpb->sectorCount; // large partition partBpb->partStart = sector; partBpb->rootDirStart = partBpb->partStart + (partBpb->fatCount * partBpb->fatSize) + partBpb->resSectors; for (ret = 0; ret < 8; ret++) { @@ -426,11 +405,7 @@ static int fat_getPartitionBootSector(struct block_device *bd, unsigned int sect if (partBpb->fatType == FAT32 && partBpb->fatSize == 0) { partBpb->fatSize = getUI32(bpb32_raw->fatSize32); partBpb->activeFat = getUI16(bpb32_raw->fatStatus); - if (partBpb->activeFat & 0x80) { // fat not synced - partBpb->activeFat = (partBpb->activeFat & 0xF); - } else { - partBpb->activeFat = 0; - } + partBpb->activeFat = (partBpb->activeFat & 0x80) /* fat not synced */ ? (partBpb->activeFat & 0xF) : 0; partBpb->rootDirStart = partBpb->partStart + (partBpb->fatCount * partBpb->fatSize) + partBpb->resSectors; partBpb->rootDirCluster = getUI32(bpb32_raw->rootDirCluster); for (ret = 0; ret < 8; ret++) { @@ -533,10 +508,7 @@ int fat_getDirentry(unsigned char fatType, fat_direntry *dir_entry, fat_direntry for (i = 0; i < 8 && dir_entry->sfn.name[i] != ' '; i++) { dir->sname[i] = dir_entry->sfn.name[i]; // NT-adaption for LaunchELF - if (dir_entry->sfn.reservedNT & 0x08 && - dir->sname[i] >= 'A' && dir->sname[i] <= 'Z') { - dir->sname[i] += 0x20; // Force standard letters in name to lower case - } + dir->sname[i] += (dir_entry->sfn.reservedNT & 0x08 && dir->sname[i] >= 'A' && dir->sname[i] <= 'Z') ? 0x20 : 0; // Force standard letters in name to lower case } for (j = 0; j < 3 && dir_entry->sfn.ext[j] != ' '; j++) { if (j == 0) { @@ -545,10 +517,7 @@ int fat_getDirentry(unsigned char fatType, fat_direntry *dir_entry, fat_direntry } dir->sname[i + j] = dir_entry->sfn.ext[j]; // NT-adaption for LaunchELF - if (dir_entry->sfn.reservedNT & 0x10 && - dir->sname[i + j] >= 'A' && dir->sname[i + j] <= 'Z') { - dir->sname[i + j] += 0x20; // Force standard letters in ext to lower case - } + dir->sname[i + j] += (dir_entry->sfn.reservedNT & 0x10 && dir->sname[i + j] >= 'A' && dir->sname[i + j] <= 'Z') ? 0x20 : 0; // Force standard letters in ext to lower case } dir->sname[i + j] = 0; // terminate if (dir->name[0] == 0) { // long name desn't exit @@ -640,10 +609,8 @@ static void fat_setFatDir(fat_driver *fatd, fat_dir *fatDir, unsigned int parent M_DEBUG("%s\n", __func__); XPRINTF("setting fat dir...\n"); - srcName = dir->sname; - if (dir->name[0] != 0) { // long filename not empty - srcName = dir->name; - } + // long filename not empty + srcName = (dir->name[0] != 0) ? dir->name : dir->sname; // copy name for (i = 0; srcName[i] != 0; i++) fatDir->name[i] = srcName[i]; @@ -990,13 +957,8 @@ int fat_readFile(fat_driver *fatd, fat_dir *fatDir, unsigned int filePos, unsign j = (size + dataSkip) / fatd->partBpb.sectorSize + sectorSkip; toRead = 0; while (1) { - if (j >= fatd->partBpb.clusterSize) { - toRead += fatd->partBpb.clusterSize; - j -= fatd->partBpb.clusterSize; - } else { - toRead += j; - j = 0; - } + toRead += (j >= fatd->partBpb.clusterSize) ? fatd->partBpb.clusterSize : j; + j -= (j >= fatd->partBpb.clusterSize) ? fatd->partBpb.clusterSize : j; // Check that the next cluster is adjacent to this one, so we can read across. if ((i >= (unsigned int)(chainSize - 1)) || (fatd->cbuf[i] != (fatd->cbuf[i + 1] - 1))) @@ -1051,8 +1013,7 @@ int fat_readFile(fat_driver *fatd, fat_dir *fatDir, unsigned int filePos, unsign #ifdef BUILDING_USBHDFSD if (dataSkip > 0) { bufSize = mass_device->sectorSize - dataSkip; - if (size < bufSize) - bufSize = size; + bufSize = (size < bufSize) ? size : bufSize; ret = fat_readSingleSector(fatd->dev, startSector, buffer + bufferPos, bufSize, dataSkip); if (ret != 1) { diff --git a/iop/fs/vfat/src/fat_write.c b/iop/fs/vfat/src/fat_write.c index 81339069ff96..1e36d7df323b 100644 --- a/iop/fs/vfat/src/fat_write.c +++ b/iop/fs/vfat/src/fat_write.c @@ -115,10 +115,7 @@ static int fat_readEmptyClusters12(fat_driver *fatd) recordOffset = (cluster * 3) / 2; // offset of the cluster record (in bytes) from the FAT start fatSector = recordOffset / fatd->partBpb.sectorSize; - sectorSpan = 0; - if ((recordOffset % fatd->partBpb.sectorSize) == (fatd->partBpb.sectorSize - 1)) { - sectorSpan = 1; - } + sectorSpan = ((recordOffset % fatd->partBpb.sectorSize) == (fatd->partBpb.sectorSize - 1)) ? 1 : 0; if (lastFatSector != fatSector || sectorSpan) { ret = READ_SECTOR(DEV_ACCESSOR(fatd), fatd->partBpb.partStart + fatd->partBpb.resSectors + fatSector, sbuf); if (ret < 0) { @@ -139,11 +136,7 @@ static int fat_readEmptyClusters12(fat_driver *fatd) xbuf[3] = sbuf[1]; } } - if (sectorSpan) { // use xbuf as source buffer - clusterValue = fat_getClusterRecord12(xbuf + (recordOffset % fatd->partBpb.sectorSize) - (fatd->partBpb.sectorSize - 2), cluster % 2); - } else { // use sector buffer as source buffer - clusterValue = fat_getClusterRecord12(sbuf + (recordOffset % fatd->partBpb.sectorSize), cluster % 2); - } + clusterValue = fat_getClusterRecord12(sectorSpan ? (xbuf + (recordOffset % fatd->partBpb.sectorSize) - (fatd->partBpb.sectorSize - 2)) /* use xbuf as source buffer */ : (sbuf + (recordOffset % fatd->partBpb.sectorSize)) /* use sector buffer as source buffer */, cluster % 2); if (clusterValue == 0) { fatd->clStackLast = cluster; fatd->clStack[fatd->clStackIndex] = cluster; @@ -305,34 +298,20 @@ static int fat_readEmptyClusters(fat_driver *fatd) */ static void fat_setClusterRecord12(unsigned char *buf, unsigned int cluster, int type) { - - if (type) { // type 1 - buf[0] = (buf[0] & 0x0F) + ((cluster & 0x0F) << 4); - buf[1] = (cluster & 0xFF0) >> 4; - } else { // type 0 - buf[0] = (cluster & 0xFF); - buf[1] = (buf[1] & 0xF0) + ((cluster & 0xF00) >> 8); - } + buf[0] = type ? ((buf[0] & 0x0F) + ((cluster & 0x0F) << 4)) /* type 1 */ : (cluster & 0xFF) /* type 0 */; + buf[1] = type ? ((cluster & 0xFF0) >> 4) /* type 1 */ : ((buf[1] & 0xF0) + ((cluster & 0xF00) >> 8)) /* type 0 */; } //--------------------------------------------------------------------------- static void fat_setClusterRecord12part1(unsigned char *buf, unsigned int cluster, int type) { - if (type) { // type 1 - buf[0] = (buf[0] & 0x0F) + ((cluster & 0x0F) << 4); - } else { // type 0 - buf[0] = (cluster & 0xFF); - } + buf[0] = type ? ((buf[0] & 0x0F) + ((cluster & 0x0F) << 4)) /* type 1 */ : (cluster & 0xFF) /* type 0 */; } //--------------------------------------------------------------------------- static void fat_setClusterRecord12part2(unsigned char *buf, unsigned int cluster, int type) { - if (type) { // type 1 - buf[0] = (cluster & 0xFF0) >> 4; - } else { // type 0 - buf[0] = (buf[0] & 0xF0) + ((cluster & 0xF00) >> 8); - } + buf[0] = type ? ((cluster & 0xFF0) >> 4) /* type 1 */ : ((buf[0] & 0xF0) + ((cluster & 0xF00) >> 8)) /* type 0 */; } //--------------------------------------------------------------------------- @@ -360,9 +339,7 @@ static int fat_saveClusterRecord12(fat_driver *fatd, unsigned int currentCluster fatSector = fatd->partBpb.partStart + fatd->partBpb.resSectors + (fatNumber * fatd->partBpb.fatSize); fatSector += recordOffset / fatd->partBpb.sectorSize; sectorSpan = fatd->partBpb.sectorSize - (recordOffset % fatd->partBpb.sectorSize); - if (sectorSpan > 1) { - sectorSpan = 0; - } + sectorSpan = (sectorSpan > 1) ? 0 : sectorSpan; recordType = currentCluster % 2; ret = READ_SECTOR(DEV_ACCESSOR(fatd), fatSector, sbuf); @@ -656,15 +633,8 @@ static unsigned int fat_getFreeCluster(fat_driver *fatd, unsigned int currentClu // pop from cluster stack fatd->clStackIndex--; result = fatd->clStack[fatd->clStackIndex]; - // append the cluster chain - if (currentCluster) { - ret = fat_appendClusterChain(fatd, currentCluster, result); - } else { // create new cluster chain - ret = fat_createClusterChain(fatd, result); - } - if (ret < 0) - return 0; - return result; + ret = currentCluster ? fat_appendClusterChain(fatd, currentCluster, result) /* append the cluster chain */ : fat_createClusterChain(fatd, result) /* create new cluster chain */; + return (ret < 0) ? 0 : result; } //--------------------------------------------------------------------------- @@ -711,10 +681,7 @@ static void setLfnEntry(const char *lname, int nameSize, unsigned char chsum, fa int nameStart; nameStart = 13 * (part - 1); - j = nameSize - nameStart; - if (j > 13) { - j = 13; - } + j = ((nameSize - nameStart) > 13) ? 13 : (nameSize - nameStart); // fake unicode conversion for (i = 0; i < j; i++) { @@ -724,18 +691,12 @@ static void setLfnEntry(const char *lname, int nameSize, unsigned char chsum, fa // rest of the name is zero terminated and padded with 0xFF for (i = j; i < 13; i++) { - if (i == j) { - name[i * 2] = 0; - name[i * 2 + 1] = 0; - } else { - name[i * 2] = 0xFF; - name[i * 2 + 1] = 0xFF; - } + name[i * 2] = (i == j) ? 0 : 0xFF; + name[i * 2 + 1] = (i == j) ? 0 : 0xFF; } dlfn->entrySeq = part; - if (maxPart == part) - dlfn->entrySeq |= 0x40; + dlfn->entrySeq |= (maxPart == part) ? 0x40 : 0; dlfn->checksum = chsum; // 1st part of the name for (i = 0; i < 10; i++) @@ -836,11 +797,7 @@ static void setSfnEntry(const char *shortName, char directory, fat_direntry_sfn for (i = 0; i < 3; i++) dsfn->ext[i] = shortName[i + 8]; - if (directory > 0) { - dsfn->attr = FAT_ATTR_DIRECTORY; - } else { - dsfn->attr = FAT_ATTR_ARCHIVE; - } + dsfn->attr = (directory > 0) ? FAT_ATTR_DIRECTORY : FAT_ATTR_ARCHIVE; dsfn->reservedNT = 0; dsfn->clusterH[0] = (cluster & 0xFF0000) >> 16; dsfn->clusterH[1] = (cluster & 0xFF000000) >> 24; @@ -968,10 +925,7 @@ static int separatePathAndName(const char *fname, char *path, char *name) int path_len; const char *sp, *np; - if (!(sp = strrchr(fname, '/'))) // if last path separator missing ? - np = fname; // name starts at start of fname string - else // else last path separator found - np = sp + 1; // name starts after separator + np = (!(sp = strrchr(fname, '/'))) /* if last path separator missing ? */ ? fname /* name starts at start of fname string */ : /* else last path separator found */ (sp + 1) /* name starts after separator */; if (strlen(np) >= FAT_MAX_NAME) // if name is too long return -ENAMETOOLONG; // return error code strcpy(name, np); // copy name from correct part of fname string @@ -1243,9 +1197,7 @@ static int fat_fillDirentryInfo(fat_driver *fatd, const char *lname, const char // file we want to create already exist - return the cluster of the file if ((directory >= 0) && ((dir.attr & FAT_ATTR_DIRECTORY) != directory)) { // found directory but requested is file (and vice veresa) - if (directory) - return -ENOTDIR; - return -EISDIR; + return (directory) ? -ENOTDIR : -EISDIR; } // ends "if" clause for mismatched file/folder state XPRINTF("I: entry found! %s, %s = %s\n", dir.name, dir.sname, lname); *retSector = theSector; @@ -1257,8 +1209,7 @@ static int fat_fillDirentryInfo(fat_driver *fatd, const char *lname, const char return 0; } // ends "if" clause for matching name seq = getShortNameSequence((char *)dir_entry->sfn.name, (char *)dir_entry->sfn.ext, sname); - if (seq < SEQ_MASK_SIZE) - fatd->seq_mask[seq >> 3] |= (1 << (seq & 7)); + fatd->seq_mask[seq >> 3] |= (seq < SEQ_MASK_SIZE) ? (1 << (seq & 7)) : 0; fatd->deIdx = 0; // clear name strings dir.sname[0] = 0; @@ -2397,13 +2348,8 @@ int fat_writeFile(fat_driver *fatd, fat_dir *fatDir, int *updateClusterIndices, j = (size + dataSkip) / fatd->partBpb.sectorSize + sectorSkip; toWrite = 0; while (1) { - if (j >= fatd->partBpb.clusterSize) { - toWrite += fatd->partBpb.clusterSize; - j -= fatd->partBpb.clusterSize; - } else { - toWrite += j; - j = 0; - } + toWrite += (j >= fatd->partBpb.clusterSize) ? fatd->partBpb.clusterSize : j; + j -= (j >= fatd->partBpb.clusterSize) ? fatd->partBpb.clusterSize : j; // Check that the next cluster is adjacent to this one, so we can write across. if ((i >= chainSize - 1) || (fatd->cbuf[i] != (fatd->cbuf[i + 1] - 1))) @@ -2420,8 +2366,7 @@ int fat_writeFile(fat_driver *fatd, fat_dir *fatDir, int *updateClusterIndices, // process all sectors of the cluster (and skip leading sectors if needed) if (dataSkip > 0) { bufSize = mass_device->sectorSize - dataSkip; - if (size < bufSize) - bufSize = size; + bufSize = (size < bufSize) ? size : bufSize; ret = fat_writeSingleSector(fatd->dev, startSector, buffer + bufferPos, bufSize, dataSkip); if (ret != 1) { diff --git a/iop/fs/vfat/src/fs_driver.c b/iop/fs/vfat/src/fs_driver.c index 05979411201a..5ddcc108eed7 100644 --- a/iop/fs/vfat/src/fs_driver.c +++ b/iop/fs/vfat/src/fs_driver.c @@ -89,14 +89,8 @@ static fs_rec fsRec[MAX_FILES]; // file info record static void fillStat(iox_stat_t *stat, const fat_dir *fatdir) { stat->mode = FIO_S_IROTH | FIO_S_IXOTH; - if (fatdir->attr & FAT_ATTR_DIRECTORY) { - stat->mode |= FIO_S_IFDIR; - } else { - stat->mode |= FIO_S_IFREG; - } - if (!(fatdir->attr & FAT_ATTR_READONLY)) { - stat->mode |= FIO_S_IWOTH; - } + stat->mode |= (fatdir->attr & FAT_ATTR_DIRECTORY) ? FIO_S_IFDIR : FIO_S_IFREG; + stat->mode |= (!(fatdir->attr & FAT_ATTR_READONLY)) ? FIO_S_IWOTH : 0; stat->size = fatdir->size; @@ -539,9 +533,8 @@ static int fs_read(iop_file_t *fd, void *buffer, int size) } result = fat_readFile(fatd, &rec->dirent.fatdir, rec->filePos, (unsigned char *)buffer, size); - if (result > 0) { // read succesful - rec->filePos += result; - } + // read succesful + rec->filePos += (result > 0) ? result : 0; _fs_unlock(); return result; diff --git a/iop/fs/vfat/src/scache.c b/iop/fs/vfat/src/scache.c index a2756a67088a..a373eafca519 100644 --- a/iop/fs/vfat/src/scache.c +++ b/iop/fs/vfat/src/scache.c @@ -121,10 +121,7 @@ static int getIndexRead(cache_set *cache, unsigned int sector) cache->rec[i].tax--; // apply tax penalty } } - if (index < 0) - return index; - else - return ((index * cache->indexLimit) + (sector - cache->rec[index].sector)); + return (index < 0) ? index : ((index * cache->indexLimit) + (sector - cache->rec[index].sector)); } //--------------------------------------------------------------------------- diff --git a/iop/hdd/apa/src/hdd.c b/iop/hdd/apa/src/hdd.c index 536265f39eb1..06f26f315ddc 100644 --- a/iop/hdd/apa/src/hdd.c +++ b/iop/hdd/apa/src/hdd.c @@ -201,9 +201,7 @@ static int unlockDrive(s32 device) { int rv; u8 id[32]; - if((rv=apaGetIlinkID(id))==0) - return sceAtaSecurityUnLock(device, id); - return rv; + return ((rv=apaGetIlinkID(id))==0) ? sceAtaSecurityUnLock(device, id) : rv; } #endif diff --git a/iop/hdd/apa/src/hdd_blkio.c b/iop/hdd/apa/src/hdd_blkio.c index 6a734a182ffb..a51afebac5e1 100644 --- a/iop/hdd/apa/src/hdd_blkio.c +++ b/iop/hdd/apa/src/hdd_blkio.c @@ -125,10 +125,7 @@ static int hdd_blkio_fs_driver_mount_bd(int mount_info_index, struct block_devic return -1; } // Check if drive is formatted in APA - if (apaGetFormat(mount_info_index, &hddDevices[mount_info_index].format) != 0) - { - hddDevices[mount_info_index].status -= 1; - } + hddDevices[mount_info_index].status -= (apaGetFormat(mount_info_index, &hddDevices[mount_info_index].format) != 0) ? 1 : 0; if (hddDevices[mount_info_index].status != 0) { fs_driver_mount_info[mount_info_index].mounted_bd = NULL; @@ -265,10 +262,7 @@ int hdd_blkio_vhdd_mount(int slot, const char *filename) goto cleanup; } // Check if drive is formatted in APA - if (apaGetFormat(slot, &hddDevices[slot].format) != 0) - { - hddDevices[slot].status -= 1; - } + hddDevices[slot].status -= (apaGetFormat(slot, &hddDevices[slot].format) != 0) ? 1 : 0; if (hddDevices[slot].status != 0) { r = -EIO; diff --git a/iop/hdd/apa/src/hdd_fio.c b/iop/hdd/apa/src/hdd_fio.c index 76de6bbea293..15e7595a30b6 100644 --- a/iop/hdd/apa/src/hdd_fio.c +++ b/iop/hdd/apa/src/hdd_fio.c @@ -470,10 +470,7 @@ static int apaOpen(s32 device, hdd_file_slot_t *fileSlot, apa_params_t *params, fileSlot->nsub = clink->header->nsub; memcpy(&fileSlot->id, &clink->header->id, APA_IDMAX); apaCacheFree(clink); - if (apaPassCmp(clink->header->fpwd, params->fpwd) != 0) { - rv = (!(mode & FIO_O_WRONLY)) ? apaPassCmp(clink->header->rpwd, params->rpwd) : -EACCES; - } else - rv = 0; + rv = (apaPassCmp(clink->header->fpwd, params->fpwd) != 0) ? ((!(mode & FIO_O_WRONLY)) ? apaPassCmp(clink->header->rpwd, params->rpwd) : -EACCES) : 0; return rv; } @@ -622,11 +619,7 @@ int hddOpen(iomanX_iop_file_t *f, const char *name, int flags, int mode) } } else { #ifdef APA_SUPPORT_BHDD - if (strcmp(f->device->name, "bhdd") == 0) { - fileSlot->parts[0].start = hddDevices[f->unit].totalLBA; - } else { - fileSlot->parts[0].start = 0; - } + fileSlot->parts[0].start = (strcmp(f->device->name, "bhdd") == 0) ? hddDevices[f->unit].totalLBA : 0; #endif fileSlot->f = f; f->privdata = fileSlot; @@ -703,13 +696,10 @@ static void fioGetStatFiller(apa_cache_t *clink, iox_stat_t *stat) memcpy(&stat->ctime, &clink->header->created, sizeof(apa_ps2time_t)); memcpy(&stat->atime, &clink->header->created, sizeof(apa_ps2time_t)); memcpy(&stat->mtime, &clink->header->created, sizeof(apa_ps2time_t)); + stat->private_0 = (clink->header->flags & APA_FLAG_SUB) ? clink->header->number : clink->header->nsub; stat->private_1 = 0; stat->private_2 = 0; - if (clink->header->flags & APA_FLAG_SUB) - stat->private_0 = clink->header->number; - else { - stat->private_0 = clink->header->nsub; - + if (!(clink->header->flags & APA_FLAG_SUB)) { u64 totalsize = (u64)clink->header->length; for (int i = 0; i < clink->header->nsub; i++) { totalsize += (u64)clink->header->subs[i].length; @@ -787,10 +777,7 @@ int hddDread(iomanX_iop_file_t *f, iox_dirent_t *dirent) rv = strlen(dirent->name); } fioGetStatFiller(clink, &dirent->stat); - if (clink->header->next == 0) - fileSlot->parts[0].start = -1; // mark end - else - fileSlot->parts[0].start = clink->header->next; // set next + fileSlot->parts[0].start = (clink->header->next == 0) ? -1 /* mark end */ : clink->header->next /* set next */; apaCacheFree(clink); } SignalSema(fioSema); diff --git a/iop/hdd/fsck/src/fsck.c b/iop/hdd/fsck/src/fsck.c index dc3d7e31ce69..0324ef22cab0 100644 --- a/iop/hdd/fsck/src/fsck.c +++ b/iop/hdd/fsck/src/fsck.c @@ -543,9 +543,8 @@ static void fsckFixDEntry(pfs_cache_t *clink, pfs_dentry_t *dentry) pfs_dentry_t *pDEntryNew, *pDEntry; dEntrySize = (u32)((u8 *)dentry - (u8 *)clink->u.dentry); - // if((s32)dEntrySize < 0) - if (clink->u.dentry > dentry) - dEntrySize += 0x1FF; + // ((s32)dEntrySize < 0) + dEntrySize += (clink->u.dentry > dentry) ? 0x1FF : 0; dEntrySize = dEntrySize >> 9 << 9; // Round off pDEntryNew = (pfs_dentry_t *)((u8 *)clink->u.dentry + dEntrySize); @@ -905,9 +904,7 @@ static int fsckCheckBitmap(pfs_mount_t *mount, void *buffer) block = 0; for (block = 0, count = pfsGetBitmapSizeBlocks(mount->sector_scale, ZoneSizes[i]); block < count; block++) { BitmapStart = block + 1; - if (i == 0) { - BitmapStart += 0x2000 >> mount->sector_scale; - } + BitmapStart += (i == 0) ? (0x2000 >> mount->sector_scale) : 0; if ((result = mount->blockDev->transfer(mount->fd, buffer, i, BitmapStart << mount->sector_scale, 1 << mount->sector_scale, PFS_IO_MODE_READ)) < 0) { PFS_PRINTF("cannot read bitmap\n"); @@ -1107,9 +1104,7 @@ static int FsckOpen(iomanX_iop_file_t *fd, const char *name, int flags, int mode fsckRuntimeData.status.zoneUsed = MainPFSMount.total_zones - MainPFSMount.zfree; for (i = 0; (u32)i < MainPFSMount.num_subs + 1; fsckRuntimeData.status.inodeBlockCount += count, i++) { count = pfsGetBitmapSizeBlocks(MainPFSMount.sector_scale, ZoneSizes[i]) + 1; - if (i == 0) { - count += (0x2000 >> MainPFSMount.sector_scale) + MainPFSMount.log.count; - } + count += (i == 0) ? ((0x2000 >> MainPFSMount.sector_scale) + MainPFSMount.log.count) : 0; if (fsckCheckZones(ZoneMap[i], count) < 0) { break; diff --git a/iop/hdd/fssk/src/fssk.c b/iop/hdd/fssk/src/fssk.c index 437b171de17f..00568fb1f4b7 100644 --- a/iop/hdd/fssk/src/fssk.c +++ b/iop/hdd/fssk/src/fssk.c @@ -212,9 +212,7 @@ static int fsckBitmapSearchFreeZoneSpecial(pfs_mount_t *pfsMount, pfs_blockinfo_ num++; } count = (max_count < 33) ? max_count : 32; - if (count < bi->count) { - count = bi->count; - } + count = (count < bi->count) ? bi->count : count; for (--num; num >= 0; num--) { for (i = count; i != 0; i /= 2) { diff --git a/iop/hdd/hdsk/src/hdsk.c b/iop/hdd/hdsk/src/hdsk.c index c1fc365784ac..e7740156754d 100644 --- a/iop/hdd/hdsk/src/hdsk.c +++ b/iop/hdd/hdsk/src/hdsk.c @@ -703,8 +703,7 @@ static int HdskDevctl(iomanX_iop_file_t *fd, const char *name, int cmd, void *ar break; case HDSK_DEVCTL_POLL: result = PollEventFlag(hdskEventFlagID, 1, WEF_CLEAR | WEF_OR, &bits); - if (result == KE_EVF_COND) - result = 1; + result = (result == KE_EVF_COND) ? 1 : result; break; case HDSK_DEVCTL_GET_STATUS: result = hdskStatus; diff --git a/iop/hdd/hdsk/src/sim.c b/iop/hdd/hdsk/src/sim.c index 5241aa58a3a5..36d2e54f3ab6 100644 --- a/iop/hdd/hdsk/src/sim.c +++ b/iop/hdd/hdsk/src/sim.c @@ -34,9 +34,7 @@ void hdskSimGetFreeSectors(s32 device, struct hdskStat *stat, apa_device_t *devi #endif for (i = 0; hdskBitmap[i].next != hdskBitmap; sectors += hdskBitmap[i].length, i++) { if (hdskBitmap[i].type == 0) { - if ((maxsize < hdskBitmap[i].length) || ((stat->free & hdskBitmap[i].length) == 0)) { - stat->free += hdskBitmap[i].length; - } + stat->free += ((maxsize < hdskBitmap[i].length) || ((stat->free & hdskBitmap[i].length) == 0)) ? hdskBitmap[i].length : 0; sectors += hdskBitmap[i].length; } } @@ -45,9 +43,7 @@ void hdskSimGetFreeSectors(s32 device, struct hdskStat *stat, apa_device_t *devi for (; minsize < partMax; partMax /= 2) { // Non-SONY: Perform 64-bit arithmetic here to avoid overflows when dealing with large disks. if ((sectors % partMax == 0) && ((u64)sectors + partMax < deviceinfo[device].totalLBA)) { - if ((maxsize < partMax) || (stat->free & partMax) == 0) { - stat->free += partMax; - } + stat->free += ((maxsize < partMax) || (stat->free & partMax) == 0) ? partMax : 0; sectors += partMax; break; } @@ -229,19 +225,7 @@ static int hdskCheckIsLastPart(struct hdskBitmap *part, u32 size, int mode) } } - if (PartSize == size) { - if (mode != 0) { - if (part->start % (size * 2) != 0) { - return (hdskCheckIfPrevPartEmpty(part, size) == 0 ? 0 : 1); - } else { - return (CurrPart != hdskBitmap[0].prev ? (hdskCheckIfNextPartEmpty(CurrPart, size) != 0) : 1); - } - } else { - return 1; - } - } - - return 0; + return (PartSize == size) ? ((mode != 0) ? ((part->start % (size * 2) != 0) ? (hdskCheckIfPrevPartEmpty(part, size) == 0 ? 0 : 1) : (CurrPart != hdskBitmap[0].prev ? (hdskCheckIfNextPartEmpty(CurrPart, size) != 0) : 1)) : 1) : 0; } struct hdskBitmap *hdskSimFindLastUsedBlock(u32 size, u32 start, int mode) diff --git a/iop/hdd/libapa/src/apa.c b/iop/hdd/libapa/src/apa.c index bf1ad953f1ba..3451099cab43 100644 --- a/iop/hdd/libapa/src/apa.c +++ b/iop/hdd/libapa/src/apa.c @@ -449,9 +449,7 @@ int apaReadHeader(s32 device, apa_header_t *header, u32 lba) int apaWriteHeader(s32 device, apa_header_t *header, u32 lba) { - if (blkIoDmaTransfer(device, header, lba, 2, BLKIO_DIR_WRITE)) - return -EIO; - return 0; + return (blkIoDmaTransfer(device, header, lba, 2, BLKIO_DIR_WRITE)) ? -EIO : 0; } int apaGetFormat(s32 device, int *format) diff --git a/iop/hdd/libapa/src/cache.c b/iop/hdd/libapa/src/cache.c index 2d596fa2e623..232aba54b12e 100644 --- a/iop/hdd/libapa/src/cache.c +++ b/iop/hdd/libapa/src/cache.c @@ -89,10 +89,7 @@ apa_cache_t *apaCacheUnLink(apa_cache_t *clink) int apaCacheTransfer(apa_cache_t *clink, int type) { int err; - if(type) - err=apaWriteHeader(clink->device, clink->header, clink->sector); - else// 0 - err=apaReadHeader(clink->device, clink->header, clink->sector); + err = (type ? apaWriteHeader : apaReadHeader)(clink->device, clink->header, clink->sector); if(err) { diff --git a/iop/hdd/libapa/src/journal.c b/iop/hdd/libapa/src/journal.c index 67a8c6781569..5839e8718626 100644 --- a/iop/hdd/libapa/src/journal.c +++ b/iop/hdd/libapa/src/journal.c @@ -28,13 +28,7 @@ static apa_journal_t journalBuf; int apaJournalFlush(s32 device) {// this write any thing that in are journal buffer :) - if(blkIoFlushCache(device)) - return -EIO; - if(blkIoDmaTransfer(device, &journalBuf, APA_SECTOR_APAL, 1, BLKIO_DIR_WRITE)) - return -EIO; - if(blkIoFlushCache(device)) - return -EIO; - return 0; + return (blkIoFlushCache(device) || blkIoDmaTransfer(device, &journalBuf, APA_SECTOR_APAL, 1, BLKIO_DIR_WRITE) || blkIoFlushCache(device)) ? -EIO : 0; } int apaJournalReset(s32 device) diff --git a/iop/hdd/libapa/src/password.c b/iop/hdd/libapa/src/password.c index f6e8921e2123..5a4ad01549f8 100644 --- a/iop/hdd/libapa/src/password.c +++ b/iop/hdd/libapa/src/password.c @@ -141,18 +141,8 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c { shift = PC1[i] - 1; - if((shift << 26) >= 0) - { //0 to 31-bit shift - if((shift << 26) > 0) //Shift all bits left by shift (hi,lo >> shift) - key1 = (BitMask_lo >> shift) | (BitMask_hi << (-shift)); - else //0-bit shift, which should not happen. - key1 = BitMask_lo >> shift; - - key2 = BitMask_hi >> shift; - } else { //>31-bit shift - key2 = 0; - key1 = BitMask_hi >> shift; - } + key1 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (((shift << 26) > 0) ? /* Shift all bits left by shift (hi,lo >> shift) */ ((BitMask_lo >> shift) | (BitMask_hi << (-shift))) : /* 0-bit shift, which should not happen. */ (BitMask_lo >> shift)) : /* >31-bit shift */ (BitMask_hi >> shift); + key2 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (BitMask_hi >> shift) : /* >31-bit shift */ 0; //If bit (shift) is set, set the current bit. if(((password_lo & key1) | (password_hi & key2)) != 0) @@ -187,64 +177,36 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c //Calculate all Cn and Dn. for(i = 0; i < 16; i++) { - if(Rotations[i] != 1) - { //Rotate left twice - //hi 26:0 | lo 31:26 - key1 = ((pairC[i].hi << 6) | (pairC[i].lo >> 26)) & Rot2Mask_lo; - //lo 29:0 - //key1|key 4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLXX, where X is from key1 - key4 = pairC[i].lo << 2; - //hi 31:26 - //This part is discarded. - key2 = (pairC[i].hi >> 26) & Rot2Mask_hi; - //hi 29:2 | lo 31:30 - //key2|key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHLL - key3 = (pairC[i].hi << 2) | (pairC[i].lo >> 30); - } else { //Rotate left once - //hi 27:0 | lo 31:27 - key1 = ((pairC[i].hi << 5) | (pairC[i].lo >> 27)) & Rot1Mask_lo; - //lo 30:0 - //key1|key4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLX, where X is from key1 - key4 = pairC[i].lo << 1; - //hi 31:27 - //This part is discarded. - key2 = (pairC[i].hi >> 27) & Rot1Mask_hi; - //hi 30:0 | lo 31:31 - //key2:key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHL - key3 = (pairC[i].hi << 1) | (pairC[i].lo >> 31); - } + //Rotate left twice / Rotate left once + //hi 26:0 | lo 31:26 / hi 27:0 | lo 31:27 + key1 = (Rotations[i] != 1) ? (((pairC[i].hi << 6) | (pairC[i].lo >> 26)) & Rot2Mask_lo) : (((pairC[i].hi << 5) | (pairC[i].lo >> 27)) & Rot1Mask_lo); + //lo 29:0 / lo 30:0 + //key1|key 4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLXX, where X is from key1 / key1|key4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLX, where X is from key1 + key4 = (Rotations[i] != 1) ? (pairC[i].lo << 2) : (pairC[i].lo << 1); + //hi 31:26 / hi 31:27 + //This part is discarded. / This part is discarded. + key2 = (Rotations[i] != 1) ? ((pairC[i].hi >> 26) & Rot2Mask_hi) : ((pairC[i].hi >> 27) & Rot1Mask_hi); + //hi 29:2 | lo 31:30 / hi 30:0 | lo 31:31 + //key2|key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHLL / key2:key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHL + key3 = (Rotations[i] != 1) ? ((pairC[i].hi << 2) | (pairC[i].lo >> 30)) : ((pairC[i].hi << 1) | (pairC[i].lo >> 31)); //Merge the two rotated parts together, for the hi and low pair. //Note: hi contains nothing. pairC[i + 1].lo = (key1 | key4) & PermutedKeyMask_lo; pairC[i + 1].hi = (key2 | key3) & PermutedKeyMask_hi; - if(Rotations[i] != 1) - { //Rotate left twice - //hi 26:0 | lo 31:26 - key1 = ((pairD[i].hi << 6) | (pairD[i].lo >> 26)) & Rot2Mask_lo; - //lo 29:0 - //key1|key 4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLXX, where X is from key1 - key4 = pairD[i].lo << 2; - //hi 31:26 - //This part is discarded. - key2 = (pairD[i].hi >> 26) & Rot2Mask_hi; - //hi 29:2 | lo 31:30 - //key2|key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHLL - key3 = (pairD[i].hi << 2) | (pairD[i].lo >> 30); - } else { //Rotate left once - //hi 27:0 | lo 31:27 - key1 = ((pairD[i].hi << 5) | (pairD[i].lo >> 27)) & Rot1Mask_lo; - //lo 30:0 - //key1|key4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLX, where X is from key1 - key4 = pairD[i].lo << 1; - //hi 31:27 - //This part is discarded. - key2 = (pairD[i].hi >> 27) & Rot1Mask_hi; - //hi 30:0 | lo 31:31 - //key2:key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHL - key3 = (pairD[i].hi << 1) | (pairD[i].lo >> 31); - } + //Rotate left twice / Rotate left once + //hi 26:0 | lo 31:26 / hi 27:0 | lo 31:27 + key1 = (Rotations[i] != 1) ? (((pairD[i].hi << 6) | (pairD[i].lo >> 26)) & Rot2Mask_lo) : (((pairD[i].hi << 5) | (pairD[i].lo >> 27)) & Rot1Mask_lo); + //lo 29:0 / lo 30:0 + //key1|key 4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLXX, where X is from key1 / key1|key4 results in: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLX, where X is from key1 + key4 = (Rotations[i] != 1) ? (pairD[i].lo << 2) : (pairD[i].lo << 1); + //hi 31:26 / hi 31:27 + //This part is discarded. / This part is discarded. + key2 = (Rotations[i] != 1) ? ((pairD[i].hi >> 26) & Rot2Mask_hi) : ((pairD[i].hi >> 27) & Rot1Mask_hi); + //hi 29:2 | lo 31:30 / hi 30:0 | lo 31:31 + //key2|key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHLL / key2:key3 results in: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHL + key3 = (Rotations[i] != 1) ? ((pairD[i].hi << 2) | (pairD[i].lo >> 30)) : ((pairD[i].hi << 1) | (pairD[i].lo >> 31)); //Merge the two rotated parts together, for the hi and low pair. //Note: hi contains nothing. @@ -283,18 +245,8 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c { shift = PC2[i] - 1; - if((shift << 26) >= 0) - { //0 to 31-bit shift - if((shift << 26) > 0) //Shift all bits left by shift (hi,lo >> shift) - key1 = (BitMask_lo >> shift) | (BitMask_hi << (-shift)); - else //0-bit shift, which should not happen. - key1 = BitMask_lo >> shift; - - key2 = BitMask_hi >> shift; - } else { //>31-bit shift - key2 = 0; - key1 = BitMask_hi >> shift; - } + key1 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (((shift << 26) > 0) ? /* Shift all bits left by shift (hi,lo >> shift) */ ((BitMask_lo >> shift) | (BitMask_hi << (-shift))) : /* 0-bit shift, which should not happen. */ (BitMask_lo >> shift)) : /* >31-bit shift */ (BitMask_hi >> shift); + key2 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (BitMask_hi >> shift) : /* >31-bit shift */ 0; //If bit (shift) is set, set the current bit. if(((input_lo & key1) | (input_hi & key2)) != 0) @@ -325,18 +277,8 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c { shift = IP[i] - 1; - if((shift << 26) >= 0) - { //0 to 31-bit shift - if((shift << 26) > 0) //Shift all bits left by shift (hi,lo >> shift) - key1 = (BitMask_lo >> shift) | (BitMask_hi << (-shift)); - else //0-bit shift, which should not happen. - key1 = BitMask_lo >> shift; - - key2 = BitMask_hi >> shift; - } else { //>31-bit shift - key2 = 0; - key1 = BitMask_hi >> shift; - } + key1 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (((shift << 26) > 0) ? /* Shift all bits left by shift (hi,lo >> shift) */ ((BitMask_lo >> shift) | (BitMask_hi << (-shift))) : /* 0-bit shift, which should not happen. */ (BitMask_lo >> shift)) : /* >31-bit shift */ (BitMask_hi >> shift); + key2 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (BitMask_hi >> shift) : /* >31-bit shift */ 0; //If bit (shift) is set, set the current bit. if(((id_lo & key1) | (id_hi & key2)) != 0) @@ -376,18 +318,8 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c for(i = 0; i < 48; i++) { shift = Expansion[i] - 1; - if((shift << 26) >= 0) - { //0 to 31-bit shift - if((shift << 26) > 0) //Shift all bits left by shift (hi,lo >> shift) - key1 = (BitMask_lo >> shift) | (BitMask_hi << (-shift)); - else //0-bit shift, which should not happen. - key1 = BitMask_lo >> shift; - - key2 = BitMask_hi >> shift; - } else { //>31-bit shift - key2 = 0; - key1 = BitMask_hi >> shift; - } + key1 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (((shift << 26) > 0) ? /* Shift all bits left by shift (hi,lo >> shift) */ ((BitMask_lo >> shift) | (BitMask_hi << (-shift))) : /* 0-bit shift, which should not happen. */ (BitMask_lo >> shift)) : /* >31-bit shift */ (BitMask_hi >> shift); + key2 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (BitMask_hi >> shift) : /* >31-bit shift */ 0; //If bit (shift) is set, set the current bit. if(((input_lo & key1) | (input_hi & key2)) != 0) @@ -420,18 +352,8 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c eVal_hi >>= 6; input_hi = 0; - if((s32)((u32)shift << 26) >= 0) - { //0 to 31-bit shift - if((shift << 26) > 0) //Shift all bits right by shift (hi,lo >> shift) - key3 = (input_hi << shift) | (input_lo >> (-shift)); - else //0-bit shift, which should not happen. - key3 = input_hi << shift; - - key4 = input_lo << shift; - } else { //>31-bit shift - key3 = input_lo << shift; - key4 = 0; - } + key3 = ((s32)((u32)shift << 26) >= 0) ? /* 0 to 31-bit shift */ (((shift << 26) > 0) ? /* Shift all bits right by shift (hi,lo >> shift) */ ((input_hi << shift) | (input_lo >> (-shift))) : /* 0-bit shift, which should not happen. */ (input_hi << shift)) : /* >31-bit shift */ (input_lo << shift); + key4 = ((s32)((u32)shift << 26) >= 0) ? /* 0 to 31-bit shift */ (input_lo << shift) : /* >31-bit shift */ 0; sVal_lo |= key4; sVal_hi |= key3; @@ -447,18 +369,8 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c for(i = 0; i < 32; i++) { shift = Permutation[i] - 1; - if((shift << 26) >= 0) - { //0 to 31-bit shift - if((shift << 26) > 0) //Shift all bits left by shift (hi,lo >> shift) - key1 = (BitMask_lo >> shift) | (BitMask_hi << (-shift)); - else //0-bit shift, which should not happen. - key1 = BitMask_lo >> shift; - - key2 = BitMask_hi >> shift; - } else { //>31-bit shift - key1 = BitMask_hi >> shift; - key2 = 0; - } + key1 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (((shift << 26) > 0) ? /* Shift all bits left by shift (hi,lo >> shift) */ ((BitMask_lo >> shift) | (BitMask_hi << (-shift))) : /* 0-bit shift, which should not happen. */ (BitMask_lo >> shift)) : /* >31-bit shift */ (BitMask_hi >> shift); + key2 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (BitMask_hi >> shift) : /* >31-bit shift */ 0; //If bit (shift) is set, set the current bit. if(((sVal_lo & key1) | (sVal_hi & key2)) != 0) @@ -491,18 +403,8 @@ static void DESEncryptPassword(u32 id_lo, u32 id_hi, char *password_out, const c for(i = 0; i < 64; i++) { shift = FP[i] - 1; - if((shift << 26) >= 0) - { //0 to 31-bit shift - if((shift << 26) > 0) //Shift all bits left by shift (hi,lo >> shift) - key1 = (BitMask_lo >> shift) | (BitMask_hi << (-shift)); - else //0-bit shift, which should not happen. - key1 = BitMask_lo >> shift; - - key2 = BitMask_hi >> shift; - } else { //>31-bit shift - key1 = BitMask_hi >> shift; - key2 = 0; - } + key1 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (((shift << 26) > 0) ? /* Shift all bits left by shift (hi,lo >> shift) */ ((BitMask_lo >> shift) | (BitMask_hi << (-shift))) : /* 0-bit shift, which should not happen. */ (BitMask_lo >> shift)) : /* >31-bit shift */ (BitMask_hi >> shift); + key2 = ((shift << 26) >= 0) ? /* 0 to 31-bit shift */ (BitMask_hi >> shift) : /* >31-bit shift */ 0; //If bit (shift) is set, set the current bit. if(((input_lo & key1) | (input_hi & key2)) != 0) diff --git a/iop/hdd/libpfs/src/bitmap.c b/iop/hdd/libpfs/src/bitmap.c index 6c829e31be17..1b3ca9bca3fa 100644 --- a/iop/hdd/libpfs/src/bitmap.c +++ b/iop/hdd/libpfs/src/bitmap.c @@ -76,9 +76,7 @@ void pfsBitmapAllocFree(pfs_cache_t *clink, u32 operation, u32 subpart, u32 chun chunk++; - sector = (1 << clink->pfsMount->inode_scale) + chunk; - if(subpart==0) - sector += 0x2000 >> pfsBlockSize; + sector = (1 << clink->pfsMount->inode_scale) + chunk + ((subpart==0) ? (0x2000 >> pfsBlockSize ) : 0); clink = pfsCacheGetData(clink->pfsMount, subpart, sector, PFS_CACHE_FLAG_BITMAP, &result); } @@ -108,8 +106,7 @@ int pfsBitmapAllocateAdditionalZones(pfs_mount_t *pfsMount, pfs_blockinfo_t *bi, u32 sector=(1<inode_scale) + info.chunk; // if main partition, add offset (in units of blocks) - if (bi->subpart==0) - sector += 0x2000 >> pfsBlockSize; + sector += (bi->subpart==0) ? (0x2000 >> pfsBlockSize) : 0; // Read the bitmap chunk from the hdd c=pfsCacheGetData(pfsMount, bi->subpart, sector, PFS_CACHE_FLAG_BITMAP, &result); @@ -170,9 +167,7 @@ int pfsBitmapAllocZones(pfs_mount_t *pfsMount, pfs_blockinfo_t *bi, u32 amount) ((info.partitionRemainder!=0) && (info.chunk < info.partitionChunks+1)); info.chunk++){ u32 *bitmapEnd; - sector = info.chunk + (1 << pfsMount->inode_scale); - if(bi->subpart==0) - sector += 0x2000 >> pfsBlockSize; + sector = info.chunk + (1 << pfsMount->inode_scale) + ((bi->subpart==0) ? (0x2000 >> pfsBlockSize) : 0); // read in the bitmap chunk bitmap = pfsCacheGetData(pfsMount, bi->subpart, sector, PFS_CACHE_FLAG_BITMAP, &result); @@ -203,9 +198,7 @@ int pfsBitmapAllocZones(pfs_mount_t *pfsMount, pfs_blockinfo_t *bi, u32 amount) if (bitmap->block != (startChunk + (1 << pfsMount->inode_scale))) { pfsCacheFree(bitmap); - sector = (1 << pfsMount->inode_scale) + startChunk; - if(bi->subpart==0) - sector += 0x2000 >> pfsBlockSize; + sector = (1 << pfsMount->inode_scale) + startChunk + ((bi->subpart==0) ? (0x2000 >> pfsBlockSize) : 0); bitmap = pfsCacheGetData(pfsMount, bi->subpart, sector, PFS_CACHE_FLAG_BITMAP, &result); } @@ -238,9 +231,8 @@ int pfsBitmapSearchFreeZone(pfs_mount_t *pfsMount, pfs_blockinfo_t *bi, u32 max_ if (bi->number) num = pfsMount->num_subs + 2; - count = max_count < 33 ? max_count : 32; //min(max_count, 32) - if(count < bi->count) - count = bi->count; //max(count, bi->count) + count = max_count < 33 ? max_count : 32; //min(max_count, 32) + count = (count < bi->count) ? bi->count : count; //max(count, bi->count) // => count = bound(bi->count, 32); for(i = num - 1; i < num; i--) @@ -275,9 +267,7 @@ void pfsBitmapFreeBlockSegment(pfs_mount_t *pfsMount, pfs_blockinfo_t *bi) pfsBitmapSetupInfo(pfsMount, &info, bi->subpart, bi->number); - sector = (1 << pfsMount->inode_scale) + info.chunk; - if(bi->subpart==0) - sector += 0x2000 >> pfsBlockSize; + sector = (1 << pfsMount->inode_scale) + info.chunk + ((bi->subpart==0) ? (0x2000 >> pfsBlockSize) : 0); if((clink=pfsCacheGetData(pfsMount, (u16)bi->subpart, sector, PFS_CACHE_FLAG_BITMAP, &rv)) != NULL) { @@ -305,9 +295,7 @@ int pfsBitmapCalcFreeZones(pfs_mount_t *pfsMount, int sub) bitmapSize = info.chunk==info.partitionChunks ? info.partitionRemainder / 8 : pfsMetaSize; - sector = (1<inode_scale) + info.chunk; - if (sub==0) - sector +=0x2000>>pfsBlockSize; + sector = (1<inode_scale) + info.chunk + ((sub==0) ? (0x2000>>pfsBlockSize) : 0); if ((clink=pfsCacheGetData(pfsMount, sub, sector, PFS_CACHE_FLAG_BITMAP, &result))) { @@ -344,8 +332,7 @@ void pfsBitmapShow(pfs_mount_t *pfsMount) u32 sector = (1<inode_scale) + info.chunk; u32 i; - if(pn==0) - sector += 0x2000 >> pfsBlockSize; + sector += (pn == 0) ? (0x2000 >> pfsBlockSize) : 0; clink=pfsCacheGetData(pfsMount, pn, sector, PFS_CACHE_FLAG_BITMAP, &result); if (info.chunk == info.partitionChunks) diff --git a/iop/hdd/libpfs/src/block.c b/iop/hdd/libpfs/src/block.c index c501d109c843..26aa59b99591 100644 --- a/iop/hdd/libpfs/src/block.c +++ b/iop/hdd/libpfs/src/block.c @@ -86,13 +86,7 @@ int pfsBlockInitPos(pfs_cache_t *clink, pfs_blockpos_t *blockpos, u64 position) blockpos->inode=pfsCacheUsedAdd(clink); blockpos->byte_offset=0; - if (clink->u.inode->size) - { - blockpos->block_segment=1; - blockpos->block_offset=0; - }else{ - blockpos->block_segment=0; - blockpos->block_offset=1; - } + blockpos->block_segment=clink->u.inode->size ? 1 : 0; + blockpos->block_offset=clink->u.inode->size ? 0 : 1; return pfsInodeSync(blockpos, position, clink->u.inode->number_data); } diff --git a/iop/hdd/libpfs/src/blockWrite.c b/iop/hdd/libpfs/src/blockWrite.c index 62c309d20c93..6cc54742383a 100644 --- a/iop/hdd/libpfs/src/blockWrite.c +++ b/iop/hdd/libpfs/src/blockWrite.c @@ -121,8 +121,7 @@ int pfsBlockAllocNewSegment(pfs_cache_t *clink, pfs_blockpos_t *blockpos, u32 bl blockpos->inode->flags |= PFS_CACHE_FLAG_DIRTY; blocks -= bi.count; - if (blocks) - blocks -= pfsBlockExpandSegment(clink, blockpos, blocks); + blocks -= (blocks) ? pfsBlockExpandSegment(clink, blockpos, blocks) : 0; return old_blocks - blocks; } diff --git a/iop/hdd/libpfs/src/dir.c b/iop/hdd/libpfs/src/dir.c index b4cabe3ca92b..5092682f8b7f 100644 --- a/iop/hdd/libpfs/src/dir.c +++ b/iop/hdd/libpfs/src/dir.c @@ -173,8 +173,7 @@ pfs_cache_t *pfsDirAddEntry(pfs_cache_t *dir, char *filename, pfs_blockinfo_t *b dcache=pfsGetDentry(dir, filename, &dentry, &size, 1); if (dcache != NULL){ len=dentry->aLen & 0xFFF; - if (dentry->pLen) - len-=(dentry->pLen + 11) & 0x1FC; + len-=(dentry->pLen) ? ((dentry->pLen + 11) & 0x1FC) : 0; dentry->aLen=(dentry->aLen & FIO_S_IFMT) | ((dentry->aLen & 0xFFF) - len); dentry=(pfs_dentry_t *)((u8*)dentry + (dentry->aLen & 0xFFF)); }else{ @@ -221,8 +220,7 @@ pfs_cache_t *pfsDirRemoveEntry(pfs_cache_t *clink, char *path) dnext->inode=0; dnext->pLen=0; - if (size+aLen >= clink->u.inode->size) - clink->u.inode->size -= aLen; + clink->u.inode->size -= (size+aLen >= clink->u.inode->size) ? aLen : 0; } return c; } @@ -335,8 +333,6 @@ pfs_cache_t *pfsInodeGetFile(pfs_mount_t *pfsMount, pfs_cache_t *clink, void pfsInodeFill(pfs_cache_t *ci, pfs_blockinfo_t *bi, u16 mode, u16 uid, u16 gid) { - u32 val; - memset(ci->u.inode, 0, pfsMetaSize); ci->u.inode->magic=PFS_SEGD_MAGIC; @@ -353,16 +349,10 @@ void pfsInodeFill(pfs_cache_t *ci, pfs_blockinfo_t *bi, u16 mode, u16 uid, u16 g ci->u.inode->uid=uid; ci->u.inode->gid=gid; - if ((mode & FIO_S_IFMT) == FIO_S_IFDIR){ - ci->u.inode->attr=0xA0; - ci->u.inode->size=sizeof(pfs_dentry_t); - val=2; - }else{ - ci->u.inode->size=0; - val=1; - } - ci->u.inode->number_data=val; - ci->u.inode->number_blocks=val; + ci->u.inode->attr=((mode & FIO_S_IFMT) == FIO_S_IFDIR) ? 0xA0 : ci->u.inode->attr; + ci->u.inode->size=((mode & FIO_S_IFMT) == FIO_S_IFDIR) ? sizeof(pfs_dentry_t) : 0; + ci->u.inode->number_data=((mode & FIO_S_IFMT) == FIO_S_IFDIR) ? 2 : 1; + ci->u.inode->number_blocks=((mode & FIO_S_IFMT) == FIO_S_IFDIR) ? 2 : 1; pfsGetTime(&ci->u.inode->ctime); memcpy(&ci->u.inode->atime, &ci->u.inode->ctime, sizeof(pfs_datetime_t)); @@ -559,11 +549,7 @@ int pfsCheckAccess(pfs_cache_t *clink, int flags) if ((clink->pfsMount->flags & FIO_MT_RDONLY) && (flags & FIO_O_WRONLY)) return -EROFS; - if (((clink->u.inode->mode & FIO_S_IFMT) != FIO_S_IFDIR) && - ((clink->u.inode->mode & 0111) == 0)) - mode=6; - else - mode=7; + mode = (((clink->u.inode->mode & FIO_S_IFMT) != FIO_S_IFDIR) && ((clink->u.inode->mode & 0111) == 0)) ? 6 : 7; return ((mode & flags) & 7) == flags ? 0 : -EACCES; } @@ -683,11 +669,9 @@ void pfsFreeZones(pfs_cache_t *pfree) b.count = j; b.number = bi->number + bi->count; - j = 0; clink->flags |= PFS_CACHE_FLAG_DIRTY; } - else - j -= bi->count; + j -= (j < bi->count) ? j : bi->count; } } diff --git a/iop/hdd/libpfs/src/superWrite.c b/iop/hdd/libpfs/src/superWrite.c index ea35f0eb5442..7a0084919968 100644 --- a/iop/hdd/libpfs/src/superWrite.c +++ b/iop/hdd/libpfs/src/superWrite.c @@ -34,8 +34,7 @@ int pfsFormatSub(pfs_block_device_t *blockDev, int fd, u32 sub, u32 reserved, u3 size = blockDev->getSize(fd, sub); sector = 1 << scale; count = pfsGetBitmapSizeSectors(scale, size); - if (reserved>=2) - sector+=0x2000; + sector += (reserved >= 2) ? 0x2000 : 0; reserved += pfsGetBitmapSizeBlocks(scale, size); if((cache = pfsCacheAllocClean(&result))) diff --git a/iop/hdd/pfs/src/pfs.c b/iop/hdd/pfs/src/pfs.c index 47a38416b205..24761c9b9a51 100644 --- a/iop/hdd/pfs/src/pfs.c +++ b/iop/hdd/pfs/src/pfs.c @@ -171,10 +171,7 @@ int PFS_ENTRYPOINT(int argc, char *argv[]) // Get filename of IRX filename = strrchr(argv[0], '/'); - if(filename++) - pfsFilename = filename; - else - pfsFilename = argv[0]; + pfsFilename = (filename++) ? filename : argv[0]; argc--; argv++; diff --git a/iop/hdd/pfs/src/pfs_fio.c b/iop/hdd/pfs/src/pfs_fio.c index 864db1e2210b..1720a9c7c776 100644 --- a/iop/hdd/pfs/src/pfs_fio.c +++ b/iop/hdd/pfs/src/pfs_fio.c @@ -167,8 +167,8 @@ static int openFile(pfs_mount_t *pfsMount, pfs_file_slot_t *freeSlot, const char // Setup flags flags=openFlagArray[openFlags & FIO_O_RDWR]; - if (openFlags & FIO_O_TRUNC) flags |= 2; - if (openFlags & PFS_FDIRO) flags |= 4; + flags |= (openFlags & FIO_O_TRUNC) ? 2 : 0; + flags |= (openFlags & PFS_FDIRO) ? 4 : 0; if ((mode & 0x10000) || ((openFlags & (FIO_O_CREAT|FIO_O_EXCL)) == (FIO_O_CREAT|FIO_O_EXCL))){ result=-EEXIST; @@ -284,10 +284,7 @@ static int openFile(pfs_mount_t *pfsMount, pfs_file_slot_t *freeSlot, const char if ((result==0) && freeSlot && fileInode) { freeSlot->clink=fileInode; - if (openFlags & FIO_O_APPEND) - freeSlot->position = fileInode->u.inode->size; - else - freeSlot->position = 0; + freeSlot->position = (openFlags & FIO_O_APPEND) ? fileInode->u.inode->size : 0; result=pfsBlockInitPos(freeSlot->clink, &freeSlot->block_pos, freeSlot->position); if (result==0) @@ -1126,8 +1123,7 @@ int pfsFioRename(iomanX_iop_file_t *ff, const char *old, const char *new_) if (strcmp(path1, ".") && strcmp(path1, "..") && strcmp(path2, ".") && strcmp(path2, "..")){ result=pfsCheckAccess(parentOld, 3); - if (result==0) - result=pfsCheckAccess(parentNew, 3); + result=(result==0) ? pfsCheckAccess(parentNew, 3) : result; }else result=-EINVAL; @@ -1156,8 +1152,7 @@ int pfsFioRename(iomanX_iop_file_t *ff, const char *old, const char *new_) parentNew->pfsMount=NULL; }else{ if (sameParent){ - if (removeOld!=addNew) - removeOld->flags |= PFS_CACHE_FLAG_DIRTY; + removeOld->flags |= (removeOld!=addNew) ? PFS_CACHE_FLAG_DIRTY : 0; }else { pfsInodeSetTimeParent(parentOld, removeOld); @@ -1365,8 +1360,7 @@ int pfsFioReadlink(iomanX_iop_file_t *f, const char *path, char *buf, unsigned i else { rv=strlen((char *)&clink->u.inode->data[1]); - if(buflen < (unsigned int)rv) - rv=(int)buflen; + rv=(buflen < (unsigned int)rv) ? (int)buflen : rv; memcpy(buf, &clink->u.inode->data[1], rv); } pfsCacheFree(clink); diff --git a/iop/hdd/pfs/src/pfs_fioctl.c b/iop/hdd/pfs/src/pfs_fioctl.c index 29b4a6936a85..b2a21342fbf5 100644 --- a/iop/hdd/pfs/src/pfs_fioctl.c +++ b/iop/hdd/pfs/src/pfs_fioctl.c @@ -267,11 +267,7 @@ static pfs_aentry_t *getAentry(pfs_cache_t *clink, char *key, char *value, int m pfs_aentry_t *end; kLen=strlen(key); - fullsize = 0; - if (value != NULL) - { - fullsize=(kLen+strlen(value)+7) & ~3; - } + fullsize=(value != NULL) ? ((kLen+strlen(value)+7) & ~3) : 0; for(end=(pfs_aentry_t *)((u8*)aentry+1024);aentry < end; aentry=(pfs_aentry_t *)((u8*)aentry+aentry->aLen)) { //Other than critical errors, do nothing about the filesystem errors. if(aentry->aLen & 3) @@ -347,10 +343,7 @@ static int ioctl2AttrAdd(pfs_cache_t *clink, pfs_ioctl2attr_t *attr) if((aentry=getAentry(clink, attr->key, attr->value, PFS_AENTRY_MODE_ADD)) == NULL) return -ENOSPC; - if(aentry->kLen==0) - tmp=aentry->aLen; - else - tmp=aentry->aLen-((aentry->kLen+(aentry->vLen + 7)) & 0x3FC); //The only case that uses 0x3FC within the whole PFS driver. + tmp=aentry->aLen-((aentry->kLen==0) ? 0 : ((aentry->kLen+(aentry->vLen + 7)) & 0x3FC)); //The only case that uses 0x3FC within the whole PFS driver. aentry->aLen-=tmp; aentry = (pfs_aentry_t*)((u8 *)aentry + aentry->aLen); diff --git a/iop/iLink/IEEE1394_bd/src/sbp2_driver.c b/iop/iLink/IEEE1394_bd/src/sbp2_driver.c index 678d8b7fd6f6..d46ec2874557 100644 --- a/iop/iLink/IEEE1394_bd/src/sbp2_driver.c +++ b/iop/iLink/IEEE1394_bd/src/sbp2_driver.c @@ -542,8 +542,7 @@ static int sbp2_queue_cmd(struct scsi_interface *scsi, const unsigned char *cmd, cdb.misc = ORB_NOTIFY | ORB_REQUEST_FORMAT(0) | CDB_MAX_PAYLOAD(dev->max_payload) | CDB_SPEED(dev->speed); cdb.misc |= data_wr ? CDB_DIRECTION(READ_TRANSACTION) : CDB_DIRECTION(WRITE_TRANSACTION); // flipped - if (data_len > 0) - cdb.misc |= CDB_DATA_SIZE(data_len); + cdb.misc |= (data_len > 0) ? CDB_DATA_SIZE(data_len) : 0; cdb.DataDescriptor.low = data_wr ? (u32)writeBuffer : (u32)data; cdb.DataDescriptor.high = 0; diff --git a/iop/iLink/iLinkman/src/iLink_crom.c b/iop/iLink/iLinkman/src/iLink_crom.c index 2032f60e843c..9b9fef8c2d1c 100644 --- a/iop/iLink/iLinkman/src/iLink_crom.c +++ b/iop/iLink/iLinkman/src/iLink_crom.c @@ -277,8 +277,7 @@ static void BuildConfigurationROM(void) TotalExtraCROMUnitSize = 0; for (i = 0; i < 16; i++) - if (ExtraCROMUnits[i] != NULL) - TotalExtraCROMUnitSize += ExtraCROMUnitsSize[i]; + TotalExtraCROMUnitSize += (ExtraCROMUnits[i] != NULL) ? ExtraCROMUnitsSize[i] : 0; TotalRootDirectorySizeInQuads = (sizeof(struct Root_Directory) + TotalExtraCROMUnitSize) / 4; diff --git a/iop/iLink/iLinkman/src/iLink_intr.c b/iop/iLink/iLinkman/src/iLink_intr.c index d24b15e5ef58..e263c9ee56a1 100644 --- a/iop/iLink/iLinkman/src/iLink_intr.c +++ b/iop/iLink/iLinkman/src/iLink_intr.c @@ -253,23 +253,12 @@ static void ReadRequestHandler(unsigned int header, volatile unsigned int *buffe ReadReqHeader[i] = *buffer; } - if (tCode == IEEE1394_TCODE_READB) { - offset_low = BSWAP32(((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_low); - offset_high = BSWAP32(((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_high); - DestinationNodeID = BSWAP16((unsigned short int)offset_high); - } else { - offset_low = ((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_low; - offset_high = ((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_high; - DestinationNodeID = (unsigned short int)(offset_high >> 16); - } + offset_low = (tCode == IEEE1394_TCODE_READB) ? BSWAP32(((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_low) : ((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_low; + offset_high = (tCode == IEEE1394_TCODE_READB) ? BSWAP32(((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_high) : ((struct ieee1394_TrCommonRdPktHdr *)ReadReqHeader)->offset_high; + DestinationNodeID = (tCode == IEEE1394_TCODE_READB) ? BSWAP16((unsigned short int)offset_high) : (unsigned short int)(offset_high >> 16); - if (tCode == IEEE1394_TCODE_READQ) { - nBytes = 4; - speed = (((struct ieee1394_TrQuadRdPacketHdr *)ReadReqHeader)->trailer >> 16) & 0x7; - } else { - nBytes = ((struct ieee1394_TrBlockRdPacketHdr *)ReadReqHeader)->nBytes >> 16; - speed = (((struct ieee1394_TrBlockRdPacketHdr *)ReadReqHeader)->trailer >> 16) & 0x7; - } + nBytes = (tCode == IEEE1394_TCODE_READQ) ? 4 : (((struct ieee1394_TrBlockRdPacketHdr *)ReadReqHeader)->nBytes >> 16); + speed = (tCode == IEEE1394_TCODE_READQ) ? ((((struct ieee1394_TrQuadRdPacketHdr *)ReadReqHeader)->trailer >> 16) & 0x7) : ((((struct ieee1394_TrBlockRdPacketHdr *)ReadReqHeader)->trailer >> 16) & 0x7); DEBUG_PRINTF(" read request to 0x%08x %08x with length %u.\n", offset_high, offset_low, nBytes); @@ -344,8 +333,7 @@ int iLinkIntrHandler(void *arg) DEBUG_PRINTF("iLink interrupt: 0x%08x 0x%08x\n", LocalCachedIntr0Register, LocalCachedIntr1Register); - if (LocalCachedIntr1Register & iLink_INTR1_UTD) - EventFlagBitsToSet |= iLinkEventDataSent; + EventFlagBitsToSet |= (LocalCachedIntr1Register & iLink_INTR1_UTD) ? iLinkEventDataSent : 0; #ifdef REQ_CHECK_DMAC_STAT if (LocalCachedIntr0Register & iLink_INTR0_DRFR) { @@ -384,9 +372,7 @@ int iLinkIntrHandler(void *arg) iDEBUG_PRINTF("-=PHTs initialized=-\n"); } - if (LocalCachedIntr0Register & iLink_INTR0_URx) { - EventFlagBitsToSet |= iLinkEventURx; - } + EventFlagBitsToSet |= (LocalCachedIntr0Register & iLink_INTR0_URx) ? iLinkEventURx : 0; if (LocalCachedIntr0Register & (iLink_INTR0_InvAck | iLink_INTR0_RetEx | iLink_INTR0_UResp)) { EventFlagBitsToSet |= iLinkEventError; diff --git a/iop/input/padman/src/padCmds.c b/iop/input/padman/src/padCmds.c index caee2f54f90a..f65fabea3e4d 100644 --- a/iop/input/padman/src/padCmds.c +++ b/iop/input/padman/src/padCmds.c @@ -172,10 +172,7 @@ u32 ReadData(padState_t *pstate) for(i=0; i < (u32)(pstate->ee_actDirectSize); i++) { - if(pstate->ee_actAlignData.data[i] == 0xFF) - pstate->inbuffer[i+3] = pstate->ee_actAlignData.data[i]; - else - pstate->inbuffer[i+3] = pstate->ee_actDirectData.data[i]; + pstate->inbuffer[i+3] = (pstate->ee_actAlignData.data[i] == 0xFF) ? pstate->ee_actAlignData.data[i] : pstate->ee_actDirectData.data[i]; } pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer); @@ -674,20 +671,10 @@ u32 QueryButtonMask(padState_t *pstate) if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer); - if(pstate->outbuffer[8] == 0x5A) - { - pstate->buttonMask[0] = pstate->outbuffer[3]; - pstate->buttonMask[1] = pstate->outbuffer[4]; - pstate->buttonMask[2] = pstate->outbuffer[5]; - pstate->buttonMask[3] = pstate->outbuffer[6]; - } - else - { - pstate->buttonMask[0] = 0; - pstate->buttonMask[1] = 0; - pstate->buttonMask[2] = 0; - pstate->buttonMask[3] = 0; - } + pstate->buttonMask[0] = (pstate->outbuffer[8] == 0x5A) ? pstate->outbuffer[3] : 0; + pstate->buttonMask[1] = (pstate->outbuffer[8] == 0x5A) ? pstate->outbuffer[4] : 0; + pstate->buttonMask[2] = (pstate->outbuffer[8] == 0x5A) ? pstate->outbuffer[5] : 0; + pstate->buttonMask[3] = (pstate->outbuffer[8] == 0x5A) ? pstate->outbuffer[6] : 0; ret = 1; } diff --git a/iop/input/padman/src/padData.c b/iop/input/padman/src/padData.c index d2676410ce87..7c3af7d42a8e 100644 --- a/iop/input/padman/src/padData.c +++ b/iop/input/padman/src/padData.c @@ -52,12 +52,9 @@ static int pd_set_change_slot_buffer(s32 *status) int i, ret = 1; for (i = 0; i < 4; i++, status++) { - if ((*status + 1) < 2) - status[4] = 1; - else { - status[4] = 0; + status[4] = ((*status + 1) < 2) ? 1 : 0; + if ((*status + 1) >= 2) ret = 0; - } } return ret; @@ -497,10 +494,7 @@ u32 pdCheckConnection(u32 port, u32 slot) s32 pdGetError(u32 port, u32 slot) { - if(port < 2) - return padData[port][slot].error; - else - return -1; + return (port < 2) ? padData[port][slot].error : -1; } u32 pdSetCtrl1(u32 port, u32 slot, u32 ctrl) diff --git a/iop/input/padman/src/padInit.c b/iop/input/padman/src/padInit.c index dd8030434081..f596866519a1 100644 --- a/iop/input/padman/src/padInit.c +++ b/iop/input/padman/src/padInit.c @@ -86,149 +86,18 @@ u32 padSetupEEButtonData(u32 port, u32 slot, padState_t *pstate) //Check button status & update pressure data value = ~((data[2] << 8) | data[3]); - if(value & 0x2000) - { - if(data[8] == 0) - data[8] = 1; - } - else - { - { - data[8] = 0; - } - } - - if(value & 0x8000) - { - if(data[9] == 0) - data[9] = 1; - } - else - { - { - data[9] = 0; - } - } - - if(value & 0x1000) - { - if(data[10] == 0) - data[10] = 1; - } - else - { - { - data[10] = 0; - } - } - - if(value & 0x4000) - { - if(data[11] == 0) - data[11] = 1; - } - else - { - { - data[11] = 0; - } - } - - if(value & 0x0010) - { - if(data[12] == 0) - data[12] = 1; - } - else - { - { - data[12] = 0; - } - } - - if(value & 0x0020) - { - if(data[13] == 0) - data[13] = 1; - } - else - { - { - data[13] = 0; - } - } - - if(value & 0x0040) - { - if(data[14] == 0) - data[14] = 1; - } - else - { - { - data[14] = 0; - } - } - - if(value & 0x0080) - { - if(data[15] == 0) - data[15] = 1; - } - else - { - { - data[15] = 0; - } - } - - if(value & 0x0004) - { - if(data[16] == 0) - data[16] = 1; - } - else - { - { - data[16] = 0; - } - } - - if(value & 0x0008) - { - if(data[17] == 0) - data[17] = 1; - } - else - { - { - data[17] = 0; - } - } - - if(value & 0x0001) - { - if(data[18] == 0) - data[18] = 1; - } - else - { - { - data[18] = 0; - } - } - - if(value & 0x0002) - { - if(data[19] == 0) - data[19] = 1; - } - else - { - { - data[19] = 0; - } - } + data[8] = (value & 0x2000) ? ((data[8] == 0) ? 1 : data[8]) : 0; + data[9] = (value & 0x8000) ? ((data[9] == 0) ? 1 : data[9]) : 0; + data[10] = (value & 0x1000) ? ((data[10] == 0) ? 1 : data[10]) : 0; + data[11] = (value & 0x4000) ? ((data[11] == 0) ? 1 : data[11]) : 0; + data[12] = (value & 0x0010) ? ((data[12] == 0) ? 1 : data[12]) : 0; + data[13] = (value & 0x0020) ? ((data[13] == 0) ? 1 : data[13]) : 0; + data[14] = (value & 0x0040) ? ((data[14] == 0) ? 1 : data[14]) : 0; + data[15] = (value & 0x0080) ? ((data[15] == 0) ? 1 : data[15]) : 0; + data[16] = (value & 0x0004) ? ((data[16] == 0) ? 1 : data[16]) : 0; + data[17] = (value & 0x0008) ? ((data[17] == 0) ? 1 : data[17]) : 0; + data[18] = (value & 0x0001) ? ((data[18] == 0) ? 1 : data[18]) : 0; + data[19] = (value & 0x0002) ? ((data[19] == 0) ? 1 : data[19]) : 0; } return 32; @@ -281,10 +150,7 @@ static void DmaSendEE(void) if (pad_ee_addr) { - if( (sif_buffer[0] % 2) == 0) - sifdma_td[sifdma_count].dest = (void *)(((u8 *)pad_ee_addr) + 128); - else - sifdma_td[sifdma_count].dest = pad_ee_addr; + sifdma_td[sifdma_count].dest = ( (sif_buffer[0] % 2) == 0) ? (void *)(((u8 *)pad_ee_addr) + 128) : pad_ee_addr; sifdma_td[sifdma_count].src = sif_buffer; sifdma_td[sifdma_count].size = 128; @@ -320,11 +186,7 @@ static void DmaSendEE(void) p->ee_pdata.currentTask = p->currentTask; p->ee_old_pdata.frame = p->frame; p->ee_old_pdata.model = p->model; - p->ee_old_pdata.state = p->state; - if (p->state == PAD_STATE_ERROR && p->findPadRetries != 0) - { - p->ee_old_pdata.state = PAD_STATE_FINDPAD; - } + p->ee_old_pdata.state = (p->state == PAD_STATE_ERROR && p->findPadRetries != 0) ? PAD_STATE_FINDPAD : p->state; p->ee_old_pdata.reqState = p->reqState; p->frame++; @@ -352,10 +214,7 @@ static void DmaSendEE(void) *((pad_ee_addr) ? &(p->ee_pdata.length) : &(p->ee_old_pdata.length)) = (p->buttonDataReady == 1) ? padSetupEEButtonData(port, slot, p) : 0; - if( (p->frame & 1) == 0) - sifdma_td[sifdma_count].dest = (void*)p->padarea_ee_addr; - else - sifdma_td[sifdma_count].dest = (void*)(p->padarea_ee_addr + (pad_ee_addr ? 128 : 64)); + sifdma_td[sifdma_count].dest = ( (p->frame & 1) == 0) ? (void*)p->padarea_ee_addr : (void*)(p->padarea_ee_addr + (pad_ee_addr ? 128 : 64)); sifdma_td[sifdma_count].src = pad_ee_addr ? (void *)&p->ee_pdata : (void *)&p->ee_old_pdata; sifdma_td[sifdma_count].size = pad_ee_addr ? 128 : 64; @@ -417,10 +276,7 @@ static u32 GetThreadsStatus(padState_t *state) if( (tinfo.status & THS_DORMANT) == 0) count++; } - if(count == 0) - return 1; - else - return 0; + return (count == 0) ? 1 : 0; } static void DeleteThreads(padState_t *state) diff --git a/iop/input/padman/src/padMiscFuncs.c b/iop/input/padman/src/padMiscFuncs.c index d66505b7ecb6..674b9afe3394 100644 --- a/iop/input/padman/src/padMiscFuncs.c +++ b/iop/input/padman/src/padMiscFuncs.c @@ -192,39 +192,13 @@ s32 padInfoMode(u32 port, u32 slot, s32 term, u32 offs) switch(term) { case 2: - if(padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD) - return 0; - else - return padState[port][slot].modeTable.data[padState[port][slot].modeCurOffs]; + return (padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD) ? 0 : padState[port][slot].modeTable.data[padState[port][slot].modeCurOffs]; case 1: - if( padState[port][slot].modeCurId != PAD_ID_CONFIG) - return (PAD_ID_HI(PAD_ID_CONFIG)); - else - return 0; + return ( padState[port][slot].modeCurId != PAD_ID_CONFIG) ? (PAD_ID_HI(PAD_ID_CONFIG)) : 0; case 3: - if(padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD) - return 0; - else - return padState[port][slot].modeCurOffs; + return (padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD) ? 0 : padState[port][slot].modeCurOffs; case 4: - if(padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD) - return 0; - else - { - if(offs == (u32)(-1)) - { - return padState[port][slot].numModes; - } - else - { - u16* mode = padState[port][slot].modeTable.data; - - if(offs < padState[port][slot].numModes) - return mode[offs]; - else - return 0; - } - } + return (padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD) ? 0 : ((offs == (u32)(-1)) ? padState[port][slot].numModes : ((offs < padState[port][slot].numModes) ? ((u16 *)(padState[port][slot].modeTable.data))[offs] : 0)); } return -1; diff --git a/iop/input/padman/src/padPortOpen.c b/iop/input/padman/src/padPortOpen.c index 560b5ce3ee73..7a05839bb273 100644 --- a/iop/input/padman/src/padPortOpen.c +++ b/iop/input/padman/src/padPortOpen.c @@ -63,10 +63,7 @@ static void UpdatePadThread(void *arg) pstate->buttonDataReady = 1; - if(pstate->modeConfig == MODE_CONFIG_QUERY_PAD) - pstate->state = PAD_STATE_FINDCTP1; - else - pstate->state = PAD_STATE_STABLE ; + pstate->state = (pstate->modeConfig == MODE_CONFIG_QUERY_PAD) ? PAD_STATE_FINDCTP1 : PAD_STATE_STABLE; if( (pstate->reqState == PAD_RSTAT_BUSY) && (pstate->runTask == TASK_NONE)) pstate->reqState = PAD_RSTAT_COMPLETE; diff --git a/iop/input/padman/src/sio2Cmds.c b/iop/input/padman/src/sio2Cmds.c index 46fcf936c2ac..d479f0ba97aa 100644 --- a/iop/input/padman/src/sio2Cmds.c +++ b/iop/input/padman/src/sio2Cmds.c @@ -116,18 +116,12 @@ static u32 FindPadsGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 FindPadsGetPortCtrl2(u32 a) { - if(a == 0) - return 0x2000A; - else - return 0x2012C; + return (a == 0) ? 0x2000A : 0x2012C; } static u32 FindPadsGetSize1(void) @@ -208,18 +202,12 @@ static u32 MouseGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 MouseGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 MouseRegData(void) @@ -299,19 +287,13 @@ static u32 NegiconGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 NegiconGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 NegiconRegData(void) @@ -388,18 +370,12 @@ static u32 KonamiGunGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 KonamiGunGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 KonamiGunRegData(void) @@ -472,18 +448,12 @@ static u32 DigitalGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 DigitalGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 DigitalRegData(void) @@ -560,18 +530,12 @@ static u32 JoystickGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 JoystickGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 JoystickRegData(void) @@ -652,18 +616,12 @@ static u32 NamcoGunGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 NamcoGunGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 NamcoGunRegData(void) @@ -754,24 +712,15 @@ static u32 AnalogGetPortCtrl1(u32 a, u32 b) { u32 val1, val2, val3 ; - if((b & 0x2) == 0) - val1 = 0x5; - else - val1 = 0xA; + val1 = ((b & 0x2) == 0) ? 0x5 : 0xA; - if((b & 0x2) == 0) - val2 = 0x5; - else - val2 = 0xA; + val2 = ((b & 0x2) == 0) ? 0x5 : 0xA; val1 &= 0xFFFF00FF; val3 = val1 | ( val2 << 8); - if((b & 0x2) == 0) - val1 = 0xC0; - else - val1 = 0x60; + val1 = ((b & 0x2) == 0) ? 0xC0 : 0x60; val3 &= 0xFF00FFFF; val3 = val3 | (val1 << 16) | 0xFF000000; @@ -782,10 +731,7 @@ static u32 AnalogGetPortCtrl1(u32 a, u32 b) static u32 AnalogGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 AnalogEnterConfigMode(u8 *a) @@ -861,18 +807,12 @@ static u32 JogconGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 JogconGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 JogconRegData(void) @@ -957,18 +897,12 @@ static u32 ConfigGetPortCtrl1(u32 a, u32 b) { (void)b; - if(a == 0) - return 0xFFC00505; - else - return 0xFF060505; + return (a == 0) ? 0xFFC00505 : 0xFF060505; } static u32 ConfigGetPortCtrl2(u32 a) { - if(a == 0) - return 0x20014; - else - return 0x2012C; + return (a == 0) ? 0x20014 : 0x2012C; } static u32 ConfigRegData(void) diff --git a/iop/input/rmman/src/rmman.c b/iop/input/rmman/src/rmman.c index 3ee2a979b0e7..52a38994f8fb 100644 --- a/iop/input/rmman/src/rmman.c +++ b/iop/input/rmman/src/rmman.c @@ -145,7 +145,6 @@ static int InitInitRmCmd(struct RmData *RmData); int _start(int argc, char *argv[]) { - int result; struct irx_export_table *export_table; (void)argc; @@ -161,13 +160,7 @@ int _start(int argc, char *argv[]) export_table = &_exp_rmman; #endif - if(RegisterLibraryEntries(export_table) == 0) - { - result = CreateMainThread() <= 0 ? MODULE_NO_RESIDENT_END : MODULE_RESIDENT_END; - } - else result = MODULE_NO_RESIDENT_END; - - return result; + return (RegisterLibraryEntries(export_table) == 0) ? (CreateMainThread() <= 0 ? MODULE_NO_RESIDENT_END : MODULE_RESIDENT_END) : MODULE_NO_RESIDENT_END; } int rmmanInit(void) @@ -362,10 +355,7 @@ static void MainThread(void *arg) if(evfInfo.currBits == RM_EF_CLOSE_PORT) { RmData[port][slot].powerMode = 3; - if(InitRemote(&RmData[port][slot]) == 0) - RmData[port][slot].closed = 0; - else - RmData[port][slot].closed = 1; + RmData[port][slot].closed = (InitRemote(&RmData[port][slot]) == 0) ? 0 : 1; SetEventFlag(RmData[port][slot].eventFlagID, RM_EF_CLOSE_PORT_DONE); } else { @@ -545,22 +535,13 @@ static int InitPollRmCmd(struct RmData *RmData) static int RmExecute(struct RmData *RmData) { - int result; - sio2_rm_transfer_init(); sio2_transfer(&RmData->sio2Data); sio2_transfer_reset(); - if(((RmData->sio2Data.stat6c >> 14) & 3) == 0) - { - RmData->connected = 1; - result = 1; - } else { - RmData->connected = 0; - result = 0; - } + RmData->connected = (((RmData->sio2Data.stat6c >> 14) & 3) == 0) ? 1 : 0; - return result; + return RmData->connected; } static int HandleRmTaskFailed(struct RmData *RmData) diff --git a/iop/memorycard/mcman/src/main.c b/iop/memorycard/mcman/src/main.c index 4c6a463bf1be..7f60f896fc16 100644 --- a/iop/memorycard/mcman/src/main.c +++ b/iop/memorycard/mcman/src/main.c @@ -368,20 +368,9 @@ int mcman_checkdirpath(const char *str1, const char *str2) pos2 = mcman_chrpos(p2, '*'); if ((pos1 < 0) && (pos2 < 0)) { - if (!strcmp(p2, p1)) - return 1; - return 0; - } - pos = pos2; - if (pos1 >= 0) { - pos = pos1; - if (pos2 >= 0) { - pos = pos2; - if (pos1 < pos2) { - pos = pos1; - } - } + return (!strcmp(p2, p1)) ? 1 : 0; } + pos = (pos1 >= 0) ? ((pos2 >= 0) ? ((pos1 < pos2) ? pos1 : pos2) : pos1) : pos2; if (strncmp(p2, p1, pos) != 0) return 0; @@ -436,8 +425,7 @@ int McCloseAll(void) // Export #25 XMCMAN only register int rc; rc = McClose(fd); - if (rc < rv) - rv = rc; + rv = (rc < rv) ? rc : rv; } fd++; @@ -508,11 +496,7 @@ int mcman_detectcard(int port, int slot) } } else { - if (PS1CardFlag) - return sceMcResSucceed; - if (mcdi->cardtype == sceMcTypePS1) - return sceMcResDeniedPS1Permit; - return sceMcResSucceed; + return PS1CardFlag ? sceMcResSucceed : ((mcdi->cardtype == sceMcTypePS1) ? sceMcResDeniedPS1Permit : sceMcResSucceed); } } #else @@ -584,11 +568,7 @@ int McDetectCard2(int port, int slot) // Export #21 XMCMAN only } } else { - if (PS1CardFlag) - return sceMcResSucceed; - if (mcdi->cardtype == sceMcTypePS1) - return sceMcResDeniedPS1Permit; - return sceMcResSucceed; + return PS1CardFlag ? sceMcResSucceed : ((mcdi->cardtype == sceMcTypePS1) ? sceMcResDeniedPS1Permit : sceMcResSucceed); } } #else @@ -619,10 +599,7 @@ int McOpen(int port, int slot, const char *filename, int flag) // Export #6 if (!PS1CardFlag) flag &= ~0x00002000; // disables FRCOM flag OR what is it - if (mcman_devinfos[port][slot].cardtype == sceMcTypePS2) - r = mcman_open2(port, slot, filename, flag); - else - r = mcman_open1(port, slot, filename, flag); + r = ((mcman_devinfos[port][slot].cardtype == sceMcTypePS2) ? mcman_open2 : mcman_open1)(port, slot, filename, flag); if (r < -9) { mcman_invhandles(port, slot); @@ -664,10 +641,7 @@ int McClose(int fd) // Export #7 fh->unknown2 = 0; mcdi = (MCDevInfo *)&mcman_devinfos[fh->port][fh->slot]; - if (mcdi->cardtype == sceMcTypePS2) - r = mcman_close2(fd); - else - r = mcman_close1(fd); + r = ((mcdi->cardtype == sceMcTypePS2) ? mcman_close2 : mcman_close1)(fd); if (r < -9) { mcman_invhandles(fh->port, fh->slot); @@ -720,10 +694,7 @@ int McFlush(int fd) // Export #14 fh->unknown2 = 0; mcdi = (MCDevInfo *)&mcman_devinfos[fh->port][fh->slot]; - if (mcdi->cardtype == sceMcTypePS2) - r = mcman_close2(fd); - else - r = mcman_close1(fd); + r = ((mcdi->cardtype == sceMcTypePS2) ? mcman_close2 : mcman_close1)(fd); if (r < -9) { mcman_invhandles(fh->port, fh->slot); @@ -803,10 +774,7 @@ int McRead(int fd, void *buf, int length) // Export #8 if (r != sceMcResSucceed) return r; - if (mcman_devinfos[fh->port][fh->slot].cardtype == sceMcTypePS2) - r = mcman_read2(fd, buf, length); - else - r = mcman_read1(fd, buf, length); + r = ((mcman_devinfos[fh->port][fh->slot].cardtype == sceMcTypePS2) ? mcman_read2 : mcman_read1)(fd, buf, length); if (r < 0) fh->status = 0; @@ -839,10 +807,7 @@ int McWrite(int fd, void *buf, int length) // Export #9 if (r != sceMcResSucceed) return r; - if (mcman_devinfos[fh->port][fh->slot].cardtype == sceMcTypePS2) - r = mcman_write2(fd, buf, length); - else - r = mcman_write1(fd, buf, length); + r = ((mcman_devinfos[fh->port][fh->slot].cardtype == sceMcTypePS2) ? mcman_write2 : mcman_write1)(fd, buf, length); if (r < 0) fh->status = 0; @@ -885,10 +850,7 @@ int McGetDir(int port, int slot, const char *dirname, int flags, int maxent, sce if (r != sceMcResSucceed) return r; - if (mcman_devinfos[port][slot].cardtype == sceMcTypePS2) - r = mcman_getdir2(port, slot, dirname, flags & 0xFFFF, maxent, info); - else - r = mcman_getdir1(port, slot, dirname, flags & 0xFFFF, maxent, info); + r = ((mcman_devinfos[port][slot].cardtype == sceMcTypePS2) ? mcman_getdir2 : mcman_getdir1)(port, slot, dirname, flags & 0xFFFF, maxent, info); if (r < -9) { mcman_invhandles(port, slot); @@ -918,10 +880,7 @@ int mcman_dread(int fd, MC_IO_DRE_T *dirent) if (r != sceMcResSucceed) return r; - if (mcman_devinfos[fh->port][fh->slot].cardtype == sceMcTypePS2) - r = mcman_dread2(fd, dirent); - else - r = mcman_dread1(fd, dirent); + r = ((mcman_devinfos[fh->port][fh->slot].cardtype == sceMcTypePS2) ? mcman_dread2 : mcman_dread1)(fd, dirent); if (r < 0) fh->status = 0; @@ -943,10 +902,7 @@ int mcman_getstat(int port, int slot, const char *filename, MC_IO_STA_T *stat) if (r != sceMcResSucceed) return r; - if (mcman_devinfos[port][slot].cardtype == sceMcTypePS2) - r = mcman_getstat2(port, slot, filename, stat); - else - r = mcman_getstat1(port, slot, filename, stat); + r = ((mcman_devinfos[port][slot].cardtype == sceMcTypePS2) ? mcman_getstat2 : mcman_getstat1)(port, slot, filename, stat); if (r < -9) { mcman_invhandles(port, slot); @@ -965,10 +921,7 @@ int McSetFileInfo(int port, int slot, const char *filename, sceMcTblGetDir *info if (r != sceMcResSucceed) return r; - if (mcman_devinfos[port][slot].cardtype == sceMcTypePS2) - r = mcman_setinfo2(port, slot, filename, info, flags); - else - r = mcman_setinfo1(port, slot, filename, info, flags); + r = ((mcman_devinfos[port][slot].cardtype == sceMcTypePS2) ? mcman_setinfo2 : mcman_setinfo1)(port, slot, filename, info, flags); if (r < -9) { mcman_invhandles(port, slot); @@ -1019,10 +972,7 @@ int McDelete(int port, int slot, const char *filename, int flags) // Export #13 if (r != sceMcResSucceed) return r; - if (mcman_devinfos[port][slot].cardtype == sceMcTypePS2) - r = mcman_delete2(port, slot, filename, flags); - else - r = mcman_delete1(port, slot, filename, flags); + r = ((mcman_devinfos[port][slot].cardtype == sceMcTypePS2) ? mcman_delete2 : mcman_delete1)(port, slot, filename, flags); if (r < -9) { mcman_invhandles(port, slot); @@ -1045,10 +995,7 @@ int McFormat(int port, int slot) // Export #11 mcman_clearcache(port, slot); - if (mcman_devinfos[port][slot].cardtype == sceMcTypePS2) - r = mcman_format2(port, slot); - else - r = mcman_format1(port, slot); + r = ((mcman_devinfos[port][slot].cardtype == sceMcTypePS2) ? mcman_format2 : mcman_format1)(port, slot); if (r < -9) { mcman_invhandles(port, slot); @@ -1071,10 +1018,7 @@ int McUnformat(int port, int slot) // Export #36 mcman_clearcache(port, slot); - if (mcman_devinfos[port][slot].cardtype == sceMcTypePS2) - r = mcman_unformat2(port, slot); - else - r = mcman_unformat1(port, slot); + r = ((mcman_devinfos[port][slot].cardtype == sceMcTypePS2) ? mcman_unformat2 : mcman_unformat1)(port, slot); mcman_devinfos[port][slot].cardform = 0; @@ -1116,10 +1060,8 @@ int mcman_getmcrtime(sceMcStDateTime *tm) tm->Hour = btoi(cdtime.hour); tm->Day = btoi(cdtime.day); - if ((cdtime.month & 0x10) != 0) //Keep only valid bits: 0x1f (for month values 1-12 in BCD) - tm->Month = (cdtime.month & 0xf) + 0xa; - else - tm->Month = cdtime.month & 0xf; + //Keep only valid bits: 0x1f (for month values 1-12 in BCD) + tm->Month = ((cdtime.month & 0x10) != 0) ? ((cdtime.month & 0xf) + 0xa) : (cdtime.month & 0xf); tm->Year = btoi(cdtime.year) + 2000; } @@ -1188,8 +1130,7 @@ int McReadPage(int port, int slot, int page, void *buf) // Export #18 do { r = mcman_correctdata(pdata, peccb); - if (r < ecres) - ecres = r; + ecres = (r < ecres) ? r : ecres; peccb += 3; pdata += 128; @@ -1450,9 +1391,7 @@ int mcman_reportBadBlocks(int port, int slot) err_limit = ((mcdi->pagesize & 0xffff) + (mcdi->pagesize & 0x1)) >> 1; //s7 - erase_byte = 0; - if ((mcdi->cardflags & CF_ERASE_ZEROES) != 0) - erase_byte = 0xff; + erase_byte = ((mcdi->cardflags & CF_ERASE_ZEROES) != 0) ? 0xff : 0; bad_blocks = 0; // s2 @@ -1590,18 +1529,11 @@ int mcman_fatRseek(int fd) //s5 = 0 - if ((u32)entries_to_read < fh->clust_offset) //v1 = fh->fh->clust_offset - fat_index = fh->freeclink; - else { - fat_index = fh->clink; // a2 - entries_to_read -= fh->clust_offset; - } + fat_index = ((u32)entries_to_read < fh->clust_offset) ? fh->freeclink : fh->clink; // a2 + entries_to_read -= ((u32)entries_to_read >= fh->clust_offset) ? fh->clust_offset : 0; //v1 = fh->fh->clust_offset if (entries_to_read == 0) { - if (fat_index >= 0) - return fat_index + mcdi->alloc_offset; - - return sceMcResFullDevice; + return (fat_index >= 0) ? (fat_index + mcdi->alloc_offset) : sceMcResFullDevice; } do { @@ -1812,14 +1744,10 @@ int mcman_cachedirentry(int port, int slot, const char *filename, McCacheDir *pc } p = filename; + cluster = (*p == '/') ? 0 : mcdi->rootdir_cluster2; + fsindex = (*p == '/') ? 0 : mcdi->unknown1; if (*p == '/') { p++; - cluster = 0; - fsindex = 0; - } - else { - cluster = mcdi->rootdir_cluster2; - fsindex = mcdi->unknown1; } r = McReadDirEntry(port, slot, cluster, fsindex, &fse); @@ -1917,8 +1845,7 @@ int mcman_getdirinfo(int port, int slot, McFsEntry *pfse, const char *filename, DPRINTF("mcman_getdirinfo port%d slot%d name %s\n", port, slot, filename); pos = mcman_chrpos(filename, '/'); - if (pos < 0) - pos = strlen(filename); + pos = (pos < 0) ? strlen(filename) : pos; ret = 0; if ((pos == 2) && (!strncmp(filename, "..", 2))) { @@ -1954,12 +1881,9 @@ int mcman_getdirinfo(int port, int slot, McFsEntry *pfse, const char *filename, } while (pfsentry < pfseend); if ((fse->mode & sceMcFileAttrHidden) != 0) { - ret = 1; - if (!PS1CardFlag) { - ret = 2; - if ((pcd == NULL) || (pcd->maxent < 0)) - return 3; - } + ret = (!PS1CardFlag) ? 2 : 1; + if (!PS1CardFlag && ((pcd == NULL) || (pcd->maxent < 0))) + return 3; } if ((pcd == NULL) || (pcd->maxent < 0)) @@ -2024,29 +1948,19 @@ int mcman_getdirinfo(int port, int slot, McFsEntry *pfse, const char *filename, continue; if ((pos >= 11) && (!strncmp(&filename[10], &fse->name[10], pos-10))) { - len = pos; - if (strlen(fse->name) >= (unsigned int)pos) - len = strlen(fse->name); + len = (strlen(fse->name) >= (unsigned int)pos) ? strlen(fse->name) : pos; if (!strncmp(filename, fse->name, len)) goto continue_check; } - if (strlen(fse->name) >= (unsigned int)pos) - len = strlen(fse->name); - else - len = pos; + len = (strlen(fse->name) >= (unsigned int)pos) ? strlen(fse->name) : pos; if (strncmp(filename, fse->name, len)) continue; continue_check: - ret = 1; - - if ((fse->mode & sceMcFileAttrHidden) != 0) { - if (!PS1CardFlag) - ret = 2; - } + ret = (((fse->mode & sceMcFileAttrHidden) != 0) && (!PS1CardFlag)) ? 2 : 1; if (pcd == NULL) break; @@ -2103,10 +2017,7 @@ int mcman_writecluster(int port, int slot, int cluster, int flag) pageword_cnt = mcdi->pagesize >> 2; page = block * mcdi->blocksize; - if (mcdi->cardflags & CF_ERASE_ZEROES) - erase_value = 0xffffffff; - else - erase_value = 0x00000000; + erase_value = (mcdi->cardflags & CF_ERASE_ZEROES) ? 0xffffffff : 0x00000000; for (i = 0; i < pageword_cnt; i++) mcman_pagebuf.word[i] = erase_value; @@ -2222,10 +2133,7 @@ int McSetDirEntryState(int port, int slot, int cluster, int fsindex, int flags) } while (++i < MAX_FDHANDLES); - if (flags == 0) - fse->mode = fse->mode & (sceMcFileAttrExists - 1); - else - fse->mode = fse->mode | sceMcFileAttrExists; + fse->mode = (flags == 0) ? (fse->mode & (sceMcFileAttrExists - 1)) : (fse->mode | sceMcFileAttrExists); Mc1stCacheEntSetWrFlagOff(); @@ -2273,17 +2181,13 @@ int mcman_checkBackupBlocks(int port, int slot) // First check backup block2 to see if it's in erased state r1 = McReadPage(port, slot, mcdi->backup_block2 * mcdi->blocksize, &mcman_pagebuf); //s1 - value1 = *pagebuf; //s3 - if (((mcdi->cardflags & CF_ERASE_ZEROES) != 0) && (value1 == 0)) - value1 = 0xffffffff; + value1 = (((mcdi->cardflags & CF_ERASE_ZEROES) != 0) && (*pagebuf == 0)) ? 0xffffffff : *pagebuf; //s3 if (value1 != 0xffffffff) value1 = value1 & ~0x80000000; r2 = McReadPage(port, slot, (mcdi->backup_block2 * mcdi->blocksize) + 1, &mcman_pagebuf); //a0 - value2 = *pagebuf; //s0 - if (((mcdi->cardflags & CF_ERASE_ZEROES) != 0) && (value2 == 0)) - value2 = 0xffffffff; + value2 = (((mcdi->cardflags & CF_ERASE_ZEROES) != 0) && (*pagebuf == 0)) ? 0xffffffff : *pagebuf; //s0 if (value2 != 0xffffffff) value2 = value2 & ~0x80000000; @@ -2317,8 +2221,7 @@ int mcman_checkBackupBlocks(int port, int slot) for (r1 = 0; r1 < mcdi->blocksize; r1++) { eccsize = mcdi->pagesize; - if (eccsize < 0) - eccsize += 0x1f; + eccsize += (eccsize < 0) ? 0x1f : 0; eccsize = eccsize >> 5; r = McWritePage(port, slot, (value1 * ((mcdi->blocksize << 16) >> 16)) + r1, \ @@ -2350,8 +2253,7 @@ int McCheckBlock(int port, int slot, int block) pageword_cnt = mcdi->pagesize >> 2; //s6 ecc_count = mcdi->pagesize; - if (mcdi->pagesize < 0) - ecc_count += 127; + ecc_count += (mcdi->pagesize < 0) ? 127 : 0; ecc_count = ecc_count >> 7; // s7 flag = 0; // s4 @@ -2488,9 +2390,7 @@ int McCheckBlock(int port, int slot, int block) return sceMcResSucceed; } - erase_value = 0x00000000; - if ((mcdi->cardflags & CF_ERASE_ZEROES) != 0) - erase_value = 0xffffffff; + erase_value = ((mcdi->cardflags & CF_ERASE_ZEROES) != 0) ? 0xffffffff : 0x00000000; for (j = 0; j < pageword_cnt; j++) mcman_pagebuf.word[j] = erase_value; @@ -2588,14 +2488,8 @@ int mcman_getPS1direntry(int port, int slot, const char *filename, McFsEntryPS1 if (r != sceMcResSucceed) return r; - if (flag != 0) { - if (pfse[0]->mode != 0x51) - continue; - } - else { - if (pfse[0]->mode != 0xa1) - continue; - } + if (pfse[0]->mode != ((flag != 0) ? 0x51 : 0xa1)) + continue; if (!strcmp(p, pfse[0]->name)) return i; @@ -2630,35 +2524,22 @@ int mcman_clearPS1direntry(int port, int slot, int cluster, int flags) fh++; } - if (!flags) { - if (fse->mode != 0x51) - return sceMcResNoEntry; - } - else { - if (fse->mode != 0xa1) - return sceMcResNoEntry; - } + if (fse->mode != (!flags ? 0x51 : 0xa1)) + return sceMcResNoEntry; do { lbl0: mce = mcman_get1stcacheEntp(); - if (cluster + 1 < 0) - temp = cluster + 8; - else - temp = cluster + 1; + temp = (cluster + 1 < 0) ? (cluster + 8) : (cluster + 1); temp &= ~0x00000007; temp = (cluster + 1) - temp; - if (temp < 0) - temp = 0; + temp = (temp < 0) ? 0 : temp; mce->wr_flag |= 1 << temp; - if (flags == 0) - temp = (fse->mode & 0xf) | 0xa0; - else - temp = (fse->mode & 0xf) | 0x50; + temp = (flags == 0) ? ((fse->mode & 0xf) | 0xa0) : ((fse->mode & 0xf) | 0x50); fse->mode = temp; fse->edc = mcman_calcEDC((void *)fse, 127); @@ -2763,8 +2644,7 @@ int mcman_fatRseekPS1(int fd) rpos = fh->position % mcdi->cluster_size; - if (rpos < 0) - rpos += 1023; + rpos += (rpos < 0) ? 1023 : 0; return ((clust + 1) << 6) + ((rpos >> 10) * (1024 / mcdi->pagesize)); } @@ -2814,10 +2694,7 @@ int mcman_FNC8ca4(int port, int slot, MC_FHANDLE *fh) DPRINTF("mcman_FNC8ca4 port%d slot%d\n", port, slot); - if ((int)(mcdi->cluster_size) < 0) - cluster_size = mcdi->cluster_size + 1023; - else - cluster_size = mcdi->cluster_size; + cluster_size = ((int)(mcdi->cluster_size) < 0) ? (mcdi->cluster_size + 1023) : mcdi->cluster_size; cluster_size = cluster_size >> 10; @@ -2863,15 +2740,11 @@ int mcman_FNC8ca4(int port, int slot, MC_FHANDLE *fh) mce = mcman_get1stcacheEntp(); - if (mcfree + 1 < 0) - temp = mcfree + 8; - else - temp = mcfree + 1; + temp = (mcfree + 1 < 0) ? (mcfree + 8) : (mcfree + 1); temp &= ~0x00000007; temp = (mcfree + 1) - temp; - if (temp < 0) - temp = 0; + temp = (temp < 0) ? 0 : temp; mce->wr_flag |= 1 << temp; @@ -2909,8 +2782,7 @@ int mcman_FNC8ca4(int port, int slot, MC_FHANDLE *fh) temp &= ~0x00000007; temp = (j + 1) - temp; - if (temp < 0) - temp = 0; + temp = (temp < 0) ? 0 : temp; mce->wr_flag |= 1 << temp; fse3->linked_block = mcfree; @@ -2939,15 +2811,11 @@ int mcman_FNC8ca4(int port, int slot, MC_FHANDLE *fh) mce = mcman_get1stcacheEntp(); - if (mcfree + 1 < 0) - temp = mcfree + 8; - else - temp = mcfree + 1; + temp = (mcfree + 1 < 0) ? (mcfree + 8) : (mcfree + 1); temp &= ~0x00000007; temp = (mcfree + 1) - temp; - if (temp < 0) - temp = 0; + temp = (temp < 0) ? 0 : temp; mce->wr_flag |= 1 << temp; @@ -2963,15 +2831,11 @@ int mcman_FNC8ca4(int port, int slot, MC_FHANDLE *fh) mce = mcman_get1stcacheEntp(); - if ((j + 1) < 0) - temp = j + 8; - else - temp = j + 1; + temp = ((j + 1) < 0) ? (j + 8) : j + 1; temp &= ~0x00000007; temp = (j + 1) - temp; - if (temp < 0) - temp = 0; + temp = (temp < 0) ? 0 : temp; mce->wr_flag |= 1 << temp; @@ -3098,20 +2962,13 @@ int mcman_cachePS1dirs(int port, int slot) temp2 = j + 1; - if (j < 7) - index = 0; - else - index = 1; + index = (j < 7) ? 0 : 1; - if (temp2 < 0) - temp1 = j + 8; - else - temp1 = temp2; + temp1 = (temp2 < 0) ? (j + 8) : temp2; temp1 &= ~0x00000007; temp1 = temp2 - temp1; - if (temp1 < 0) - temp1 = 0; + temp1 = (temp1 < 0) ? 0 : temp1; mce[index]->wr_flag |= 1 << temp1; @@ -3132,20 +2989,13 @@ int mcman_cachePS1dirs(int port, int slot) temp2 = i + 1; - if (i < 7) - index = 0; - else - index = 1; + index = (i < 7) ? 0 : 1; - if (temp2 < 0) - temp1 = i + 8; - else - temp1 = temp2; + temp1 = (temp2 < 0) ? (i + 8) : temp2; temp1 &= ~0x00000007; temp1 = temp2 - temp1; - if (temp1 < 0) - temp1 = 0; + temp1 = (temp1 < 0) ? 0 : temp1; mce[index]->wr_flag |= 1 << temp1; @@ -3448,8 +3298,7 @@ int mcman_flushcacheentry(McCacheEntry *mce) if (j == pages_per_fatclust) { r = mcman_probePS1Card2(mce->mc_port, mce->mc_slot); - if (r == -14) - r = sceMcResFailReplace; + r = (r == -14) ? sceMcResFailReplace : r; } if (cardtype != sceMcTypePS1) { if (r == sceMcResFailReplace) @@ -3568,10 +3417,7 @@ int mcman_flushcacheentry(McCacheEntry *mce) i = 0; //s1 do { - if (pagesize < 0) - ecc_count = (pagesize + 0x7f) >> 7; - else - ecc_count = pagesize >> 7; + ecc_count = ((pagesize < 0) ? (pagesize + 0x7f) : pagesize) >> 7; if (i >= ecc_count) break; @@ -3620,9 +3466,7 @@ int mcman_flushcacheentry(McCacheEntry *mce) if (pmce[i] != 0) pmce[i]->wr_flag = 0; } - if (r == sceMcResFailReplace) - return r; - return -58; + return (r == sceMcResFailReplace) ? r : -58; } if (r != sceMcResSucceed) return -57; @@ -3640,9 +3484,7 @@ int mcman_flushcacheentry(McCacheEntry *mce) if (pmce[i] != 0) pmce[i]->wr_flag = 0; } - if (r == sceMcResFailReplace) - return r; - return -58; + return (r == sceMcResFailReplace) ? r : -58; } if (r != sceMcResSucceed) return -57; @@ -3664,9 +3506,7 @@ int mcman_flushcacheentry(McCacheEntry *mce) if (pmce[i] != 0) pmce[i]->wr_flag = 0; } - if (r == sceMcResFailReplace) - return r; - return -58; + return (r == sceMcResFailReplace) ? r : -58; } if (r != sceMcResSucceed) return -57; @@ -4359,9 +4199,7 @@ int mcman_clearsuperblock(int port, int slot) for (i = 0; (u32)((unsigned int)i < sizeof(MCDevInfo)); i += 1024) { register int size, temp; - temp = i; - if (i < 0) - temp = i + 1023; + temp = (i < 0) ? (i + 1023) : i; r = McReadCluster(port, slot, temp >> 10, &mce); if (r != sceMcResSucceed) return -48; diff --git a/iop/memorycard/mcman/src/mcdev.c b/iop/memorycard/mcman/src/mcdev.c index e0196c22ce80..e9ba89b5bc79 100644 --- a/iop/memorycard/mcman/src/mcdev.c +++ b/iop/memorycard/mcman/src/mcdev.c @@ -188,9 +188,7 @@ int mcman_modloadcb(const char *filename, int *port, int *slot) if (port) { upos --; - if (((u8)path[upos] - 0x30) < 10) - *port = (u8)path[upos] - 0x30; - else *port = 0; + *port = (((u8)path[upos] - 0x30) < 10) ? ((u8)path[upos] - 0x30) : 0; } upos--; @@ -548,13 +546,13 @@ int mc_chstat(MC_IO_FIL_T *f, const char *filename, MC_IO_STA_T *stat, unsigned if (statmask & MC_IO_CST_MODE) { flags |= 0x200; mctbl.AttrFile = 0; - if (stat->mode & MC_IO_S_RD) mctbl.AttrFile |= sceMcFileAttrReadable; - if (stat->mode & MC_IO_S_WR) mctbl.AttrFile |= sceMcFileAttrWriteable; - if (stat->mode & MC_IO_S_EX) mctbl.AttrFile |= sceMcFileAttrExecutable; + mctbl.AttrFile |= (stat->mode & MC_IO_S_RD) ? sceMcFileAttrReadable : 0; + mctbl.AttrFile |= (stat->mode & MC_IO_S_WR) ? sceMcFileAttrWriteable : 0; + mctbl.AttrFile |= (stat->mode & MC_IO_S_EX) ? sceMcFileAttrExecutable : 0; #if !MCMAN_ENABLE_EXTENDED_DEV_OPS - if (stat->mode & SCE_STM_C) mctbl.AttrFile |= sceMcFileAttrDupProhibit; - if (stat->mode & sceMcFileAttrPS1) mctbl.AttrFile |= sceMcFileAttrPS1; - if (stat->mode & sceMcFileAttrPDAExec) mctbl.AttrFile |= sceMcFileAttrPDAExec; + mctbl.AttrFile |= (stat->mode & SCE_STM_C) ? sceMcFileAttrDupProhibit : 0; + mctbl.AttrFile |= (stat->mode & sceMcFileAttrPS1) ? sceMcFileAttrPS1 : 0; + mctbl.AttrFile |= (stat->mode & sceMcFileAttrPDAExec) ? sceMcFileAttrPDAExec : 0; #endif } diff --git a/iop/memorycard/mcman/src/mciomanx_backing.c b/iop/memorycard/mcman/src/mciomanx_backing.c index 7d9ddda0a965..865ae4e0d2d6 100644 --- a/iop/memorycard/mcman/src/mciomanx_backing.c +++ b/iop/memorycard/mcman/src/mciomanx_backing.c @@ -95,12 +95,7 @@ int mcman_iomanx_backing_mount(int port, int slot, const char *filename) read_result = iomanX_read(fd, &superblock, sizeof(superblock)); if (read_result != sizeof(superblock)) { - if (read_result >= 0) { - r = -EINVAL; - } - else { - r = read_result; - } + r = (read_result >= 0) ? -EINVAL : read_result; goto cleanup; } // Check magic @@ -323,10 +318,7 @@ int mcman_iomanx_backing_read(int port, int slot, int page, void *pagebuf, void i = 0; //s1 do { - if (pagesize < 0) - ecc_count = (pagesize + 0x7f) >> 7; - else - ecc_count = pagesize >> 7; + ecc_count = ((pagesize < 0) ? (pagesize + 0x7f) : pagesize) >> 7; if (i >= ecc_count) break; diff --git a/iop/memorycard/mcman/src/mcsio2.c b/iop/memorycard/mcman/src/mcsio2.c index c8126bac856e..c1a2b11628df 100644 --- a/iop/memorycard/mcman/src/mcsio2.c +++ b/iop/memorycard/mcman/src/mcsio2.c @@ -502,8 +502,7 @@ int mcman_eraseblock(int port, int slot, int block, void **pagebuf, void *eccbuf page = 0; while (page < mcdi->blocksize) { ecc_offset = page * mcdi->pagesize; - if (ecc_offset < 0) - ecc_offset += 0x1f; + ecc_offset += (ecc_offset < 0) ? 0x1f : 0; ecc_offset = ecc_offset >> 5; p_ecc = (void *)((u8 *)eccbuf + ecc_offset); size = 0; @@ -794,8 +793,7 @@ int McGetCardSpec(int port, int slot, s16 *pagesize, u16 *blocksize, int *cardsi *blocksize = dev9_flash_info.block_pages; *cardsize = dev9_flash_info.blocks * dev9_flash_info.block_pages; *flags = 0x22 | CF_BAD_BLOCK; - if (dev9_flash_info.page_bytes != 512) - *flags |= CF_USE_ECC; + *flags |= (dev9_flash_info.page_bytes != 512) ? CF_USE_ECC : 0; #endif DPRINTF("McGetCardSpec sio2cmd pagesize=%d blocksize=%u cardsize=%d flags%x\n", *pagesize, *blocksize, *cardsize, *flags); HAKAMA_SIGNALSEMA(); @@ -1117,10 +1115,7 @@ int mcman_probePS1Card(int port, int slot) return -11; if (mcman_sio2outbufs_PS1PDA[1] == 0) { - if (mcdi->cardform != 0) - return sceMcResSucceed; - else - return sceMcResNoFormat; + return (mcdi->cardform != 0) ? sceMcResSucceed : sceMcResNoFormat; } else if (mcman_sio2outbufs_PS1PDA[1] != 8) { return -12; @@ -1201,8 +1196,7 @@ int McWritePS1PDACard(int port, int slot, int page, void *buf) // Export #30 mcman_sio2packet_PS1PDA.regdata[1] = 0; for (i = 0; i < 20; i++) { - if (mcdi->bad_block_list[i] == page) - page += 36; + page += (mcdi->bad_block_list[i] == page) ? 36 : 0; } mcman_sio2inbufs_PS1PDA[0] = 0x81; @@ -1271,8 +1265,7 @@ int McReadPS1PDACard(int port, int slot, int page, void *buf) // Export #29 mcman_sio2packet_PS1PDA.regdata[1] = 0; for (i = 0; i < 20; i++) { - if (mcdi->bad_block_list[i] == page) - page += 36; + page += (mcdi->bad_block_list[i] == page) ? 36 : 0; } mcman_sio2inbufs_PS1PDA[0] = 0x81; diff --git a/iop/memorycard/mcman/src/ps1mc_fio.c b/iop/memorycard/mcman/src/ps1mc_fio.c index b2d4616b1f1b..8f1f2946abd2 100644 --- a/iop/memorycard/mcman/src/ps1mc_fio.c +++ b/iop/memorycard/mcman/src/ps1mc_fio.c @@ -86,8 +86,7 @@ int mcman_open1(int port, int slot, const char *filename, int flags) DPRINTF("mcman_open1 port%d slot%d filename %s flags %x\n", port, slot, filename, flags); - if ((flags & sceMcFileCreateFile) != 0) - flags |= sceMcFileAttrWriteable; + flags |= ((flags & sceMcFileCreateFile) != 0) ? sceMcFileAttrWriteable : 0; for (fd = 0; fd < MAX_FDHANDLES; fd++) { fh = (MC_FHANDLE *)&mcman_fdhandles[fd]; @@ -119,14 +118,7 @@ int mcman_open1(int port, int slot, const char *filename, int flags) fh->freeclink = r; - if (r >= 0) { - if (fse->field_7d == 1) - fh->filesize = fse->field_38; - else - fh->filesize = fse->length; - } - else - fh->filesize = 0; + fh->filesize = (r >= 0) ? ((fse->field_7d == 1) ? fse->field_38 : fse->length) : 0; fh->rdflag = flags & sceMcFileAttrReadable; fh->wrflag = flags & sceMcFileAttrWriteable; @@ -272,17 +264,11 @@ int mcman_read1(int fd, void *buffer, int nbyte) do { register int r, size, temp, offset, maxsize; - if ((int)(fh->position) < 0) - temp = fh->position + 0x3ff; - else - temp = fh->position; + temp = ((int)(fh->position) < 0) ? (fh->position + 0x3ff) : fh->position; offset = (fh->position - (temp & ~0x000003ff)); maxsize = MCMAN_CLUSTERSIZE - offset; - if (maxsize < nbyte) - size = maxsize; - else - size = nbyte; + size = (maxsize < nbyte) ? maxsize : nbyte; r = mcman_fatRseekPS1(fd); if (r < 0) @@ -350,17 +336,11 @@ int mcman_write1(int fd, void *buffer, int nbyte) if (r != sceMcResSucceed) return r; - if ((int)(fh->position) < 0) - temp = fh->position + 0x3ff; - else - temp = fh->position; + temp = ((int)(fh->position) < 0) ? (fh->position + 0x3ff) : fh->position; offset = fh->position - (temp & ~0x000003ff); maxsize = MCMAN_CLUSTERSIZE - offset; - if (maxsize < nbyte) - size = maxsize; - else - size = nbyte; + size = (maxsize < nbyte) ? maxsize : nbyte; memcpy((void *)(mce->cl_data + offset), &p[wpos], size); @@ -415,19 +395,15 @@ int mcman_dread1(int fd, MC_IO_DRE_T *dirent) #if !MCMAN_ENABLE_EXTENDED_DEV_OPS dirent->stat.mode |= sceMcFileAttrDupProhibit | sceMcFileAttrPS1; - if (fse->field_7e == 1) - dirent->stat.mode |= sceMcFileAttrPDAExec; + dirent->stat.mode |= (fse->field_7e == 1) ? sceMcFileAttrPDAExec : 0; #endif if (fse->field_7d == 1) { memcpy(dirent->stat.ctime, &fse->created, sizeof(sceMcStDateTime)); memcpy(dirent->stat.mtime, &fse->modified, sizeof(sceMcStDateTime)); - dirent->stat.size = fse->field_38; dirent->stat.attr = fse->field_28; } - else { - dirent->stat.size = fse->length; - } + dirent->stat.size = (fse->field_7d == 1) ? fse->field_38 : fse->length; return 1; } @@ -459,8 +435,7 @@ int mcman_getstat1(int port, int slot, const char *filename, MC_IO_STA_T *stat) if (fse->field_7d == 1) { #if !MCMAN_ENABLE_EXTENDED_DEV_OPS - if ((fse->field_2c & sceMcFileAttrClosed) != 0) - stat->mode |= sceMcFileAttrClosed; + stat->mode |= ((fse->field_2c & sceMcFileAttrClosed) != 0) ? sceMcFileAttrClosed : 0; #endif memcpy(stat->ctime, &fse->created, sizeof(sceMcStDateTime)); @@ -544,10 +519,7 @@ int mcman_setinfo1(int port, int slot, const char *filename, sceMcTblGetDir *inf #endif if ((flags & sceMcFileAttrExecutable) != 0) { - if ((info->AttrFile & sceMcFileAttrPDAExec) != 0) - fse2->field_7e = 1; - else - fse2->field_7e = 0; + fse2->field_7e = ((info->AttrFile & sceMcFileAttrPDAExec) != 0) ? 1 : 0; } //Special fix clause for file managers (like uLaunchELF) @@ -627,24 +599,16 @@ int mcman_getdir1(int port, int slot, const char *dirname, int flags, int maxent memset((void *)info, 0, sizeof (sceMcTblGetDir)); - info->AttrFile = 0x9417; - - if (fse->field_7e == 1) - info->AttrFile = 0x9c17; //MC_ATTR_PDAEXEC set !!! + info->AttrFile = (fse->field_7e == 1) ? 0x9c17 /* MC_ATTR_PDAEXEC set !!! */ : 0x9417; if (fse->field_7d == 1) { - if ((fse->field_2c & sceMcFileAttrClosed) != 0) { - info->AttrFile |= sceMcFileAttrClosed; - } + info->AttrFile |= ((fse->field_2c & sceMcFileAttrClosed) != 0) ? sceMcFileAttrClosed : 0; info->Reserve1 = fse->field_2e; info->_Create = fse->created; info->_Modify = fse->modified; - info->FileSizeByte = fse->field_38; info->Reserve2 = fse->field_28; } - else { - info->FileSizeByte = fse->length; - } + info->FileSizeByte = (fse->field_7d == 1) ? fse->field_38 : fse->length; strncpy(info->EntryName, fse->name, 20); info->EntryName[20] = 0; @@ -692,10 +656,7 @@ int mcman_close1(int fd) mce = mcman_get1stcacheEntp(); - if ((int)(fh->freeclink + 1) < 0) - temp = fh->freeclink + 8; - else - temp = fh->freeclink + 1; + temp = ((int)(fh->freeclink + 1) < 0) ? (fh->freeclink + 8) : fh->freeclink + 1; temp &= ~0x00000007; temp = (fh->freeclink + 1) - temp; @@ -704,18 +665,7 @@ int mcman_close1(int fd) mce->wr_flag |= 1 << temp; - if (fh->filesize == 0) { - fse->length = 0x2000; - } - else { - if ((int)(fh->filesize - 1) < 0) - temp = (fh->filesize + 8190) >> 13; - else - temp = (fh->filesize - 1) >> 13; - - temp++; - fse->length = temp << 13; - } + fse->length = (fh->filesize == 0) ? 0x2000 : ((((int)(fh->filesize - 1) < 0) ? ((fh->filesize + 8190) >> 13) : ((fh->filesize - 1) >> 13) + 1) << 13); #ifdef BUILDING_XMCMAN fse->field_7d = 0; // <--- To preserve for XMCMAN diff --git a/iop/memorycard/mcman/src/ps2mc_fio.c b/iop/memorycard/mcman/src/ps2mc_fio.c index d5a706837c90..b0cf01f84a3f 100644 --- a/iop/memorycard/mcman/src/ps2mc_fio.c +++ b/iop/memorycard/mcman/src/ps2mc_fio.c @@ -215,10 +215,7 @@ int mcman_format2(int port, int slot) // read superblock to mc cache for (i = 0; (unsigned int)i < sizeof (MCDevInfo); i += MCMAN_CLUSTERSIZE) { - if (i < 0) - size = i + (MCMAN_CLUSTERSIZE - 1); - else - size = i; + size = (i < 0) ? (i + (MCMAN_CLUSTERSIZE - 1)) : i; if (McReadCluster(port, slot, size >> 10, &mce) != sceMcResSucceed) return -48; @@ -283,24 +280,15 @@ int mcman_dread2(int fd, MC_IO_DRE_T *dirent) strcpy(dirent->name, fse->name); *(u8 *)&dirent->name[32] = 0; - if (fse->mode & sceMcFileAttrReadable) - dirent->stat.mode |= MC_IO_S_RD; - if (fse->mode & sceMcFileAttrWriteable) - dirent->stat.mode |= MC_IO_S_WR; - if (fse->mode & sceMcFileAttrExecutable) - dirent->stat.mode |= MC_IO_S_EX; + dirent->stat.mode |= (fse->mode & sceMcFileAttrReadable) ? MC_IO_S_RD : 0; + dirent->stat.mode |= (fse->mode & sceMcFileAttrWriteable) ? MC_IO_S_WR : 0; + dirent->stat.mode |= (fse->mode & sceMcFileAttrExecutable) ? MC_IO_S_EX : 0; #if !MCMAN_ENABLE_EXTENDED_DEV_OPS - if (fse->mode & sceMcFileAttrPS1) - dirent->stat.mode |= sceMcFileAttrPS1; - if (fse->mode & sceMcFileAttrPDAExec) - dirent->stat.mode |= sceMcFileAttrPDAExec; - if (fse->mode & sceMcFileAttrDupProhibit) - dirent->stat.mode |= sceMcFileAttrDupProhibit; + dirent->stat.mode |= (fse->mode & sceMcFileAttrPS1) ? sceMcFileAttrPS1 : 0; + dirent->stat.mode |= (fse->mode & sceMcFileAttrPDAExec) ? sceMcFileAttrPDAExec : 0; + dirent->stat.mode |= (fse->mode & sceMcFileAttrDupProhibit) ? sceMcFileAttrDupProhibit : 0; #endif - if (fse->mode & sceMcFileAttrSubdir) - dirent->stat.mode |= MC_IO_S_DR; - else - dirent->stat.mode |= MC_IO_S_FL; + dirent->stat.mode |= (fse->mode & sceMcFileAttrSubdir) ? MC_IO_S_DR : MC_IO_S_FL; dirent->stat.attr = fse->attr; dirent->stat.size = fse->length; @@ -324,24 +312,15 @@ int mcman_getstat2(int port, int slot, const char *filename, MC_IO_STA_T *stat) mcman_wmemset((void *)stat, sizeof (MC_IO_STA_T), 0); - if (fse->mode & sceMcFileAttrReadable) - stat->mode |= MC_IO_S_RD; - if (fse->mode & sceMcFileAttrWriteable) - stat->mode |= MC_IO_S_WR; - if (fse->mode & sceMcFileAttrExecutable) - stat->mode |= MC_IO_S_EX; + stat->mode |= (fse->mode & sceMcFileAttrReadable) ? MC_IO_S_RD : 0; + stat->mode |= (fse->mode & sceMcFileAttrWriteable) ? MC_IO_S_WR : 0; + stat->mode |= (fse->mode & sceMcFileAttrExecutable) ? MC_IO_S_EX : 0; #if !MCMAN_ENABLE_EXTENDED_DEV_OPS - if (fse->mode & sceMcFileAttrPS1) - stat->mode |= sceMcFileAttrPS1; - if (fse->mode & sceMcFileAttrPDAExec) - stat->mode |= sceMcFileAttrPDAExec; - if (fse->mode & sceMcFileAttrDupProhibit) - stat->mode |= sceMcFileAttrDupProhibit; + stat->mode |= (fse->mode & sceMcFileAttrPS1) ? sceMcFileAttrPS1 : 0; + stat->mode |= (fse->mode & sceMcFileAttrPDAExec) ? sceMcFileAttrPDAExec : 0; + stat->mode |= (fse->mode & sceMcFileAttrDupProhibit) ? sceMcFileAttrDupProhibit : 0; #endif - if (fse->mode & sceMcFileAttrSubdir) - stat->mode |= MC_IO_S_DR; - else - stat->mode |= MC_IO_S_FL; + stat->mode |= (fse->mode & sceMcFileAttrSubdir) ? MC_IO_S_DR : MC_IO_S_FL; stat->attr = fse->attr; @@ -407,16 +386,7 @@ int mcman_setinfo2(int port, int slot, const char *filename, sceMcTblGetDir *inf r = mcman_getdirinfo(port, slot, &mfe, info->EntryName, NULL, 1); if (r != 1) { - if (r < 2) { - if (r == 0) - return sceMcResNoEntry; - return r; - } - else { - if (r != 2) - return r; - return sceMcResDeniedPermit; - } + return (r < 2) ? ((r == 0) ? sceMcResNoEntry : r) : ((r != 2) ? r : sceMcResDeniedPermit); } } @@ -442,16 +412,12 @@ int mcman_setinfo2(int port, int slot, const char *filename, sceMcTblGetDir *inf fse->attr = info->Reserve2; if ((flags & sceMcFileAttrExecutable) != 0) { - fmode = 0xffff7fcf; - if (!PS1CardFlag) - fmode = 0x180f; + fmode = (!PS1CardFlag) ? 0x180f : 0xffff7fcf; fse->mode = (fse->mode & ~fmode) | (info->AttrFile & fmode); } if ((flags & sceMcFileCreateFile) != 0) { - fmode = 0x380f; - if (!PS1CardFlag) - fmode = 0x180f; + fmode = (!PS1CardFlag) ? 0x180f : 0x380f; fse->mode = (fse->mode & ~fmode) | (info->AttrFile & fmode); } @@ -482,8 +448,7 @@ int mcman_read2(int fd, void *buffer, int nbyte) register int temp, rpos; temp = fh->filesize - fh->position; - if (nbyte > temp) - nbyte = temp; + nbyte = (nbyte > temp) ? temp : nbyte; rpos = 0; if (nbyte > 0) { @@ -493,10 +458,7 @@ int mcman_read2(int fd, void *buffer, int nbyte) offset = fh->position % mcdi->cluster_size; // file pointer offset % cluster size temp = mcdi->cluster_size - offset; - if (temp < nbyte) - size = temp; - else - size = nbyte; + size = (temp < nbyte) ? temp : nbyte; r = mcman_fatRseek(fd); @@ -572,10 +534,7 @@ int mcman_write2(int fd, void *buffer, int nbyte) offset = fh->position % mcdi->cluster_size; // file pointer offset % cluster size r2 = mcdi->cluster_size - offset; - if (r2 < nbyte) - size = r2; - else - size = nbyte; + size = (r2 < nbyte) ? r2 : nbyte; memcpy((void *)((u8 *)(mce->cl_data) + offset), (void *)((u8 *)buffer + wpos), size); @@ -615,12 +574,7 @@ int mcman_close2(int fd) if (r != sceMcResSucceed) return -31; - if (fh->unknown2 == 0) { - fmode = fse1->mode | sceMcFileAttrClosed; - } - else { - fmode = fse1->mode & 0xff7f; - } + fmode = (fh->unknown2 == 0) ? (fse1->mode | sceMcFileAttrClosed) : (fse1->mode & 0xff7f); fse1->mode = fmode; mcman_getmcrtime(&fse1->modified); @@ -658,8 +612,7 @@ int mcman_open2(int port, int slot, const char *filename, int flags) DPRINTF("mcman_open2 port%d slot%d name %s flags %x\n", port, slot, filename, flags); - if ((flags & sceMcFileCreateFile) != 0) - flags |= sceMcFileAttrWriteable; // s5 + flags |= ((flags & sceMcFileCreateFile) != 0) ? sceMcFileAttrWriteable : 0; // s5 //if (!mcman_checkpath(filename)) // return sceMcResNoEntry; @@ -682,10 +635,7 @@ int mcman_open2(int port, int slot, const char *filename, int flags) mcdi = (MCDevInfo *)&mcman_devinfos[port][slot]; // s3 - if ((flags & (sceMcFileCreateFile | sceMcFileCreateDir)) == 0) - cacheDir.maxent = -1; //sp20 - else - cacheDir.maxent = 0; //sp20 + cacheDir.maxent = ((flags & (sceMcFileCreateFile | sceMcFileCreateDir)) == 0) ? -1 : 0; //sp20 //fse1 = sp28 //sp18 = cacheDir @@ -809,15 +759,9 @@ int mcman_open2(int port, int slot, const char *filename, int flags) fh->filesize = mcman_dircache[1].length; fh->clink = fh->freeclink; - if (fh->rdflag != 0) - fh->rdflag = (*((u8 *)&mcman_dircache[1].mode)) & sceMcFileAttrReadable; - else - fh->rdflag = 0; + fh->rdflag = (fh->rdflag != 0) ? ((*((u8 *)&mcman_dircache[1].mode)) & sceMcFileAttrReadable) : 0; - if (fh->wrflag != 0) - fh->wrflag = (mcman_dircache[1].mode >> 1) & sceMcFileAttrReadable; - else - fh->wrflag = 0; + fh->wrflag = (fh->wrflag != 0) ? ((mcman_dircache[1].mode >> 1) & sceMcFileAttrReadable) : 0; fh->status = 1; @@ -1069,10 +1013,7 @@ int mcman_chdir(int port, int slot, const char *newdir, char *currentdir) lbl1: if (strcmp(fse->name, ".")) { - if (strlen(fse->name) < 32) - len = strlen(fse->name); - else - len = 32; + len = (strlen(fse->name) < 32) ? strlen(fse->name) : 32; if (strlen(currentdir)) { len2 = strlen(currentdir); @@ -1144,10 +1085,7 @@ int mcman_getdir2(int port, int slot, const char *dirname, int flags, int maxent } while (1); if (pos <= 0) { - if (pos == 0) - *p = 0; - else - p[-1] = 0; + p[(pos == 0) ? 0 : -1] = 0; } else { mcman_curdirpath[pos] = 0; @@ -1169,10 +1107,7 @@ int mcman_getdir2(int port, int slot, const char *dirname, int flags, int maxent mcman_curdircluster = fse->cluster; mcman_curdirlength = fse->length; - if ((fse->cluster == mcdi->rootdir_cluster) && (fse->dir_entry == 0)) - mcman_curdirmaxent = 2; - else - mcman_curdirmaxent = 0; + mcman_curdirmaxent = ((fse->cluster == mcdi->rootdir_cluster) && (fse->dir_entry == 0)) ? 2 : 0; } else { if (mcman_curdircluster < 0) @@ -1325,9 +1260,7 @@ int mcman_unformat2(int port, int slot) pageword_cnt = mcdi->pagesize >> 2; blocks_on_card = mcdi->clusters_per_card / mcdi->clusters_per_block; //sp18 - erase_value = 0xffffffff; //s6 - if (!(mcdi->cardflags & CF_ERASE_ZEROES)) - erase_value = 0x00000000; + erase_value = (!(mcdi->cardflags & CF_ERASE_ZEROES)) ? 0x00000000 : 0xffffffff; //s6 for (i = 0; i < pageword_cnt; i++) mcman_pagebuf.word[i] = erase_value; diff --git a/iop/memorycard/mcserv/src/mcserv.c b/iop/memorycard/mcserv/src/mcserv.c index 77a3903382d2..c46ce9ae17d7 100644 --- a/iop/memorycard/mcserv/src/mcserv.c +++ b/iop/memorycard/mcserv/src/mcserv.c @@ -751,9 +751,7 @@ int _McWrite(void *rpc_buf) r = McWrite(dP->fd, &mcserv_buf, size_to_write); if (r != size_to_write) { - if (r < 0) - return r; - return r + size_written; + return (r < 0) ? r : (r + size_written); } size_written += size_to_write; @@ -938,16 +936,11 @@ int _McGetInfo2(void *rpc_buf) if (dP->offset > 0) { mc_free = McGetFreeClusters(dP->port, dP->slot); - if (mc_free < 0) - eP.free = 0; - else - eP.free = mc_free; + eP.free = (mc_free < 0) ? 0 : mc_free; } if (dP->size > 0) { - eP.formatted = 0; - if (McGetFormat(dP->port, dP->slot) > 0) - eP.formatted = 1; + eP.formatted = (McGetFormat(dP->port, dP->slot) > 0) ? 1 : 0; } dma_transfer: diff --git a/iop/network/netcnf/src/netcnf.c b/iop/network/netcnf/src/netcnf.c index 82b3c7a8b845..1533077a14bb 100644 --- a/iop/network/netcnf/src/netcnf.c +++ b/iop/network/netcnf/src/netcnf.c @@ -1092,9 +1092,7 @@ static int do_write_memcard_files(const char *fpath, const char *icon_value, con return result; do_safe_make_pathname(cur_combpath, sizeof(cur_combpath), cur_basepath, "icon.sys"); result = do_copy_netcnf_path(iconsys_value, cur_combpath); - if ( result < 0 ) - return result; - return 0; + return ( result < 0 ) ? result : 0; } static int do_handle_fname(char *fpath, size_t maxlen, const char *fname) @@ -1496,8 +1494,7 @@ static int do_add_entry_inner( i = 0; for ( curentry1 = g_add_entry_heapptr; *curentry1; curentry1 = do_get_str_line(curentry1) ) { - if ( do_type_check(type, curentry1) == 1 ) - i += 1; + i += ( do_type_check(type, curentry1) == 1 ) ? 1 : 0; } switch ( type ) { @@ -1521,8 +1518,7 @@ static int do_add_entry_inner( i = 0; for ( curentry2 = g_add_entry_heapptr; *curentry2; curentry2 = do_get_str_line(curentry2) ) { - if ( do_type_check(type, curentry2) == 1 ) - i += 1; + i += ( do_type_check(type, curentry2) == 1 ) ? 1 : 0; } switch ( type ) { @@ -2515,10 +2511,7 @@ static int do_check_nameserver(sceNetCnfEnv_t *e, struct sceNetCnfInterface *ifc if ( do_netcnfname2address_wrap(e, opt_argv[2], &nameservermem_1->address) ) return -1; nameservermem_1->cmd.back = ifc->cmd_tail; - if ( ifc->cmd_tail ) - ifc->cmd_tail->forw = &nameservermem_1->cmd; - else - ifc->cmd_head = &nameservermem_1->cmd; + *( ifc->cmd_tail ? &(ifc->cmd_tail->forw) : &(ifc->cmd_head) ) = &nameservermem_1->cmd; nameservermem_1->cmd.forw = 0; ifc->cmd_tail = &nameservermem_1->cmd; return 0; @@ -2580,10 +2573,7 @@ static int do_check_route(sceNetCnfEnv_t *e, struct sceNetCnfInterface *ifc, int } } route_mem_1->cmd.back = ifc->cmd_tail; - if ( ifc->cmd_tail ) - ifc->cmd_tail->forw = &route_mem_1->cmd; - else - ifc->cmd_head = &route_mem_1->cmd; + *( ifc->cmd_tail ? &(ifc->cmd_tail->forw) : &(ifc->cmd_head)) = &route_mem_1->cmd; route_mem_1->cmd.forw = 0; ifc->cmd_tail = &route_mem_1->cmd; return 0; @@ -2641,10 +2631,7 @@ static int do_check_args(sceNetCnfEnv_t *e, struct sceNetCnfUnknownList *unknown cpydst_1 = (struct sceNetCnfUnknown *)&((char *)cpydst_1)[cpysz + 1]; } listtmp->back = unknown_list->tail; - if ( unknown_list->tail ) - unknown_list->tail->forw = listtmp; - else - unknown_list->head = listtmp; + *( unknown_list->tail ? &(unknown_list->tail->forw) : &(unknown_list->head) ) = listtmp; listtmp->forw = 0; unknown_list->tail = listtmp; return 0; @@ -2708,10 +2695,7 @@ static int do_check_other_keywords( } *((u8 *)cnfdata + options->m_offset) = (u8)numval; } - if ( !strcmp("want.auth", (const char *)e->av[0]) ) - *((u8 *)cnfdata + 171) = !wasprefixed; - else - *((u8 *)cnfdata + 247) = !wasprefixed; + *((u8 *)cnfdata + (!strcmp("want.auth", (const char *)e->av[0]) ? 171 : 247)) = !wasprefixed; return 0; case 'C': if ( !wasprefixed ) @@ -2720,10 +2704,7 @@ static int do_check_other_keywords( break; *(u32 *)((char *)cnfdata + options->m_offset) = numval; } - if ( !strcmp("want.accm", (const char *)e->av[0]) ) - *((u8 *)cnfdata + 170) = !wasprefixed; - else - *((u8 *)cnfdata + 246) = !wasprefixed; + *((u8 *)cnfdata + (!strcmp("want.accm", (const char *)e->av[0]) ? 170 : 246)) = !wasprefixed; return 0; case 'D': numval = 0xFFFFFFFF; @@ -2763,10 +2744,7 @@ static int do_check_other_keywords( break; *(u16 *)((char *)cnfdata + options->m_offset) = (u16)numval; } - if ( !strcmp("want.mru", (const char *)e->av[0]) ) - *((u8 *)cnfdata + 169) = !wasprefixed; - else - *((u8 *)cnfdata + 245) = !wasprefixed; + *((u8 *)cnfdata + (!strcmp("want.mru", (const char *)e->av[0]) ? 169 : 245)) = !wasprefixed; return 0; case 'P': numval = 0xFFFFFFFF; @@ -3034,8 +3012,7 @@ do_check_line_buffer(sceNetCnfEnv_t *e, u8 *lbuf, int (*readcb)(sceNetCnfEnv_t * { if ( *j == '\\' ) { - if ( j[1] ) - j += 1; + j += ( j[1] ) ? 1 : 0; } else { @@ -3072,8 +3049,7 @@ static int do_read_netcnf(sceNetCnfEnv_t *e, const char *netcnf_path, char **net result = (!is_attach_cnf || e->f_no_decode) ? do_read_netcnf_no_decode(netcnf_path, netcnf_heap_ptr) : do_read_netcnf_decode(netcnf_path, netcnf_heap_ptr); - if ( result < 0 ) - e->file_err += 1; + e->file_err += ( result < 0 ) ? 1 : 0; return result; } @@ -3103,24 +3079,7 @@ static int do_netcnf_read_related( return -1; if ( e->f_verbose ) { - printf("netcnf: reading \"%s\" as ", fullpath); - if ( (char *)readcb == (char *)do_handle_net_cnf ) - { - printf("NET_CNF"); - } - else if ( (char *)readcb == (char *)do_handle_attach_cnf ) - { - printf("ATTACH_CNF"); - } - else if ( (char *)readcb == (char *)do_handle_dial_cnf ) - { - printf("DIAL_CNF"); - } - else - { - printf("???"); - } - printf("\n"); + printf("netcnf: reading \"%s\" as %s\n", fullpath, ( (char *)readcb == (char *)do_handle_net_cnf ) ? "NET_CNF" : (( (char *)readcb == (char *)do_handle_attach_cnf ) ? "ATTACH_CNF" : (( (char *)readcb == (char *)do_handle_dial_cnf ) ? "DIAL_CNF" : "???"))); } e->fname = fullpath; read_res1 = do_read_netcnf(e, fullpath, &ptr, readcb == do_handle_attach_cnf); @@ -3166,8 +3125,7 @@ static int do_netcnf_read_related( } } } - if ( e->lbuf < lbuf ) - cur_linelen += do_check_line_buffer(e, lbuf, readcb, userdata); + cur_linelen += ( e->lbuf < lbuf ) ? do_check_line_buffer(e, lbuf, readcb, userdata) : 0; do_free_heapmem(ptr); return cur_linelen; } @@ -3471,8 +3429,7 @@ static int do_netcnf_vsprintf_buffer(sceNetCnfEnv_t *e, const char *fmt, va_list { strlened = 10 * strlened - '0' + *fmt; } - if ( *fmt == 'l' ) - fmt += 1; + fmt += ( *fmt == 'l' ) ? 1 : 0; fmt_flag_str = -1; strpad1 = 0; switch ( *fmt ) @@ -4086,12 +4043,7 @@ static int do_write_netcnf(sceNetCnfEnv_t *e, const char *path, int is_attach_cn return -1; if ( e->f_verbose ) { - printf("netcnf: writing \"%s\" as ", fullpath); - if ( is_attach_cnf ) - printf("ATTACH_CNF"); - else - printf("NET_CNF"); - printf("\n"); + printf("netcnf: writing \"%s\" as %s\n", fullpath, is_attach_cnf ? "ATTACH_CNF" : "NET_CNF"); } if ( !is_attach_cnf || e->f_no_decode ) { @@ -4148,9 +4100,7 @@ static int do_export_netcnf_inner(sceNetCnfEnv_t *e, const char *arg_fname, stru if ( result < 0 ) return result; result = do_netcnf_unknown_write(e, &ifc->unknown_list); - if ( result < 0 ) - return result; - return do_write_netcnf(e, arg_fname, 1); + return ( result < 0 ) ? result : do_write_netcnf(e, arg_fname, 1); } for ( pair_head = e->root->pair_head; pair_head; pair_head = pair_head->forw ) { @@ -4163,9 +4113,7 @@ static int do_export_netcnf_inner(sceNetCnfEnv_t *e, const char *arg_fname, stru if ( result < 0 ) return result; result = do_netcnf_unknown_write(e, &e->root->unknown_list); - if ( result < 0 ) - return result; - return do_write_netcnf(e, arg_fname, 0); + return ( result < 0 ) ? result : do_write_netcnf(e, arg_fname, 0); } static int do_export_netcnf(sceNetCnfEnv_t *e) @@ -4240,9 +4188,7 @@ static int do_name_2_address_inner(unsigned int *dst, const char *buf) offsbase1 = *buf - '0'; if ( !isdigit(*buf) ) { - offsbase1 = *buf - '7'; - if ( !isupper(*buf) ) - offsbase1 = *buf - 'W'; + offsbase1 = *buf - (( !isupper(*buf) ) ? 'W' : '7'); } if ( offsbase1 >= (int)base ) break; @@ -4436,8 +4382,7 @@ static int do_check_aolnet(const char *auth_name) for ( i = 0; periodpos; i += 1 ) { periodpos = strchr(periodpos, '.'); - if ( periodpos ) - periodpos += 1; + periodpos += ( periodpos ) ? 1 : 0; } return (i != 5) ? 0 : -20; } @@ -4460,8 +4405,7 @@ static int do_check_authnet(char *argst, char *arged) ; for ( ; *j && isspace(*j); j += 1 ) ; - if ( *j == '"' ) - j += 1; + j += ( *j == '"' ) ? 1 : 0; result = do_check_aolnet(j); if ( result < 0 ) return result; @@ -4603,20 +4547,14 @@ static const char *do_handle_netcnf_dirname(const char *fpath, const char *entry { for ( ; fpath < fpath_1_minus_1 && *fpath_1_minus_1 != ':'; fpath_1_minus_1 -= 1 ) ; - if ( fpath <= fpath_1_minus_1 && (*fpath_1_minus_1 == ':' || *fpath_1_minus_1 == '/' || *fpath_1_minus_1 == '\\') ) - { - fpath_1_minus_1 += 1; - } + fpath_1_minus_1 += ( fpath <= fpath_1_minus_1 && (*fpath_1_minus_1 == ':' || *fpath_1_minus_1 == '/' || *fpath_1_minus_1 == '\\') ) ? 1 : 0; } else if ( fpath <= fpath_1_minus_1 && *fpath_1_minus_1 != ':' ) { for ( ; fpath < fpath_1_minus_1 && *fpath_1_minus_1 != ':' && *fpath_1_minus_1 != '/' && *fpath_1_minus_1 != '\\'; fpath_1_minus_1 -= 1 ) ; - if ( *fpath_1_minus_1 == ':' || *fpath_1_minus_1 == '/' || *fpath_1_minus_1 == '\\' ) - { - fpath_1_minus_1 += 1; - } + fpath_1_minus_1 += ( *fpath_1_minus_1 == ':' || *fpath_1_minus_1 == '/' || *fpath_1_minus_1 == '\\' ) ? 1 : 0; } fpath_2 = fpath; for ( i = netcnf_file_path; fpath_2 < fpath_1_minus_1; i += 1 ) diff --git a/iop/network/netcnfif/src/netcnfif.c b/iop/network/netcnfif/src/netcnfif.c index deae165cd975..e9418627ac63 100644 --- a/iop/network/netcnfif/src/netcnfif.c +++ b/iop/network/netcnfif/src/netcnfif.c @@ -404,8 +404,7 @@ static void *sceNetcnfifInterfaceServer(int fno, sceNetcnfifArg_t *buf, int size / sizeof(env.root->pair_head->ifc->phone_numbers[0])); i += 1 ) { - if ( i < 3 && i >= 0 && env.root->pair_head->ifc->phone_numbers[i] ) - redial_count += 1; + redial_count += ( i < 3 && i >= 0 && env.root->pair_head->ifc->phone_numbers[i] ) ? 1 : 0; } env.root->pair_head->ifc->redial_count = redial_count - 1; if ( env.root->pair_head->ifc->pppoe != 1 && env.root->pair_head->ifc->type != 2 ) @@ -692,71 +691,46 @@ static int put_gw(sceNetCnfEnv_t *e, const char *gw) memset(&gateway, 0, sizeof(gateway)); gateway.cmd.code = 3; gateway.cmd.back = e->ifc->cmd_tail; - if ( gateway.cmd.back ) - gateway.cmd.back->forw = &gateway.cmd; - else - e->ifc->cmd_head = &gateway.cmd; + *(gateway.cmd.back ? &(gateway.cmd.back->forw) : &(e->ifc->cmd_head)) = &gateway.cmd; gateway.cmd.forw = 0; e->ifc->cmd_tail = &gateway.cmd; - if ( gw ) - { - retres = sceNetCnfName2Address(&gateway.re.dstaddr, 0); - if ( retres < 0 ) - return retres; - retres = sceNetCnfName2Address(&gateway.re.gateway, gw); - if ( retres < 0 ) - return retres; - retres = sceNetCnfName2Address(&gateway.re.genmask, 0); - if ( retres < 0 ) - return retres; - gateway.re.flags |= 4u; - } - else - { - retres = sceNetCnfName2Address(&gateway.re.dstaddr, 0); - if ( retres < 0 ) - return retres; - retres = sceNetCnfName2Address(&gateway.re.gateway, 0); - if ( retres < 0 ) - return retres; - retres = sceNetCnfName2Address(&gateway.re.genmask, 0); - if ( retres < 0 ) - return retres; - gateway.re.flags = 0; - } + retres = sceNetCnfName2Address(&gateway.re.dstaddr, 0); + if ( retres < 0 ) + return retres; + retres = sceNetCnfName2Address(&gateway.re.gateway, gw); + if ( retres < 0 ) + return retres; + retres = sceNetCnfName2Address(&gateway.re.genmask, 0); + if ( retres < 0 ) + return retres; + gateway.re.flags = gw ? 4 : 0; return retres; } static int put_ns(sceNetCnfEnv_t *e, const char *ns, int ns_count) { - nameserver_t *ns1; - nameserver_t *ns2; + nameserver_t *nsp; - ns1 = 0; + nsp = 0; switch ( ns_count ) { case 1: - ns1 = &dns1; - ns2 = &dns1; + nsp = &dns1; break; case 2: - ns1 = &dns2; - ns2 = &dns2; + nsp = &dns2; break; default: // Unofficial: return error instead of writing 1 to 0x00000008 return -1; } - memset(ns2, 0, sizeof(nameserver_t)); - ns1->cmd.code = 1; - ns1->cmd.back = e->ifc->cmd_tail; - if ( e->ifc->cmd_tail ) - e->ifc->cmd_tail->forw = &ns1->cmd; - else - e->ifc->cmd_head = &ns1->cmd; - ns1->cmd.forw = 0; - e->ifc->cmd_tail = &ns1->cmd; - return sceNetCnfName2Address(&ns1->address, ns); + memset(nsp, 0, sizeof(nameserver_t)); + nsp->cmd.code = 1; + nsp->cmd.back = e->ifc->cmd_tail; + *(e->ifc->cmd_tail ? &(e->ifc->cmd_tail->forw) : &(e->ifc->cmd_head)) = &nsp->cmd; + nsp->cmd.forw = 0; + e->ifc->cmd_tail = &nsp->cmd; + return sceNetCnfName2Address(&nsp->address, ns); } static int put_cmd(sceNetCnfEnv_t *e, sceNetcnfifData_t *data) diff --git a/iop/network/netman/src/netdev.c b/iop/network/netman/src/netdev.c index c90a0338a033..023e4ae1cea9 100644 --- a/iop/network/netman/src/netdev.c +++ b/iop/network/netman/src/netdev.c @@ -63,8 +63,7 @@ static int NetDevAdaptorIoctl(unsigned int command, void *args, unsigned int arg result = NETMAN_NETIF_ETH_LINK_MODE_10M_FDX; /* 10Base-TX FDX */ if (ret2 & 0x01) result = NETMAN_NETIF_ETH_LINK_MODE_10M_HDX; /* 10Base-TX HDX */ - if (!(ret2 & 0x40)) - result |= NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE; + result |= (!(ret2 & 0x40)) ? NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE : 0; break; case NETMAN_NETIF_IOCTL_GET_LINK_STATUS: g_ops->control(g_ops->priv, sceInetNDCC_GET_LINK_STATUS, &ret2, sizeof(ret2)); @@ -125,8 +124,7 @@ static int NetDevAdaptorIoctl(unsigned int command, void *args, unsigned int arg break; } } - if (!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE)) - ret2 |= sceInetNDNEGO_PAUSE; + ret2 |= (!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE)) ? sceInetNDNEGO_PAUSE : 0; g_ops->control(g_ops->priv, sceInetNDCC_SET_NEGO_MODE, &ret2, sizeof(ret2)); break; case NETMAN_NETIF_IOCTL_ETH_GET_STATUS: @@ -139,8 +137,7 @@ static int NetDevAdaptorIoctl(unsigned int command, void *args, unsigned int arg result = NETMAN_NETIF_ETH_LINK_MODE_10M_FDX; /* 10Base-TX FDX */ if (ret2 & 0x01) result = NETMAN_NETIF_ETH_LINK_MODE_10M_HDX; /* 10Base-TX HDX */ - if (!(ret2 & 0x40)) - result |= NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE; + result |= (!(ret2 & 0x40)) ? NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE : 0; ((struct NetManEthStatus *)output)->LinkMode = result; g_ops->control(g_ops->priv, sceInetNDCC_GET_LINK_STATUS, &ret2, sizeof(ret2)); result = (ret2 > 0) ? NETMAN_NETIF_ETH_LINK_STATE_UP : NETMAN_NETIF_ETH_LINK_STATE_DOWN; diff --git a/iop/network/netman/src/netman.c b/iop/network/netman/src/netman.c index ae8848bea887..49052ce26603 100644 --- a/iop/network/netman/src/netman.c +++ b/iop/network/netman/src/netman.c @@ -81,12 +81,7 @@ int NetManGetGlobalNetIFLinkState(void){ void NetManUpdateStackNIFLinkState(void){ if(IsInitialized){ - if(NIFLinkState){ - MainNetProtStack.LinkStateUp(); - } - else{ - MainNetProtStack.LinkStateDown(); - } + (NIFLinkState ? MainNetProtStack.LinkStateUp : MainNetProtStack.LinkStateDown)(); } } @@ -151,10 +146,7 @@ int NetManIoctl(unsigned int command, void *args, unsigned int args_len, void *o WaitSema(NetManIOSemaID); - if(MainNetIF!=NULL){ - result=MainNetIF->ioctl(command, args, args_len, output, length); - } - else result=-1; + result = (MainNetIF != NULL) ? MainNetIF->ioctl(command, args, args_len, output, length) : -1; SignalSema(NetManIOSemaID); @@ -250,12 +242,11 @@ void NetManToggleNetIFLinkState(int NetIFID, unsigned char state){ if(state){ pNetIF->flags|=NETMAN_NETIF_LINK_UP; - SetEventFlag(pNetIF->EventFlagID, NETMAN_NETIF_EVF_UP); } else{ pNetIF->flags&=~NETMAN_NETIF_LINK_UP; - SetEventFlag(pNetIF->EventFlagID, NETMAN_NETIF_EVF_DOWN); } + SetEventFlag(pNetIF->EventFlagID, state ? NETMAN_NETIF_EVF_UP : NETMAN_NETIF_EVF_DOWN); UpdateNetIFStatus(); } diff --git a/iop/network/smap/src/main.c b/iop/network/smap/src/main.c index 5692b0457749..1872fc5864a9 100644 --- a/iop/network/smap/src/main.c +++ b/iop/network/smap/src/main.c @@ -161,11 +161,9 @@ int SMapTxPacketNext(void **payload) { int len; - if (TxTail != NULL) { + if (TxTail != NULL) *payload = TxTail->payload; - len = TxTail->len; - } else - len = 0; + len = (TxTail != NULL) ? TxTail->len : 0; return len; } diff --git a/iop/network/smap/src/smap.c b/iop/network/smap/src/smap.c index f6641d9a4e02..176854474530 100644 --- a/iop/network/smap/src/smap.c +++ b/iop/network/smap/src/smap.c @@ -175,8 +175,7 @@ static int InitPHY(struct SmapDriverData *SmapDrivPrivData) LinkSpeed100M = 0 < (SmapConfiguration & 0x180); /* Toggles between SMAP_PHY_BMCR_10M and SMAP_PHY_BMCR_100M. */ value = LinkSpeed100M << 13; - if (SmapConfiguration & 0x140) - value |= SMAP_PHY_BMCR_DUPM; + value |= (SmapConfiguration & 0x140) ? SMAP_PHY_BMCR_DUPM : 0; _smap_write_phy(SmapDrivPrivData->emac3_regbase, SMAP_DsPHYTER_BMCR, value); WaitLink: @@ -358,23 +357,17 @@ static int InitPHY(struct SmapDriverData *SmapDrivPrivData) FlowControlEnabled = SmapConfiguration >> 10 & 1; } - if (LinkSpeed100M) - result = LinkFDX ? 8 : 4; - else - result = LinkFDX ? 2 : 1; + result = (LinkSpeed100M) ? (LinkFDX ? 8 : 4) : (LinkFDX ? 2 : 1); SmapDrivPrivData->LinkMode = result; - if (FlowControlEnabled) - SmapDrivPrivData->LinkMode |= 0x40; + SmapDrivPrivData->LinkMode |= FlowControlEnabled ? 0x40 : 0; DEBUG_PRINTF("%s %s Duplex Mode %s Flow Control\n", LinkSpeed100M ? "100BaseTX" : "10BaseT", LinkFDX ? "Full" : "Half", FlowControlEnabled ? "with" : "without"); emac3_regbase = SmapDrivPrivData->emac3_regbase; emac3_value = SMAP_EMAC3_GET32(SMAP_R_EMAC3_MODE1) & 0x67FFFFFF; - if (LinkFDX) - emac3_value |= SMAP_E3_FDX_ENABLE; - if (FlowControlEnabled) - emac3_value |= SMAP_E3_FLOWCTRL_ENABLE | SMAP_E3_ALLOW_PF; + emac3_value |= LinkFDX ? SMAP_E3_FDX_ENABLE : 0; + emac3_value |= FlowControlEnabled ? (SMAP_E3_FLOWCTRL_ENABLE | SMAP_E3_ALLOW_PF) : 0; SMAP_EMAC3_SET32(SMAP_R_EMAC3_MODE1, emac3_value); return 0; @@ -822,10 +815,7 @@ void SMAPXmit(void) #endif if (SmapDriverData.LinkStatus) { - if (QueryIntrContext()) - iSetEventFlag(SmapDrivPrivData->Dev9IntrEventFlag, SMAP_EVENT_XMIT); - else - SetEventFlag(SmapDrivPrivData->Dev9IntrEventFlag, SMAP_EVENT_XMIT); + (QueryIntrContext() ? iSetEventFlag : SetEventFlag)(SmapDrivPrivData->Dev9IntrEventFlag, SMAP_EVENT_XMIT); } else { // No link. Clear the packet queue. ClearPacketQueue(SmapDrivPrivData); @@ -863,8 +853,7 @@ static int SMAPGetLinkMode(void) result = NETMAN_NETIF_ETH_LINK_MODE_10M_FDX; /* 10Base-TX FDX */ if (value & 0x01) result = NETMAN_NETIF_ETH_LINK_MODE_10M_HDX; /* 10Base-TX HDX */ - if (!(value & 0x40)) - result |= NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE; + result |= (!(value & 0x40)) ? NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE : 0; } return result; @@ -909,8 +898,7 @@ static int SMAPSetLinkMode(int mode) } if (result == 0) { - if (!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE)) - SmapConfiguration |= 0x400; // Enable flow control. + SmapConfiguration |= (!(mode & NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE)) ? 0x400 : 0; // Enable flow control. SetEventFlag(SmapDriverData.Dev9IntrEventFlag, SMAP_EVENT_STOP | SMAP_EVENT_START); SmapDriverData.NetDevStopFlag = 1; @@ -1017,9 +1005,7 @@ static int SMAPIoctl(unsigned int command, void *args, unsigned int args_len, vo result = sceInetNDIFT_ETHERNET; break; case sceInetNDCC_GET_NEGO_STATUS: { - result = 0; - if ((int)(SmapDrivPrivData->LinkStatus) > 0) - result = SmapDrivPrivData->LinkMode; + result = ((int)(SmapDrivPrivData->LinkStatus) > 0) ? SmapDrivPrivData->LinkMode : 0; break; } case sceInetNDCC_GET_LINK_STATUS: @@ -1041,18 +1027,12 @@ static int SMAPIoctl(unsigned int command, void *args, unsigned int args_len, vo } case sceInetNDCC_GET_NEGO_MODE: { bufasint = 0; - if (EnableAutoNegotiation != 0) - bufasint |= sceInetNDNEGO_AUTO; - if ((SmapConfiguration & 0x400) != 0) - bufasint |= sceInetNDNEGO_PAUSE; - if ((SmapConfiguration & 0x100) != 0) - bufasint |= sceInetNDNEGO_TX_FD; - if ((SmapConfiguration & 0x80) != 0) - bufasint |= sceInetNDNEGO_TX; - if ((SmapConfiguration & 0x40) != 0) - bufasint |= sceInetNDNEGO_10_FD; - if ((SmapConfiguration & 0x20) != 0) - bufasint |= sceInetNDNEGO_10; + bufasint |= (EnableAutoNegotiation != 0) ? sceInetNDNEGO_AUTO : 0; + bufasint |= ((SmapConfiguration & 0x400) != 0) ? sceInetNDNEGO_PAUSE : 0; + bufasint |= ((SmapConfiguration & 0x100) != 0) ? sceInetNDNEGO_TX_FD : 0; + bufasint |= ((SmapConfiguration & 0x80) != 0) ? sceInetNDNEGO_TX : 0; + bufasint |= ((SmapConfiguration & 0x40) != 0) ? sceInetNDNEGO_10_FD : 0; + bufasint |= ((SmapConfiguration & 0x20) != 0) ? sceInetNDNEGO_10 : 0; tmpoutptr = &bufasint; break; } @@ -1063,16 +1043,11 @@ static int SMAPIoctl(unsigned int command, void *args, unsigned int args_len, vo tmpconfig = 0; memcpy(&bufasint, in_out_ptr, 4); EnableAutoNegotiation = ((bufasint & sceInetNDNEGO_AUTO) != 0 ? 1 : 0); - if ((bufasint & sceInetNDNEGO_PAUSE) != 0) - tmpconfig |= 0x400; - if ((bufasint & sceInetNDNEGO_TX_FD) != 0) - tmpconfig |= 0x100; - if ((bufasint & sceInetNDNEGO_TX) != 0) - tmpconfig |= 0x80; - if ((bufasint & sceInetNDNEGO_10_FD) != 0) - tmpconfig |= 0x40; - if ((bufasint & sceInetNDNEGO_10) != 0) - tmpconfig |= 0x20; + tmpconfig |= ((bufasint & sceInetNDNEGO_PAUSE) != 0) ? 0x400 : 0; + tmpconfig |= ((bufasint & sceInetNDNEGO_TX_FD) != 0) ? 0x100 : 0; + tmpconfig |= ((bufasint & sceInetNDNEGO_TX) != 0) ? 0x80 : 0; + tmpconfig |= ((bufasint & sceInetNDNEGO_10_FD) != 0) ? 0x40 : 0; + tmpconfig |= ((bufasint & sceInetNDNEGO_10) != 0) ? 0x20 : 0; SmapConfiguration = tmpconfig; result = 0; } diff --git a/iop/network/smap/src/xfer.c b/iop/network/smap/src/xfer.c index 3cd440b67ae9..fe1e417c9fc0 100644 --- a/iop/network/smap/src/xfer.c +++ b/iop/network/smap/src/xfer.c @@ -24,21 +24,12 @@ static int SmapDmaTransfer(volatile u8 *smap_regbase, void *buffer, unsigned int size, int direction) { unsigned int NumBlocks; - int result; (void)smap_regbase; /* Non-Sony: the original block size was (32*4 = 128) bytes. However, that resulted in slightly lower performance due to the IOP needing to copy more data. */ - if ((NumBlocks = size >> 6) > 0) { - if (SpdDmaTransfer(1, buffer, NumBlocks << 16 | 0x10, direction) >= 0) { - result = NumBlocks << 6; - } else - result = 0; - } else - result = 0; - - return result; + return ((NumBlocks = size >> 6) > 0) ? ((SpdDmaTransfer(1, buffer, NumBlocks << 16 | 0x10, direction) >= 0) ? (NumBlocks << 6) : 0) : 0; } static inline void CopyFromFIFO(volatile u8 *smap_regbase, void *buffer, unsigned int length, u16 RxBdPtr) diff --git a/iop/network/smbman/src/des.c b/iop/network/smbman/src/des.c index def36bc5d59f..89f82ae774bb 100644 --- a/iop/network/smbman/src/des.c +++ b/iop/network/smbman/src/des.c @@ -475,13 +475,8 @@ static unsigned char *DES_createkeys(const unsigned char *key) for (i = 0; i < ITERATIONS; i++) { unsigned int s; - if (shifts[i]) { - c = ((c >> 2) | (c << 26)); - d = ((d >> 2) | (d << 26)); - } else { - c = ((c >> 1) | (c << 27)); - d = ((d >> 1) | (d << 27)); - } + c = shifts[i] ? ((c >> 2) | (c << 26)) : ((c >> 1) | (c << 27)); + d = shifts[i] ? ((d >> 2) | (d << 26)) : ((d >> 1) | (d << 27)); c &= 0x0fffffff; d &= 0x0fffffff; /* could be a few less shifts but I am to lazy at this diff --git a/iop/network/smbman/src/md4.c b/iop/network/smbman/src/md4.c index 67d8de1feaec..43e7694e5531 100644 --- a/iop/network/smbman/src/md4.c +++ b/iop/network/smbman/src/md4.c @@ -164,12 +164,9 @@ unsigned char *MD4(unsigned char *message, int len, unsigned char *cipher) memcpy(buffer.ucbuff, message, len); buffer.ucbuff[len] = 0x80; - if (len < 56) { - buffer.uibuff[56 / sizeof(unsigned int)] = b; - transform(buffer.ucbuff); - } else { - buffer.uibuff[120 / sizeof(unsigned int)] = b; - transform(buffer.ucbuff); + buffer.uibuff[((len < 56) ? 56 : 120) / sizeof(unsigned int)] = b; + transform(buffer.ucbuff); + if (len >= 56) { transform(&buffer.ucbuff[64]); } diff --git a/iop/network/smbman/src/smb.c b/iop/network/smbman/src/smb.c index 4d201bd9863b..9bf53962c8a4 100644 --- a/iop/network/smbman/src/smb.c +++ b/iop/network/smbman/src/smb.c @@ -446,10 +446,7 @@ static int AddPassword(char *Password, int PasswordType, int AuthType, void *Ans } else if (server_specs.PasswordType == SERVER_USE_PLAINTEXT_PASSWORD) { // It seems that PlainText passwords and Unicode isn't meant to be... passwordlen = strlen(Password); - if (passwordlen > 14) - passwordlen = 14; - else if (passwordlen == 0) - passwordlen = 1; + passwordlen = (passwordlen > 14) ? 14 : ((passwordlen == 0) ? 1 : passwordlen); memcpy(AnsiPassLen, &passwordlen, 2); memcpy(Buffer, Password, passwordlen); } @@ -483,8 +480,7 @@ int smb_SessionSetupAndX(char *User, char *Password, int PasswordType, u32 capab SSR->smbH.Cmd = SMB_COM_SESSION_SETUP_ANDX; SSR->smbH.Flags = SMB_FLAGS_CASELESS_PATHNAMES; SSR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (useUnicode) - SSR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + SSR->smbH.Flags2 |= (useUnicode) ? SMB_FLAGS2_UNICODE_STRING : 0; SSR->smbWordcount = 13; SSR->smbAndxCmd = SMB_COM_NONE; // no ANDX command SSR->MaxBufferSize = CLIENT_MAX_BUFFER_SIZE; @@ -573,8 +569,7 @@ int smb_TreeConnectAndX(int UID, char *ShareName, char *Password, int PasswordTy TCR->smbH.Cmd = SMB_COM_TREE_CONNECT_ANDX; TCR->smbH.Flags = SMB_FLAGS_CASELESS_PATHNAMES; TCR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - TCR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + TCR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; TCR->smbH.UID = UID; TCR->smbWordcount = 4; TCR->smbAndxCmd = SMB_COM_NONE; // no ANDX command @@ -776,8 +771,7 @@ int smb_QueryPathInformation(int UID, int TID, PathInformation_t *Info, char *Pa QPIR->smbH.Cmd = SMB_COM_TRANSACTION2; QPIR->smbH.Flags = SMB_FLAGS_CANONICAL_PATHNAMES; QPIR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - QPIR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + QPIR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; QPIR->smbH.UID = (u16)UID; QPIR->smbH.TID = (u16)TID; QPIR->smbWordcount = 15; @@ -864,8 +858,7 @@ int smb_NTCreateAndX(int UID, int TID, char *filename, s64 *filesize, int mode) NTCR->smbH.Cmd = SMB_COM_NT_CREATE_ANDX; NTCR->smbH.Flags = SMB_FLAGS_CANONICAL_PATHNAMES; NTCR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - NTCR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + NTCR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; NTCR->smbH.UID = (u16)UID; NTCR->smbH.TID = (u16)TID; NTCR->smbWordcount = 24; @@ -873,12 +866,8 @@ int smb_NTCreateAndX(int UID, int TID, char *filename, s64 *filesize, int mode) NTCR->AccessMask = ((mode & O_RDWR) == O_RDWR || (mode & O_WRONLY)) ? 0x2019f : 0x20089; NTCR->FileAttributes = ((mode & O_RDWR) == O_RDWR || (mode & O_WRONLY)) ? EXT_ATTR_NORMAL : EXT_ATTR_READONLY; NTCR->ShareAccess = 0x01; // Share in read mode only - if (mode & O_CREAT) - NTCR->CreateDisposition |= 0x02; - if (mode & O_TRUNC) - NTCR->CreateDisposition |= 0x04; - else - NTCR->CreateDisposition |= 0x01; + NTCR->CreateDisposition |= (mode & O_CREAT) ? 0x02 : 0; + NTCR->CreateDisposition |= (mode & O_TRUNC) ? 0x04 : 0x01; if (NTCR->CreateDisposition == 0x06) NTCR->CreateDisposition = 0x05; NTCR->ImpersonationLevel = 2; @@ -943,20 +932,15 @@ int smb_OpenAndX(int UID, int TID, char *filename, s64 *filesize, int mode) OR->smbH.Cmd = SMB_COM_OPEN_ANDX; OR->smbH.Flags = SMB_FLAGS_CANONICAL_PATHNAMES; OR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - OR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + OR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; OR->smbH.UID = (u16)UID; OR->smbH.TID = (u16)TID; OR->smbWordcount = 15; OR->smbAndxCmd = SMB_COM_NONE; // no ANDX command OR->AccessMask = ((mode & O_RDWR) == O_RDWR || (mode & O_WRONLY)) ? 0x02 : 0x00; OR->FileAttributes = ((mode & O_RDWR) == O_RDWR || (mode & O_WRONLY)) ? EXT_ATTR_NORMAL : EXT_ATTR_READONLY; - if (mode & O_CREAT) - OR->CreateOptions |= 0x10; - if (mode & O_TRUNC) - OR->CreateOptions |= 0x02; - else - OR->CreateOptions |= 0x01; + OR->CreateOptions |= (mode & O_CREAT) ? 0x10 : 0; + OR->CreateOptions |= (mode & O_TRUNC) ? 0x02 : 0x01; offset = 0; if (server_specs.Capabilities & SERVER_CAP_UNICODE) { @@ -1196,8 +1180,7 @@ int smb_Delete(int UID, int TID, char *Path) DR->smbH.Cmd = SMB_COM_DELETE; DR->smbH.Flags = SMB_FLAGS_CANONICAL_PATHNAMES; DR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - DR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + DR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; DR->smbH.UID = (u16)UID; DR->smbH.TID = (u16)TID; DR->smbWordcount = 1; @@ -1238,8 +1221,7 @@ int smb_ManageDirectory(int UID, int TID, char *Path, int cmd) MDR->smbH.Cmd = (u8)cmd; MDR->smbH.Flags = SMB_FLAGS_CANONICAL_PATHNAMES; MDR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - MDR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + MDR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; MDR->smbH.UID = (u16)UID; MDR->smbH.TID = (u16)TID; MDR->BufferFormat = 0x04; @@ -1284,8 +1266,7 @@ int smb_Rename(int UID, int TID, char *oldPath, char *newPath) RR->smbH.Cmd = SMB_COM_RENAME; RR->smbH.Flags = SMB_FLAGS_CANONICAL_PATHNAMES; RR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - RR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + RR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; RR->smbH.UID = (u16)UID; RR->smbH.TID = (u16)TID; RR->smbWordcount = 1; @@ -1349,8 +1330,7 @@ int smb_FindFirstNext2(int UID, int TID, char *Path, int cmd, SearchInfo_t *info FFNR->smbH.Cmd = SMB_COM_TRANSACTION2; FFNR->smbH.Flags = SMB_FLAGS_CANONICAL_PATHNAMES; FFNR->smbH.Flags2 = SMB_FLAGS2_KNOWS_LONG_NAMES | SMB_FLAGS2_32BIT_STATUS; - if (server_specs.Capabilities & SERVER_CAP_UNICODE) - FFNR->smbH.Flags2 |= SMB_FLAGS2_UNICODE_STRING; + FFNR->smbH.Flags2 |= (server_specs.Capabilities & SERVER_CAP_UNICODE) ? SMB_FLAGS2_UNICODE_STRING : 0; FFNR->smbH.UID = (u16)UID; FFNR->smbH.TID = (u16)TID; FFNR->smbWordcount = 15; diff --git a/iop/network/smbman/src/smb_fio.c b/iop/network/smbman/src/smb_fio.c index 05c3dba02d91..bf9c0286eaa4 100644 --- a/iop/network/smbman/src/smb_fio.c +++ b/iop/network/smbman/src/smb_fio.c @@ -433,9 +433,7 @@ int smb_read(iop_file_t *f, void *buf, int size) smb_io_lock(); r = smb_ReadFile(UID, TID, fh->smb_fid, fh->position, buf, size); - if (r > 0) { - fh->position += r; - } + fh->position += (r > 0) ? r : 0; smb_io_unlock(); @@ -459,8 +457,7 @@ int smb_write(iop_file_t *f, void *buf, int size) r = smb_WriteFile(UID, TID, fh->smb_fid, fh->position, buf, size); if (r > 0) { fh->position += r; - if (fh->position > fh->filesize) - fh->filesize += fh->position - fh->filesize; + fh->filesize += (fh->position > fh->filesize) ? (fh->position - fh->filesize) : 0; } smb_io_unlock(); diff --git a/iop/network/spduart/src/spduart.c b/iop/network/spduart/src/spduart.c index d730aeb55177..9c535bf74935 100644 --- a/iop/network/spduart/src/spduart.c +++ b/iop/network/spduart/src/spduart.c @@ -165,10 +165,7 @@ static int module_stop(int ac, char *av[], void *startaddr, ModuleInfo_t *mi); int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { - if ( argc >= 0 ) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(argc, argv, startaddr, mi); + return (( argc >= 0 ) ? module_start : module_stop)(argc, argv, startaddr, mi); } static void spduart_dump_msr(u8 msr) @@ -234,10 +231,7 @@ static int spduart_send(struct spduart_internals_ *priv) spduart_internals.dev9_uart_reg_area->r_wrthr_rdrbr = v7; ++v4; } while ( v6 > 0 ); - if ( priv->send_buf_struct.m_cur_xfer_len > 0 ) - { - priv->spduart_fcr_cached |= 2; - } + priv->spduart_fcr_cached |= ( priv->send_buf_struct.m_cur_xfer_len > 0 ) ? 2 : 0; } else { @@ -277,10 +271,7 @@ static int spduart_dev9_intr_cb(int flag) } if ( (spduart_internals.dev9_uart_reg_area->r_scr & 1) != 0 ) { - if ( (spduart_internals.dev9_uart_reg_area->r_scr & 0x10) != 0 ) - { - v2 |= 4u; - } + v2 |= ( (spduart_internals.dev9_uart_reg_area->r_scr & 0x10) != 0 ) ? 4u : 0; } if ( r_scr & 2 ) { @@ -305,9 +296,7 @@ static int spduart_dev9_intr_cb(int flag) } if ( (r_scr & 8) && ((spduart_internals.spduart_msr_cached ^ (u8)r_scr) & 0x80) != 0 ) { - v18 = 32; - if ( (r_scr & 0x80) != 0 ) - v18 = 16; + v18 = ( (r_scr & 0x80) != 0 ) ? 16 : 32; iSetEventFlag(spduart_internals.spduart_modem_ops.evfid, v18); } spduart_internals.spduart_msr_cached = r_scr; @@ -660,8 +649,7 @@ static void spduart_init_hw(struct spduart_internals_ *priv) { buf1data += 1; } - if ( *buf1data == '\n' ) - buf1data += 1; + buf1data += ( *buf1data == '\n' ) ? 1 : 0; } sprintf(priv->buf2data, "AT+GCI=%c%c\r", (u8)*buf1data, (u8)buf1data[1]); sceInetPrintf("spduart: sending \"%S\"\n", priv->buf2data); @@ -832,14 +820,10 @@ static int spduart_op_recv(void *userdata, void *ptr, int len) struct spduart_internals_ *priv; priv = (struct spduart_internals_ *)userdata; - m_cur_xfer_len = len; v7 = 0; - if ( priv->recv_buf_struct.m_cur_xfer_len < len ) - m_cur_xfer_len = priv->recv_buf_struct.m_cur_xfer_len; + m_cur_xfer_len = ( priv->recv_buf_struct.m_cur_xfer_len < len ) ? priv->recv_buf_struct.m_cur_xfer_len : len; v8 = priv->recv_buf_struct.m_offset2 & 0x3FF; - v9 = 1024 - v8; - if ( m_cur_xfer_len < 1024 - v8 ) - v9 = m_cur_xfer_len; + v9 = ( m_cur_xfer_len < 1024 - v8 ) ? m_cur_xfer_len : (1024 - v8); if ( v9 > 0 ) { size_t v10; @@ -879,14 +863,10 @@ static int spduart_op_send(void *userdata, void *ptr, int len) struct spduart_internals_ *priv; priv = (struct spduart_internals_ *)userdata; - v4 = len; v7 = 0; - if ( 1024 - priv->send_buf_struct.m_cur_xfer_len < len ) - v4 = 1024 - priv->send_buf_struct.m_cur_xfer_len; + v4 = ( 1024 - priv->send_buf_struct.m_cur_xfer_len < len ) ? (1024 - priv->send_buf_struct.m_cur_xfer_len) : len; v8 = priv->send_buf_struct.m_offset1 & 0x3FF; - v9 = 1024 - v8; - if ( (unsigned int)v4 < v9 ) - v9 = v4; + v9 = ( (unsigned int)v4 < (1024 - v8) ) ? v4 : (1024 - v8); if ( v9 > 0 ) { size_t v10; @@ -1011,10 +991,7 @@ static int spduart_op_control(void *userdata, int code, void *ptr, int len) { v25 = ((priv->spduart_mcr_cached & 3) << 28) | ((priv->spduart_mcr_cached & 0x18) << 27) | priv->spduart_baud_ | 0x2000000; - if ( (priv->spduart_mcr_cached & 4) != 0 ) - v25 |= 0xC000000; - else - v25 |= 0x4000000; + v25 |= ( (priv->spduart_mcr_cached & 4) != 0 ) ? 0xC000000 : 0x4000000; bcopy((int *)&v25, ptr, 4); return 0; } @@ -1029,13 +1006,9 @@ static int spduart_op_control(void *userdata, int code, void *ptr, int len) int v6; bcopy(ptr, &priority, 4); - v6 = 0; - if ( priv->spduart_thread > 0 ) - { - v6 = ChangeThreadPriority(priv->spduart_thread, priority); - if ( !v6 ) - priv->spduart_thpri_ = priority; - } + v6 = ( priv->spduart_thread > 0 ) ? ChangeThreadPriority(priv->spduart_thread, priority) : 0; + if ( !v6 ) + priv->spduart_thpri_ = priority; if ( priv->spduart_thread <= 0 || v6 == -413 ) { if ( (unsigned int)(priority - 9) < 0x73 ) diff --git a/iop/network/udptty/src/udptty.c b/iop/network/udptty/src/udptty.c index 02beb76c0ab2..79af6f7969e0 100644 --- a/iop/network/udptty/src/udptty.c +++ b/iop/network/udptty/src/udptty.c @@ -130,10 +130,7 @@ static int Kprintf_Handler(void *context, const char *format, va_list ap) res = CpuInvokeInKmode(Kprnt, kpa, format, ap); - if (QueryIntrContext()) - iSetEventFlag(kpa->eflag, 1); - else - SetEventFlag(kpa->eflag, 1); + (QueryIntrContext() ? iSetEventFlag : SetEventFlag)(kpa->eflag, 1); return res; } diff --git a/iop/security/secrman/src/keyman.c b/iop/security/secrman/src/keyman.c index a059f74d9c1d..026ea68dc8b8 100644 --- a/iop/security/secrman/src/keyman.c +++ b/iop/security/secrman/src/keyman.c @@ -24,12 +24,9 @@ void store_kbit(void *buffer, const void *kbit) int offset = 0x20; u8 *kbit_offset; - if (header->BIT_count > 0) - offset += header->BIT_count * 0x10; // They used a loop for this. D: - if (((header->flags) & 1) != 0) - offset += ((unsigned char *)buffer)[offset] + 1; - if (((header->flags) & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * 0x10) : 0; // They used a loop for this. D: + offset += (((header->flags) & 1) != 0) ? (((unsigned char *)buffer)[offset] + 1) : 0; + offset += (((header->flags) & 0xF000) == 0) ? (8) : 0; kbit_offset = (u8 *)buffer + offset; memcpy((void *)kbit_offset, kbit, 16); @@ -43,12 +40,9 @@ void store_kc(void *buffer, const void *kc) int offset = 0x20; u8 *kc_offset; - if (header->BIT_count > 0) - offset += header->BIT_count * 0x10; // They used a loop for this. D: - if (((header->flags) & 1) != 0) - offset += ((unsigned char *)buffer)[offset] + 1; - if (((header->flags) & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * 0x10) : 0; // They used a loop for this. D: + offset += (((header->flags) & 1) != 0) ? (((unsigned char *)buffer)[offset] + 1) : 0; + offset += (((header->flags) & 0xF000) == 0) ? (8) : 0; kc_offset = (u8 *)buffer + offset + 0x10; memcpy((void *)kc_offset, kc, 16); @@ -62,12 +56,9 @@ void get_Kbit(const void *buffer, void *Kbit) int offset = sizeof(SecrKELFHeader_t); u8 *kbit_offset; - if (header->BIT_count > 0) - offset += header->BIT_count * sizeof(SecrBitBlockData_t); // They used a loop for this. D: - if (((header->flags) & 1) != 0) - offset += ((unsigned char *)buffer)[offset] + 1; - if (((header->flags) & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * sizeof(SecrBitBlockData_t)) : 0; // They used a loop for this. D: + offset += (((header->flags) & 1) != 0) ? (((unsigned char *)buffer)[offset] + 1) : 0; + offset += (((header->flags) & 0xF000) == 0) ? (8) : 0; kbit_offset = (u8 *)buffer + offset; memcpy(Kbit, (void *)kbit_offset, 16); @@ -81,12 +72,9 @@ void get_Kc(const void *buffer, void *Kc) int offset = sizeof(SecrKELFHeader_t); u8 *kc_offset; - if (header->BIT_count > 0) - offset += header->BIT_count * sizeof(SecrBitBlockData_t); // They used a loop for this. D: - if (((header->flags) & 1) != 0) - offset += ((unsigned char *)buffer)[offset] + 1; - if (((header->flags) & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * sizeof(SecrBitBlockData_t)) : 0; // They used a loop for this. D: + offset += (((header->flags) & 1) != 0) ? (((unsigned char *)buffer)[offset] + 1) : 0; + offset += (((header->flags) & 0xF000) == 0) ? (8) : 0; kc_offset = (u8 *)buffer + offset + 0x10; // Goes after Kbit memcpy(Kc, (void *)kc_offset, 16); diff --git a/iop/security/secrman/src/secrman.c b/iop/security/secrman/src/secrman.c index d895a8c877b4..82ea1231b45d 100644 --- a/iop/security/secrman/src/secrman.c +++ b/iop/security/secrman/src/secrman.c @@ -192,18 +192,15 @@ static int func_00000bfc(void *dest, unsigned int size) } */ while (size > 0) { - if (size >= 16) { // if(size>>4!=0) - if (func_00001b00(dest, 0x10) == 0) { - return 0; - } - size -= 0x10; - dest = (void *)((u8 *)dest + 0x10); - } else { - if (func_00001b00(dest, size) == 0) { - return 0; - } - size = 0; + int cur_sz; + + // (size>>4!=0) + cur_sz = (size >= 0x10) ? 0x10 : size; + if (func_00001b00(dest, cur_sz) == 0) { + return 0; } + size -= cur_sz; + dest = (void *)((u8 *)dest + cur_sz); } return 1; @@ -827,15 +824,13 @@ static int secr_set_header(int mode, int cnum, int arg2, void *buffer) while (HeaderLength > 0) { int write_data_result; + int cur_sz; - if (HeaderLength >= 0x10) { // if(HeaderLength>>4!=0) - write_data_result = write_data(buffer, 0x10); - buffer = (void *)((u8 *)buffer + 0x10); - HeaderLength -= 0x10; - } else { - write_data_result = write_data(buffer, HeaderLength); - HeaderLength = 0; - } + // (HeaderLength>>4!=0) + cur_sz = (HeaderLength >= 0x10) ? 0x10 : HeaderLength; + write_data_result = write_data(buffer, cur_sz); + buffer = (void *)((u8 *)buffer + cur_sz); + HeaderLength -= cur_sz; if (write_data_result == 0) { _printf("secr_set_header: fail write_data\n"); @@ -864,18 +859,14 @@ static int Read_BIT(SecrBitTable_t *BitTable) DataToCopy = BitLength; while (DataToCopy != 0) { - if (DataToCopy >= 0x10) { - if (func_00001b00(BitTable, 0x10) == 0) { - return 0; - } - BitTable = (SecrBitTable_t *)((u8 *)BitTable + 0x10); - DataToCopy -= 0x10; - } else { - if (func_00001b00(BitTable, DataToCopy) == 0) { - return 0; - } - DataToCopy = 0; + int cur_sz; + + cur_sz = (DataToCopy >= 0x10) ? 0x10 : DataToCopy; + if (func_00001b00(BitTable, cur_sz) == 0) { + return 0; } + BitTable = (SecrBitTable_t *)((u8 *)BitTable + cur_sz); + DataToCopy -= cur_sz; } return BitLength; @@ -917,12 +908,9 @@ static unsigned int get_BitTableOffset(const void *buffer) const SecrKELFHeader_t *header = buffer; int offset = sizeof(SecrKELFHeader_t); - if (header->BIT_count > 0) - offset += header->BIT_count * sizeof(SecrBitBlockData_t); // They used a loop for this. D: - if ((header->flags & 1) != 0) - offset += ((const unsigned char *)buffer)[offset] + 1; - if ((header->flags & 0xF000) == 0) - offset += 8; + offset += (header->BIT_count > 0) ? (header->BIT_count * sizeof(SecrBitBlockData_t)) : 0; // They used a loop for this. D: + offset += ((header->flags & 1) != 0) ? (((const unsigned char *)buffer)[offset] + 1) : 0; + offset += ((header->flags & 0xF000) == 0) ? 8 : 0; return (offset + 0x20); // Goes after Kbit and Kc. } diff --git a/iop/sio/mtapman/src/freemtap.c b/iop/sio/mtapman/src/freemtap.c index f559bc9bea4f..e5bce18dbed2 100644 --- a/iop/sio/mtapman/src/freemtap.c +++ b/iop/sio/mtapman/src/freemtap.c @@ -80,10 +80,7 @@ void get_slot_number_setup_td(u32 port, u32 reg) td.in[td.in_size] = 0x21; - if(port < 2) - td.in[td.in_size + 1] = 0x12; - else - td.in[td.in_size + 1] = 0x13; + td.in[td.in_size + 1] = (port < 2) ? 0x12 : 0x13; td.in_size += 6; td.out_size += 6; @@ -96,17 +93,7 @@ s32 get_slot_number_check_td(u32 bit) s32 res; u32 i; - if(read_stat6c_bit(bit, &td) != 1) - { - if(td.out[5] == 0x66) - res = -2; - else - res = td.out[3]; - } - else - { - res = -1; - } + res = (read_stat6c_bit(bit, &td) != 1) ? ((td.out[5] == 0x66) ? -2 : td.out[3]) : -1; for(i=0; i < 250; i++) td.out[i] = td.out[i+6]; @@ -171,21 +158,9 @@ void update_slot_numbers_thread(void *arg) { if(state_open[port] == 1) { - if(state_getcon[port] == 0) - slots = get_slot_number(port, 10); - else - slots = get_slot_number(port, 0); - - if(slots < 0) - { - state_slots[port] = 1; - state_getcon[port] = 0; - } - else - { - state_slots[port] = slots; - state_getcon[port] = 1; - } + slots = get_slot_number(port, (state_getcon[port] == 0) ? 10 : 0); + state_slots[port] = (slots < 0) ? 1 : slots; + state_getcon[port] = (slots < 0) ? 0 : 1; } } @@ -207,14 +182,7 @@ s32 change_slot_setup_td(u32 port, s32 slot, u32 reg) td.in[td.in_size] = 0x21; - if(port < 2) - { - td.in[td.in_size + 1] = 0x21; - } - else - { - td.in[td.in_size + 1] = 0x22; - } + td.in[td.in_size + 1] = (port < 2) ? 0x21 : 0x22; td.in[td.in_size + 2] = (u8)slot; @@ -234,18 +202,7 @@ s32 change_slot_check_td(u32 a) if(td.out_size >= 7) { - if(read_stat6c_bit(a, &td) != 1) - { - if(td.out[5] == 0x66) - res = -2; - else - res = td.out[5]; - - } - else - { - res = -1; - } + res = (read_stat6c_bit(a, &td) != 1) ? ((td.out[5] == 0x66) ? -2 : td.out[5]) : -1; } else { @@ -305,10 +262,7 @@ int change_slot(s32 *arg) } else { - if(arg[port] == 0) - arg[port+4] = 1; - else - arg[port+4] = -1; + arg[port+4] = (arg[port] == 0) ? 1 : -1; } } else @@ -338,10 +292,7 @@ int change_slot(s32 *arg) { if(res >= 0) { - if(res == arg[port]) - arg[port+4] = 1; - else - arg[port+4] = -1; + arg[port+4] = (res == arg[port]) ? 1 : -1; count--; } @@ -475,18 +426,9 @@ s32 mtapPortOpen(u32 port) s32 res = get_slot_number(port, 10); - if(res < 0) - { - state_getcon[port] = 0; - state_slots[port] = 1; - return res; - } - else - { - state_getcon[port] = 1; - state_slots[port] = res; - return 1; - } + state_getcon[port] = (res < 0) ? 0 : 1; + state_slots[port] = (res < 0) ? 1 : res; + return (res < 0) ? res : 1; } return 0; @@ -515,10 +457,7 @@ s32 mtapGetSlotNumber(u32 port) res = get_slot_number(port, 10); - if(res >= 0) - return res; - else - return 1; + return (res >= 0) ? res : 1; } s32 mtapChangeSlot(u32 port, u32 slot) diff --git a/iop/sio/mx4sio_bd/src/ioplib.c b/iop/sio/mx4sio_bd/src/ioplib.c index 0b8885786ee6..44a05578880f 100644 --- a/iop/sio/mx4sio_bd/src/ioplib.c +++ b/iop/sio/mx4sio_bd/src/ioplib.c @@ -51,10 +51,7 @@ unsigned int ioplib_getTableSize(iop_library_t *lib) void **exp; unsigned int size; - exp = NULL; - if (lib != NULL) { - exp = lib->exports; - } + exp = (lib != NULL) ? lib->exports : NULL; size = 0; if (exp != NULL) diff --git a/iop/sio/mx4sio_bd/src/mx4sio.c b/iop/sio/mx4sio_bd/src/mx4sio.c index e96ac3bfcb6c..d336e8855376 100644 --- a/iop/sio/mx4sio_bd/src/mx4sio.c +++ b/iop/sio/mx4sio_bd/src/mx4sio.c @@ -51,11 +51,7 @@ int mx_sio2_dma_isr_rx(void *arg) /* NOTE: Some cards respond with 0xFE immediately after the CRC16, others do not. * Try to get 0xFE regardless of whether the transfers complete as it's * needed for correct alignment of CMD12 (STOP_TRANSMISSION) later */ - if (inl_sio2_data_in() != 0xFE) { - cmd.response = mx_sio2_wait_equal(0xFE, READ_TOKEN_TIMEOUT); - } else { - cmd.response = SPISD_RESULT_OK; - } + cmd.response = (inl_sio2_data_in() != 0xFE) ? mx_sio2_wait_equal(0xFE, READ_TOKEN_TIMEOUT) : SPISD_RESULT_OK; cmd.sectors_transferred++; @@ -834,8 +830,5 @@ int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi) { M_PRINTF("MX4SIO v1.2\n"); - if (argc >= 0) - return module_start(argc, argv, startaddr, mi); - else - return module_stop(-argc, argv, startaddr, mi); + return (argc >= 0) ? module_start(argc, argv, startaddr, mi) : module_stop(-argc, argv, startaddr, mi); } diff --git a/iop/sio/sio2man/src/log.c b/iop/sio/sio2man/src/log.c index 7e0bcf8de778..6262c52fdf18 100644 --- a/iop/sio/sio2man/src/log.c +++ b/iop/sio/sio2man/src/log.c @@ -108,8 +108,7 @@ void log_dma(int type, struct _sio2_dma_arg *arg) log_write32(arg->count); effective = arg->size * 4 * arg->count; - if (effective > DMA_MAX) - effective = DMA_MAX; + effective = (effective > DMA_MAX) ? DMA_MAX : effective; for (i = 0, p = (u8 *)arg->addr; i < effective; i++) log_write8(p[i]); diff --git a/iop/sound/ahx/src/AHX.c b/iop/sound/ahx/src/AHX.c index ff49320c9119..d2896692fecc 100644 --- a/iop/sound/ahx/src/AHX.c +++ b/iop/sound/ahx/src/AHX.c @@ -110,10 +110,7 @@ void GenerateTriangle(char *Buffer, int Len) esi = edi + d4; for (ecx = 0; ecx < d5 * 2; ecx++) { *edi++ = *esi++; - if (edi[-1] == 0x7f) - edi[-1] = 0x80; - else - edi[-1] = -edi[-1]; + edi[-1] = (edi[-1] == 0x7f) ? 0x80 : -edi[-1]; } } @@ -145,12 +142,7 @@ void GenerateWhiteNoise(char *Buffer, int Len) unsigned int Seed = 0x41595321; while (Len--) { - if (Seed & 0x100) - *Buffer = (char)(Seed & 0xff); - else if (!(Seed & 0xffff)) - *Buffer = 0x80; - else - *Buffer = 0x7f; + *Buffer = (Seed & 0x100) ? ((char)(Seed & 0xff)) : ((!(Seed & 0xffff)) ? 0x80 : 0x7f); Buffer++; unsigned int tmp = Seed; // ror 5 @@ -493,10 +485,7 @@ int AHXPlayer_InitSubsong(int Nr) if (Nr > Song.SubsongNr) return 0; - if (Nr == 0) - PosNr = 0; - else - PosNr = Song.Subsongs[Nr - 1]; + PosNr = (Nr == 0) ? 0 : Song.Subsongs[Nr - 1]; PosJump = 0; PatternBreak = 0; @@ -564,8 +553,7 @@ void AHXPlayer_ProcessStep(int v) case 0xd: // Patternbreak PosJump = PosNr + 1; PosJumpNote = (FXParam & 0x0f) + (FXParam >> 4) * 10; - if (PosJumpNote > Song.TrackLength) - PosJumpNote = 0; + PosJumpNote = (PosJumpNote > Song.TrackLength) ? 0 : PosJumpNote; PatternBreak = 1; break; case 0xe: // Enhanced commands @@ -634,10 +622,8 @@ void AHXPlayer_ProcessStep(int v) d6 = Voices[v].Instrument->FilterSpeed; d3 = Voices[v].Instrument->FilterLowerLimit; d4 = Voices[v].Instrument->FilterUpperLimit; - if (d3 & 0x80) - d6 |= 0x20; - if (d4 & 0x80) - d6 |= 0x40; + d6 |= (d3 & 0x80) ? 0x20 : 0; + d6 |= (d4 & 0x80) ? 0x40 : 0; Voices[v].FilterSpeed = d6; d3 &= ~0x80; d4 &= ~0x80; @@ -747,11 +733,8 @@ void AHXPlayer_PListCommandParse(int v, int FX, int FXParam) switch (FX) { case 0: if (Song.Revision > 0 && FXParam != 0) { - if (Voices[v].IgnoreFilter) { - Voices[v].FilterPos = Voices[v].IgnoreFilter; - Voices[v].IgnoreFilter = 0; - } else - Voices[v].FilterPos = FXParam; + Voices[v].FilterPos = Voices[v].IgnoreFilter ? Voices[v].IgnoreFilter : FXParam; + Voices[v].IgnoreFilter = 0; Voices[v].NewWaveform = 1; } break; @@ -825,10 +808,7 @@ void AHXPlayer_ProcessFrame(int v) } if (Voices[v].HardCut) { int NextInstrument; - if (NoteNr + 1 < Song.TrackLength) - NextInstrument = Tracks[Voices[v].Track][NoteNr + 1].Instrument; - else - NextInstrument = Tracks[Voices[v].NextTrack][0].Instrument; + NextInstrument = (NoteNr + 1 < Song.TrackLength) ? Tracks[Voices[v].Track][NoteNr + 1].Instrument : Tracks[Voices[v].NextTrack][0].Instrument; if (NextInstrument) { int d1 = Tempo - Voices[v].HardCut; if (d1 < 0) @@ -884,10 +864,7 @@ void AHXPlayer_ProcessFrame(int v) d2 = -d2; if (d0) { int d3 = (d0 + d2) ^ d0; - if (d3 >= 0) - d0 = Voices[v].PeriodSlidePeriod + d2; - else - d0 = Voices[v].PeriodSlideLimit; + d0 = (d3 >= 0) ? (Voices[v].PeriodSlidePeriod + d2) : Voices[v].PeriodSlideLimit; Voices[v].PeriodSlidePeriod = d0; Voices[v].PlantPeriod = 1; } @@ -1010,8 +987,7 @@ void AHXPlayer_ProcessFrame(int v) Voices[v].SquareReverse = 1; } // OkDownSquare - if (--X) - SquarePtr += X << 7; + SquarePtr += (--X) ? (X << 7) : 0; int Delta = 32 >> Voices[v].WaveLength; WaveformTab[2] = Voices[v].SquareTempBuffer; for (i = 0; i < (1 << Voices[v].WaveLength) * 4; i++) { @@ -1027,12 +1003,8 @@ void AHXPlayer_ProcessFrame(int v) if (Voices[v].NewWaveform) { AudioSource = WaveformTab[Voices[v].Waveform]; - if (Voices[v].Waveform != 3 - 1) { - AudioSource += (Voices[v].FilterPos - 0x20) * (0xfc + 0xfc + 0x80 * 0x1f + 0x80 + 0x280 * 3); - } - if (Voices[v].Waveform < 3 - 1) { - AudioSource += Offsets[Voices[v].WaveLength]; - } + AudioSource += (Voices[v].Waveform != 3 - 1) ? ((Voices[v].FilterPos - 0x20) * (0xfc + 0xfc + 0x80 * 0x1f + 0x80 + 0x280 * 3)) : 0; + AudioSource += (Voices[v].Waveform < 3 - 1) ? Offsets[Voices[v].WaveLength] : 0; if (Voices[v].Waveform == 4 - 1) { // AddRandomMoving AudioSource += (WNRandom & (2 * 0x280 - 1)) & ~1; @@ -1045,15 +1017,13 @@ void AHXPlayer_ProcessFrame(int v) // StillHoldWaveform // AudioInitPeriod Voices[v].AudioPeriod = Voices[v].InstrPeriod; - if (!Voices[v].FixedNote) - Voices[v].AudioPeriod += Voices[v].Transpose + Voices[v].TrackPeriod - 1; + Voices[v].AudioPeriod += (!Voices[v].FixedNote) ? (Voices[v].Transpose + Voices[v].TrackPeriod - 1) : 0; if (Voices[v].AudioPeriod > 5 * 12) Voices[v].AudioPeriod = 5 * 12; if (Voices[v].AudioPeriod < 0) Voices[v].AudioPeriod = 0; Voices[v].AudioPeriod = PeriodTable[Voices[v].AudioPeriod]; - if (!Voices[v].FixedNote) - Voices[v].AudioPeriod += Voices[v].PeriodSlidePeriod; + Voices[v].AudioPeriod += (!Voices[v].FixedNote) ? Voices[v].PeriodSlidePeriod : 0; Voices[v].AudioPeriod += Voices[v].PeriodPerfSlidePeriod + Voices[v].VibratoPeriod; if (Voices[v].AudioPeriod > 0x0d60) Voices[v].AudioPeriod = 0x0d60; @@ -1174,8 +1144,7 @@ void AHXOutput_MixChunk(int NrSamples, int **mb) samples_to_mix = NrSamples; mixpos = 0; while (samples_to_mix) { - if (pos[v] > (0x280 << 16)) - pos[v] -= 0x280 << 16; + pos[v] -= (pos[v] > (0x280 << 16)) ? (0x280 << 16) : 0; thiscount = min(samples_to_mix, ((0x280 << 16) - pos[v] - 1) / delta + 1); samples_to_mix -= thiscount; VolTab = &VolumeTable[Voices[v].VoiceVolume][128]; diff --git a/iop/sound/ahx/src/ahx_irx.c b/iop/sound/ahx/src/ahx_irx.c index 0cf878e03a06..3d53088eefe9 100644 --- a/iop/sound/ahx/src/ahx_irx.c +++ b/iop/sound/ahx/src/ahx_irx.c @@ -196,10 +196,7 @@ void AHX_PlayThread(void *param) AHXOutput_MixBuffer((short *)(pcmbuf + (0xF00 * i))); // remix } seg_done[i] = 1; // mark segment as mixed and ready - if (i > 0) - seg_done[i - 1] = 0; - else - seg_done[7] = 0; // catch end segment + seg_done[(i > 0) ? (i - 1) : 7 /* catch end segment */] = 0; } } } diff --git a/iop/sound/ahx/src/spu2.c b/iop/sound/ahx/src/spu2.c index e6def9224479..b31553103402 100644 --- a/iop/sound/ahx/src/spu2.c +++ b/iop/sound/ahx/src/spu2.c @@ -324,13 +324,8 @@ void InitCoreVolume(s32 flag) { *SD_C_SPDIF_OUT = 0xC032; - if (flag) { - *SD_CORE_ATTR(0) = SD_SPU2_ON | SD_ENABLE_EFFECTS | SD_MUTE; - *SD_CORE_ATTR(1) = SD_SPU2_ON | SD_ENABLE_EFFECTS | SD_MUTE | SD_ENABLE_EX_INPUT; - } else { - *SD_CORE_ATTR(0) = SD_SPU2_ON | SD_MUTE; - *SD_CORE_ATTR(1) = SD_SPU2_ON | SD_MUTE | SD_ENABLE_EX_INPUT; - } + *SD_CORE_ATTR(0) = SD_SPU2_ON | (flag ? SD_ENABLE_EFFECTS : 0) | SD_MUTE; + *SD_CORE_ATTR(1) = SD_SPU2_ON | (flag ? SD_ENABLE_EFFECTS : 0) | SD_MUTE | SD_ENABLE_EX_INPUT; // HIgh is voices 0-15, LOw is 16-23, representing voices 0..23 (24) #ifndef ISJPCM @@ -524,10 +519,7 @@ void sceSdSetParam(u16 reg, u16 val) core = reg & 1; // Determine the channel offset - if (reg & 0x80) - offs = (40 * core) >> 1; - else - offs = (1024 * core) >> 1; + offs = (reg & 0x80) ? ((40 * core) >> 1) : ((1024 * core) >> 1); reg_index = (reg >> 8) & 0xFF; voice = (reg & 0x3E) << 2; @@ -579,10 +571,7 @@ u32 DmaStop(u32 core) core &= 1; - if (*U16_REGISTER(0x1B0 + (core * 1024)) == 0) - retval = 0; - else - retval = *SD_DMA_ADDR(core); + retval = (*U16_REGISTER(0x1B0 + (core * 1024)) == 0) ? 0 : (*SD_DMA_ADDR(core)); *SD_DMA_CHCR(core) &= ~SD_DMA_START; *U16_REGISTER(0x1B0 + (core * 1024)) = 0; @@ -629,8 +618,7 @@ s32 BlockTransWriteFrom(u8 *iopaddr, u32 size, s32 chan, u16 mode, u8 *startaddr } } - if (offset & 1023) - offset += 1024; + offset += (offset & 1023) ? 1024 : 0; iopaddr += (BlockTransSize[core] * BlockTransBuff[core]) + offset; @@ -816,10 +804,7 @@ u32 sceSdBlockTransStatus(s16 chan, s16 flag) chan &= 1; - if (*U16_REGISTER(0x1B0 + (chan * 1024)) == 0) - retval = 0; - else - retval = *SD_DMA_ADDR(chan); + retval = (*U16_REGISTER(0x1B0 + (chan * 1024)) == 0) ? 0 : (*SD_DMA_ADDR(chan)); retval = (BlockTransBuff[chan] << 24) | (retval & 0xFFFFFF); diff --git a/iop/sound/audsrv/src/adpcm.c b/iop/sound/audsrv/src/adpcm.c index d42cd81bfae5..b054d92ac46e 100644 --- a/iop/sound/audsrv/src/adpcm.c +++ b/iop/sound/audsrv/src/adpcm.c @@ -164,11 +164,8 @@ void *audsrv_load_adpcm(u32 *buffer, int size, int id) adpcm = adpcm_loaded(id); if (adpcm == NULL) { - int spu2_addr = 0x5010; /* Need to change this so it considers to PCM streaming space usage :) */ - if (adpcm_list_tail != NULL) - { - spu2_addr = adpcm_list_tail->spu2_addr + adpcm_list_tail->size; - } + int spu2_addr; + spu2_addr = (adpcm_list_tail != NULL) ? (adpcm_list_tail->spu2_addr + adpcm_list_tail->size) : 0x5010 /* Need to change this so it considers to PCM streaming space usage :) */; if (spu2_addr + size - 16 > 2097152) { sbuffer[0] = -AUDSRV_ERR_OUT_OF_MEMORY; diff --git a/iop/sound/audsrv/src/audsrv.c b/iop/sound/audsrv/src/audsrv.c index 394b3e6d3a43..260ac0b73be3 100644 --- a/iop/sound/audsrv/src/audsrv.c +++ b/iop/sound/audsrv/src/audsrv.c @@ -277,14 +277,7 @@ int audsrv_init() */ int audsrv_available() { - if (writepos <= readpos) - { - return readpos - writepos; - } - else - { - return (ringbuf_size - (writepos - readpos)); - } + return (writepos <= readpos) ? (readpos - writepos) : (ringbuf_size - (writepos - readpos)); } /** Returns the number of bytes already in queue @@ -294,14 +287,7 @@ int audsrv_available() */ int audsrv_queued() { - if (writepos < readpos) - { - return (ringbuf_size - (readpos - writepos)); - } - else - { - return writepos - readpos; - } + return (writepos < readpos) ? (ringbuf_size - (readpos - writepos)) : (writepos - readpos); } /** Blocks until there is enough space to enqueue chunk diff --git a/iop/sound/clearspu/src/clearspu.c b/iop/sound/clearspu/src/clearspu.c index c76dcaa5cb4a..cfde469c08c5 100644 --- a/iop/sound/clearspu/src/clearspu.c +++ b/iop/sound/clearspu/src/clearspu.c @@ -237,9 +237,7 @@ static void do_dma_stop(int which_core) static int do_dma_get_status(int which_core) { // Unofficial: Apply fixed variables - if ( *(vu16 *)((which_core << 10) + 0xBF9001B0) ) - return (*(vu32 *)(1088 * which_core + 0xBF8010C0)) & 0xFFFFFF; - return 0; + return ( *(vu16 *)((which_core << 10) + 0xBF9001B0) ) ? ((*(vu32 *)(1088 * which_core + 0xBF8010C0)) & 0xFFFFFF) : 0; } static void do_dma_start(void *addr, int size, int which_core) diff --git a/iop/sound/libsd/src/block.c b/iop/sound/libsd/src/block.c index fc32f96d85a2..62fb0d7302a1 100644 --- a/iop/sound/libsd/src/block.c +++ b/iop/sound/libsd/src/block.c @@ -222,10 +222,7 @@ u32 sceSdBlockTransStatus(s16 chan, s16 flag) chan &= 1; - if(U16_REGISTER_READ(U16_REGISTER(0x1B0 + (chan * 1024))) == 0) - retval = 0; - else - retval = U32_REGISTER_READ(SD_DMA_ADDR(chan)); + retval = (U16_REGISTER_READ(U16_REGISTER(0x1B0 + (chan * 1024))) == 0) ? 0 : U32_REGISTER_READ(SD_DMA_ADDR(chan)); retval = (BlockTransBuff[chan] << 24) | (retval & 0xFFFFFF); diff --git a/iop/sound/libsd/src/effect.c b/iop/sound/libsd/src/effect.c index e21cccf0f625..114f2b6c1e95 100644 --- a/iop/sound/libsd/src/effect.c +++ b/iop/sound/libsd/src/effect.c @@ -252,10 +252,7 @@ int sceSdClearEffectWorkArea(int core, int chan, int effect_type) { u32 size; - if(effect_size < 1024) - size = effect_size; - else - size = 1024; + size = (effect_size < 1024) ? effect_size : 1024; sceSdVoiceTrans(chan, 0, (u8*)ClearEffectData, (u32*)effect_addr, size); sceSdVoiceTransStatus(chan, 1); // Wait for completion diff --git a/iop/sound/libsd/src/freesd.c b/iop/sound/libsd/src/freesd.c index d8c3c2b8a5ff..189875818302 100644 --- a/iop/sound/libsd/src/freesd.c +++ b/iop/sound/libsd/src/freesd.c @@ -423,16 +423,8 @@ void InitCoreVolume(s32 flag) { U16_REGISTER_WRITE(SD_C_SPDIF_OUT, 0xC032); - if(flag) - { - U16_REGISTER_WRITE(SD_CORE_ATTR(0), SD_SPU2_ON | SD_ENABLE_EFFECTS | SD_MUTE); - U16_REGISTER_WRITE(SD_CORE_ATTR(1), SD_SPU2_ON | SD_ENABLE_EFFECTS | SD_MUTE | SD_ENABLE_EX_INPUT); - } - else - { - U16_REGISTER_WRITE(SD_CORE_ATTR(0), SD_SPU2_ON | SD_MUTE); - U16_REGISTER_WRITE(SD_CORE_ATTR(1), SD_SPU2_ON | SD_MUTE | SD_ENABLE_EX_INPUT); - } + U16_REGISTER_WRITE(SD_CORE_ATTR(0), SD_SPU2_ON | (flag ? SD_ENABLE_EFFECTS : 0) | SD_MUTE); + U16_REGISTER_WRITE(SD_CORE_ATTR(1), SD_SPU2_ON | (flag ? SD_ENABLE_EFFECTS : 0) | SD_MUTE | SD_ENABLE_EX_INPUT); // HIgh is voices 0-15, LOw is 16-23, representing voices 0..23 (24) U16_REGISTER_WRITE(SD_S_VMIXL_HI(0), 0xFFFF); @@ -524,10 +516,7 @@ void sceSdSetParam(u16 reg, u16 val) core = reg & 1; // Determine the channel offset - if(reg & 0x80) - offs = (40 * core) >> 1; - else - offs = (1024 * core) >> 1; + offs = (reg & 0x80) ? ((40 * core) >> 1) : ((1024 * core) >> 1); reg_index = (reg >> 8) & 0xFF; voice = (reg & 0x3E) << 2; @@ -547,10 +536,7 @@ u16 sceSdGetParam(u16 reg) core = reg & 1; // Determine the channel offset - if(reg & 0x80) - offs = (40 * core) >> 1; - else - offs = (1024 * core) >> 1; + offs = (reg & 0x80) ? ((40 * core) >> 1) : ((1024 * core) >> 1); reg_index = (reg >> 8) & 0xFF; voice = (reg & 0x3E) << 2; @@ -593,10 +579,7 @@ u32 DmaStop(u32 core) core &= 1; - if(U16_REGISTER_READ(U16_REGISTER(0x1B0 + (core * 1024))) == 0) - retval = 0; - else - retval = U32_REGISTER_READ(SD_DMA_ADDR(core)); + retval = (U16_REGISTER_READ(U16_REGISTER(0x1B0 + (core * 1024))) == 0) ? 0 : U32_REGISTER_READ(SD_DMA_ADDR(core)); U32_REGISTER_WRITEAND(SD_DMA_CHCR(core), ~SD_DMA_START); U16_REGISTER_WRITE(U16_REGISTER(0x1B0 + (core * 1024)), 0); @@ -642,7 +625,7 @@ u16 sceSdNote2Pitch (u16 center_note, u16 center_fine, u16 note, short fine) offset2 = _fine - _fine2 * 128; - if(_note < 0) val2 = -1; else val2 = 0; + val2 = (_note < 0) ? -1 : 0; if(val3 < 0) val3--; val2 = (val3 / 2) - val2; diff --git a/iop/sound/libsd/src/voice.c b/iop/sound/libsd/src/voice.c index 23ea28f33943..823469d206c7 100644 --- a/iop/sound/libsd/src/voice.c +++ b/iop/sound/libsd/src/voice.c @@ -90,10 +90,7 @@ s32 VoiceTrans_Write_IOMode(u32 iopaddr, u32 spu_addr, s32 size, s16 chan) { volatile u16 *statx; - if(size > 64) - count = 64; - else - count = size; + count = (size > 64) ? 64 : size; if(count > 0) { @@ -125,10 +122,7 @@ int sceSdVoiceTrans(s16 chan, u16 mode, u8 *iopaddr, u32 *spuaddr, u32 size) chan &= 1; - if(mode & SD_TRANS_MODE_IO) - VoiceTransIoMode[chan] = 1; - else - VoiceTransIoMode[chan] = 0; + VoiceTransIoMode[chan] = (mode & SD_TRANS_MODE_IO) ? 1 : 0; if(VoiceTransIoMode[chan] == 0) { diff --git a/iop/sound/libsnd2/src/cc_6.c b/iop/sound/libsnd2/src/cc_6.c index 829088a22348..fe93a983a288 100644 --- a/iop/sound/libsnd2/src/cc_6.c +++ b/iop/sound/libsnd2/src/cc_6.c @@ -59,22 +59,13 @@ void _SsContDataEntry(s16 sep_no, s16 seq_no, u8 control_value) score_struct->m_delta_value = _SsReadDeltaValue(sep_no, seq_no); return; } - if ( score_struct->m_unk1B == 16 ) - SsFCALL.ccentry[(u8)score_struct->m_fn_idx]( - (char)score_struct->m_vab_id, - (u8)score_struct->m_programs[m_channel_idx], - 0, - old_vag_attr, - score_struct->m_fn_idx, - control_value); - else - SsFCALL.ccentry[(u8)score_struct->m_fn_idx]( - (char)score_struct->m_vab_id, - (u8)score_struct->m_programs[m_channel_idx], - score_struct->m_unk1B, - old_vag_attr, - score_struct->m_fn_idx, - control_value); + SsFCALL.ccentry[(u8)score_struct->m_fn_idx]( + (char)score_struct->m_vab_id, + (u8)score_struct->m_programs[m_channel_idx], + ( score_struct->m_unk1B == 16 ) ? 0 : score_struct->m_unk1B, + old_vag_attr, + score_struct->m_fn_idx, + control_value); score_struct->m_delta_value = _SsReadDeltaValue(sep_no, seq_no); score_struct->m_unk1F = 0; } diff --git a/iop/sound/libsnd2/src/cc_64.c b/iop/sound/libsnd2/src/cc_64.c index f5b0a3fb6e78..1f3dbe2c234a 100644 --- a/iop/sound/libsnd2/src/cc_64.c +++ b/iop/sound/libsnd2/src/cc_64.c @@ -15,9 +15,6 @@ void _SsContDamper(s16 sep_no, s16 seq_no, u8 control_value) libsnd2_sequence_struct_t *score_struct; score_struct = &_ss_score[sep_no][seq_no]; - if ( control_value >= 0x40u ) - _SsVmDamperOn(); - else - _SsVmDamperOff(); + (( control_value >= 0x40u ) ? _SsVmDamperOn : _SsVmDamperOff)(); score_struct->m_delta_value = _SsReadDeltaValue(sep_no, seq_no); } diff --git a/iop/sound/libsnd2/src/ccadsr.c b/iop/sound/libsnd2/src/ccadsr.c index e02f0e4a2d4b..9ee1eac958e2 100644 --- a/iop/sound/libsnd2/src/ccadsr.c +++ b/iop/sound/libsnd2/src/ccadsr.c @@ -33,10 +33,8 @@ void _SsUtBuildADSR(const u16 *adsr_buf, u16 *adsr1, u16 *adsr2) v5 = adsr_buf[6] != 0 ? 0xFFFF8000 : 0; v6 = v5; v7 = adsr_buf[5] != 0 ? 0xFFFF8000 : 0; - if ( adsr_buf[8] ) - v6 = v5 | 0x4000; - if ( adsr_buf[7] ) - v6 |= 0x20u; + v6 |= ( adsr_buf[8] ) ? 0x4000 : 0; + v6 |= ( adsr_buf[7] ) ? 0x20u : 0; v8 = v6 | ((adsr_buf[3] << 6) & 0x1FC0) | (adsr_buf[4] & 0x1F); *adsr1 = v7 | ((*adsr_buf << 8) & 0x7F00) | ((16 * adsr_buf[1]) & 0xF0) | (adsr_buf[2] & 0xF); *adsr2 = v8; diff --git a/iop/sound/libsnd2/src/cres.c b/iop/sound/libsnd2/src/cres.c index d8f5c7ac982a..d7c1f48b4e20 100644 --- a/iop/sound/libsnd2/src/cres.c +++ b/iop/sound/libsnd2/src/cres.c @@ -37,15 +37,11 @@ void _SsSndCrescendo(s16 sep_no, s16 seq_no) score_struct->m_unk4A = new_field_4a; _SsVmGetSeqVol(sep_no | (seq_no << 8), &seq_left_vol, &seq_right_vol); voll_clamped = (u16)seq_left_vol + vol_inc_by; - if ( voll_clamped >= 128 ) - voll_clamped = 127; - if ( voll_clamped < 0 ) - voll_clamped = 0; + voll_clamped = ( voll_clamped >= 128 ) ? 127 : voll_clamped; + voll_clamped = ( voll_clamped < 0 ) ? 0 : voll_clamped; volr_clamped = (u16)seq_right_vol + vol_inc_by; - if ( volr_clamped >= 128 ) - volr_clamped = 127; - if ( volr_clamped < 0 ) - volr_clamped = 0; + volr_clamped = ( volr_clamped >= 128 ) ? 127 : volr_clamped; + volr_clamped = ( volr_clamped < 0 ) ? 0 : volr_clamped; _SsVmSetSeqVol(sep_no | (seq_no << 8), voll_clamped, volr_clamped); if ( (voll_clamped == 127 && volr_clamped == 127) || (voll_clamped == 0 && volr_clamped == 0) ) { diff --git a/iop/sound/libsnd2/src/midimeta.c b/iop/sound/libsnd2/src/midimeta.c index c3a3a71f97fe..8bfbfddb0059 100644 --- a/iop/sound/libsnd2/src/midimeta.c +++ b/iop/sound/libsnd2/src/midimeta.c @@ -53,11 +53,7 @@ void _SsGetMetaEvent(s16 sep_no, s16 seq_no, u8 meta_event) v15 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_unk94 / v11; v16 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_unk94 % v11; score_struct->m_unk52 = -1; - score_struct->m_unk54 = v15; - if ( (unsigned int)(2 * (v10 - v9)) < v16 ) - { - score_struct->m_unk54 = v15 + 1; - } + score_struct->m_unk54 = ( (unsigned int)(2 * (v10 - v9)) < v16 ) ? (v15 + 1) : v15; } score_struct->m_delta_value = _SsReadDeltaValue(sep_no, seq_no); } diff --git a/iop/sound/libsnd2/src/midiread.c b/iop/sound/libsnd2/src/midiread.c index 94a09a66f043..0df4351dfb1c 100644 --- a/iop/sound/libsnd2/src/midiread.c +++ b/iop/sound/libsnd2/src/midiread.c @@ -81,10 +81,7 @@ void _SsSeqGetEof(s16 sep_no, s16 seq_no) score_struct->m_flags |= 0x200u; score_struct->m_flags |= 4u; score_struct->m_play_mode = SSPLAY_PAUSE; - if ( (score_struct->m_flags & 0x400) != 0 ) - score_struct->m_unk08 = score_struct->m_unk0C; - else - score_struct->m_unk08 = score_struct->m_unk04; + score_struct->m_unk08 = ( (score_struct->m_flags & 0x400) != 0 ) ? score_struct->m_unk0C : score_struct->m_unk04; if ( score_struct->m_next_sep != -1 ) { score_struct->m_play_mode = SSPLAY_PAUSE; @@ -99,10 +96,7 @@ void _SsSeqGetEof(s16 sep_no, s16 seq_no) score_struct->m_unk88 = 0; score_struct->m_unk1C = 0; score_struct->m_delta_value = 0; - if ( (score_struct->m_flags & 0x400) != 0 ) - m_unk04 = score_struct->m_unk0C; - else - m_unk04 = score_struct->m_unk04; + m_unk04 = ( (score_struct->m_flags & 0x400) != 0 ) ? score_struct->m_unk0C : score_struct->m_unk04; score_struct->m_seq_ptr = m_unk04; score_struct->m_unk08 = m_unk04; } @@ -112,10 +106,7 @@ void _SsSeqGetEof(s16 sep_no, s16 seq_no) score_struct->m_unk88 = 0; score_struct->m_unk1C = 0; score_struct->m_delta_value = 0; - if ( (score_struct->m_flags & 0x400) != 0 ) - score_struct->m_seq_ptr = score_struct->m_unk0C; - else - score_struct->m_seq_ptr = score_struct->m_unk04; + score_struct->m_seq_ptr = ( (score_struct->m_flags & 0x400) != 0 ) ? score_struct->m_unk0C : score_struct->m_unk04; } } diff --git a/iop/sound/libsnd2/src/sepinit.c b/iop/sound/libsnd2/src/sepinit.c index c3f77ce4f1ac..4c5b948e6caf 100644 --- a/iop/sound/libsnd2/src/sepinit.c +++ b/iop/sound/libsnd2/src/sepinit.c @@ -150,11 +150,7 @@ int _SsInitSoundSep(s16 sep_no, int seq_no, u8 vab_id, u8 *addr) v36 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_tempo / tmp2; v37 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_tempo % tmp2; score_struct->m_unk52 = -1; - score_struct->m_unk54 = v36; - if ( (unsigned int)(30 * tmp1) < v37 ) - { - score_struct->m_unk54 = v36 + 1; - } + score_struct->m_unk54 = ( (unsigned int)(30 * tmp1) < v37 ) ? (v36 + 1) : v36; } score_struct->m_unk56 = score_struct->m_unk54; return v33 + v27; diff --git a/iop/sound/libsnd2/src/seqinit.c b/iop/sound/libsnd2/src/seqinit.c index bc775ecf1b6b..a6c62717d4d0 100644 --- a/iop/sound/libsnd2/src/seqinit.c +++ b/iop/sound/libsnd2/src/seqinit.c @@ -118,11 +118,7 @@ s16 _SsInitSoundSeq(s16 seq_no, s16 vab_id, u8 *addr) v27 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_tempo / tmp2; v28 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_tempo % tmp2; score_struct->m_unk52 = -1; - score_struct->m_unk54 = v27; - if ( (unsigned int)(30 * tmp1) < v28 ) - { - score_struct->m_unk54 = v27 + 1; - } + score_struct->m_unk54 = ( (unsigned int)(30 * tmp1) < v28 ) ? (v27 + 1) : v27; } score_struct->m_unk56 = score_struct->m_unk54; return 0; diff --git a/iop/sound/libsnd2/src/ssaccele.c b/iop/sound/libsnd2/src/ssaccele.c index 9309c7191304..a99be2b803f4 100644 --- a/iop/sound/libsnd2/src/ssaccele.c +++ b/iop/sound/libsnd2/src/ssaccele.c @@ -63,9 +63,7 @@ void _SsSndSetAccele(s16 sep_no, s16 seq_no, int tempo, int v_time) v14 = score_struct->m_unk94; v15 = score_struct->m_unkA8; - v16 = tempo - v14; - if ( tempo - v14 < 0 ) - v16 = v14 - tempo; + v16 = ( tempo - v14 < 0 ) ? (v14 - tempo) : (tempo - v14); if ( v15 == -1 && (unsigned int)v16 == 0x80000000 ) __builtin_trap(); score_struct->m_unk4E = ~(u16)(v16 / v15); diff --git a/iop/sound/libsnd2/src/ssopenq.c b/iop/sound/libsnd2/src/ssopenq.c index fb7e74eecd3f..80629834e2e9 100644 --- a/iop/sound/libsnd2/src/ssopenq.c +++ b/iop/sound/libsnd2/src/ssopenq.c @@ -69,7 +69,5 @@ s16 SsSeqOpen(unsigned int *addr, s16 vab_id) SsFCALL.ccentry[DE_ECHO_FB] = _SsSetNrpnVabAttr17; SsFCALL.ccentry[DE_ECHO_DELAY] = _SsSetNrpnVabAttr18; SsFCALL.ccentry[DE_DELAY] = _SsSetNrpnVabAttr19; - if ( seq_init == -1 ) - return -1; - return open_counter_2; + return ( seq_init == -1 ) ? -1 : open_counter_2; } diff --git a/iop/sound/libsnd2/src/ssopenqj.c b/iop/sound/libsnd2/src/ssopenqj.c index 6c0dee08648c..ac53e73e0baf 100644 --- a/iop/sound/libsnd2/src/ssopenqj.c +++ b/iop/sound/libsnd2/src/ssopenqj.c @@ -30,7 +30,5 @@ s16 SsSeqOpenJ(unsigned int *addr, s16 vab_id) } } _snd_openflag |= 1 << v2; - if ( _SsInitSoundSeq(v2, vab_id, (u8 *)addr) == -1 ) - return -1; - return v2; + return ( _SsInitSoundSeq(v2, vab_id, (u8 *)addr) == -1 ) ? -1 : v2; } diff --git a/iop/sound/libsnd2/src/sstempo.c b/iop/sound/libsnd2/src/sstempo.c index ab95a21615a0..9580ee21e5b5 100644 --- a/iop/sound/libsnd2/src/sstempo.c +++ b/iop/sound/libsnd2/src/sstempo.c @@ -42,11 +42,7 @@ void SsSetTempo(s16 sep_no, s16 seq_no, s16 tempo) v11 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_unk94 / v7; v12 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_unk94 % v7; score_struct->m_unk52 = -1; - score_struct->m_unk54 = v11; - if ( (unsigned int)(2 * v6) < v12 ) - { - score_struct->m_unk54 = v11 + 1; - } + score_struct->m_unk54 = ( (unsigned int)(2 * v6) < v12 ) ? (v11 + 1) : v11; } score_struct->m_unk56 = score_struct->m_unk54; } diff --git a/iop/sound/libsnd2/src/sstick.c b/iop/sound/libsnd2/src/sstick.c index 33138b113156..b00f4979f5c4 100644 --- a/iop/sound/libsnd2/src/sstick.c +++ b/iop/sound/libsnd2/src/sstick.c @@ -12,16 +12,8 @@ void SsSetTickMode(int tick_mode) { - if ( (tick_mode & SS_NOTICK) != 0 ) - { - _snd_seq_tick_env.m_manual_tick = 1; - _snd_seq_tick_env.m_tick_mode = tick_mode & 0xFFF; - } - else - { - _snd_seq_tick_env.m_manual_tick = 0; - _snd_seq_tick_env.m_tick_mode = tick_mode; - } + _snd_seq_tick_env.m_manual_tick = ( (tick_mode & SS_NOTICK) != 0 ) ? 1 : 0; + _snd_seq_tick_env.m_tick_mode = ( (tick_mode & SS_NOTICK) != 0 ) ? (tick_mode & 0xFFF) : tick_mode; switch ( _snd_seq_tick_env.m_tick_mode ) { case SS_NOTICK0: diff --git a/iop/sound/libsnd2/src/tempo.c b/iop/sound/libsnd2/src/tempo.c index 5d3ebfbf16f8..72fb00a2e925 100644 --- a/iop/sound/libsnd2/src/tempo.c +++ b/iop/sound/libsnd2/src/tempo.c @@ -44,16 +44,12 @@ void _SsSndTempo(s16 sep_no, s16 seq_no) v16 = m_unk94 - m_unk4E; m_unkAC = score_struct->m_unkAC; - score_struct->m_unk94 = v16; - if ( m_unkAC < v16 ) - score_struct->m_unk94 = m_unkAC; + score_struct->m_unk94 = ( m_unkAC < v16 ) ? m_unkAC : v16; } } else { - score_struct->m_unk94 = v14; - if ( v14 < m_unkAC ) - score_struct->m_unk94 = m_unkAC; + score_struct->m_unk94 = ( v14 < m_unkAC ) ? m_unkAC : v14; } } else if ( m_unk4E > 0 ) @@ -65,10 +61,7 @@ void _SsSndTempo(s16 sep_no, s16 seq_no) return; v9 = score_struct->m_unk94; v10 = score_struct->m_unkAC; - if ( v10 < v9 ) - score_struct->m_unk94 = v9 - 1; - else if ( v9 < v10 ) - score_struct->m_unk94 = v9 + 1; + score_struct->m_unk94 = ( v10 < v9 ) ? (v9 - 1) : (( v9 < v10 ) ? (v9 + 1) : score_struct->m_unk94); } else { @@ -77,9 +70,7 @@ void _SsSndTempo(s16 sep_no, s16 seq_no) calc = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_unk94 / (unsigned int)(60 * VBLANK_MINUS); if ( (60 * VBLANK_MINUS) == 0 ) __builtin_trap(); - score_struct->m_unk54 = calc; - if ( (int)calc <= 0 ) - score_struct->m_unk54 = 1; + score_struct->m_unk54 = ( (int)calc <= 0 ) ? 1 : calc; if ( !score_struct->m_unkA8 || score_struct->m_unk94 == score_struct->m_unkAC ) { score_struct->m_flags &= ~0x40u; diff --git a/iop/sound/libsnd2/src/vm/q_keyon.c b/iop/sound/libsnd2/src/vm/q_keyon.c index f2d62cd94121..35cdb9c3ba55 100644 --- a/iop/sound/libsnd2/src/vm/q_keyon.c +++ b/iop/sound/libsnd2/src/vm/q_keyon.c @@ -56,10 +56,7 @@ void SsQueueReverb(int voices, int reverb) if ( v2 >= 16 ) { v9 = v2 - 16; - if ( v8 == 0 ) - v10 = _svm_orev2 & ~(1 << v9); - else - v10 = _svm_orev2 | (1 << v9); + v10 = ( v8 == 0 ) ? (_svm_orev2 & ~(1 << v9)) : (_svm_orev2 | (1 << v9)); _svm_orev2 = v10; } else @@ -77,10 +74,8 @@ void SsQueueRegisters(int vc, SndRegisterAttr *sra) { u32 mask; - mask = sra->mask; printf("SsQueueRegisters \n"); - if ( mask == 0 ) - mask = 0xFFFFFFFF; + mask = ( sra->mask == 0 ) ? 0xFFFFFFFF : sra->mask; if ( (mask & SND_VOLL) != 0 ) { _svm_sreg_buf[vc].m_vol_left = sra->volume.left & ~0x8000; @@ -115,9 +110,7 @@ void SsQueueRegisters(int vc, SndRegisterAttr *sra) s16 SsGetActualProgFromProg(s16 vab_id, s16 prog) { - if ( !((u16)vab_id < 0x11u && prog >= 0 && kMaxPrograms >= prog) ) - return -1; - return _svm_vab_pg[vab_id][prog].m_fake_prog_idx; + return ( !((u16)vab_id < 0x11u && prog >= 0 && kMaxPrograms >= prog) ) ? -1 : _svm_vab_pg[vab_id][prog].m_fake_prog_idx; } void SsSetVoiceSettings(int vc, const SndVoiceStats *snd_v_attr) @@ -145,11 +138,5 @@ s16 SsVoiceCheck(int vc, int vab_id, s16 note) if ( (unsigned int)vc >= 0x18 ) return -1; voice_struct = &_svm_voice[vc]; - if ( voice_struct->m_vab_id != vab_id >> 8 ) - return -1; - if ( voice_struct->m_prog != (u8)vab_id ) - return -1; - if ( voice_struct->m_note != note ) - return -1; - return 0; + return ( voice_struct->m_vab_id != vab_id >> 8 || voice_struct->m_prog != (u8)vab_id || voice_struct->m_note != note ) ? -1 : 0; } \ No newline at end of file diff --git a/iop/sound/libsnd2/src/vm/ut_gvad.c b/iop/sound/libsnd2/src/vm/ut_gvad.c index 7f2094732214..44be92e39d6a 100644 --- a/iop/sound/libsnd2/src/vm/ut_gvad.c +++ b/iop/sound/libsnd2/src/vm/ut_gvad.c @@ -12,17 +12,5 @@ int SsUtGetVagAddr(s16 vab_id, s16 vag_id) { - int m_vag_spu_addr; - - if ( _SsVmVSetUp(vab_id, 0) == -1 ) - return -1; - if ( (vag_id & 1) != 0 ) - { - m_vag_spu_addr = _svm_pg[(vag_id - 1) / 2].m_vag_spu_addr_hi; - } - else - { - m_vag_spu_addr = _svm_pg[(vag_id - 1) / 2].m_vag_spu_addr_lo; - } - return (m_vag_spu_addr << 4) | (gVabOffet[_svm_cur.m_vab_id] << 20); + return ( _SsVmVSetUp(vab_id, 0) == -1 ) ? -1 : (((( (vag_id & 1) != 0 ) ? _svm_pg[(vag_id - 1) / 2].m_vag_spu_addr_hi : _svm_pg[(vag_id - 1) / 2].m_vag_spu_addr_lo) << 4) | (gVabOffet[_svm_cur.m_vab_id] << 20)); } diff --git a/iop/sound/libsnd2/src/vm/ut_gvaft.c b/iop/sound/libsnd2/src/vm/ut_gvaft.c index 0b0a2012f652..76297c71be0a 100644 --- a/iop/sound/libsnd2/src/vm/ut_gvaft.c +++ b/iop/sound/libsnd2/src/vm/ut_gvaft.c @@ -13,18 +13,9 @@ unsigned int SsUtGetVagAddrFromTone(s16 vab_id, s16 prog, s16 tone) { s16 vag; - int m_vag_spu_addr; if ( _SsVmVSetUp(vab_id, prog) == -1 ) return -1; vag = _svm_tn[16 * _svm_cur.m_fake_program + tone].vag; - if ( (vag & 1) != 0 ) - { - m_vag_spu_addr = _svm_pg[(vag - 1) / 2].m_vag_spu_addr_hi; - } - else - { - m_vag_spu_addr = _svm_pg[(vag - 1) / 2].m_vag_spu_addr_lo; - } - return (m_vag_spu_addr << 4) | (gVabOffet[_svm_cur.m_vab_id] << 20); + return ((( (vag & 1) != 0 ) ? _svm_pg[(vag - 1) / 2].m_vag_spu_addr_hi : _svm_pg[(vag - 1) / 2].m_vag_spu_addr_lo) << 4) | (gVabOffet[_svm_cur.m_vab_id] << 20); } diff --git a/iop/sound/libsnd2/src/vm/ut_gvba.c b/iop/sound/libsnd2/src/vm/ut_gvba.c index a306c51eb06b..a7729dd18082 100644 --- a/iop/sound/libsnd2/src/vm/ut_gvba.c +++ b/iop/sound/libsnd2/src/vm/ut_gvba.c @@ -12,9 +12,5 @@ unsigned int SsUtGetVBaddrInSB(s16 vab_id) { - if ( (u16)vab_id >= 0x11u ) - return -1; - if ( _svm_vab_used[vab_id] != 1 ) - return -1; - return _svm_vab_start[vab_id]; + return ( (u16)vab_id >= 0x11u || _svm_vab_used[vab_id] != 1 ) ? -1 : _svm_vab_start[vab_id]; } diff --git a/iop/sound/libsnd2/src/vm/ut_pb.c b/iop/sound/libsnd2/src/vm/ut_pb.c index d87c27360c42..7a9408203caf 100644 --- a/iop/sound/libsnd2/src/vm/ut_pb.c +++ b/iop/sound/libsnd2/src/vm/ut_pb.c @@ -16,7 +16,5 @@ s16 SsUtPitchBend(s16 vc, s16 vab_id, s16 prog, s16 note, s16 pbend) _SsVmVSetUp(vab_id, prog); _svm_cur.m_seq_sep_no = 33; - if ( _SsVmPBVoice(vc, 33, vab_id, prog, pbend) == 0 ) - return -1; - return 0; + return ( _SsVmPBVoice(vc, 33, vab_id, prog, pbend) == 0 ) ? -1 : 0; } diff --git a/iop/sound/libsnd2/src/vm/ut_rev.c b/iop/sound/libsnd2/src/vm/ut_rev.c index 13c9972af130..c16178caf041 100644 --- a/iop/sound/libsnd2/src/vm/ut_rev.c +++ b/iop/sound/libsnd2/src/vm/ut_rev.c @@ -14,24 +14,14 @@ s16 SsUtSetReverbType(s16 type) { int flag_tmp; int type_tmp1; - int type_mode_flag_tmp; s16 type_tmp2; - flag_tmp = 0; - type_tmp1 = type; - if ( (type & 0x8000) != 0 ) - { - flag_tmp = 1; - type_tmp1 = -type; - } + flag_tmp = ( (type & 0x8000) != 0 ) ? 1 : 0; + type_tmp1 = ( (type & 0x8000) != 0 ) ? -type : type; if ( (u16)type_tmp1 >= SS_REV_TYPE_MAX ) return -1; _svm_rattr.mask = SPU_REV_MODE; - if ( flag_tmp ) - type_mode_flag_tmp = (type_tmp1 | SPU_REV_MODE_CLEAR_WA); - else - type_mode_flag_tmp = type_tmp1; - _svm_rattr.mode = type_mode_flag_tmp; + _svm_rattr.mode = flag_tmp ? (type_tmp1 | SPU_REV_MODE_CLEAR_WA) : type_tmp1; type_tmp2 = type_tmp1; if ( !(u16)type_tmp1 ) SpuSetReverb(SPU_OFF); diff --git a/iop/sound/libsnd2/src/vm/vm_aloc1.c b/iop/sound/libsnd2/src/vm/vm_aloc1.c index 8c7424d4968d..b103701432af 100644 --- a/iop/sound/libsnd2/src/vm/vm_aloc1.c +++ b/iop/sound/libsnd2/src/vm/vm_aloc1.c @@ -83,9 +83,7 @@ s16 _SsVmAlloc(void) } if ( voice_to_alloc_idx == 99 ) { - voice_to_alloc_idx = lowest_match; - if ( !match_counter ) - voice_to_alloc_idx = _SsVmMaxVoice; + voice_to_alloc_idx = ( !match_counter ) ? _SsVmMaxVoice : lowest_match; } if ( voice_to_alloc_idx < _SsVmMaxVoice ) { @@ -97,8 +95,7 @@ s16 _SsVmAlloc(void) libsnd2_spu_voice_t *voice_struct_1; voice_struct_1 = &_svm_voice[(u8)v16]; - if ( (_snd_vmask & (1 << (u8)v16)) == 0 ) - voice_struct_1->m_unk02 += 1; + voice_struct_1->m_unk02 += ( (_snd_vmask & (1 << (u8)v16)) == 0 ) ? 1 : 0; } voice_struct = &_svm_voice[voice_to_alloc_idx]; voice_struct->m_unk02 = 0; diff --git a/iop/sound/libsnd2/src/vm/vm_aloc2.c b/iop/sound/libsnd2/src/vm/vm_aloc2.c index a7e7b6c5d433..9aaecba6d8e3 100644 --- a/iop/sound/libsnd2/src/vm/vm_aloc2.c +++ b/iop/sound/libsnd2/src/vm/vm_aloc2.c @@ -13,7 +13,6 @@ void _SsVmDoAllocate(void) { int v0; - u16 vag_spu_addr; const VagAtr *v6; s16 damper; libsnd2_spu_voice_t *voice_struct; @@ -24,22 +23,13 @@ void _SsVmDoAllocate(void) { _svm_envx_hist[v0] &= ~(1 << (_svm_cur.m_voice_idx & 0xFF)); } - if ( (_svm_cur.m_vag_idx2 & 1) != 0 ) - { - vag_spu_addr = _svm_pg[(_svm_cur.m_vag_idx2 - 1) / 2].m_vag_spu_addr_hi; - } - else - { - vag_spu_addr = _svm_pg[(_svm_cur.m_vag_idx2 - 1) / 2].m_vag_spu_addr_lo; - } - _svm_sreg_buf2[_svm_cur.m_voice_idx].m_vag_spu_addr = vag_spu_addr; + _svm_sreg_buf2[_svm_cur.m_voice_idx].m_vag_spu_addr = ( (_svm_cur.m_vag_idx2 & 1) != 0 ) ? _svm_pg[(_svm_cur.m_vag_idx2 - 1) / 2].m_vag_spu_addr_hi : _svm_pg[(_svm_cur.m_vag_idx2 - 1) / 2].m_vag_spu_addr_lo; _svm_sreg_dirty[_svm_cur.m_voice_idx] |= 8u; _svm_sreg_buf2[_svm_cur.m_voice_idx].m_vab_spu_offset = gVabOffet[_svm_cur.m_vab_id]; v6 = &_svm_tn[16 * _svm_cur.m_fake_program + _svm_cur.m_tone]; _svm_sreg_buf[_svm_cur.m_voice_idx].m_adsr1 = v6->adsr1; damper = _svm_damper + (v6->adsr2 & 0x1F); - if ( damper >= 32 ) - damper = 31; + damper = ( damper >= 32 ) ? 31 : damper; _svm_sreg_buf[_svm_cur.m_voice_idx].m_adsr2 = damper | (v6->adsr2 & ~0x1F); _svm_sreg_dirty[_svm_cur.m_voice_idx] |= 0x30u; } diff --git a/iop/sound/libsnd2/src/vm/vm_autop.c b/iop/sound/libsnd2/src/vm/vm_autop.c index a89eacf9114d..ebe1db826846 100644 --- a/iop/sound/libsnd2/src/vm/vm_autop.c +++ b/iop/sound/libsnd2/src/vm/vm_autop.c @@ -129,36 +129,28 @@ void SetAutoPan(int vc) int v22; v22 = (u16)v18 * (127 - mpan); - v18 = (unsigned int)v22 >> 6; - if ( v22 < 0 ) - v18 = (unsigned int)(v22 + 63) >> 6; + v18 = ( v22 < 0 ) ? ((unsigned int)(v22 + 63) >> 6) : ((unsigned int)v22 >> 6); } else { int v21; v21 = (u16)v19 * mpan; - v19 = (unsigned int)v21 >> 6; - if ( v21 < 0 ) - v19 = (unsigned int)(v21 + 63) >> 6; + v19 = ( v21 < 0 ) ? ((unsigned int)(v21 + 63) >> 6) : ((unsigned int)v21 >> 6); } if ( m_auto_pan_start >= 64 ) { int v24; v24 = (u16)v18 * (127 - m_auto_pan_start); - v18 = (unsigned int)v24 >> 6; - if ( v24 < 0 ) - v18 = (unsigned int)(v24 + 63) >> 6; + v18 = ( v24 < 0 ) ? ((unsigned int)(v24 + 63) >> 6) : ((unsigned int)v24 >> 6); } else { int v23; v23 = (u16)v19 * m_auto_pan_start; - v19 = (unsigned int)v23 >> 6; - if ( v23 < 0 ) - v19 = (unsigned int)(v23 + 63) >> 6; + v19 = ( v23 < 0 ) ? ((unsigned int)(v23 + 63) >> 6) : ((unsigned int)v23 >> 6); } if ( _svm_stereo_mono == 1 ) { diff --git a/iop/sound/libsnd2/src/vm/vm_autov.c b/iop/sound/libsnd2/src/vm/vm_autov.c index def7551681f1..54132493d46f 100644 --- a/iop/sound/libsnd2/src/vm/vm_autov.c +++ b/iop/sound/libsnd2/src/vm/vm_autov.c @@ -120,36 +120,28 @@ void SetAutoVol(int vc) int v13; v13 = (u16)v10 * (127 - (u8)_svm_cur.m_mpan); - v10 = (unsigned int)v13 >> 6; - if ( v13 < 0 ) - v10 = (unsigned int)(v13 + 63) >> 6; + v10 = ( v13 < 0 ) ? ((unsigned int)(v13 + 63) >> 6) : ((unsigned int)v13 >> 6); } else { int v12; v12 = (u16)v11 * (u8)_svm_cur.m_mpan; - v11 = (unsigned int)v12 >> 6; - if ( v12 < 0 ) - v11 = (unsigned int)(v12 + 63) >> 6; + v11 = ( v12 < 0 ) ? ((unsigned int)(v12 + 63) >> 6) : ((unsigned int)v12 >> 6); } if ( (u8)_svm_cur.m_unk05 >= 0x40u ) { int v15; v15 = (u16)v10 * (127 - (u8)_svm_cur.m_unk05); - v10 = (unsigned int)v15 >> 6; - if ( v15 < 0 ) - v10 = (unsigned int)(v15 + 63) >> 6; + v10 = ( v15 < 0 ) ? ((unsigned int)(v15 + 63) >> 6) : ((unsigned int)v15 >> 6); } else { int v14; v14 = (u16)v11 * (u8)_svm_cur.m_unk05; - v11 = (unsigned int)v14 >> 6; - if ( v14 < 0 ) - v11 = (unsigned int)(v14 + 63) >> 6; + v11 = ( v14 < 0 ) ? ((unsigned int)(v14 + 63) >> 6) : ((unsigned int)v14 >> 6); } if ( _svm_stereo_mono == 1 ) { diff --git a/iop/sound/libsnd2/src/vm/vm_f.c b/iop/sound/libsnd2/src/vm/vm_f.c index b38136f67581..9ca0ba990bd9 100644 --- a/iop/sound/libsnd2/src/vm/vm_f.c +++ b/iop/sound/libsnd2/src/vm/vm_f.c @@ -131,8 +131,7 @@ void _SsVmFlush(void) voice_struct = &_svm_voice[v1]; SpuGetVoiceEnvelope(v1, &(voice_struct->m_key_stat)); - if ( !voice_struct->m_key_stat ) - _svm_envx_hist[_svm_envx_ptr] |= 1 << v1; + _svm_envx_hist[_svm_envx_ptr] |= ( !voice_struct->m_key_stat ) ? (1 << v1) : 0; } if ( !_svm_auto_kof_mode ) { @@ -156,13 +155,8 @@ void _SsVmFlush(void) int mask_1; int mask2; - mask_1 = 1 << v7; - mask2 = 0; - if ( v7 >= 16 ) - { - mask_1 = 0; - mask2 = 1 << (v7 - 16); - } + mask_1 = ( v7 >= 16 ) ? 0 : (1 << v7); + mask2 = ( v7 >= 16 ) ? (1 << (v7 - 16)) : 0; SpuSetNoiseVoice(SPU_OFF, ((u8)mask2 << 16) | (s16)mask_1); } voice_struct->m_unk1d = 0; @@ -189,11 +183,9 @@ void _SsVmFlush(void) { voice_attr.mask |= SPU_VOICE_VOLL | SPU_VOICE_VOLR; voice_attr.volume.left = _svm_sreg_buf[v12].m_vol_left; + voice_attr.volume.left = ( voice_attr.volume.left == 614 ) ? 615 : voice_attr.volume.left; voice_attr.volume.right = _svm_sreg_buf[v12].m_vol_right; - if ( voice_attr.volume.left == 614 ) - voice_attr.volume.left = 615; - if ( voice_attr.volume.right == 614 ) - voice_attr.volume.right = 615; + voice_attr.volume.right = ( voice_attr.volume.right == 614 ) ? 615 : voice_attr.volume.right; } if ( (_svm_sreg_dirty[v12] & 4) != 0 ) { diff --git a/iop/sound/libsnd2/src/vm/vm_init.c b/iop/sound/libsnd2/src/vm/vm_init.c index afac3eb1638d..a455d0cb5e8e 100644 --- a/iop/sound/libsnd2/src/vm/vm_init.c +++ b/iop/sound/libsnd2/src/vm/vm_init.c @@ -25,10 +25,7 @@ void _SsVmInit(int voice_count) memset(&_svm_sreg_dirty, 0, sizeof(_svm_sreg_dirty)); _svm_vab_count = 0; memset(&_svm_vab_used, 0, sizeof(_svm_vab_used)); - if ( ((char)voice_count & 0xFFFFu) < 0x18 ) - _SsVmMaxVoice = (char)voice_count; - else - _SsVmMaxVoice = 24; + _SsVmMaxVoice = ( ((char)voice_count & 0xFFFFu) < 0x18 ) ? (char)voice_count : 24; voice_attr.mask = SPU_VOICE_VOLL | SPU_VOICE_VOLR | SPU_VOICE_PITCH | SPU_VOICE_WDSA | SPU_VOICE_ADSR_ADSR1 | SPU_VOICE_ADSR_ADSR2; voice_attr.pitch = 0x1000; diff --git a/iop/sound/libsnd2/src/vm/vm_key.c b/iop/sound/libsnd2/src/vm/vm_key.c index 44a7b3e67509..038f4b5313fe 100644 --- a/iop/sound/libsnd2/src/vm/vm_key.c +++ b/iop/sound/libsnd2/src/vm/vm_key.c @@ -22,11 +22,7 @@ int _SsVmKeyOn(int seq_sep_no, s16 vab_id, s16 prog, s16 note, s16 voll, s16 unk u8 vag_nums[128]; u8 vag_index_nums[128]; - score_struct = NULL; - if ( seq_sep_no != 33 ) - { - score_struct = &_ss_score[(u8)seq_sep_no][(seq_sep_no & 0xFF00) >> 8]; - } + score_struct = ( seq_sep_no != 33 ) ? &_ss_score[(u8)seq_sep_no][(seq_sep_no & 0xFF00) >> 8] : NULL; on_keys_mask_1 = 0; on_keys_mask_2 = -1; if ( _SsVmVSetUp(vab_id, prog) != 0 ) @@ -36,10 +32,7 @@ int _SsVmKeyOn(int seq_sep_no, s16 vab_id, s16 prog, s16 note, s16 voll, s16 unk _svm_cur.m_seq_sep_no = seq_sep_no; _svm_cur.m_note = note; _svm_cur.m_fine = 0; - if ( score_struct != NULL ) - _svm_cur.m_voll = (u16)voll * score_struct->m_vol[score_struct->m_channel_idx] / 127; - else - _svm_cur.m_voll = voll; + _svm_cur.m_voll = ( score_struct != NULL ) ? ((u16)voll * score_struct->m_vol[score_struct->m_channel_idx] / 127) : voll; _svm_cur.m_unk05 = unknown27; prog_attr_Ptr = &_svm_pg[prog]; _svm_cur.m_mvol = prog_attr_Ptr->mvol; @@ -141,21 +134,8 @@ int _SsVmSeKeyOn(s16 vab_id, s16 prog, u16 note, int pitch, u16 voll, u16 volr) (void)pitch; - if ( voll == volr ) - { - unknown27 = 64; - voll_ = voll; - } - else if ( volr >= (unsigned int)voll ) - { - voll_ = volr; - unknown27 = 127 - (voll << 6) / volr; - } - else - { - voll_ = voll; - unknown27 = (volr << 6) / voll; - } + voll_ = ( voll == volr ) ? voll : (( volr >= (unsigned int)voll ) ? volr : voll); + unknown27 = ( voll == volr ) ? 64 : (( volr >= (unsigned int)voll ) ? (127 - (voll << 6) / volr) : ((volr << 6) / voll)); return _SsVmKeyOn(33, vab_id, prog, note, voll_, unknown27); } diff --git a/iop/sound/libsnd2/src/vm/vm_n2p.c b/iop/sound/libsnd2/src/vm/vm_n2p.c index 0e274e1581ae..15d3658b620e 100644 --- a/iop/sound/libsnd2/src/vm/vm_n2p.c +++ b/iop/sound/libsnd2/src/vm/vm_n2p.c @@ -41,9 +41,7 @@ s16 note2pitch(void) { u8 m_shift; - m_shift = _svm_cur.m_shift; - if ( (m_shift & 0x80u) != 0 ) - m_shift = 127; + m_shift = ( (_svm_cur.m_shift & 0x80u) != 0 ) ? 127 : _svm_cur.m_shift; return SsPitchFromNote(_svm_cur.m_note, 0, _svm_cur.m_centre, m_shift); } @@ -71,21 +69,13 @@ u16 SsPitchFromNote(s16 note, s16 fine, u8 center, u8 shift) shift_plus_fine_div_minus_tmp = shift_plus_fine_div_minus; shift_plus_fine_mod = shift_plus_fine % 128; shift_plus_fine_mod_tmp = shift_plus_fine_mod; - if ( (shift_plus_fine_mod & 0x8000) != 0 ) - { - shift_plus_fine_mod_tmp = shift_plus_fine_mod + 128; - shift_plus_fine_div_minus_tmp = shift_plus_fine_div_minus - 1 + (s16)(shift_plus_fine_mod + 128) / 128; - } + shift_plus_fine_mod_tmp += ( (shift_plus_fine_mod & 0x8000) != 0 ) ? 128 : 0; + shift_plus_fine_div_minus_tmp -= (( (shift_plus_fine_mod & 0x8000) != 0 ) ? (1 + (s16)(shift_plus_fine_mod + 128) / 128) : 0); shift_plus_fine_mul_minus = ((int)((u64)(0x2AAAAAABLL * (s16)shift_plus_fine_div_minus_tmp) >> 32) >> 1) - ((int)(shift_plus_fine_div_minus_tmp << 16 >> 31)); v10 = (s16)shift_plus_fine_div_minus_tmp / 12 - 2; v11 = (s16)shift_plus_fine_div_minus_tmp - 12 * shift_plus_fine_mul_minus; - if ( (v11 & 0x8000) != 0 ) - { - v11 += 12; - v10 = shift_plus_fine_mul_minus - 3; - } - if ( v10 >= 0 ) - return 0x3FFF; - return (unsigned int)(((_svm_ntable[v11] * _svm_ftable[shift_plus_fine_mod_tmp]) >> 16) + (1 << (-v10 - 1))) >> -v10; + v11 += ( (v11 & 0x8000) != 0 ) ? 12 : 0; + v10 = ( (v11 & 0x8000) != 0 ) ? (shift_plus_fine_mul_minus - 3) : v10; + return ( v10 >= 0 ) ? 0x3FFF : ((unsigned int)(((_svm_ntable[v11] * _svm_ftable[shift_plus_fine_mod_tmp]) >> 16) + (1 << (-v10 - 1))) >> -v10); } diff --git a/iop/sound/libsnd2/src/vm/vm_no1.c b/iop/sound/libsnd2/src/vm/vm_no1.c index 8836be5a7b61..ddee52887536 100644 --- a/iop/sound/libsnd2/src/vm/vm_no1.c +++ b/iop/sound/libsnd2/src/vm/vm_no1.c @@ -24,26 +24,14 @@ void vmNoiseOn(u8 vc) right_vol_calc = _svm_cur.m_voll * 0x3FFF * _svm_vh->mvol / 0x3F01 * _svm_cur.m_mvol * _svm_cur.m_vol / 0x3F01u; left_vol_calc = right_vol_calc; - score_struct = NULL; - if ( _svm_cur.m_seq_sep_no != 33 ) - { - score_struct = &_ss_score[(_svm_cur.m_seq_sep_no & 0xFF)][(_svm_cur.m_seq_sep_no & 0xFF00) >> 8]; - } + score_struct = ( _svm_cur.m_seq_sep_no != 33 ) ? &_ss_score[(_svm_cur.m_seq_sep_no & 0xFF)][(_svm_cur.m_seq_sep_no & 0xFF00) >> 8] : NULL; if ( score_struct != NULL ) { left_vol_calc = right_vol_calc * (u16)score_struct->m_voll / 0x7F; right_vol_calc = right_vol_calc * (u16)score_struct->m_volr / 0x7F; } - if ( (unsigned int)_svm_cur.m_pan >= 0x40 ) - { - right_vol_final = right_vol_calc; - left_vol_final = left_vol_calc * (127 - _svm_cur.m_pan) / 0x3F; - } - else - { - left_vol_final = left_vol_calc; - right_vol_final = right_vol_calc * _svm_cur.m_pan / 0x3F; - } + left_vol_final = ( (unsigned int)_svm_cur.m_pan >= 0x40 ) ? (left_vol_calc * (127 - _svm_cur.m_pan) / 0x3F) : left_vol_calc; + right_vol_final = ( (unsigned int)_svm_cur.m_pan >= 0x40 ) ? right_vol_calc : (right_vol_calc * _svm_cur.m_pan / 0x3F); if ( (unsigned int)_svm_cur.m_mpan >= 0x40 ) left_vol_final = left_vol_final * (127 - _svm_cur.m_mpan) / 0x3F; else @@ -68,16 +56,8 @@ void vmNoiseOn(u8 vc) _svm_sreg_buf[vc].m_vol_left = left_vol_final; _svm_sreg_buf[vc].m_vol_right = right_vol_final; _svm_sreg_dirty[vc] |= 3; - if ( vc >= 0x10u ) - { - v8 = 0; - v9 = 1 << (vc - 16); - } - else - { - v8 = 1 << vc; - v9 = 0; - } + v8 = ( vc >= 0x10u ) ? 0 : (1 << vc); + v9 = ( vc >= 0x10u ) ? (1 << (vc - 16)) : 0; voice_struct = &_svm_voice[vc]; voice_struct->m_pitch = 10; for ( v11 = 0; (s16)v11 < _SsVmMaxVoice; v11 += 1 ) diff --git a/iop/sound/libsnd2/src/vm/vm_no2.c b/iop/sound/libsnd2/src/vm/vm_no2.c index ab651da7a78b..3dd51563354f 100644 --- a/iop/sound/libsnd2/src/vm/vm_no2.c +++ b/iop/sound/libsnd2/src/vm/vm_no2.c @@ -25,16 +25,8 @@ void vmNoiseOn2(u8 vc, u16 voll, u16 volr, u16 arg3, u16 arg4) _svm_sreg_buf[vc].m_vol_left = voll; _svm_sreg_buf[vc].m_vol_right = volr; _svm_sreg_dirty[vc] |= 3; - if ( vc >= 0x10u ) - { - vc_mask_tmp1 = 0; - vc_mask_tmp2 = 1 << (vc - 16); - } - else - { - vc_mask_tmp1 = 1 << vc; - vc_mask_tmp2 = 0; - } + vc_mask_tmp1 = ( vc >= 0x10u ) ? 0 : (1 << vc); + vc_mask_tmp2 = ( vc >= 0x10u ) ? (1 << (vc - 16)) : 0; voice_struct->m_pitch = 10; voice_struct->m_unk1d = 2; okon1_tmp = _svm_okon1; diff --git a/iop/sound/libsnd2/src/vm/vm_nowof.c b/iop/sound/libsnd2/src/vm/vm_nowof.c index 3e0dbf89c1c7..9594388a5993 100644 --- a/iop/sound/libsnd2/src/vm/vm_nowof.c +++ b/iop/sound/libsnd2/src/vm/vm_nowof.c @@ -20,16 +20,8 @@ void _SsVmKeyOffNow(void) libsnd2_spu_voice_t *voice_struct; m_voice_idx = (u16)_svm_cur.m_voice_idx; - if ( (u16)m_voice_idx >= 0x10u ) - { - bits_upper = 0; - bits_lower = 1 << ((m_voice_idx & 0xFF) - 16); - } - else - { - bits_upper = 1 << (m_voice_idx & 0xFF); - bits_lower = 0; - } + bits_upper = ( (u16)m_voice_idx >= 0x10u ) ? 0 : (1 << (m_voice_idx & 0xFF)); + bits_lower = ( (u16)m_voice_idx >= 0x10u ) ? (1 << ((m_voice_idx & 0xFF) - 16)) : 0; voice_struct = &_svm_voice[m_voice_idx]; voice_struct->m_unk1d = 0; okof1_tmp = _svm_okof1; diff --git a/iop/sound/libsnd2/src/vm/vm_nowon.c b/iop/sound/libsnd2/src/vm/vm_nowon.c index 02cbf0fb5ce9..04ebedd12b9a 100644 --- a/iop/sound/libsnd2/src/vm/vm_nowon.c +++ b/iop/sound/libsnd2/src/vm/vm_nowon.c @@ -27,26 +27,14 @@ void _SsVmKeyOnNow(s16 vag_count, s16 pitch) m_voice_idx = _svm_cur.m_voice_idx; left = _svm_cur.m_voll * 0x3FFF * _svm_vh->mvol / 0x3F01 * _svm_cur.m_mvol * _svm_cur.m_vol / 0x3F01u; left_tmp2 = left; - score_struct = NULL; - if ( _svm_cur.m_seq_sep_no != 33 ) - { - score_struct = &_ss_score[(_svm_cur.m_seq_sep_no & 0xFF)][(_svm_cur.m_seq_sep_no & 0xFF00) >> 8]; - } + score_struct = ( _svm_cur.m_seq_sep_no != 33 ) ? &_ss_score[(_svm_cur.m_seq_sep_no & 0xFF)][(_svm_cur.m_seq_sep_no & 0xFF00) >> 8] : NULL; if ( score_struct != NULL ) { left_tmp2 = left * (u16)score_struct->m_voll / 0x7F; left = left * (u16)score_struct->m_volr / 0x7F; } - if ( (u8)_svm_cur.m_pan >= 0x40u ) - { - left_tmp = left; - right_tmp = left_tmp2 * (127 - (u8)_svm_cur.m_pan) / 0x3F; - } - else - { - right_tmp = left_tmp2; - left_tmp = left * (u8)_svm_cur.m_pan / 0x3F; - } + left_tmp = ( (u8)_svm_cur.m_pan >= 0x40u ) ? left : (left * (u8)_svm_cur.m_pan / 0x3F); + right_tmp = ( (u8)_svm_cur.m_pan >= 0x40u ) ? (left_tmp2 * (127 - (u8)_svm_cur.m_pan) / 0x3F) : left_tmp2; if ( (u8)_svm_cur.m_mpan >= 0x40u ) right_tmp = right_tmp * (127 - (u8)_svm_cur.m_mpan) / 0x3F; else @@ -73,16 +61,8 @@ void _SsVmKeyOnNow(s16 vag_count, s16 pitch) _svm_sreg_dirty[_svm_cur.m_voice_idx] |= 7u; voice_struct = &_svm_voice[_svm_cur.m_voice_idx]; voice_struct->m_pitch = pitch; - if ( _svm_cur.m_voice_idx >= 16 ) - { - bits_lower = 0; - bits_upper = 1 << ((_svm_cur.m_voice_idx & 0xFF) - 16); - } - else - { - bits_lower = 1 << (_svm_cur.m_voice_idx & 0xFF); - bits_upper = 0; - } + bits_lower = ( _svm_cur.m_voice_idx >= 16 ) ? 0 : (1 << (_svm_cur.m_voice_idx & 0xFF)); + bits_upper = ( _svm_cur.m_voice_idx >= 16 ) ? (1 << ((_svm_cur.m_voice_idx & 0xFF) - 16)) : 0; if ( (_svm_cur.m_mode & 4) != 0 ) { _svm_orev1 |= bits_lower; diff --git a/iop/sound/libsnd2/src/vm/vm_prog.c b/iop/sound/libsnd2/src/vm/vm_prog.c index d8a0e537cc38..38e5bd8d4975 100644 --- a/iop/sound/libsnd2/src/vm/vm_prog.c +++ b/iop/sound/libsnd2/src/vm/vm_prog.c @@ -18,9 +18,7 @@ void _SsVmSetProgVol(s16 vab_id, s16 prog, u8 vol) int _SsVmGetProgVol(s16 vab_id, s16 prog) { - if ( _SsVmVSetUp(vab_id, prog) != 0 ) - return -1; - return _svm_pg[prog].mvol; + return ( _SsVmVSetUp(vab_id, prog) != 0 ) ? -1 : _svm_pg[prog].mvol; } int _SsVmSetProgPan(s16 vab_id, s16 prog, char mpan) @@ -35,7 +33,5 @@ int _SsVmSetProgPan(s16 vab_id, s16 prog, char mpan) int _SsVmGetProgPan(s16 vab_id, s16 prog) { - if ( _SsVmVSetUp(vab_id, prog) != 0 ) - return -1; - return _svm_pg[prog].mpan; + return ( _SsVmVSetUp(vab_id, prog) != 0 ) ? -1 : _svm_pg[prog].mpan; } diff --git a/iop/sound/libsnd2/src/vm/vm_seq.c b/iop/sound/libsnd2/src/vm/vm_seq.c index d17d257e66db..459746d10dea 100644 --- a/iop/sound/libsnd2/src/vm/vm_seq.c +++ b/iop/sound/libsnd2/src/vm/vm_seq.c @@ -24,12 +24,8 @@ void _SsVmSetSeqVol(s16 seq_sep_num, s16 voll, s16 volr) unsigned int m_pan; score_struct = &_ss_score[(u8)seq_sep_num][(seq_sep_num & 0xFF00) >> 8]; - score_struct->m_voll = voll; - score_struct->m_volr = volr; - if ( (u16)voll >= 0x7Fu ) - score_struct->m_voll = 127; - if ( (u16)score_struct->m_volr >= 0x7Fu ) - score_struct->m_volr = 127; + score_struct->m_voll = ( (u16)voll >= 0x7Fu ) ? 127 : voll; + score_struct->m_volr = ( (u16)score_struct->m_volr >= 0x7Fu ) ? 127 : volr; for ( v5 = 0; (s16)v5 < _SsVmMaxVoice; v5 += 1 ) { if ( (_snd_vmask & (1 << v5)) == 0 ) diff --git a/iop/sound/libsnd2/src/vm/vs_vh.c b/iop/sound/libsnd2/src/vm/vs_vh.c index e4bdfa806260..70248cc431f5 100644 --- a/iop/sound/libsnd2/src/vm/vs_vh.c +++ b/iop/sound/libsnd2/src/vm/vs_vh.c @@ -121,8 +121,7 @@ int _SsVabOpenHeadWithMode(u8 *addr, int vab_id, libsnd2_vab_allocate_callback a { v24 = &prog_atr_ptr[v21]; v24->m_fake_prog_idx = fake_prog_idx; - if ( v24->tones ) - fake_prog_idx += 1; + fake_prog_idx += ( v24->tones ) ? 1 : 0; } total_vags_size = 0; _svm_vab_tn[vab_id_tmp] = vag_attr_ptr1; @@ -132,9 +131,7 @@ int _SsVabOpenHeadWithMode(u8 *addr, int vab_id, libsnd2_vab_allocate_callback a if ( vab_hdr_ptr->vs >= v27 ) { v31 = *(u16 *)&vag_attr_ptr2->prior; - v32 = 4 * v31; - if ( vab_hdr_ptr->ver >= 5 ) - v32 = 8 * v31; + v32 = ( vab_hdr_ptr->ver >= 5 ) ? (8 * v31) : (4 * v31); vag_lens[v27] = v32; total_vags_size += vag_lens[v27]; } @@ -156,10 +153,7 @@ int _SsVabOpenHeadWithMode(u8 *addr, int vab_id, libsnd2_vab_allocate_callback a for ( vag_idx = 0; vag_idx <= vab_hdr_ptr->vs; vag_idx += 1 ) { total_vag_size_1 += vag_lens[vag_idx]; - if ( (vag_idx & 1) != 0 ) - prog_atr_ptr[vag_idx / 2].m_vag_spu_addr_lo = (spu_alloc_mem + total_vag_size_1) >> 4; - else - prog_atr_ptr[vag_idx / 2].m_vag_spu_addr_hi = (spu_alloc_mem + total_vag_size_1) >> 4; + *(( (vag_idx & 1) != 0 ) ? &(prog_atr_ptr[vag_idx / 2].m_vag_spu_addr_lo) : &(prog_atr_ptr[vag_idx / 2].m_vag_spu_addr_hi)) = (spu_alloc_mem + total_vag_size_1) >> 4; } _svm_vab_total[(s16)vab_id_tmp] = total_vag_size_1; _svm_vab_used[(s16)vab_id_tmp] = 2; diff --git a/iop/sound/libsnd2/src/vm/vs_vtbp.c b/iop/sound/libsnd2/src/vm/vs_vtbp.c index 88a43b7f9add..3313fbfed860 100644 --- a/iop/sound/libsnd2/src/vm/vs_vtbp.c +++ b/iop/sound/libsnd2/src/vm/vs_vtbp.c @@ -41,9 +41,7 @@ s16 SsVabTransBodyPartly(u8 *addr, unsigned int bufsize, s16 vab_id) _spu_setInTransfer(0); return -1; } - bufsize_tmp = bufsize; - if ( (unsigned int)_svm_vab_not_send_size < bufsize ) - bufsize_tmp = _svm_vab_not_send_size; + bufsize_tmp = ( (unsigned int)_svm_vab_not_send_size < bufsize ) ? _svm_vab_not_send_size : bufsize; _spu_setInTransfer(1); SpuWritePartly(addr, bufsize_tmp); _svm_vab_not_send_size -= bufsize_tmp; diff --git a/iop/sound/libspu2/src/s_crwa.c b/iop/sound/libspu2/src/s_crwa.c index 60e9221d6845..49578d6ac382 100644 --- a/iop/sound/libspu2/src/s_crwa.c +++ b/iop/sound/libspu2/src/s_crwa.c @@ -23,16 +23,8 @@ int SpuClearReverbWorkArea(int mode) ck_1 = 0; if ( (unsigned int)mode >= SPU_REV_MODE_MAX ) return -1; - if ( mode ) - { - m = 8 * _spu_rev_workareasize[mode]; - n = (SpuGetReverbEndAddr() - m) >> 1; - } - else - { - m = 32; - n = 2097120; - } + m = mode ? (8 * _spu_rev_workareasize[mode]) : 32; + n = mode ? ((SpuGetReverbEndAddr() - m) >> 1) : 2097120; printf("### addr = %u size = %u\n", n, m); t = _spu_transMode; if ( _spu_transMode == 1 ) diff --git a/iop/sound/libspu2/src/s_f.c b/iop/sound/libspu2/src/s_f.c index 9d7121db356e..260a530d20b4 100644 --- a/iop/sound/libspu2/src/s_f.c +++ b/iop/sound/libspu2/src/s_f.c @@ -17,11 +17,7 @@ unsigned int SpuFlush(unsigned int ev) unsigned int ev_tmp; retval = 0; - ev_tmp = ev; - if ( ev_tmp == 0 ) - { - ev_tmp = 0xFFFFFFFF; - } + ev_tmp = ( ev == 0 ) ? 0xFFFFFFFF : ev; if ( ((ev_tmp & SPU_EVENT_PITCHLFO) != 0) && (_spu_RQmask & 2) != 0 ) { vu16 *regstmp1; diff --git a/iop/sound/libspu2/src/s_gca.c b/iop/sound/libspu2/src/s_gca.c index c2d804828385..2892aff341aa 100644 --- a/iop/sound/libspu2/src/s_gca.c +++ b/iop/sound/libspu2/src/s_gca.c @@ -87,14 +87,8 @@ void SpuGetCommonAttr(SpuCommonAttr *attr) } v5 &= ~0xF000; } - if ( v4 < 0x4000u ) - attr->mvol.left = v4; - else - attr->mvol.left = v4 + 0x8000; - if ( v5 < 0x4000u ) - attr->mvol.right = v5; - else - attr->mvol.right = v5 + 0x8000; + attr->mvol.left = ( v4 < 0x4000u ) ? v4 : (v4 + 0x8000); + attr->mvol.right = ( v5 < 0x4000u ) ? v5 : (v5 + 0x8000); attr->mvolmode.right = v6; attr->mvolmode.left = v2; v11 = &_spu_RXX[20 * _spu_core]; diff --git a/iop/sound/libspu2/src/s_gccm.c b/iop/sound/libspu2/src/s_gccm.c index 7e0756a4df34..7b50ee88e60d 100644 --- a/iop/sound/libspu2/src/s_gccm.c +++ b/iop/sound/libspu2/src/s_gccm.c @@ -12,7 +12,5 @@ void SpuGetCommonCDMix(int *cd_mix) { - *cd_mix = SPU_OFF; - if ( (_spu_RXX[512 * _spu_core + 205] & 1) != 0 ) - *cd_mix = SPU_ON; + *cd_mix = ( (_spu_RXX[512 * _spu_core + 205] & 1) != 0 ) ? SPU_ON : SPU_OFF; } diff --git a/iop/sound/libspu2/src/s_gccr.c b/iop/sound/libspu2/src/s_gccr.c index 2fbaf8b02686..6be1d6059fc2 100644 --- a/iop/sound/libspu2/src/s_gccr.c +++ b/iop/sound/libspu2/src/s_gccr.c @@ -12,7 +12,5 @@ void SpuGetCommonCDReverb(int *cd_reverb) { - *cd_reverb = SPU_OFF; - if ( (_spu_RXX[512 * _spu_core + 205] & 4) != 0 ) - *cd_reverb = SPU_ON; + *cd_reverb = ( (_spu_RXX[512 * _spu_core + 205] & 4) != 0 ) ? SPU_ON : SPU_OFF; } diff --git a/iop/sound/libspu2/src/s_gcmv.c b/iop/sound/libspu2/src/s_gcmv.c index 0579d9f9e1e8..4aa77e63f15f 100644 --- a/iop/sound/libspu2/src/s_gcmv.c +++ b/iop/sound/libspu2/src/s_gcmv.c @@ -23,12 +23,6 @@ void SpuGetCommonMasterVolume(s16 *mvol_left, s16 *mvol_right) v3 &= ~0xF000; if ( (v2[945] & 0x8000) != 0 ) v4 &= ~0xF000; - if ( v3 < 0x4000u ) - *mvol_left = v3; - else - *mvol_left = v3 + 0x8000; - if ( v4 < 0x4000u ) - *mvol_right = v4; - else - *mvol_right = v4 + 0x8000; + *mvol_left = ( v3 < 0x4000u ) ? v3 : (v3 + 0x8000); + *mvol_right = ( v4 < 0x4000u ) ? v4 : (v4 + 0x8000); } diff --git a/iop/sound/libspu2/src/s_gcmva.c b/iop/sound/libspu2/src/s_gcmva.c index f6a787ccfc30..86f5fd3c54f5 100644 --- a/iop/sound/libspu2/src/s_gcmva.c +++ b/iop/sound/libspu2/src/s_gcmva.c @@ -88,12 +88,6 @@ void SpuGetCommonMasterVolumeAttr(s16 *mvol_left, s16 *mvol_right, s16 *mvolmode } *mvolmode_left = v4; *mvolmode_right = v8; - if ( v6 < 0x4000u ) - *mvol_left = v6; - else - *mvol_left = v6 + 0x8000; - if ( v7 < 0x4000u ) - *mvol_right = v7; - else - *mvol_right = v7 + 0x8000; + *mvol_left = ( v6 < 0x4000u ) ? v6 : (v6 + 0x8000); + *mvol_right = ( v7 < 0x4000u ) ? v7 : (v7 + 0x8000); } diff --git a/iop/sound/libspu2/src/s_gks.c b/iop/sound/libspu2/src/s_gks.c index 34231fb38184..d0cef0f5d58a 100644 --- a/iop/sound/libspu2/src/s_gks.c +++ b/iop/sound/libspu2/src/s_gks.c @@ -24,30 +24,5 @@ int SpuGetKeyStatus(unsigned int voice_bit) break; } } - if ( v1 == -1 ) - { - return -1; - } - if ( (_spu_keystat[_spu_core] & (1 << v1)) != 0 ) - { - if ( _spu_RXX[512 * _spu_core + 5 + 8 * v1] != 0 ) - { - return SPU_ON; - } - else - { - return SPU_ON_ENV_OFF; - } - } - else - { - if ( _spu_RXX[512 * _spu_core + 5 + 8 * v1] != 0 ) - { - return SPU_OFF_ENV_ON; - } - else - { - return SPU_OFF; - } - } + return ( v1 == -1 ) ? -1 : (( (_spu_keystat[_spu_core] & (1 << v1)) != 0 ) ? (( _spu_RXX[512 * _spu_core + 5 + 8 * v1] != 0 ) ? SPU_ON : SPU_ON_ENV_OFF) : (( _spu_RXX[512 * _spu_core + 5 + 8 * v1] != 0 ) ? SPU_OFF_ENV_ON : SPU_OFF)); } diff --git a/iop/sound/libspu2/src/s_gtm.c b/iop/sound/libspu2/src/s_gtm.c index c15cb98026e1..f6af55a95280 100644 --- a/iop/sound/libspu2/src/s_gtm.c +++ b/iop/sound/libspu2/src/s_gtm.c @@ -12,9 +12,6 @@ int SpuGetTransferMode(void) { - if ( _spu_transMode == SPU_TRANSFER_BY_IO ) - _spu_trans_mode = SPU_TRANSFER_BY_IO; - else - _spu_trans_mode = SPU_TRANSFER_BY_DMA; + _spu_trans_mode = ( _spu_transMode == SPU_TRANSFER_BY_IO ) ? SPU_TRANSFER_BY_IO : SPU_TRANSFER_BY_DMA; return _spu_trans_mode; } diff --git a/iop/sound/libspu2/src/s_gva.c b/iop/sound/libspu2/src/s_gva.c index 5bf1c8992aaf..cbb1ee6d52b0 100644 --- a/iop/sound/libspu2/src/s_gva.c +++ b/iop/sound/libspu2/src/s_gva.c @@ -109,14 +109,8 @@ void SpuGetVoiceAttr(SpuVoiceAttr *arg) } v9 &= ~0xF000; } - if ( v8 < 0x4000u ) - arg->volume.left = v8; - else - arg->volume.left = v8 + 0x8000; - if ( v9 < 0x4000u ) - arg->volume.right = v9; - else - arg->volume.right = v9 + 0x8000; + arg->volume.left = ( v8 < 0x4000u ) ? v8 : (v8 + 0x8000); + arg->volume.right = ( v9 < 0x4000u ) ? v9 : (v9 + 0x8000); arg->volmode.left = v10; arg->volmode.right = v12; v16 = &_spu_RXX[512 * _spu_core + v6]; @@ -125,10 +119,7 @@ void SpuGetVoiceAttr(SpuVoiceAttr *arg) arg->pitch = v16[2]; v17 = _spu_pitch2note( (_spu_voice_centerNote[_spu_core][v2] >> 8) & 0xFF, (u8)_spu_voice_centerNote[_spu_core][v2], arg->pitch); - if ( v17 < 0 ) - arg->note = 0; - else - arg->note = v17; + arg->note = ( v17 < 0 ) ? 0 : v17; arg->sample_note = _spu_voice_centerNote[_spu_core][v2]; arg->envx = _spu_RXX[512 * _spu_core + v6 + 5]; arg->addr = _spu_MGFgetRXX2(224); @@ -136,9 +127,7 @@ void SpuGetVoiceAttr(SpuVoiceAttr *arg) v21 = &_spu_RXX[512 * _spu_core + v6]; v22 = v21[3]; v23 = v21[4]; - v24 = SPU_VOICE_EXPIncN; - if ( (v22 & 0x8000) == 0 ) - v24 = SPU_VOICE_LINEARIncN; + v24 = ( (v22 & 0x8000) == 0 ) ? SPU_VOICE_LINEARIncN : SPU_VOICE_EXPIncN; arg->a_mode = v24; switch ( v23 & 0xE000 ) { @@ -156,9 +145,7 @@ void SpuGetVoiceAttr(SpuVoiceAttr *arg) break; } arg->s_mode = v26; - v27 = SPU_VOICE_EXPDec; - if ( (v23 & 0x20) == 0 ) - v27 = SPU_VOICE_LINEARDecN; + v27 = ( (v23 & 0x20) == 0 ) ? SPU_VOICE_LINEARDecN : SPU_VOICE_EXPDec; arg->r_mode = v27; arg->ar = (v22 >> 8) & 0x3F; arg->dr = (u8)(v22 & 0xF0) >> 4; diff --git a/iop/sound/libspu2/src/s_gvada.c b/iop/sound/libspu2/src/s_gvada.c index d8ecb616477f..d113a773491b 100644 --- a/iop/sound/libspu2/src/s_gvada.c +++ b/iop/sound/libspu2/src/s_gvada.c @@ -21,9 +21,7 @@ void SpuGetVoiceADSRAttr( v10 = v9[3]; v11 = v9[4]; *ar = (v10 >> 8) & 0x3F; - *ar_mode = SPU_VOICE_LINEARIncN; - if ( (v10 & 0x8000) != 0 ) - *ar_mode = SPU_VOICE_EXPIncN; + *ar_mode = ( (v10 & 0x8000) != 0 ) ? SPU_VOICE_EXPIncN : SPU_VOICE_LINEARIncN; *dr = (u8)(v10 & 0xF0) >> 4; *sr = (v11 >> 6) & 0x7F; switch ( v11 & 0xE000 ) @@ -42,8 +40,6 @@ void SpuGetVoiceADSRAttr( break; } *rr = v11 & 0x1F; - *rr_mode = SPU_VOICE_LINEARDecN; - if ( (v11 & 0x20) != 0 ) - *rr_mode = SPU_VOICE_EXPDec; + *rr_mode = ( (v11 & 0x20) != 0 ) ? SPU_VOICE_EXPDec : SPU_VOICE_LINEARDecN; *sl = v10 & 0xF; } diff --git a/iop/sound/libspu2/src/s_gvara.c b/iop/sound/libspu2/src/s_gvara.c index e9bf33d27dcd..a76322d58e64 100644 --- a/iop/sound/libspu2/src/s_gvara.c +++ b/iop/sound/libspu2/src/s_gvara.c @@ -16,7 +16,5 @@ void SpuGetVoiceARAttr(int v_num, u16 *ar, int *ar_mode) v3 = _spu_RXX[512 * _spu_core + 3 + 8 * (v_num & 0x1F)]; *ar = (v3 >> 8) & 0x3F; - *ar_mode = SPU_VOICE_LINEARIncN; - if ( (v3 & 0x8000) != 0 ) - *ar_mode = SPU_VOICE_EXPIncN; + *ar_mode = ( (v3 & 0x8000) != 0 ) ? SPU_VOICE_EXPIncN : SPU_VOICE_LINEARIncN; } diff --git a/iop/sound/libspu2/src/s_gvea.c b/iop/sound/libspu2/src/s_gvea.c index 9203ea6db361..2218100a47f3 100644 --- a/iop/sound/libspu2/src/s_gvea.c +++ b/iop/sound/libspu2/src/s_gvea.c @@ -16,26 +16,5 @@ void SpuGetVoiceEnvelopeAttr(int v_num, int *key_stat, s16 *envx) v3 = _spu_RXX[512 * _spu_core + 5 + 8 * v_num]; *envx = v3; - if ( (_spu_keystat[_spu_core] & (1 << v_num)) != 0 ) - { - if ( v3 ) - { - *key_stat = SPU_ON; - } - else - { - *key_stat = SPU_ON_ENV_OFF; - } - } - else - { - if ( v3 ) - { - *key_stat = SPU_OFF_ENV_ON; - } - else - { - *key_stat = SPU_OFF; - } - } + *key_stat = ( (_spu_keystat[_spu_core] & (1 << v_num)) != 0 ) ? (v3 ? SPU_ON : SPU_ON_ENV_OFF) : (v3 ? SPU_OFF_ENV_ON : SPU_OFF); } diff --git a/iop/sound/libspu2/src/s_gvn.c b/iop/sound/libspu2/src/s_gvn.c index 58bcd6640f9d..41ca685ff88c 100644 --- a/iop/sound/libspu2/src/s_gvn.c +++ b/iop/sound/libspu2/src/s_gvn.c @@ -17,8 +17,5 @@ void SpuGetVoiceNote(int v_num, u16 *note) v3 = (u16)_spu_voice_centerNote[_spu_core][v_num]; v4 = _spu_pitch2note(v3 >> 8, (u8)v3, _spu_RXX[512 * _spu_core + 2 + 8 * (v_num & 0x1F)]); - if ( v4 < 0 ) - *note = 0; - else - *note = v4; + *note = ( v4 < 0 ) ? 0 : v4; } diff --git a/iop/sound/libspu2/src/s_gvrra.c b/iop/sound/libspu2/src/s_gvrra.c index e645c29fc8fd..4ad8c523b84d 100644 --- a/iop/sound/libspu2/src/s_gvrra.c +++ b/iop/sound/libspu2/src/s_gvrra.c @@ -16,7 +16,5 @@ void SpuGetVoiceRRAttr(int v_num, u16 *rr, int *rr_mode) v3 = _spu_RXX[512 * _spu_core + 4 + 8 * (v_num & 0x1F)]; *rr = v3 & 0x1F; - *rr_mode = SPU_VOICE_LINEARDecN; - if ( (v3 & 0x20) != 0 ) - *rr_mode = SPU_VOICE_EXPDec; + *rr_mode = ( (v3 & 0x20) != 0 ) ? SPU_VOICE_EXPDec : SPU_VOICE_LINEARDecN; } diff --git a/iop/sound/libspu2/src/s_gvv.c b/iop/sound/libspu2/src/s_gvv.c index 7660fdcd159c..55ca4c70367c 100644 --- a/iop/sound/libspu2/src/s_gvv.c +++ b/iop/sound/libspu2/src/s_gvv.c @@ -19,12 +19,6 @@ void SpuGetVoiceVolume(int v_num, s16 *voll, s16 *volr) v3 = &_spu_RXX[512 * _spu_core + 8 * (v_num & 0x1F)]; v4 = v3[1]; v5 = v3[0]; - if ( v5 < 0x4000 ) - *voll = v5; - else - *voll = v5 + 0x8000; - if ( v4 < 0x4000u ) - *volr = v4; - else - *volr = v4 + 0x8000; + *voll = ( v5 < 0x4000 ) ? v5 : (v5 + 0x8000); + *volr = ( v4 < 0x4000u ) ? v4 : (v4 + 0x8000); } diff --git a/iop/sound/libspu2/src/s_gvva.c b/iop/sound/libspu2/src/s_gvva.c index 36cd5bf08298..c6af8b2ccd21 100644 --- a/iop/sound/libspu2/src/s_gvva.c +++ b/iop/sound/libspu2/src/s_gvva.c @@ -87,12 +87,6 @@ void SpuGetVoiceVolumeAttr(int v_num, s16 *voll, s16 *volr, s16 *voll_mode, s16 } *voll_mode = v8; *volr_mode = v10; - if ( v6 < 0x4000u ) - *voll = v6; - else - *voll = v6 + 0x8000; - if ( v7 < 0x4000u ) - *volr = v7; - else - *volr = v7 + 0x8000; + *voll = ( v6 < 0x4000u ) ? v6 : (v6 + 0x8000); + *volr = ( v7 < 0x4000u ) ? v7 : (v7 + 0x8000); } diff --git a/iop/sound/libspu2/src/s_m_m.c b/iop/sound/libspu2/src/s_m_m.c index 7a790e426890..ff3678544d92 100644 --- a/iop/sound/libspu2/src/s_m_m.c +++ b/iop/sound/libspu2/src/s_m_m.c @@ -26,10 +26,7 @@ int SpuMalloc(int size) libspu2_malloc_t *p_last_block_3; found_block_idx = -1; - if ( _spu_rev_reserve_wa ) - rev_size_zero = 0x200000 - _spu_rev_offsetaddr; - else - rev_size_zero = 0; + rev_size_zero = _spu_rev_reserve_wa ? (0x200000 - _spu_rev_offsetaddr) : 0; size_adjusted = 2 * (size >> 1); if ( (_spu_memList->addr_area & 0x40000000) != 0 ) { diff --git a/iop/sound/libspu2/src/s_m_wsa.c b/iop/sound/libspu2/src/s_m_wsa.c index d66d010621ee..6993dafb9850 100644 --- a/iop/sound/libspu2/src/s_m_wsa.c +++ b/iop/sound/libspu2/src/s_m_wsa.c @@ -30,10 +30,7 @@ int SpuMallocWithStartAddr(unsigned int addr, int size) libspu2_malloc_t *v22; int v29; - if ( _spu_rev_reserve_wa ) - v7 = 0x200000 - _spu_rev_offsetaddr; - else - v7 = 0; + v7 = _spu_rev_reserve_wa ? (0x200000 - _spu_rev_offsetaddr) : 0; v8 = 2 * ((int)addr >> 1); v9 = 2 * (size >> 1); if ( v8 < 0x5010 || (int)(0x200000 - v7) < v8 + v9 ) @@ -59,9 +56,7 @@ int SpuMallocWithStartAddr(unsigned int addr, int size) size_area = v17->size_area; addr_area = v17->addr_area; v2 = v17->addr_area & 0xFFFFFFF; - v19 = size_area; - if ( v2 < v8 ) - v19 = size_area - (v8 - v2); + v19 = ( v2 < v8 ) ? (size_area - (v8 - v2)) : size_area; if ( v19 >= v9 ) { v5 = addr_area & 0xF0000000; @@ -138,20 +133,5 @@ int SpuMallocWithStartAddr(unsigned int addr, int size) static int getNeedBlock(int unk_a1, int unk_a2, int addr_area, int unk_a4) { - if ( (addr_area & 0xFFFFFFF) >= unk_a1 ) - { - if ( unk_a2 != unk_a4 ) - return 1; - return (addr_area & 0x40000000) != 0; - } - else - { - if ( unk_a2 == unk_a4 ) - { - if ( (addr_area & 0x40000000) != 0 ) - return 2; - return 1; - } - } - return 2; + return ( (addr_area & 0xFFFFFFF) >= unk_a1 ) ? (( unk_a2 != unk_a4 ) ? 1 : ((addr_area & 0x40000000) != 0)) : (( unk_a2 == unk_a4 ) ? (( (addr_area & 0x40000000) != 0 ) ? 2 : 1) : 2); } diff --git a/iop/sound/libspu2/src/s_n2p.c b/iop/sound/libspu2/src/s_n2p.c index de15e827ab0b..afa10d115167 100644 --- a/iop/sound/libspu2/src/s_n2p.c +++ b/iop/sound/libspu2/src/s_n2p.c @@ -54,16 +54,9 @@ u16 _spu_note2pitch(u16 cen_note_high, u16 cen_note_low, u16 note_high, u16 note calc_note_div12_min12 = calc_note / 12 - 2; calc_note_mod12 = calc_note % 12; calc_note_mod12_idx = calc_note_mod12; - if ( (calc_note_mod12 & 0x8000) != 0 ) - { - calc_note_mod12_idx = calc_note_mod12 + 12; - calc_note_div12_min12 = calc_note_div12 - 3; - } - if ( (calc_note_div12_min12 & 0x8000u) == 0 ) - return 0x3FFF; - return (unsigned int)(((_spu_NTable[calc_note_mod12_idx] * (u16)_spu_FTable[max_lo_idx]) >> 16) - + (1 << (-(s16)calc_note_div12_min12 - 1))) - >> -(s16)calc_note_div12_min12; + calc_note_mod12_idx += ( (calc_note_mod12 & 0x8000) != 0 ) ? 12 : 0; + calc_note_div12_min12 = ( (calc_note_mod12 & 0x8000) != 0 ) ? (calc_note_div12 - 3) : calc_note_div12_min12; + return ( (calc_note_div12_min12 & 0x8000u) == 0 ) ? 0x3FFF : ((unsigned int)(((_spu_NTable[calc_note_mod12_idx] * (u16)_spu_FTable[max_lo_idx]) >> 16) + (1 << (-(s16)calc_note_div12_min12 - 1))) >> -(s16)calc_note_div12_min12); } int _spu_pitch2note(s16 note_high, s16 note_low, u16 pitch) @@ -79,8 +72,7 @@ int _spu_pitch2note(s16 note_high, s16 note_low, u16 pitch) v3 = 0; v4 = 0; v5 = 0; - if ( pitch >= 0x4000u ) - pitch = 0x3FFF; + pitch = ( pitch >= 0x4000u ) ? 0x3FFF : pitch; for ( v6 = 0; v6 < 14; v6 += 1 ) { if ( (((int)pitch >> v6) & 1) != 0 ) diff --git a/iop/sound/libspu2/src/s_r.c b/iop/sound/libspu2/src/s_r.c index 0c038c1f4c13..bbe23956809c 100644 --- a/iop/sound/libspu2/src/s_r.c +++ b/iop/sound/libspu2/src/s_r.c @@ -14,9 +14,7 @@ unsigned int SpuRead(u8 *addr, unsigned int size) { unsigned int size_tmp; - size_tmp = size; - if ( size > 0x1FAFF0 ) - size_tmp = 0x1FAFF0; + size_tmp = ( size > 0x1FAFF0 ) ? 0x1FAFF0 : size; _spu_Fr(addr, size_tmp); if ( !_spu_transferCallback ) _spu_inTransfer = 0; diff --git a/iop/sound/libspu2/src/s_sav.c b/iop/sound/libspu2/src/s_sav.c index 02ebdd879ebb..d2165cf0a879 100644 --- a/iop/sound/libspu2/src/s_sav.c +++ b/iop/sound/libspu2/src/s_sav.c @@ -17,16 +17,8 @@ unsigned int _SpuSetAnyVoice(int on_off_flags, unsigned int voice_bits, int word int p_register_2; unsigned int ret_bits; - if ( (_spu_env & 1) != 0 ) - { - p_register_1 = _spu_RQ[word_idx1 - 188]; - p_register_2 = (u8)_spu_RQ[word_idx2 - 188]; - } - else - { - p_register_1 = _spu_RXX[512 * _spu_core + word_idx1]; - p_register_2 = (u8)_spu_RXX[512 * _spu_core + word_idx2]; - } + p_register_1 = ( (_spu_env & 1) != 0 ) ? _spu_RQ[word_idx1 - 188] : _spu_RXX[512 * _spu_core + word_idx1]; + p_register_2 = ( (_spu_env & 1) != 0 ) ? (u8)_spu_RQ[word_idx2 - 188] : (u8)_spu_RXX[512 * _spu_core + word_idx2]; ret_bits = p_register_1 | (p_register_2 << 16); switch ( on_off_flags ) { @@ -36,10 +28,7 @@ unsigned int _SpuSetAnyVoice(int on_off_flags, unsigned int voice_bits, int word _spu_RQ[word_idx1 - 188] &= ~(u16)voice_bits; _spu_RQ[word_idx2 - 188] &= ~((voice_bits >> 16) & 0xFF); _spu_RQmask |= 1 << ((word_idx1 - 190) >> 1); - if ( (1 << ((word_idx1 - 190) >> 1)) == 16 ) - { - _spu_RQmask |= 8; - } + _spu_RQmask |= ( (1 << ((word_idx1 - 190) >> 1)) == 16 ) ? 8 : 0; } else { @@ -54,10 +43,7 @@ unsigned int _SpuSetAnyVoice(int on_off_flags, unsigned int voice_bits, int word _spu_RQ[word_idx1 - 188] |= voice_bits; _spu_RQ[word_idx2 - 188] |= (voice_bits >> 16) & 0xFF; _spu_RQmask |= 1 << ((word_idx1 - 190) >> 1); - if ( (1 << ((word_idx1 - 190) >> 1)) == 16 ) - { - _spu_RQmask |= 8; - } + _spu_RQmask |= ( (1 << ((word_idx1 - 190) >> 1)) == 16 ) ? 8 : 0; } else { @@ -72,10 +58,7 @@ unsigned int _SpuSetAnyVoice(int on_off_flags, unsigned int voice_bits, int word _spu_RQ[word_idx1 - 188] = voice_bits; _spu_RQ[word_idx2 - 188] = (voice_bits >> 16) & 0xFF; _spu_RQmask |= 1 << ((word_idx1 - 190) >> 1); - if ( (1 << ((word_idx1 - 190) >> 1)) == 16 ) - { - _spu_RQmask |= 8; - } + _spu_RQmask |= ( (1 << ((word_idx1 - 190) >> 1)) == 16 ) ? 8 : 0; } else { diff --git a/iop/sound/libspu2/src/s_sca.c b/iop/sound/libspu2/src/s_sca.c index 91f6e1e42ecb..a0eea9011a4a 100644 --- a/iop/sound/libspu2/src/s_sca.c +++ b/iop/sound/libspu2/src/s_sca.c @@ -25,14 +25,10 @@ void SpuSetCommonAttr(SpuCommonAttr *attr) u16 attrtmp3; left_1 = 0; - mask = attr->mask; right_1 = 0; mov_left_part1 = 0; mov_right_part1 = 0; - if ( mask == 0 ) - { - mask = 0xFFFFFFFF; - } + mask = ( attr->mask == 0 ) ? 0xFFFFFFFF : attr->mask; if ( (mask & SPU_COMMON_MVOLL) != 0 ) { if ( (mask & SPU_COMMON_MVOLMODEL) != 0 ) @@ -70,13 +66,7 @@ void SpuSetCommonAttr(SpuCommonAttr *attr) int left_2; left_2 = attr->mvol.left; - left_1 = 127; - if ( left_2 < 128 ) - { - left_1 = 0; - if ( left_2 >= 0 ) - left_1 = attr->mvol.left; - } + left_1 = ( left_2 < 128 ) ? (( left_2 >= 0 ) ? attr->mvol.left : 0) : 127; } _spu_RXX[20 * _spu_core + 944] = (left_1 & ~0x8000) | mov_left_part1; } @@ -121,13 +111,7 @@ void SpuSetCommonAttr(SpuCommonAttr *attr) s16 right_3; right_2 = attr->mvol.right; - right_3 = 127; - if ( right_2 < 128 ) - { - right_3 = 0; - if ( right_2 >= 0 ) - right_3 = attr->mvol.right; - } + right_3 = ( right_2 < 128 ) ? (( right_2 >= 0 ) ? attr->mvol.right : 0) : 127; right_masked = right_3 & ~0x8000; } _spu_RXX[20 * _spu_core + 945] = right_masked | mov_right_part1; @@ -143,28 +127,19 @@ void SpuSetCommonAttr(SpuCommonAttr *attr) if ( (mask & SPU_COMMON_CDREV) != 0 ) { regstmp1 = &_spu_RXX[512 * _spu_core]; - if ( attr->cd.reverb == SPU_ON ) - attrtmp1 = regstmp1[205] | 4; - else - attrtmp1 = regstmp1[205] & ~4; + attrtmp1 = ( attr->cd.reverb == SPU_ON ) ? (regstmp1[205] | 4) : (regstmp1[205] & ~4); regstmp1[205] = attrtmp1; } if ( (mask & SPU_COMMON_CDMIX) != 0 ) { regstmp2 = &_spu_RXX[512 * _spu_core]; - if ( attr->cd.mix == SPU_ON ) - attrtmp2 = regstmp2[205] | 1; - else - attrtmp2 = regstmp2[205] & ~1; + attrtmp2 = ( attr->cd.mix == SPU_ON ) ? (regstmp2[205] | 1) : (regstmp2[205] & ~1); regstmp2[205] = attrtmp2; } if ( (mask & SPU_COMMON_EXTREV) != 0 ) { regstmp3 = &_spu_RXX[512 * _spu_core]; - if ( attr->ext.reverb == SPU_ON ) - attrtmp3 = regstmp3[205] | 8; - else - attrtmp3 = regstmp3[205] & ~8; + attrtmp3 = ( attr->ext.reverb == SPU_ON ) ? (regstmp3[205] | 8) : (regstmp3[205] & ~8); regstmp3[205] = attrtmp3; } if ( (mask & SPU_COMMON_EXTMIX) != 0 ) diff --git a/iop/sound/libspu2/src/s_sccm.c b/iop/sound/libspu2/src/s_sccm.c index dea68a931071..646258fb16a7 100644 --- a/iop/sound/libspu2/src/s_sccm.c +++ b/iop/sound/libspu2/src/s_sccm.c @@ -16,9 +16,6 @@ void SpuSetCommonCDMix(int cd_mix) u16 v2; v1 = &_spu_RXX[512 * _spu_core]; - if ( cd_mix ) - v2 = v1[205] | 1; - else - v2 = v1[205] & ~1; + v2 = cd_mix ? (v1[205] | 1) : (v1[205] & ~1); v1[205] = v2; } diff --git a/iop/sound/libspu2/src/s_sccr.c b/iop/sound/libspu2/src/s_sccr.c index c72d938fd5bb..247282a87a80 100644 --- a/iop/sound/libspu2/src/s_sccr.c +++ b/iop/sound/libspu2/src/s_sccr.c @@ -16,9 +16,6 @@ void SpuSetCommonCDReverb(int cd_reverb) u16 v2; v1 = &_spu_RXX[512 * _spu_core]; - if ( cd_reverb ) - v2 = v1[205] | 4; - else - v2 = v1[205] & ~4; + v2 = cd_reverb ? (v1[205] | 4) : (v1[205] & ~4); v1[205] = v2; } diff --git a/iop/sound/libspu2/src/s_scmva.c b/iop/sound/libspu2/src/s_scmva.c index afab8f33ffc7..9242179db80e 100644 --- a/iop/sound/libspu2/src/s_scmva.c +++ b/iop/sound/libspu2/src/s_scmva.c @@ -49,13 +49,7 @@ void SpuSetCommonMasterVolumeAttr(s16 mvol_left, s16 mvol_right, s16 mvolmode_le } if ( v6 ) { - v4 = 127; - if ( mvol_left < 128 ) - { - v4 = mvol_left; - if ( mvol_left < 0 ) - v4 = 0; - } + v4 = ( mvol_left < 128 ) ? (( mvol_left < 0 ) ? 0 : mvol_left) : 127; } _spu_RXX[20 * _spu_core + 944] = (v4 & ~0x8000) | v6; switch ( mvolmode_right ) @@ -86,13 +80,7 @@ void SpuSetCommonMasterVolumeAttr(s16 mvol_left, s16 mvol_right, s16 mvolmode_le } if ( v7 ) { - v5 = 127; - if ( mvol_right < 128 ) - { - v5 = mvol_right; - if ( mvol_right < 0 ) - v5 = 0; - } + v5 = ( mvol_right < 128 ) ? (( mvol_right < 0 ) ? 0 : mvol_right) : 127; } _spu_RXX[20 * _spu_core + 945] = (v5 & ~0x8000) | v7; } diff --git a/iop/sound/libspu2/src/s_se.c b/iop/sound/libspu2/src/s_se.c index 65d0a44e961c..15239e3e7489 100644 --- a/iop/sound/libspu2/src/s_se.c +++ b/iop/sound/libspu2/src/s_se.c @@ -14,11 +14,7 @@ void SpuSetEnv(const SpuEnv *env) { int mask; - mask = env->mask; - if ( mask == 0 ) - { - mask = 0xFFFFFFFF; - } + mask = ( env->mask == 0 ) ? 0xFFFFFFFF : env->mask; if ( (mask & SPU_ENV_EVENT_QUEUEING) != 0 ) { switch ( env->queueing ) diff --git a/iop/sound/libspu2/src/s_snc.c b/iop/sound/libspu2/src/s_snc.c index 167c05ebf884..d5cfbfb283fa 100644 --- a/iop/sound/libspu2/src/s_snc.c +++ b/iop/sound/libspu2/src/s_snc.c @@ -14,13 +14,7 @@ int SpuSetNoiseClock(int n_clock) { int n_clock_fixed; - n_clock_fixed = 0; - if ( n_clock >= 0 ) - { - n_clock_fixed = n_clock; - if ( n_clock >= 64 ) - n_clock_fixed = 63; - } + n_clock_fixed = ( n_clock >= 0 ) ? (( n_clock >= 64 ) ? 63 : n_clock) : 0; _spu_RXX[512 * _spu_core + 205] = (_spu_RXX[512 * _spu_core + 205] & ~0x3F00) | ((n_clock_fixed & 0x3F) << 8); return n_clock_fixed; } diff --git a/iop/sound/libspu2/src/s_sra.c b/iop/sound/libspu2/src/s_sra.c index 082f40c0a874..c4cb3ad21303 100644 --- a/iop/sound/libspu2/src/s_sra.c +++ b/iop/sound/libspu2/src/s_sra.c @@ -15,8 +15,7 @@ void _spu_setReverbAttr(const libspu2_reverb_param_entry_t *p_rev_param_entry) u32 flags; flags = p_rev_param_entry->flags; - if ( flags == 0 ) - flags = 0xFFFFFFFF; + flags = ( flags == 0 ) ? 0xFFFFFFFF : flags; if ( (flags & 1) != 0 ) _spu_MGFsetRXX2(370, p_rev_param_entry->dAPF1); if ( (flags & 2) != 0 ) diff --git a/iop/sound/libspu2/src/s_srd.c b/iop/sound/libspu2/src/s_srd.c index 52fa36de9567..fce2387a4769 100644 --- a/iop/sound/libspu2/src/s_srd.c +++ b/iop/sound/libspu2/src/s_srd.c @@ -14,9 +14,7 @@ int SpuSetReverbDepth(SpuReverbAttr *attr) { unsigned int mask; - mask = attr->mask; - if ( mask == 0 ) - mask = 0xFFFFFFFF; + mask = ( attr->mask == 0 ) ? 0xFFFFFFFF : attr->mask; if ( (mask & SPU_REV_DEPTHL) != 0 ) { _spu_RXX[20 * _spu_core + 946] = attr->depth.left; diff --git a/iop/sound/libspu2/src/s_srmp.c b/iop/sound/libspu2/src/s_srmp.c index 25eb5d69c356..3b702c8262f3 100644 --- a/iop/sound/libspu2/src/s_srmp.c +++ b/iop/sound/libspu2/src/s_srmp.c @@ -28,8 +28,7 @@ int SpuSetReverbModeParam(SpuReverbAttr *attr) mask = attr->mask; b_mode_is_7_to_9_bit0x10 = 0; entry.flags = 0; - if ( mask == 0 ) - mask = 0xFFFFFFFF; + mask = ( mask == 0 ) ? 0xFFFFFFFF : mask; if ( (mask & SPU_REV_MODE) != 0 ) { unsigned int mode; @@ -91,15 +90,11 @@ int SpuSetReverbModeParam(SpuReverbAttr *attr) b_mode_is_7_to_9_bit0x10 = 1; if ( !b_r_mode_in_bounds ) { - if ( b_mode_is_7_to_9_bit0x8 ) - { - flagstmp = entry.flags | 0x80; - } - else + if ( !b_mode_is_7_to_9_bit0x8 ) { memcpy(&entry, &_spu_rev_param[_spu_rev_attr.mode], sizeof(entry)); - flagstmp = 128; } + flagstmp = b_mode_is_7_to_9_bit0x8 ? (entry.flags | 0x80) : 128; entry.flags = flagstmp; } _spu_rev_attr.feedback = attr->feedback; diff --git a/iop/sound/libspu2/src/s_stm.c b/iop/sound/libspu2/src/s_stm.c index bbaa929e86d9..73cfd8ee0c46 100644 --- a/iop/sound/libspu2/src/s_stm.c +++ b/iop/sound/libspu2/src/s_stm.c @@ -14,10 +14,7 @@ int SpuSetTransferMode(int mode) { int result; - if ( mode == SPU_TRANSFER_BY_DMA ) - result = SPU_TRANSFER_BY_DMA; - else - result = (mode == SPU_TRANSFER_BY_IO) ? SPU_TRANSFER_BY_IO : SPU_TRANSFER_BY_DMA; + result = ( mode == SPU_TRANSFER_BY_DMA ) ? SPU_TRANSFER_BY_DMA : ((mode == SPU_TRANSFER_BY_IO) ? SPU_TRANSFER_BY_IO : SPU_TRANSFER_BY_DMA); _spu_trans_mode = mode; _spu_transMode = result; return result; diff --git a/iop/sound/libspu2/src/s_sva.c b/iop/sound/libspu2/src/s_sva.c index 7f9248cb0cff..cf3887897cbb 100644 --- a/iop/sound/libspu2/src/s_sva.c +++ b/iop/sound/libspu2/src/s_sva.c @@ -43,11 +43,7 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg) s16 attr_r_mode_converted; unsigned int attr_sl; - attr_mask = arg->mask; - if ( attr_mask == 0 ) - { - attr_mask = 0xFFFFFFFF; - } + attr_mask = ( arg->mask == 0 ) ? 0xFFFFFFFF : arg->mask; for ( voice_num = 0; voice_num < 24; voice_num += 1 ) { if ( (arg->voice & (1 << voice_num)) != 0 ) @@ -172,28 +168,20 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg) _spu_RXX[512 * _spu_core + 4 + converted_voice_num] = arg->adsr2; if ( (attr_mask & SPU_VOICE_ADSR_AR) != 0 ) { - attr_ar = arg->ar; - if ( attr_ar >= 0x80 ) - attr_ar = 127; - adsr_ar_part = 0; - if ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg->a_mode == SPU_VOICE_EXPIncN ) - adsr_ar_part = 128; + attr_ar = ( arg->ar >= 0x80 ) ? 127 : arg->ar; + adsr_ar_part = ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg->a_mode == SPU_VOICE_EXPIncN ) ? 128 : 0; _spu_RXX[512 * _spu_core + 3 + converted_voice_num] = (u8)_spu_RXX[512 * _spu_core + 3 + converted_voice_num] | (u16)(((u16)attr_ar | (u16)adsr_ar_part) << 8); } if ( (attr_mask & SPU_VOICE_ADSR_DR) != 0 ) { - adsr_dr_part = arg->dr; - if ( adsr_dr_part >= 0x10 ) - adsr_dr_part = 15; + adsr_dr_part = ( arg->dr >= 0x10 ) ? 15 : arg->dr; _spu_RXX[512 * _spu_core + 3 + converted_voice_num] = (_spu_RXX[512 * _spu_core + 3 + converted_voice_num] & ~0xf0) | (16 * adsr_dr_part); } if ( (attr_mask & SPU_VOICE_ADSR_SR) != 0 ) { - adsr_sr_part = arg->sr; - if ( adsr_sr_part >= 0x80 ) - adsr_sr_part = 127; + adsr_sr_part = ( arg->sr >= 0x80 ) ? 127 : arg->sr; converted_s_mode = 256; if ( (attr_mask & SPU_VOICE_ADSR_SMODE) != 0 ) { @@ -218,23 +206,14 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg) } if ( (attr_mask & SPU_VOICE_ADSR_RR) != 0 ) { - adsr_rr_part = arg->rr; - if ( adsr_rr_part >= 0x20 ) - adsr_rr_part = 31; - attr_r_mode_converted = 0; - if ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 ) - { - if ( arg->r_mode == SPU_VOICE_EXPDec ) - attr_r_mode_converted = 32; - } + adsr_rr_part = ( arg->rr >= 0x20 ) ? 31 : arg->rr; + attr_r_mode_converted = ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 && arg->r_mode == SPU_VOICE_EXPDec ) ? 32 : 0; _spu_RXX[512 * _spu_core + 4 + converted_voice_num] = (_spu_RXX[512 * _spu_core + 4 + converted_voice_num] & ~0x3f) | adsr_rr_part | attr_r_mode_converted; } if ( (attr_mask & SPU_VOICE_ADSR_SL) != 0 ) { - attr_sl = arg->sl; - if ( attr_sl >= 0x10 ) - attr_sl = 15; + attr_sl = ( arg->sl >= 0x10 ) ? 15 : arg->sl; _spu_RXX[512 * _spu_core + 3 + converted_voice_num] = (_spu_RXX[512 * _spu_core + 3 + converted_voice_num] & ~0xF) | attr_sl; } diff --git a/iop/sound/libspu2/src/s_svada.c b/iop/sound/libspu2/src/s_svada.c index ab5a29101f36..dfee03d5538c 100644 --- a/iop/sound/libspu2/src/s_svada.c +++ b/iop/sound/libspu2/src/s_svada.c @@ -51,8 +51,7 @@ void SpuSetVoiceADSRAttr(int v_num, u16 ar, u16 dr, u16 sr, u16 rr, u16 sl, int break; } v13 = v10 | v12; - if ( rr_mode == SPU_VOICE_EXPDec ) - v13 = v10 | v12 | 0x20; + v13 |= ( rr_mode == SPU_VOICE_EXPDec ) ? 0x20 : 0; _spu_RXX[512 * _spu_core + 4 + v11] = v13; _spu_wait_SpuSetVoiceADSRAttr(); } diff --git a/iop/sound/libspu2/src/s_w.c b/iop/sound/libspu2/src/s_w.c index 9403654b8097..493755387f44 100644 --- a/iop/sound/libspu2/src/s_w.c +++ b/iop/sound/libspu2/src/s_w.c @@ -14,9 +14,7 @@ unsigned int SpuWrite(u8 *addr, unsigned int size) { unsigned int size_tmp; - size_tmp = size; - if ( size > 0x1FAFF0 ) - size_tmp = 0x1FAFF0; + size_tmp = ( size > 0x1FAFF0 ) ? 0x1FAFF0 : size; _spu_Fw(addr, size_tmp); if ( !_spu_transferCallback ) _spu_inTransfer = 0; @@ -45,9 +43,7 @@ unsigned int SpuAutoDMAWrite(u8 *addr, unsigned int size, unsigned int mode, ... #endif if ( (mode & SPU_AUTODMA_LOOP) != 0 ) size >>= 1; - if ( (mode & SPU_AUTODMA_START_ADDR) != 0 ) - return _spu_FwAutoDMAfrom(addr, size, mode_masked_1, v6); - return _spu_FwAutoDMA(addr, size, mode_masked_1); + return ( (mode & SPU_AUTODMA_START_ADDR) != 0 ) ? _spu_FwAutoDMAfrom(addr, size, mode_masked_1, v6) : _spu_FwAutoDMA(addr, size, mode_masked_1); #endif } diff --git a/iop/sound/libspu2/src/s_w0.c b/iop/sound/libspu2/src/s_w0.c index 656a744dd96b..7bb31921e478 100644 --- a/iop/sound/libspu2/src/s_w0.c +++ b/iop/sound/libspu2/src/s_w0.c @@ -46,8 +46,7 @@ unsigned int SpuWrite0(unsigned int size) { bsize_2 = bsize_1 << 6; ck_2 = 0; - if ( (unsigned int)bsize_2 < size ) - bsize_2 += 64; + bsize_2 += ( (unsigned int)bsize_2 < size ) ? 64 : 0; } else { diff --git a/iop/sound/libspu2/src/s_wp.c b/iop/sound/libspu2/src/s_wp.c index cbee3554a38e..155c84e93962 100644 --- a/iop/sound/libspu2/src/s_wp.c +++ b/iop/sound/libspu2/src/s_wp.c @@ -14,9 +14,7 @@ unsigned int SpuWritePartly(u8 *addr, unsigned int size) { unsigned int size_tmp; - size_tmp = size; - if ( size > 0x1FAFF0 ) - size_tmp = 0x1FAFF0; + size_tmp = ( size > 0x1FAFF0 ) ? 0x1FAFF0 : size; _spu_Fw(addr, size_tmp); _spu_tsa[1] = ((2 * _spu_tsa[1]) + size_tmp) >> 1; if ( !_spu_transferCallback ) diff --git a/iop/sound/libspu2/src/sl_sva.c b/iop/sound/libspu2/src/sl_sva.c index 0b46d21cfbcd..c3cfce179897 100644 --- a/iop/sound/libspu2/src/sl_sva.c +++ b/iop/sound/libspu2/src/sl_sva.c @@ -49,11 +49,7 @@ void SpuLSetVoiceAttr(int num, SpuLVoiceAttr *arg_list) int v7; int v8; - attr_mask = arg_list[v3].attr.mask; - if ( attr_mask == 0 ) - { - attr_mask = 0xFFFFFFFF; - } + attr_mask = ( arg_list[v3].attr.mask == 0 ) ? 0xFFFFFFFF : arg_list[v3].attr.mask; voiceNum = arg_list[v3].voiceNum; v7 = 8 * voiceNum; v8 = 6 * voiceNum; @@ -173,26 +169,18 @@ void SpuLSetVoiceAttr(int num, SpuLVoiceAttr *arg_list) _spu_RXX[512 * _spu_core + 4 + v7] = arg_list[v3].attr.adsr2; if ( (attr_mask & SPU_VOICE_ADSR_AR) != 0 ) { - v16 = arg_list[v3].attr.ar; - if ( v16 >= 0x80 ) - v16 = 127; - v17 = 0; - if ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg_list[v3].attr.a_mode == SPU_VOICE_EXPIncN ) - v17 = 128; + v16 = ( arg_list[v3].attr.ar >= 0x80 ) ? 127 : arg_list[v3].attr.ar; + v17 = ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg_list[v3].attr.a_mode == SPU_VOICE_EXPIncN ) ? 128 : 0; _spu_RXX[512 * _spu_core + 3 + v7] = (u8)_spu_RXX[512 * _spu_core + 3 + v7] | (u16)(((u16)v16 | (u16)v17) << 8); } if ( (attr_mask & SPU_VOICE_ADSR_DR) != 0 ) { - v18 = arg_list[v3].attr.dr; - if ( v18 >= 0x10 ) - v18 = 15; + v18 = ( arg_list[v3].attr.dr >= 0x10 ) ? 15 : arg_list[v3].attr.dr; _spu_RXX[512 * _spu_core + 3 + v7] = (_spu_RXX[512 * _spu_core + 3 + v7] & ~0xf0) | (16 * v18); } if ( (attr_mask & SPU_VOICE_ADSR_SR) != 0 ) { - v19 = arg_list[v3].attr.sr; - if ( v19 >= 0x80 ) - v19 = 127; + v19 = ( arg_list[v3].attr.sr >= 0x80 ) ? 127 : arg_list[v3].attr.sr; v20 = 256; if ( (attr_mask & SPU_VOICE_ADSR_SMODE) != 0 ) { @@ -215,22 +203,13 @@ void SpuLSetVoiceAttr(int num, SpuLVoiceAttr *arg_list) } if ( (attr_mask & SPU_VOICE_ADSR_RR) != 0 ) { - v22 = arg_list[v3].attr.rr; - if ( v22 >= 0x20 ) - v22 = 31; - v23 = 0; - if ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 ) - { - if ( arg_list[v3].attr.r_mode == SPU_VOICE_EXPDec ) - v23 = 32; - } + v22 = ( arg_list[v3].attr.rr >= 0x20 ) ? 31 : arg_list[v3].attr.rr; + v23 = ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 && arg_list[v3].attr.r_mode == SPU_VOICE_EXPDec ) ? 32 : 0; _spu_RXX[512 * _spu_core + 4 + v7] = (_spu_RXX[512 * _spu_core + 4 + v7] & ~0x3f) | v22 | v23; } if ( (attr_mask & SPU_VOICE_ADSR_SL) != 0 ) { - v25 = arg_list[v3].attr.sl; - if ( v25 >= 0x10 ) - v25 = 15; + v25 = ( arg_list[v3].attr.sl >= 0x10 ) ? 15 : arg_list[v3].attr.sl; _spu_RXX[512 * _spu_core + 3 + v7] = (_spu_RXX[512 * _spu_core + 3 + v7] & ~0xF) | v25; } } diff --git a/iop/sound/libspu2/src/sn_gva.c b/iop/sound/libspu2/src/sn_gva.c index f6a39c257e17..e5f9431a4577 100644 --- a/iop/sound/libspu2/src/sn_gva.c +++ b/iop/sound/libspu2/src/sn_gva.c @@ -95,14 +95,8 @@ void SpuNGetVoiceAttr(int v_num, SpuVoiceAttr *arg) } v7 &= ~0xF000; } - if ( v6 < 0x4000u ) - arg->volume.left = v6; - else - arg->volume.left = v6 + 0x8000; - if ( v7 < 0x4000u ) - arg->volume.right = v7; - else - arg->volume.right = v7 + 0x8000; + arg->volume.left = ( v6 < 0x4000u ) ? v6 : (v6 + 0x8000); + arg->volume.right = ( v7 < 0x4000u ) ? v7 : (v7 + 0x8000); arg->volmode.left = v3; arg->volmode.right = v10; v14 = &_spu_RXX[512 * _spu_core + v4]; @@ -111,10 +105,7 @@ void SpuNGetVoiceAttr(int v_num, SpuVoiceAttr *arg) arg->pitch = v14[2]; v15 = _spu_pitch2note( (_spu_voice_centerNote[_spu_core][v_num] >> 8) & 0xFF, (u8)_spu_voice_centerNote[_spu_core][v_num], arg->pitch); - if ( v15 < 0 ) - arg->note = 0; - else - arg->note = v15; + arg->note = ( v15 < 0 ) ? 0 : v15; arg->sample_note = _spu_voice_centerNote[_spu_core][v_num]; arg->envx = _spu_RXX[512 * _spu_core + v4 + 5]; arg->addr = _spu_MGFgetRXX2(224); @@ -122,9 +113,7 @@ void SpuNGetVoiceAttr(int v_num, SpuVoiceAttr *arg) v19 = &_spu_RXX[512 * _spu_core + v4]; v20 = v19[3]; v21 = v19[4]; - v22 = SPU_VOICE_EXPIncN; - if ( (v20 & 0x8000) == 0 ) - v22 = SPU_VOICE_LINEARIncN; + v22 = ( (v20 & 0x8000) == 0 ) ? SPU_VOICE_LINEARIncN : SPU_VOICE_EXPIncN; arg->a_mode = v22; switch ( v21 & 0xE000 ) { @@ -142,9 +131,7 @@ void SpuNGetVoiceAttr(int v_num, SpuVoiceAttr *arg) break; } arg->s_mode = v24; - v25 = SPU_VOICE_EXPDec; - if ( (v21 & 0x20) == 0 ) - v25 = SPU_VOICE_LINEARDecN; + v25 = ( (v21 & 0x20) == 0 ) ? SPU_VOICE_LINEARDecN : SPU_VOICE_EXPDec; arg->r_mode = v25; arg->ar = (v20 >> 8) & 0x3F; arg->dr = (u8)(v20 & 0xF0) >> 4; diff --git a/iop/sound/libspu2/src/sn_sva.c b/iop/sound/libspu2/src/sn_sva.c index 099545ffeb05..3f9c0a9149ab 100644 --- a/iop/sound/libspu2/src/sn_sva.c +++ b/iop/sound/libspu2/src/sn_sva.c @@ -30,11 +30,7 @@ void SpuNSetVoiceAttr(int v_num, SpuVoiceAttr *arg) int v5; v3 = 8 * v_num; - attr_mask = arg->mask; - if ( attr_mask == 0 ) - { - attr_mask = 0xFFFFFFFF; - } + attr_mask = ( arg->mask == 0 ) ? 0xFFFFFFFF : arg->mask; v5 = 6 * v_num; if ( (attr_mask & SPU_VOICE_PITCH) != 0 ) _spu_RXX[512 * _spu_core + 2 + v3] = arg->pitch; @@ -165,21 +161,15 @@ void SpuNSetVoiceAttr(int v_num, SpuVoiceAttr *arg) unsigned int ar; s16 v13; - ar = arg->ar; - if ( ar >= 0x80 ) - ar = 127; - v13 = 0; - if ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg->a_mode == SPU_VOICE_EXPIncN ) - v13 = 128; + ar = ( arg->ar >= 0x80 ) ? 127 : arg->ar; + v13 = ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg->a_mode == SPU_VOICE_EXPIncN ) ? 128 : 0; _spu_RXX[512 * _spu_core + 3 + v3] = (u8)_spu_RXX[512 * _spu_core + 3 + v3] | (u16)(((u16)ar | (u16)v13) << 8); } if ( (attr_mask & SPU_VOICE_ADSR_DR) != 0 ) { unsigned int dr; - dr = arg->dr; - if ( dr >= 0x10 ) - dr = 15; + dr = ( arg->dr >= 0x10 ) ? 15 : arg->dr; _spu_RXX[512 * _spu_core + 3 + v3] = (_spu_RXX[512 * _spu_core + 3 + v3] & ~0xf0) | (16 * dr); } if ( (attr_mask & SPU_VOICE_ADSR_SR) != 0 ) @@ -187,9 +177,7 @@ void SpuNSetVoiceAttr(int v_num, SpuVoiceAttr *arg) unsigned int sr; s16 v16; - sr = arg->sr; - if ( sr >= 0x80 ) - sr = 127; + sr = ( arg->sr >= 0x80 ) ? 127 : arg->sr; v16 = 256; if ( (attr_mask & SPU_VOICE_ADSR_SMODE) != 0 ) { @@ -215,24 +203,15 @@ void SpuNSetVoiceAttr(int v_num, SpuVoiceAttr *arg) unsigned int rr; s16 v19; - rr = arg->rr; - if ( rr >= 0x20 ) - rr = 31; - v19 = 0; - if ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 ) - { - if ( arg->r_mode == SPU_VOICE_EXPDec ) - v19 = 32; - } + rr = ( arg->rr >= 0x20 ) ? 31 : arg->rr; + v19 = ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 && arg->r_mode == SPU_VOICE_EXPDec ) ? 32 : 0; _spu_RXX[512 * _spu_core + 4 + v3] = (_spu_RXX[512 * _spu_core + 4 + v3] & ~0x3f) | rr | v19; } if ( (attr_mask & SPU_VOICE_ADSR_SL) != 0 ) { unsigned int sl; - sl = arg->sl; - if ( sl >= 0x10 ) - sl = 15; + sl = ( arg->sl >= 0x10 ) ? 15 : arg->sl; _spu_RXX[512 * _spu_core + 3 + v3] = (_spu_RXX[512 * _spu_core + 3 + v3] & ~0xF) | sl; } _spu_wait_SpuNSetVoiceAttr(); diff --git a/iop/sound/libspu2/src/spu.c b/iop/sound/libspu2/src/spu.c index 128c0efef965..c322dcb0de0f 100644 --- a/iop/sound/libspu2/src/spu.c +++ b/iop/sound/libspu2/src/spu.c @@ -124,20 +124,9 @@ int _spu_init(int flag) int spu_do_set_DmaCoreIndex(int dma_core_index) { - int (*v1)(void *); - g_DmaCoreIndex = dma_core_index; - if ( dma_core_index ) - { - _SpuDataCallback(_spu_FiAutoDMA); - v1 = _spu_FiDMA; - } - else - { - _SpuDataCallback(_spu_FiDMA); - v1 = _spu_FiAutoDMA; - } - _SpuAutoDMACallback(v1); + _SpuDataCallback(dma_core_index ? _spu_FiAutoDMA : _spu_FiDMA); + _SpuAutoDMACallback(dma_core_index ? _spu_FiDMA : _spu_FiAutoDMA); return g_DmaCoreIndex; } @@ -156,9 +145,7 @@ static void _spu_FwriteByIO(void *addr, u32 size) s32 i; unsigned int v9; - v6 = 64; - if ( size <= 64 ) - v6 = size; + v6 = ( size <= 64 ) ? size : 64; for ( i = 0; i < v6; i += 2 ) { *((vu16 *)0xBF9001AC) = *(u16 *)((char *)addr + 2 * i); @@ -220,19 +207,14 @@ int _spu_FiAutoDMA(void *userdata) if ( gMode != SPU_AUTODMA_ONESHOT ) { gWhichBuff = 1 - gWhichBuff; - if ( gWhichBuff ) - *((vu32 *)0xBF8010C0) = (u32)&gHostAddr[512 * (gBufferSize48 / 512)]; - else - *((vu32 *)0xBF8010C0) = (u32)&gHostAddr[0]; + *((vu32 *)0xBF8010C0) = gWhichBuff ? (u32)&gHostAddr[512 * (gBufferSize48 / 512)] : (u32)&gHostAddr[0]; if ( gWhichBuff ) { int v1; int v2; v1 = (gBufferSize48 / 512) << 9; - v2 = (2 * gBufferSize48 - v1) >> 6; - if ( 2 * gBufferSize48 - v1 < 0 ) - v2 = (2 * gBufferSize48 - v1 + 63) >> 6; + v2 = ( 2 * gBufferSize48 - v1 < 0 ) ? ((2 * gBufferSize48 - v1 + 63) >> 6) : ((2 * gBufferSize48 - v1) >> 6); *((vu16 *)0xBF8010C6) = v2 + ((2 * gBufferSize48 - ((gBufferSize48 / 512) << 9)) % 64 > 0); } else @@ -245,15 +227,8 @@ int _spu_FiAutoDMA(void *userdata) if ( (gMode & SPU_AUTODMA_LOOP) != 0 ) { gWhichBuff = 1 - gWhichBuff; - if ( gWhichBuff ) - *(u32 *)(1088 * g_DmaCoreIndex + 0xBF8010C0) = (u32)&gHostAddr[512 * (gBufferSize48 / 512)]; - else - *(u32 *)(1088 * g_DmaCoreIndex + 0xBF8010C0) = (u32)gHostAddr; - if ( gWhichBuff ) - *(u16 *)(1088 * g_DmaCoreIndex + 0xBF8010C6) = (2 * gBufferSize48 - ((gBufferSize48 / 512) << 9)) / 64 - + ((2 * gBufferSize48 - ((gBufferSize48 / 512) << 9)) % 64 > 0); - else - *(u16 *)(1088 * g_DmaCoreIndex + 0xBF8010C6) = 8 * (gBufferSize48 / 512); + *(u32 *)(1088 * g_DmaCoreIndex + 0xBF8010C0) = gWhichBuff ? (u32)&gHostAddr[512 * (gBufferSize48 / 512)] : (u32)gHostAddr; + *(u16 *)(1088 * g_DmaCoreIndex + 0xBF8010C6) = gWhichBuff ? ((2 * gBufferSize48 - ((gBufferSize48 / 512) << 9)) / 64 + ((2 * gBufferSize48 - ((gBufferSize48 / 512) << 9)) % 64 > 0)) : 8 * (gBufferSize48 / 512); *(u32 *)(1088 * g_DmaCoreIndex + 0xBF8010C8) = 0x1000201; } #endif @@ -308,17 +283,12 @@ int _spu_t(int count, ...) _spu_RXX[724] = (_spu_tsa[1] >> 16) & 0xFFFF; break; case 3: - if ( _spu_dma_mode == 1 ) - _spu_FsetDelayR(1); - else - _spu_FsetDelayW(1); + (( _spu_dma_mode == 1 ) ? _spu_FsetDelayR : _spu_FsetDelayW)(1); _spu_transfer_startaddr = spu_tmp; _spu_transfer_time = (ck >> 6) + ((ck & 0x3F) != 0); ((vu32 *)0xBF8010C0)[272] = spu_tmp; ((vu32 *)0xBF8010C4)[272] = (_spu_transfer_time << 16) | 0x10; - v6 = 0x1000201; - if ( _spu_dma_mode == 1 ) - v6 = 16777728; + v6 = ( _spu_dma_mode == 1 ) ? 16777728 : 0x1000201; ((vu32 *)0xBF8010C8)[272] = v6; break; default: @@ -349,10 +319,8 @@ int _spu_StopAutoDMA(void) #else int v0; - v0 = 0; #ifdef LIB_1600 - if ( *((vu16 *)0xBF9001B0) ) - v0 = *((vu32 *)0xBF8010C0); + v0 = ( *((vu16 *)0xBF9001B0) ) ? *((vu32 *)0xBF8010C0) : 0; *((vu32 *)0xBF8010C8) &= ~0x1000000u; #else int do_set_dmacoreindex; @@ -365,8 +333,7 @@ int _spu_StopAutoDMA(void) *((vu16 *)0xBF9007C0) &= ~0xc0; } v2 = (u16 *)((g_DmaCoreIndex << 10) + 0xBF9001B0); - if ( *v2 ) - v0 = *(u32 *)(1088 * g_DmaCoreIndex + 0xBF8010C0); + v0 = ( *v2 ) ? *(u32 *)(1088 * g_DmaCoreIndex + 0xBF8010C0) : 0; *(u32 *)(1088 * g_DmaCoreIndex + 0xBF8010C8) &= ~0x1000000u; #endif #endif @@ -434,10 +401,7 @@ unsigned int _spu_FwAutoDMA(u8 *addr, unsigned int size, int mode) *(u16 *)((g_DmaCoreIndex << 10) + 0xBF90019A) &= ~0x30; *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001A8) = 0; *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001AA) = 0; - if ( g_DmaCoreIndex != 0 ) - *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001B0) = 2; - else - *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001B0) = 1; + *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001B0) = ( g_DmaCoreIndex != 0 ) ? 2 : 1; _spu_FsetDelayW(g_DmaCoreIndex); *(u32 *)((1088 * g_DmaCoreIndex) + 0xBF8010C0) = (u32)addr; *(u16 *)((1088 * g_DmaCoreIndex) + 0xBF8010C4) = 16; @@ -465,9 +429,7 @@ unsigned int _spu_FwAutoDMAfrom(u8 *addr, unsigned int size, int mode, u8 *unk_a int v7; #endif - v4 = unk_a4; - if ( !unk_a4 ) - v4 = addr; + v4 = ( !unk_a4 ) ? addr : unk_a4; gHostAddr = addr; gWhichBuff = 0; gBufferSize48 = size; @@ -496,9 +458,7 @@ unsigned int _spu_FwAutoDMAfrom(u8 *addr, unsigned int size, int mode, u8 *unk_a *((vu16 *)0xBF9001B0) = 1; *((vu32 *)0xBF8010C0) = (u32)v4; *((vu32 *)0xBF8010C4) = 16; - v7 = v5 >> 6; - if ( v5 < 0 ) - v7 = (v5 + 63) >> 6; + v7 = ( v5 < 0 ) ? ((v5 + 63) >> 6) : (v5 >> 6); *((vu16 *)0xBF8010C6) = v7 + (v5 - (v7 << 6) > 0); *((vu32 *)0xBF8010C8) = 0x1000201; *((vu16 *)0xBF900198) |= 0xC0u; @@ -513,10 +473,7 @@ unsigned int _spu_FwAutoDMAfrom(u8 *addr, unsigned int size, int mode, u8 *unk_a *(u16 *)((g_DmaCoreIndex << 10) + 0xBF90019A) &= ~0x30; *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001A8) = 0; *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001AA) = 0; - if ( g_DmaCoreIndex != 0 ) - *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001B0) = 2; - else - *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001B0) = 1; + *(u16 *)((g_DmaCoreIndex << 10) + 0xBF9001B0) = ( g_DmaCoreIndex != 0 ) ? 2 : 1; *(u32 *)((1088 * g_DmaCoreIndex) + 0xBF8010C0) = (u32)v4; *(u16 *)((1088 * g_DmaCoreIndex) + 0xBF8010C4) = 16; *(u16 *)((1088 * g_DmaCoreIndex) + 0xBF8010C6) = v5 / 64 + (v5 % 64 > 0); @@ -558,16 +515,8 @@ void _spu_FsetRXX(int l, u32 addr, int flag) vu16 *v3; v3 = &_spu_RXX[512 * _spu_core + l]; - if ( flag ) - { - *v3 = addr >> 17; - v3[1] = addr >> 1; - } - else - { - *v3 = addr >> 14; - v3[1] = 4 * addr; - } + *v3 = addr >> (flag ? 17 : 14); + v3[1] = flag ? (addr >> 1) : (4 * addr); } int _spu_FsetRXXa(int l, u32 flag) diff --git a/iop/sound/libspu2/src/sr_gaks.c b/iop/sound/libspu2/src/sr_gaks.c index cf9259510dfc..d146a808fd8f 100644 --- a/iop/sound/libspu2/src/sr_gaks.c +++ b/iop/sound/libspu2/src/sr_gaks.c @@ -31,28 +31,7 @@ int SpuRGetAllKeysStatus(int min_, int max_, char *status) const vu16 *v9; v9 = &_spu_RXX[512 * _spu_core + 8 * voice]; - if ( (_spu_keystat[_spu_core] & (1 << voice)) != 0 ) - { - if ( v9[5] ) - { - status[voice] = SPU_ON; - } - else - { - status[voice] = SPU_ON_ENV_OFF; - } - } - else - { - if ( v9[5] ) - { - status[voice] = SPU_OFF_ENV_ON; - } - else - { - status[voice] = SPU_OFF; - } - } + status[voice] = ( (_spu_keystat[_spu_core] & (1 << voice)) != 0 ) ? (( v9[5] ) ? SPU_ON : SPU_ON_ENV_OFF) : (( v9[5] ) ? SPU_OFF_ENV_ON : SPU_OFF); } return SPU_SUCCESS; } diff --git a/iop/sound/libspu2/src/sr_sva.c b/iop/sound/libspu2/src/sr_sva.c index 03942db26c0a..cc29e3d978e4 100644 --- a/iop/sound/libspu2/src/sr_sva.c +++ b/iop/sound/libspu2/src/sr_sva.c @@ -45,18 +45,11 @@ int SpuRSetVoiceAttr(int min_, int max_, SpuVoiceAttr *arg) s16 v26; unsigned int sl; - attr_mask = arg->mask; - if ( attr_mask == 0 ) - { - attr_mask = 0xFFFFFFFF; - } - v5 = max_; - if ( min_ < 0 ) - min_ = 0; + attr_mask = ( arg->mask == 0 ) ? 0xFFFFFFFF : arg->mask; + min_ = ( min_ < 0 ) ? 0 : min_; if ( min_ >= 24 ) return SPU_INVALID_ARGS; - if ( max_ >= 24 ) - v5 = 23; + v5 = ( max_ >= 24 ) ? 23 : max_; if ( v5 < 0 ) { return SPU_INVALID_ARGS; @@ -188,27 +181,19 @@ int SpuRSetVoiceAttr(int min_, int max_, SpuVoiceAttr *arg) _spu_RXX[512 * _spu_core + 4 + v11] = arg->adsr2; if ( (attr_mask & SPU_VOICE_ADSR_AR) != 0 ) { - ar = arg->ar; - if ( ar >= 0x80 ) - ar = 127; - v20 = 0; - if ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg->a_mode == SPU_VOICE_EXPIncN ) - v20 = 128; + ar = ( arg->ar >= 0x80 ) ? 127 : arg->ar; + v20 = ( ((attr_mask & SPU_VOICE_ADSR_AMODE) != 0) && arg->a_mode == SPU_VOICE_EXPIncN ) ? 128 : 0; _spu_RXX[512 * _spu_core + 3 + v11] = (u8)_spu_RXX[512 * _spu_core + 3 + v11] | (u16)(((u16)ar | (u16)v20) << 8); } if ( (attr_mask & SPU_VOICE_ADSR_DR) != 0 ) { - dr = arg->dr; - if ( dr >= 0x10 ) - dr = 15; + dr = ( arg->dr >= 0x10 ) ? 15 : arg->dr; _spu_RXX[512 * _spu_core + 3 + v11] = (_spu_RXX[512 * _spu_core + 3 + v11] & ~0xf0) | (16 * dr); } if ( (attr_mask & SPU_VOICE_ADSR_SR) != 0 ) { - sr = arg->sr; - if ( sr >= 0x80 ) - sr = 127; + sr = ( arg->sr >= 0x80 ) ? 127 : arg->sr; v23 = 256; if ( (attr_mask & SPU_VOICE_ADSR_SMODE) != 0 ) { @@ -232,22 +217,13 @@ int SpuRSetVoiceAttr(int min_, int max_, SpuVoiceAttr *arg) } if ( (attr_mask & SPU_VOICE_ADSR_RR) != 0 ) { - rr = arg->rr; - if ( rr >= 0x20 ) - rr = 31; - v26 = 0; - if ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 ) - { - if ( arg->r_mode == SPU_VOICE_EXPDec ) - v26 = 32; - } + rr = ( arg->rr >= 0x20 ) ? 31 : arg->rr; + v26 = ( (attr_mask & SPU_VOICE_ADSR_RMODE) != 0 && arg->r_mode == SPU_VOICE_EXPDec ) ? 32 : 0; _spu_RXX[512 * _spu_core + 4 + v11] = (_spu_RXX[512 * _spu_core + 4 + v11] & ~0x3f) | rr | v26; } if ( (attr_mask & SPU_VOICE_ADSR_SL) != 0 ) { - sl = arg->sl; - if ( sl >= 0x10 ) - sl = 15; + sl = ( arg->sl >= 0x10 ) ? 15 : arg->sl; _spu_RXX[512 * _spu_core + 3 + v11] = (_spu_RXX[512 * _spu_core + 3 + v11] & ~0xF) | sl; } } diff --git a/iop/sound/libspu2/src/st.c b/iop/sound/libspu2/src/st.c index 24f6b5c6fc14..07ab29778522 100644 --- a/iop/sound/libspu2/src/st.c +++ b/iop/sound/libspu2/src/st.c @@ -285,7 +285,6 @@ static void _SpuStCB_IRQ(void) int v0; unsigned int v1; int v2; - int v3; FlushDcache(); v0 = -1; @@ -293,11 +292,7 @@ static void _SpuStCB_IRQ(void) SpuSetIRQ(SPU_OFF); SpuSetCore(v1); v2 = 0; - if ( (_spu_st_stat_int & 0xF0) == 64 ) - v3 = 66; - else - v3 = 51; - _spu_st_stat_int = v3; + _spu_st_stat_int = ( (_spu_st_stat_int & 0xF0) == 64 ) ? 66 : 51; if ( _spu_st_stop_voice_bit ) { int v4; @@ -317,8 +312,7 @@ static void _SpuStCB_IRQ(void) // Added in OSDSND 110U v8 = ((_spu_st_Info.voice[v4].buf_addr >> 4) << 4) + last_size - 16; #endif - if ( !_spu_st_bufferP ) - v8 += _spu_st_buf_sizeSBhalf; + v8 += ( !_spu_st_bufferP ) ? _spu_st_buf_sizeSBhalf : 0; v9 = SpuSetCore(_st_core); _spu_FsetRXX(226 + (v4 * 6), (v8 >> 4) << 4, 1); _spu_core = v9; @@ -352,9 +346,7 @@ static void _SpuStCB_IRQ(void) // Added in OSDSND 110U v10 = ((_spu_st_Info.voice[v0].buf_addr >> 4) << 4) + v2 - 16; #endif - _spu_st_addrIRQ = v10; - if ( !_spu_st_bufferP ) - _spu_st_addrIRQ = v10 + _spu_st_buf_sizeSBhalf; + _spu_st_addrIRQ = v10 + (( !_spu_st_bufferP ) ? _spu_st_buf_sizeSBhalf : 0); v11 = SpuSetCore(_st_core); SpuSetIRQAddr(_spu_st_addrIRQ); SpuSetCore(v11); @@ -480,23 +472,17 @@ static void _SpuStCB_Transfer(void) } if ( _spu_st_cb_transfer_finished && _spu_st_start_voice_bit ) _spu_st_cb_transfer_finished(_spu_st_start_voice_bit, SPU_ST_PLAY); - v2 = _spu_st_stop_voice_smallest; - if ( _spu_st_start_voice_smallest < 24 ) - v2 = _spu_st_start_voice_smallest; + v2 = ( _spu_st_start_voice_smallest < 24 ) ? _spu_st_start_voice_smallest : _spu_st_stop_voice_smallest; v3 = (_spu_st_Info.voice[v2].buf_addr >> 4) << 4; - _spu_st_addrIRQ = v3; _spu_st_bufferP = _spu_st_bufferP != 1; - if ( _spu_st_bufferP != 1 ) - _spu_st_addrIRQ = v3 + _spu_st_buf_sizeSBhalf; + _spu_st_addrIRQ = v3 + (( _spu_st_bufferP != 1 ) ? _spu_st_buf_sizeSBhalf : 0); v4 = SpuSetCore(_st_core); SpuSetIRQAddr(_spu_st_addrIRQ); SpuSetCore(v4); v5 = SpuSetCore(_st_core); SpuSetIRQ(SPU_ON); SpuSetCore(v5); - _spu_st_stat_int = 64; - if ( _spu_st_start_voice_smallest < 24 ) - _spu_st_stat_int = 50; + _spu_st_stat_int = ( _spu_st_start_voice_smallest < 24 ) ? 50 : 64; } FlushDcache(); } @@ -567,19 +553,7 @@ int SpuStTransfer(int flag, unsigned int voice_bit) if ( !_spu_st_stat_int ) return 0; v4 = voice_bit & 0xFFFFFF; - if ( (voice_bit & 0xFFFFFF) == 0 ) - { - return SPU_ST_INVALID_ARGUMENT; - } - if ( flag == SPU_ST_PREPARE ) - { - return _SpuStStartPrepare(v4); - } - if ( flag >= SPU_ST_PREPARE && flag <= SPU_ST_PLAY ) - { - return _SpuStStart(v4); - } - return SPU_ST_INVALID_ARGUMENT; + return ( v4 == 0 ) ? SPU_ST_INVALID_ARGUMENT : (( flag == SPU_ST_PREPARE ) ? _SpuStStartPrepare(v4) : (( flag >= SPU_ST_PREPARE && flag <= SPU_ST_PLAY ) ? _SpuStStart(v4) : SPU_ST_INVALID_ARGUMENT)); } static void _SpuStReset(void) diff --git a/iop/sound/ps2snd/src/adpcm-stream.c b/iop/sound/ps2snd/src/adpcm-stream.c index 57cb1ae52f5a..ccd637811aa6 100644 --- a/iop/sound/ps2snd/src/adpcm-stream.c +++ b/iop/sound/ps2snd/src/adpcm-stream.c @@ -58,12 +58,7 @@ static inline void setloopflags(int id, u8 *buf, int len) { // if (buf[i+1] == 0) // { - if (id == 0 && i==0) - buf[i+1] = 6; /* Set 'repeat start' when at the begining of buf0 */ - else if (id == 1 && ((i+16)>=len)) - buf[i+1] = 3; /* Set 'repeat from begining' when at the end of buf1 */ - else - buf[i+1] = 2; /* Set 'in repeat section' when elsewhere */ + buf[i+1] = (id == 0 && i==0) ? 6 /* Set 'repeat start' when at the begining of buf0 */ : (((id == 1 && ((i+16)>=len)) ? 3 /* Set 'repeat from begining' when at the end of buf1 */ : 2 /* Set 'in repeat section' when elsewhere */)); // } } } @@ -310,10 +305,7 @@ int sndStreamPlay(void) return(0); /* Press down the keys :) */ - if (stream_chans>1) - sceSdSetSwitch((stream_voice[0]&1) | SD_SWITCH_KEYDOWN, 1<<(stream_voice[0]>>1) | 1<<(stream_voice[1]>>1)); - else - sceSdSetSwitch((stream_voice[0]&1) | SD_SWITCH_KEYDOWN, 1<<(stream_voice[0]>>1)); + sceSdSetSwitch((stream_voice[0]&1) | SD_SWITCH_KEYDOWN, 1<<(stream_voice[0]>>1) | ((stream_chans>1) ? (1<<(stream_voice[1]>>1)) : 0)); sceSdSetCoreAttr(SD_CORE_IRQ_ENABLE, 1); @@ -332,10 +324,7 @@ int sndStreamPause(void) return(0); /* Release keys */ - if (stream_chans>1) - sceSdSetSwitch((stream_voice[0]&1) | SD_SWITCH_KEYUP, 1<<(stream_voice[0]>>1) | 1<<(stream_voice[1]>>1)); - else - sceSdSetSwitch((stream_voice[0]&1) | SD_SWITCH_KEYUP, 1<<(stream_voice[0]>>1)); + sceSdSetSwitch((stream_voice[0]&1) | SD_SWITCH_KEYUP, 1<<(stream_voice[0]>>1) | ((stream_chans>1) ? (1<<(stream_voice[1]>>1)) : 0)); sceSdSetCoreAttr(SD_CORE_IRQ_ENABLE, 0); /* disable pesky interrupts for a minute */ diff --git a/iop/sound/rspu2drv/src/rsd_com.c b/iop/sound/rspu2drv/src/rsd_com.c index 12d164108b9b..c04e9c296485 100644 --- a/iop/sound/rspu2drv/src/rsd_com.c +++ b/iop/sound/rspu2drv/src/rsd_com.c @@ -36,8 +36,7 @@ static int g_AutoDmaBufSize; #ifndef LIB_OSD_100 static void AutoDmaStatusCB(void) { - if ( g_AutoDmaIntrCount < 4 && g_AutoDmaIntrCount >= 0 ) - g_AutoDmaIntrCount += 1; + g_AutoDmaIntrCount += ( g_AutoDmaIntrCount < 4 && g_AutoDmaIntrCount >= 0 ) ? 1 : 0; } #ifdef LIB_OSD_110 @@ -74,10 +73,7 @@ int AutoDmaWaitForCompletion(unsigned int played_size, int start_wait_count) unsigned int v4; v3 = SpuAutoDMAGetStatus(); - if ( (((v3 >> 24)) & 0xFF) == 1 ) - v4 = (v3 & 0xFFFFFF) - (u32)g_AutoDmaBuf - g_AutoDmaBufSize / 2; - else - v4 = (v3 & 0xFFFFFF) - (u32)g_AutoDmaBuf; + v4 = ( (((v3 >> 24)) & 0xFF) == 1 ) ? ((v3 & 0xFFFFFF) - (u32)g_AutoDmaBuf - g_AutoDmaBufSize / 2) : ((v3 & 0xFFFFFF) - (u32)g_AutoDmaBuf); if ( v4 >= played_size ) break; __asm__ __volatile__("" : "+g"(start_wait_count) : :); @@ -309,10 +305,7 @@ void *spuFunc(unsigned int command, void *data, int size) if ( g_AutoDmaInProcessing ) { v11 = SpuAutoDMAGetStatus(); - if ( v11 >> 24 == 1 ) - v5 = (v11 & 0xFFFFFF) - (u32)g_AutoDmaBuf - g_AutoDmaBufSize / 2; - else - v5 = (v11 & 0xFFFFFF) - (u32)g_AutoDmaBuf; + v5 = ( v11 >> 24 == 1 ) ? ((v11 & 0xFFFFFF) - (u32)g_AutoDmaBuf - g_AutoDmaBufSize / 2) : ((v11 & 0xFFFFFF) - (u32)g_AutoDmaBuf); #ifdef LIB_OSD_110 if ( v5 > 0xbfff ) #else @@ -322,10 +315,7 @@ void *spuFunc(unsigned int command, void *data, int size) while ( v5 <= 0xefff ) { v5 = SpuAutoDMAGetStatus(); - if ( v5 >> 24 == 1 ) - v5 = (v5 & 0xFFFFFF) - (u32)g_AutoDmaBuf - g_AutoDmaBufSize / 2; - else - v5 = (v5 & 0xFFFFFF) - (u32)g_AutoDmaBuf; + v5 = ( v5 >> 24 == 1 ) ? ((v5 & 0xFFFFFF) - (u32)g_AutoDmaBuf - g_AutoDmaBufSize / 2) : ((v5 & 0xFFFFFF) - (u32)g_AutoDmaBuf); } #ifndef LIB_OSD_110 v19 = 0; @@ -333,16 +323,8 @@ void *spuFunc(unsigned int command, void *data, int size) sizea = 0x2000; g_AutoDmaIntrCount = 0; #endif - if ( v11 >> 24 == 1 ) - { - v3 = (u32 *)g_AutoDmaBuf; - v4 = (void *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf); - } - else - { - v3 = (u32 *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf); - v4 = (void *)g_AutoDmaBuf; - } + v3 = ( v11 >> 24 == 1 ) ? (u32 *)g_AutoDmaBuf : (u32 *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf); + v4 = ( v11 >> 24 == 1 ) ? (void *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf) : (void *)g_AutoDmaBuf; } else { @@ -352,16 +334,8 @@ void *spuFunc(unsigned int command, void *data, int size) sizea = 0; g_AutoDmaIntrCount = 0; #endif - if ( v11 >> 24 == 1 ) - { - v3 = (u32 *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf); - v4 = (void *)g_AutoDmaBuf; - } - else - { - v3 = (u32 *)g_AutoDmaBuf; - v4 = (void *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf); - } + v3 = ( v11 >> 24 == 1 ) ? (u32 *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf) : (u32 *)g_AutoDmaBuf; + v4 = ( v11 >> 24 == 1 ) ? (void *)g_AutoDmaBuf : (void *)(g_AutoDmaBufSize / 2 + g_AutoDmaBuf); } #ifdef LIB_OSD_110 for ( j = 0; j < 0x2000; j += 128 ) diff --git a/iop/sound/sdhd/src/sdhd.c b/iop/sound/sdhd/src/sdhd.c index fddabc2c6d86..927f45748433 100644 --- a/iop/sound/sdhd/src/sdhd.c +++ b/iop/sound/sdhd/src/sdhd.c @@ -715,9 +715,7 @@ int sceSdHdGetMaxProgramNumber(void *buffer) if ( result ) return result; result = (int)do_get_prog_chunk(buffer, &dinfo); - if ( result ) - return result; - return (int)dinfo.m_prog->maxProgramNumber; + return ( result ) ? result : (int)dinfo.m_prog->maxProgramNumber; } int sceSdHdGetMaxSampleSetNumber(void *buffer) @@ -729,9 +727,7 @@ int sceSdHdGetMaxSampleSetNumber(void *buffer) if ( result ) return result; result = (int)do_get_sset_chunk(buffer, &dinfo); - if ( result ) - return result; - return (int)dinfo.m_sset->maxSampleSetNumber; + return ( result ) ? result : (int)dinfo.m_sset->maxSampleSetNumber; } int sceSdHdGetMaxSampleNumber(void *buffer) @@ -743,9 +739,7 @@ int sceSdHdGetMaxSampleNumber(void *buffer) if ( result ) return result; result = (int)do_get_smpl_chunk(buffer, &dinfo); - if ( result ) - return result; - return (int)dinfo.m_smpl->maxSampleNumber; + return ( result ) ? result : (int)dinfo.m_smpl->maxSampleNumber; } int sceSdHdGetMaxVAGInfoNumber(void *buffer) @@ -757,9 +751,7 @@ int sceSdHdGetMaxVAGInfoNumber(void *buffer) if ( result ) return result; result = (int)do_get_vagi_chunk(buffer, &dinfo); - if ( result ) - return result; - return (int)dinfo.m_vagi->maxVagInfoNumber; + return ( result ) ? result : (int)dinfo.m_vagi->maxVagInfoNumber; } int sceSdHdGetProgramParamAddr(void *buffer, unsigned int programNumber, sceHardSynthProgramParam **ptr) @@ -923,9 +915,7 @@ int sceSdHdCheckProgramNumber(void *buffer, unsigned int programNumber) if ( result ) return result; result = (int)do_get_prog_chunk(buffer, &dinfo); - if ( result ) - return result; - return (int)do_check_chunk_in_bounds(buffer, &dinfo, 0x50726F67, programNumber); + return ( result ) ? result : (int)do_check_chunk_in_bounds(buffer, &dinfo, 0x50726F67, programNumber); } int sceSdHdGetSplitBlockCountByNote(void *buffer, unsigned int programNumber, unsigned int noteNumber) @@ -1060,11 +1050,7 @@ int sceSdHdGetVAGInfoParamAddrBySampleNumber(void *buffer, unsigned int sampleNu sceHardSynthSampleParam *p_sampleparam; result = sceSdHdGetSampleParamAddr(buffer, sampleNumber, &p_sampleparam); - if ( result ) - return result; - if ( p_sampleparam->VagIndex == 0xFFFF ) - return (int)0x81039019; - return sceSdHdGetVAGInfoParamAddr(buffer, p_sampleparam->VagIndex, ptr); + return ( result ) ? result : (( p_sampleparam->VagIndex == 0xFFFF ) ? (int)0x81039019 : sceSdHdGetVAGInfoParamAddr(buffer, p_sampleparam->VagIndex, ptr)); } int sceSdHdGetVAGInfoParamBySampleNumber(void *buffer, unsigned int sampleNumber, SceSdHdVAGInfoParam *param) @@ -1108,9 +1094,7 @@ int sceSdHdGetVAGSize(void *buffer, unsigned int vagInfoNumber) sceHardSynthVagParam *p_vagparam; result = sceSdHdGetVAGInfoParamAddr(buffer, vagInfoNumber, &p_vagparam); - if ( result ) - return result; - return (int)do_get_vag_size((sceHardSynthVersionChunk *)buffer, &p_vagparam->vagOffsetAddr); + return ( result ) ? result : (int)do_get_vag_size((sceHardSynthVersionChunk *)buffer, &p_vagparam->vagOffsetAddr); } int sceSdHdGetSplitBlockCount(void *buffer, unsigned int programNumber) @@ -1119,9 +1103,7 @@ int sceSdHdGetSplitBlockCount(void *buffer, unsigned int programNumber) sceHardSynthProgramParam *p_programparam; result = sceSdHdGetProgramParamAddr(buffer, programNumber, &p_programparam); - if ( result ) - return result; - return p_programparam->nSplit; + return ( result ) ? result : p_programparam->nSplit; } int sceSdHdGetMaxSplitBlockCount(void *buffer) @@ -1459,8 +1441,7 @@ int sceSdHdGetValidProgramNumberCount(void *buffer) return result; for ( i = 0; dinfo.m_prog->maxProgramNumber >= i; i += 1 ) { - if ( dinfo.m_prog->programOffsetAddr[i] != 0xFFFFFFFF ) - validcnt += 1; + validcnt += ( dinfo.m_prog->programOffsetAddr[i] != 0xFFFFFFFF ) ? 1 : 0; } return validcnt; } @@ -1496,11 +1477,9 @@ int sceSdHdGetSampleNumberBySampleIndex(void *buffer, unsigned int sampleSetNumb sceHardSynthSampleSetParam *p_samplesetparam; result = sceSdHdGetSampleSetParamAddr(buffer, sampleSetNumber, &p_samplesetparam); - if ( result ) - return result; - return ((unsigned int)p_samplesetparam->nSample - 1 < sampleIndexNumber) ? + return ( result ) ? result : (((unsigned int)p_samplesetparam->nSample - 1 < sampleIndexNumber) ? 0x9006 : - p_samplesetparam->sampleIndex[sampleIndexNumber]; + p_samplesetparam->sampleIndex[sampleIndexNumber]); } #ifdef _IOP diff --git a/iop/sound/sdrdrv/src/sdd_com.c b/iop/sound/sdrdrv/src/sdd_com.c index c08f8c38ce05..3ac1baf42835 100644 --- a/iop/sound/sdrdrv/src/sdd_com.c +++ b/iop/sound/sdrdrv/src/sdd_com.c @@ -27,8 +27,7 @@ static int AutoDmaStatusCB(void *data) { (void)data; - if ( g_AutoDmaIntrCount < 4 && g_AutoDmaIntrCount >= 0 ) - g_AutoDmaIntrCount += 1; + g_AutoDmaIntrCount += ( g_AutoDmaIntrCount < 4 && g_AutoDmaIntrCount >= 0 ) ? 1 : 0; return 0; } #endif diff --git a/iop/sound/sdrdrv/src/sdd_main.c b/iop/sound/sdrdrv/src/sdd_main.c index 99e3412b1912..7cedfbc2de99 100644 --- a/iop/sound/sdrdrv/src/sdd_main.c +++ b/iop/sound/sdrdrv/src/sdd_main.c @@ -144,9 +144,7 @@ int sceSdrChangeThreadPriority(int priority_main, int priority_cb) cur_priority = (priority_cb < priority_main) ? priority_main : priority_cb; ReferThreadStatus(0, &thstatus); ChangeThreadPriority(0, 8); - ret = 0; - if ( g_sdrInfo.m_thid_main > 0 ) - ret = ChangeThreadPriority(g_sdrInfo.m_thid_main, priority_main); + ret = ( g_sdrInfo.m_thid_main > 0 ) ? ChangeThreadPriority(g_sdrInfo.m_thid_main, priority_main) : 0; if ( ret < 0 ) return ret; if ( g_eeCBInfo.m_thid_cb > 0 ) diff --git a/iop/sound/sdsq/src/sdsq.c b/iop/sound/sdsq/src/sdsq.c index 6e6e2c663185..07b312f9c42c 100644 --- a/iop/sound/sdsq/src/sdsq.c +++ b/iop/sound/sdsq/src/sdsq.c @@ -180,9 +180,7 @@ int sceSdSqGetMaxMidiNumber(void *addr) if ( result ) return result; result = (int)do_get_midi_chunk(addr, &dinfo); - if ( result ) - return result; - return (int)dinfo.m_midi->maxMidiNumber; + return ( result ) ? result : (int)dinfo.m_midi->maxMidiNumber; } int sceSdSqGetMaxSongNumber(void *addr) @@ -194,9 +192,7 @@ int sceSdSqGetMaxSongNumber(void *addr) if ( result ) return result; result = (int)do_get_song_chunk(addr, &dinfo); - if ( result ) - return result; - return (int)dinfo.m_song->maxSongNumber; + return ( result ) ? result : (int)dinfo.m_song->maxSongNumber; } int sceSdSqInitMidiData(void *addr, u32 midiNumber, SceSdSqMidiData *midiData) @@ -490,11 +486,7 @@ int sceSdSqGetMaxCompTableIndex(void *addr, u32 midiNumber) sceSeqMidiDataBlock *dblk; result = (int)do_get_midi_data_block(addr, midiNumber, &dblk); - if ( result ) - return result; - if ( dblk->sequenceDataOffset == 6 ) - return (int)0x81049028; - return dblk->compBlock[0].compTableSize >> 1; + return ( result ) ? result : (( dblk->sequenceDataOffset == 6 ) ? (int)0x81049028 : (dblk->compBlock[0].compTableSize >> 1)); } int sceSdSqGetCompTableOffset(void *addr, u32 midiNumber, u32 *offset) diff --git a/iop/system/excepman/src/excepman.c b/iop/system/excepman/src/excepman.c index 5eeb81833e3e..c2c2ae4431c6 100644 --- a/iop/system/excepman/src/excepman.c +++ b/iop/system/excepman/src/excepman.c @@ -55,10 +55,7 @@ int _start(int ac, char **av) u32 cur_instruction; cur_instruction = exception_handler_shellcode_start[i]; - if ( cur_instruction == 0x8F5A0000 || cur_instruction == 0x8F7B0000 ) - { - cur_instruction |= (u16)(uiptr)exception_table; - } + cur_instruction |= ( cur_instruction == 0x8F5A0000 || cur_instruction == 0x8F7B0000 ) ? (u16)(uiptr)exception_table : 0; // cppcheck-suppress nullPointer dst_ptr[i] = cur_instruction; } @@ -190,10 +187,7 @@ static void update_exception_handler_table(void) for ( i = 0; i < (sizeof(exception_handlers) / sizeof(exception_handlers[0])); i += 1 ) { exception_handler = exception_handlers[i]; - if ( exception_handler ) - exception_table[i] = (exception_handler->info & 0xFFFFFFFC) + 8; - else - exception_table[i] = (uiptr)default_handler_funccode; + exception_table[i] = exception_handler ? ((exception_handler->info & 0xFFFFFFFC) + 8) : (uiptr)default_handler_funccode; } } diff --git a/iop/system/heaplib/src/heaplib.c b/iop/system/heaplib/src/heaplib.c index ae2f0ace8598..10cf88214ef7 100644 --- a/iop/system/heaplib/src/heaplib.c +++ b/iop/system/heaplib/src/heaplib.c @@ -132,9 +132,7 @@ void *heaplib_13_chunk_do_allocate(heaplib_chunk_t *chunk, unsigned int nbytes) if ( !chunk || chunk->chunk_validation_key != (((u8 *)chunk) - 1) ) return 0; - size_calc1 = nbytes + 7; - if ( nbytes < 8 ) - size_calc1 = 15; + size_calc1 = ( nbytes < 8 ) ? 15 : (nbytes + 7); chunkfrag_prev_1 = chunk->chunk_fragment_prev; size_calc2 = (size_calc1 >> 3) + 1; chunkfrag_prev_2 = chunk->chunk_fragment_prev; @@ -261,10 +259,7 @@ void *CreateHeap(int heapblocksize, int flag) if ( heap_new ) { heap_new->heap_validation_key = (((u8 *)heap_new) + 1); - if ( (flag & 1) != 0 ) - heap_new->size2free_flags = calc_size; - else - heap_new->size2free_flags = 0; + heap_new->size2free_flags = ( (flag & 1) != 0 ) ? calc_size : 0; heap_new->size2free_flags |= ((unsigned int)flag >> 1) & 1; linked_list_set_self(&heap_new->l); HeapPrepare(&heap_new->mem_chunk, calc_size - 16); @@ -329,8 +324,7 @@ void *AllocHeapMemory(void *heap_, size_t nbytes) if ( size2free_flags >= 4 ) { size_rounded = 2 * (size2free_flags >> 1); - if ( (int)(size_rounded - 40) < (int)(nbytes) ) - size_rounded = nbytes + 40; + size_rounded = ( (int)(size_rounded - 40) < (int)(nbytes) ) ? (nbytes + 40) : size_rounded; heap_new = (heaplib_ll_t *)AllocSysMemory(heap->size2free_flags & 1, size_rounded, 0); if ( heap_new ) { diff --git a/iop/system/intrman/src/intrman.c b/iop/system/intrman/src/intrman.c index 9eb81d42459e..021ca92e4883 100644 --- a/iop/system/intrman/src/intrman.c +++ b/iop/system/intrman/src/intrman.c @@ -140,15 +140,7 @@ int RegisterIntrHandler(int irq, int mode, int (*handler)(void *arg), void *arg) CpuResumeIntr(state); return KE_FOUND_HANDLER; } - if ( irq < IOP_IRQ_DMA_MDEC_IN || irq > IOP_IRQ_DMA_SIO2_OUT ) - { - intrman_internals.interrupt_handler_table[intr_handler_offset].handler = - (int (*)(void *arg))((uiptr)handler | (mode & 3)); - } - else - { - intrman_internals.interrupt_handler_table[intr_handler_offset].handler = handler; - } + intrman_internals.interrupt_handler_table[intr_handler_offset].handler = ( irq < IOP_IRQ_DMA_MDEC_IN || irq > IOP_IRQ_DMA_SIO2_OUT ) ? (int (*)(void *arg))((uiptr)handler | (mode & 3)) : handler; intrman_internals.interrupt_handler_table[intr_handler_offset].userdata = arg; CpuResumeIntr(state); return 0; @@ -415,11 +407,9 @@ int DisableIntr(int irq, int *res) if ( (dicr_tmp & (1 << (irq_index - 16))) != 0 ) { res_temp = irq_index; - if ( ((dicr_tmp >> (irq_index - 32)) & 1) != 0 ) - res_temp |= 0x100; + res_temp |= ( ((dicr_tmp >> (irq_index - 32)) & 1) != 0 ) ? 0x100 : 0; #ifndef BUILDING_INTRMANP - if ( iop_mmio_hwport->dmac2.dicr2 & (1 << (irq_index - 32)) ) - res_temp |= 0x200; + res_temp |= ( iop_mmio_hwport->dmac2.dicr2 & (1 << (irq_index - 32)) ) ? 0x200 : 0; #endif iop_mmio_hwport->dmac1.dicr1 = dicr_tmp & ~(1 << (irq_index - 16)); } @@ -435,8 +425,7 @@ int DisableIntr(int irq, int *res) if ( (dicr_tmp & (1 << (irq_index - 24))) != 0 ) { res_temp = irq_index; - if ( (dicr_tmp >> (irq_index - 33)) & 1 ) - res_temp |= 0x200; + res_temp |= ( (dicr_tmp >> (irq_index - 33)) & 1 ) ? 0x200 : 0; iop_mmio_hwport->dmac2.dicr2 = dicr_tmp & ~(1 << (irq_index - 24)); } else diff --git a/iop/system/ioman/src/ioman.c b/iop/system/ioman/src/ioman.c index 49c678cafc38..1d50299a44b1 100644 --- a/iop/system/ioman/src/ioman.c +++ b/iop/system/ioman/src/ioman.c @@ -94,11 +94,7 @@ static int open_tty_handles(void) io_close(0); io_close(1); result = io_open("tty00:", 3); - if (result == 0) - { - return io_open("tty00:", 2); - } - return result; + return (result == 0) ? io_open("tty00:", 2) : result; } static int setup_tty_device(int should_not_add_tty_device) @@ -243,10 +239,7 @@ static char * find_iop_device(const char *dev, int *unit, iop_io_device_t **devi if (unit) { int num; - num = 0; - if (isnum(canon[len])) { - num = strtol(canon + len, 0, 10); - } + num = (isnum(canon[len])) ? strtol(canon + len, 0, 10) : 0; *unit = num; } diff --git a/iop/system/iomanx/src/iomanX.c b/iop/system/iomanx/src/iomanX.c index 77ec3a485708..ed28283d7ac9 100644 --- a/iop/system/iomanx/src/iomanX.c +++ b/iop/system/iomanx/src/iomanX.c @@ -194,25 +194,13 @@ static inline void handle_result_pre(int in_result, iomanX_iop_file_t *f, int op static inline int handle_result(int in_result, iomanX_iop_file_t *f, int op) { handle_result_pre(in_result, f, op); - if ( in_result < 0 ) - return set_errno(-in_result); - if ( (op & HANDLE_RESULT_RETURN_ZERO) ) - return 0; - if ( (op & HANDLE_RESULT_RETURN_FD) ) - return f - file_table; - return in_result; + return ( in_result < 0 ) ? set_errno(-in_result) : (( (op & HANDLE_RESULT_RETURN_ZERO) ) ? 0 : (( (op & HANDLE_RESULT_RETURN_FD) ) ? (f - file_table) : in_result)); } static inline s64 handle_result64(s64 in_result, iomanX_iop_file_t *f, int op) { handle_result_pre(in_result, f, op); - if ( in_result < 0 ) - return set_errno(-(int)in_result); - if ( (op & HANDLE_RESULT_RETURN_ZERO) ) - return 0; - if ( (op & HANDLE_RESULT_RETURN_FD) ) - return f - file_table; - return in_result; + return ( in_result < 0 ) ? set_errno(-(int)in_result) : (( (op & HANDLE_RESULT_RETURN_ZERO) ) ? 0 : (( (op & HANDLE_RESULT_RETURN_FD) ) ? (f - file_table) : in_result)); } #ifdef IOMANX_ENABLE_LEGACY_IOMAN_HOOK @@ -328,20 +316,14 @@ int mode2modex(int mode) { int modex = 0; - if ( (mode & FIO_SO_IFLNK) != 0 ) - modex |= FIO_S_IFLNK; - if ( (mode & FIO_SO_IFREG) != 0 ) - modex |= FIO_S_IFREG; - if ( (mode & FIO_SO_IFDIR) != 0 ) - modex |= FIO_S_IFDIR; + modex |= ( (mode & FIO_SO_IFLNK) != 0 ) ? FIO_S_IFLNK : 0; + modex |= ( (mode & FIO_SO_IFREG) != 0 ) ? FIO_S_IFREG : 0; + modex |= ( (mode & FIO_SO_IFDIR) != 0 ) ? FIO_S_IFDIR : 0; /* Convert the file access modes. */ - if ( mode & FIO_SO_IROTH ) - modex |= FIO_S_IRUSR | FIO_S_IRGRP | FIO_S_IROTH; - if ( mode & FIO_SO_IWOTH ) - modex |= FIO_S_IWUSR | FIO_S_IWGRP | FIO_S_IWOTH; - if ( mode & FIO_SO_IXOTH ) - modex |= FIO_S_IXUSR | FIO_S_IXGRP | FIO_S_IXOTH; + modex |= ( mode & FIO_SO_IROTH ) ? (FIO_S_IRUSR | FIO_S_IRGRP | FIO_S_IROTH) : 0; + modex |= ( mode & FIO_SO_IWOTH ) ? (FIO_S_IWUSR | FIO_S_IWGRP | FIO_S_IWOTH) : 0; + modex |= ( mode & FIO_SO_IXOTH ) ? (FIO_S_IXUSR | FIO_S_IXGRP | FIO_S_IXOTH) : 0; return modex; } @@ -350,20 +332,14 @@ int modex2mode(int modex) { int mode = 0; - if ( (modex & FIO_S_IFLNK) != 0 ) - mode |= FIO_SO_IFLNK; - if ( (modex & FIO_S_IFREG) != 0 ) - mode |= FIO_SO_IFREG; - if ( (modex & FIO_S_IFDIR) != 0 ) - mode |= FIO_SO_IFDIR; + mode |= ( (modex & FIO_S_IFLNK) != 0 ) ? FIO_SO_IFLNK : 0; + mode |= ( (modex & FIO_S_IFREG) != 0 ) ? FIO_SO_IFREG : 0; + mode |= ( (modex & FIO_S_IFDIR) != 0 ) ? FIO_SO_IFDIR : 0; /* Convert the file access modes. */ - if ( modex & (FIO_S_IRUSR | FIO_S_IRGRP | FIO_S_IROTH) ) - mode |= FIO_SO_IROTH; - if ( modex & (FIO_S_IWUSR | FIO_S_IWGRP | FIO_S_IWOTH) ) - mode |= FIO_SO_IWOTH; - if ( modex & (FIO_S_IXUSR | FIO_S_IXGRP | FIO_S_IXOTH) ) - mode |= FIO_SO_IXOTH; + mode |= ( modex & (FIO_S_IRUSR | FIO_S_IRGRP | FIO_S_IROTH) ) ? FIO_SO_IROTH : 0; + mode |= ( modex & (FIO_S_IWUSR | FIO_S_IWGRP | FIO_S_IWOTH) ) ? FIO_SO_IWOTH : 0; + mode |= ( modex & (FIO_S_IXUSR | FIO_S_IXGRP | FIO_S_IXOTH) ) ? FIO_SO_IXOTH : 0; return mode; } @@ -423,9 +399,7 @@ void iomanX_StdioInit(int mode) static int open_tty_handles(const char *tty_name) { - if ( iomanX_open(tty_name, 3) != 0 || iomanX_open(tty_name, 2) != 1 ) - return -1; - return 0; + return ( iomanX_open(tty_name, 3) != 0 || iomanX_open(tty_name, 2) != 1 ) ? -1 : 0; } int iomanX_open(const char *name, int flags, ...) @@ -496,9 +470,7 @@ int iomanX_read(int fd, void *ptr, int size) iomanX_iop_file_t *f; f = get_iob(fd); - if ( !f || !(f->mode & FIO_O_RDONLY) ) - return handle_result(-EBADF, f, 0); - return handle_result(f->device->ops->read(f, ptr, size), f, 0); + return ( !f || !(f->mode & FIO_O_RDONLY) ) ? handle_result(-EBADF, f, 0) : handle_result(f->device->ops->read(f, ptr, size), f, 0); } int iomanX_write(int fd, void *ptr, int size) @@ -506,9 +478,7 @@ int iomanX_write(int fd, void *ptr, int size) iomanX_iop_file_t *f; f = get_iob(fd); - if ( !f || !(f->mode & FIO_O_WRONLY) ) - return handle_result(-EBADF, f, 0); - return handle_result(f->device->ops->write(f, ptr, size), f, 0); + return ( !f || !(f->mode & FIO_O_WRONLY) ) ? handle_result(-EBADF, f, 0) : handle_result(f->device->ops->write(f, ptr, size), f, 0); } int iomanX_close(int fd) @@ -516,9 +486,7 @@ int iomanX_close(int fd) iomanX_iop_file_t *f; f = get_iob(fd); - if ( !f ) - return handle_result(-EBADF, f, 0); - return handle_result( + return ( !f ) ? handle_result(-EBADF, f, 0) : handle_result( (f->mode & FIO_O_DIROPEN) ? f->device->ops->dclose(f) : f->device->ops->close(f), f, HANDLE_RESULT_CLEAR_INFO | HANDLE_RESULT_RETURN_FD); @@ -529,9 +497,7 @@ int iomanX_ioctl(int fd, int cmd, void *param) iomanX_iop_file_t *f; f = get_iob(fd); - if ( !f ) - return handle_result(-EBADF, f, 0); - return handle_result(f->device->ops->ioctl(f, cmd, param), f, 0); + return ( !f ) ? handle_result(-EBADF, f, 0) : handle_result(f->device->ops->ioctl(f, cmd, param), f, 0); } int iomanX_ioctl2(int fd, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen) @@ -539,12 +505,7 @@ int iomanX_ioctl2(int fd, int cmd, void *arg, unsigned int arglen, void *buf, un iomanX_iop_file_t *f; f = get_iob(fd); - if ( !f ) - return handle_result(-EBADF, f, 0); - // The filesystem must support these ops. - if ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) - return handle_result(-EUNSUP, f, 0); - return handle_result(f->device->ops->ioctl2(f, cmd, arg, arglen, buf, buflen), f, 0); + return ( !f ) ? handle_result(-EBADF, f, 0) : (/* The filesystem must support these ops. */( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) ? handle_result(-EUNSUP, f, 0) : handle_result(f->device->ops->ioctl2(f, cmd, arg, arglen, buf, buflen), f, 0)); } int iomanX_dopen(const char *path) @@ -615,9 +576,7 @@ int iomanX_remove(const char *name) return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); #endif parsefile_res = parsefile(name, &(f->device), &(f->unit)); - if ( !parsefile_res ) - return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - return handle_result( + return ( !parsefile_res ) ? handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : handle_result( f->device->ops->remove(f, parsefile_res), f, HANDLE_RESULT_CLEAR_INFO | HANDLE_RESULT_RETURN_ZERO); } @@ -723,9 +682,7 @@ int iomanX_format(const char *dev, const char *blockdev, void *arg, int arglen) return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); #endif parsefile_res = parsefile(dev, &(f->device), &(f->unit)); - if ( !parsefile_res ) - return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - return handle_result( + return ( !parsefile_res ) ? handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : handle_result( f->device->ops->format(f, parsefile_res, blockdev, arg, arglen), f, HANDLE_RESULT_CLEAR_INFO | HANDLE_RESULT_RETURN_ZERO); @@ -864,15 +821,10 @@ int iomanX_mount(const char *fsname, const char *devname, int flag, void *arg, i return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); #endif parsefile_res = parsefile(fsname, &(f->device), &(f->unit)); - if ( !parsefile_res ) - return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - // The filesystem must support these ops. - if ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) - return handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - return handle_result( - f->device->ops->mount(f, parsefile_res, devname, flag, arg, arglen), - f, - HANDLE_RESULT_CLEAR_INFO | HANDLE_RESULT_RETURN_ZERO); + return ( !parsefile_res ) ? handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : (/* The filesystem must support these ops. */ ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) ? handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : handle_result( + f->device->ops->mount(f, parsefile_res, devname, flag, arg, arglen), + f, + HANDLE_RESULT_CLEAR_INFO | HANDLE_RESULT_RETURN_ZERO)); } int iomanX_umount(const char *fsname) @@ -891,13 +843,8 @@ int iomanX_umount(const char *fsname) return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); #endif parsefile_res = parsefile(fsname, &(f->device), &(f->unit)); - if ( !parsefile_res ) - return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - // The filesystem must support these ops. - if ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) - return handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - return handle_result( - f->device->ops->umount(f, parsefile_res), f, HANDLE_RESULT_CLEAR_INFO | HANDLE_RESULT_RETURN_ZERO); + return ( !parsefile_res ) ? handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : (/* The filesystem must support these ops. */ ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) ? handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : handle_result( + f->device->ops->umount(f, parsefile_res), f, HANDLE_RESULT_CLEAR_INFO | HANDLE_RESULT_RETURN_ZERO)); } int iomanX_devctl(const char *name, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen) @@ -916,13 +863,8 @@ int iomanX_devctl(const char *name, int cmd, void *arg, unsigned int arglen, voi return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); #endif parsefile_res = parsefile(name, &(f->device), &(f->unit)); - if ( !parsefile_res ) - return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - // The filesystem must support these ops. - if ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) - return handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - return handle_result( - f->device->ops->devctl(f, parsefile_res, cmd, arg, arglen, buf, buflen), f, HANDLE_RESULT_CLEAR_INFO); + return ( !parsefile_res ) ? handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : (/* The filesystem must support these ops. */( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) ? handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : handle_result( + f->device->ops->devctl(f, parsefile_res, cmd, arg, arglen, buf, buflen), f, HANDLE_RESULT_CLEAR_INFO)); } int iomanX_readlink(const char *path, char *buf, unsigned int buflen) @@ -941,12 +883,7 @@ int iomanX_readlink(const char *path, char *buf, unsigned int buflen) return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); #endif parsefile_res = parsefile(path, &(f->device), &(f->unit)); - if ( !parsefile_res ) - return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - // The filesystem must support these ops. - if ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) - return handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR); - return handle_result(f->device->ops->readlink(f, parsefile_res, buf, buflen), f, HANDLE_RESULT_CLEAR_INFO); + return ( !parsefile_res ) ? handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : (/* The filesystem must support these ops. */ ( (f->device->type & 0xF0000000) != IOP_DT_FSEXT ) ? handle_result(-EUNSUP, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR) : handle_result(f->device->ops->readlink(f, parsefile_res, buf, buflen), f, HANDLE_RESULT_CLEAR_INFO)); } static int _ioabort(const char *str1, const char *str2) @@ -983,9 +920,7 @@ static iomanX_iop_file_t *new_iob(void) static iomanX_iop_file_t *get_iob(int fd) { - if ( (fd < 0) || (fd >= (int)(sizeof(file_table) / sizeof(file_table[0]))) || (!file_table[fd].device) ) - return NULL; - return &file_table[fd]; + return ( (fd < 0) || (fd >= (int)(sizeof(file_table) / sizeof(file_table[0]))) || (!file_table[fd].device) ) ? NULL : &file_table[fd]; } static iomanX_iop_device_t *lookup_dev(const char *name, int show_unkdev_msg) @@ -1211,9 +1146,7 @@ unsigned int iomanX_GetDevType(int fd) iomanX_iop_file_t *f; f = get_iob(fd); - if ( !f ) - return handle_result(-EBADF, f, 0); - return f->device->type; + return ( !f ) ? handle_result(-EBADF, f, 0) : f->device->type; } static void ShowDrv(void) diff --git a/iop/system/iomanx/src/ioman_sbv.c b/iop/system/iomanx/src/ioman_sbv.c index ade246be1c07..620255d4f514 100644 --- a/iop/system/iomanx/src/ioman_sbv.c +++ b/iop/system/iomanx/src/ioman_sbv.c @@ -41,14 +41,9 @@ static int smod_get_next_mod(ModuleInfo_t *cur_mod, ModuleInfo_t *next_mod) void *addr; /* If cur_mod is 0, return the head of the list (IOP address 0x800). */ - if (!cur_mod) { - addr = GetLoadcoreInternalData()->image_info; - } else { - if (!cur_mod->next) - return 0; - else - addr = cur_mod->next; - } + addr = !cur_mod ? GetLoadcoreInternalData()->image_info : cur_mod->next; + if (!addr) + return 0; memcpy(next_mod, addr, sizeof(ModuleInfo_t)); return next_mod->id; diff --git a/iop/system/iopmgr/src/devices.c b/iop/system/iopmgr/src/devices.c index b8dbf346ac98..ba536d1e0543 100644 --- a/iop/system/iopmgr/src/devices.c +++ b/iop/system/iopmgr/src/devices.c @@ -183,9 +183,5 @@ iop_device_t *iopmgr_get_device(char *device) */ int iopmgr_get_devicetype(char *device) { - if (iopmgr_get_iomandev(device) != NULL) - return(IOPMGR_DEVTYPE_IOMAN); - if (iopmgr_get_iomanxdev(device) != NULL) - return(IOPMGR_DEVTYPE_IOMANX); - return IOPMGR_DEVTYPE_INVALID; + return (iopmgr_get_iomandev(device) != NULL) ? IOPMGR_DEVTYPE_IOMAN : ((iopmgr_get_iomanxdev(device) != NULL) ? IOPMGR_DEVTYPE_IOMANX : IOPMGR_DEVTYPE_INVALID); } diff --git a/iop/system/iopmgr/src/main.c b/iop/system/iopmgr/src/main.c index 8b09f7bc9caf..67960e731112 100644 --- a/iop/system/iopmgr/src/main.c +++ b/iop/system/iopmgr/src/main.c @@ -50,14 +50,7 @@ int _start(int argc, char *argv[]) if (argc > 1) { /* Execute in command line mode, so parse command */ - if(argc>2) - { - cmdline_handle(argv[1],argv[2]); - } - else - { - cmdline_handle(argv[1],NULL); - } + cmdline_handle(argv[1],(argc>2) ? argv[2] : NULL); } else { /* no params, so set into resident mode */ diff --git a/iop/system/iopmgr/src/slib.c b/iop/system/iopmgr/src/slib.c index bb05c8ed0563..a55c5e9ab433 100644 --- a/iop/system/iopmgr/src/slib.c +++ b/iop/system/iopmgr/src/slib.c @@ -64,9 +64,7 @@ void *slib_get_exportlist_by_name(const char *name) iop_library_t *libptr; libptr = slib_get_lib_by_name(name); - if (libptr != 0) - return libptr->exports; - return 0; + return (libptr != 0) ? libptr->exports : 0; } /** Get version number for named library. @@ -84,9 +82,7 @@ int slib_get_version_by_name(const char *name) iop_library_t *libptr; libptr = slib_get_lib_by_name(name); - if (libptr != 0) - return (int)libptr->version; - return 0; + return (libptr != 0) ? (int)libptr->version : 0; } /** Release (Unregister) a given named registered library. @@ -105,7 +101,5 @@ int slib_release_library(const char *name) struct irx_export_table *libptr; libptr = (struct irx_export_table *)slib_get_lib_by_name(name); - if (libptr != 0) - return ReleaseLibraryEntries(libptr); - return -2; + return (libptr != 0) ? ReleaseLibraryEntries(libptr) : -2; } diff --git a/iop/system/iopmgr/src/smod.c b/iop/system/iopmgr/src/smod.c index 56ba02328c49..c5d06c38f21d 100644 --- a/iop/system/iopmgr/src/smod.c +++ b/iop/system/iopmgr/src/smod.c @@ -39,15 +39,7 @@ ModuleInfo_t *smod_get_next_mod(ModuleInfo_t *cur_mod) { /* If cur_mod is 0, return the head of the list. */ - if (!cur_mod) { - return GetLoadcoreInternalData()->image_info; - } else { - if (!cur_mod->next) - return 0; - else - return cur_mod->next; - } - return 0; + return (!cur_mod) ? GetLoadcoreInternalData()->image_info : ((!cur_mod->next) ? 0 : cur_mod->next); } /** Get pointer to module structure for named module. @@ -116,10 +108,7 @@ int smod_get_modversion_by_name(const char *name) { ModuleInfo_t *modptr = 0; modptr = smod_get_mod_by_name(name); - if (modptr != 0) - return (int)modptr->version; - else - return -1; + return (modptr != 0) ? (int)modptr->version : -1; } /** Unload the named module. diff --git a/iop/system/loadcore/src/loadcore.c b/iop/system/loadcore/src/loadcore.c index 4a2c22d831a1..2bc26ce6372e 100644 --- a/iop/system/loadcore/src/loadcore.c +++ b/iop/system/loadcore/src/loadcore.c @@ -289,8 +289,6 @@ void loadcore_init(boot_params *in_params) void *curmodaddr_align; elf_header_t **cur_module_addr; int executable_type; - int memalloctype; - void *memallocaddr; int entrypoint_ret; ModuleInfo_t *mi; int *frame_pointer_curfunc; @@ -430,9 +428,7 @@ void loadcore_init(boot_params *in_params) { iop_init_entry_t next; - next.callback = (void *)*stack_reboot_handlers; - if ( i == 3 ) - next.callback = (void *)*reboot_handler_ptr; + next.callback = ( i == 3 ) ? (void *)*reboot_handler_ptr : (void *)*stack_reboot_handlers; SetGP((void *)reboot_handler_ptr[1]); ((BootupCallback_t)(*reboot_handler_ptr & (~3)))(&next, 1); } @@ -465,17 +461,7 @@ void loadcore_init(boot_params *in_params) executable_type = ProbeExecutableObject(*cur_module_addr, &fi); if ( executable_type == IOP_MOD_TYPE_IRX ) { - if ( curmodaddr_align ) - { - memalloctype = 2; - memallocaddr = curmodaddr_align; - } - else - { - memalloctype = 0; - memallocaddr = 0; - } - fi.text_start = AllocSysMemory(memalloctype, fi.MemSize + 0x30, memallocaddr); + fi.text_start = AllocSysMemory(curmodaddr_align ? 2 : 0, fi.MemSize + 0x30, curmodaddr_align); if ( !fi.text_start ) break; fi.text_start = (char *)fi.text_start + 0x30; @@ -498,8 +484,7 @@ void loadcore_init(boot_params *in_params) { RegisterModule(mi); mi->newflags = 3; - if ( (entrypoint_ret & 3) == 2 ) - mi->newflags |= 0x10; + mi->newflags |= ( (entrypoint_ret & 3) == 2 ) ? 0x10 : 0; if ( (entrypoint_ret & (~3)) != 0 ) AddRebootNotifyHandler((BootupCallback_t)(entrypoint_ret & (~3)), 2, 0); } @@ -968,9 +953,7 @@ static int CheckCallerStub(const struct irx_import_table *imp) { stubs += 2; } - if ( stubs[0] || stubs[1] ) - return 0; - return (const void **)(imp->stubs) < stubs; + return ( stubs[0] || stubs[1] ) ? 0 : ((const void **)(imp->stubs) < stubs); } static int aLinkLibEntries(struct irx_import_table *imp) @@ -1110,29 +1093,20 @@ static void lc_memmove(char *dst, const char *src, int len) static int cCpuSuspendIntr(int *state) { intrman_callbacks_t *intrman_callbacks = (intrman_callbacks_t *)(loadcore_internals.intr_suspend_tbl); - if ( intrman_callbacks && intrman_callbacks->cbCpuSuspendIntr ) - return intrman_callbacks->cbCpuSuspendIntr(state); - else - return 0; + return ( intrman_callbacks && intrman_callbacks->cbCpuSuspendIntr ) ? intrman_callbacks->cbCpuSuspendIntr(state) : 0; } static int cCpuResumeIntr(int state) { intrman_callbacks_t *intrman_callbacks = (intrman_callbacks_t *)(loadcore_internals.intr_suspend_tbl); - if ( intrman_callbacks && intrman_callbacks->cbCpuResumeIntr ) - return intrman_callbacks->cbCpuResumeIntr(state); - else - return 0; + return ( intrman_callbacks && intrman_callbacks->cbCpuResumeIntr ) ? intrman_callbacks->cbCpuResumeIntr(state) : 0; } #if 0 static int cQueryIntrContext(void) { intrman_callbacks_t *intrman_callbacks = (intrman_callbacks_t *)(loadcore_internals.intr_suspend_tbl); - if ( intrman_callbacks && intrman_callbacks->cbQueryIntrContext ) - return intrman_callbacks->cbQueryIntrContext(); - else - return 0; + return ( intrman_callbacks && intrman_callbacks->cbQueryIntrContext ) ? intrman_callbacks->cbQueryIntrContext() : 0; } #endif diff --git a/iop/system/loadfile/src/eeelfloader.c b/iop/system/loadfile/src/eeelfloader.c index d14389f0d71f..65cc4eabd08f 100644 --- a/iop/system/loadfile/src/eeelfloader.c +++ b/iop/system/loadfile/src/eeelfloader.c @@ -27,10 +27,7 @@ static int *allocate_heap_buffer(unsigned int lower_bound, unsigned int upper_bo upper_bound_rounded = upper_bound; // Align to 4 bytes - if ( (upper_bound_rounded & 3) != 0 ) - { - upper_bound_rounded += (4 - (upper_bound_rounded & 3)); - } + upper_bound_rounded += ( (upper_bound_rounded & 3) != 0 ) ? (4 - (upper_bound_rounded & 3)) : 0; CpuSuspendIntr(&state); heap_buffer_base = AllocSysMemory(ALLOC_LAST, upper_bound_rounded, NULL); CpuResumeIntr(state); @@ -50,10 +47,7 @@ static void *elf_load_alloc_buffer_from_heap(u32 alloc_size) alloc_size_rounded = alloc_size; // Align to 4 bytes - if ( (alloc_size & 3) != 0 ) - { - alloc_size_rounded += (4 - (alloc_size & 3)); - } + alloc_size_rounded += ( (alloc_size & 3) != 0 ) ? (4 - (alloc_size & 3)) : 0; // Validity check... { u8 *new_ptr; @@ -119,60 +113,12 @@ static int check_elf_header(const loadfile_elf32_ehdr_t **pehdr) const loadfile_elf32_ehdr_t *ehdr; ehdr = *pehdr; - if ( ehdr->e_ident[0] != '\x7F' ) - { - return -1; - } - if ( ehdr->e_ident[1] != 'E' ) - { - return -1; - } - if ( ehdr->e_ident[2] != 'L' ) - { - return -1; - } - if ( ehdr->e_ident[3] != 'F' ) - { - return -1; - } - return 0; + return ( ehdr->e_ident[0] != '\x7F' || ehdr->e_ident[1] != 'E' || ehdr->e_ident[2] != 'L' || ehdr->e_ident[3] != 'F' ) ? -1 : 0; } static int check_elf_architecture(const loadfile_file_load_handler_struct_t *flhs) { - if ( flhs->elf_header.e_ident[4] != 1 ) - { - return -1; - } - if ( flhs->elf_header.e_ident[5] != 1 ) - { - return -2; - } - if ( flhs->elf_header.e_type != 2 ) - { - return -3; - } - if ( flhs->elf_header.e_machine != 8 ) - { - return -4; - } - if ( flhs->elf_header.e_ehsize != 52 ) - { - return -5; - } - if ( flhs->elf_header.e_phentsize != 32 ) - { - return -6; - } - if ( !flhs->elf_header.e_shnum ) - { - return 1; - } - if ( flhs->elf_header.e_shentsize != 40 ) - { - return -7; - } - return 1; + return ( flhs->elf_header.e_ident[4] != 1 ) ? -1 : (( flhs->elf_header.e_ident[5] != 1 ) ? -2 : (( flhs->elf_header.e_type != 2 ) ? -3 : (( flhs->elf_header.e_machine != 8 ) ? -4 : (( flhs->elf_header.e_ehsize != 52 ) ? -5 : (( flhs->elf_header.e_phentsize != 32 ) ? -6 : (( flhs->elf_header.e_shnum && flhs->elf_header.e_shentsize != 40 ) ? -7 : 1)))))); } static int @@ -386,9 +332,7 @@ static int elf_load_proc( } } sh_size_for_offset = sh_offset_total - rbc->buffer_offset; - sh_size_for_alignment = sh_size_cur; - if ( rbc->buffer_length - sh_size_for_offset < sh_size_cur ) - sh_size_for_alignment = rbc->buffer_length - sh_size_for_offset; + sh_size_for_alignment = ( rbc->buffer_length - sh_size_for_offset < sh_size_cur ) ? (rbc->buffer_length - sh_size_for_offset) : sh_size_cur; dmat.src = &rbc->buffer_base[sh_size_for_offset]; sh_size_cur -= sh_size_for_alignment; dmat.size = sh_size_for_alignment; @@ -472,9 +416,7 @@ static int elf_load_single_section( for ( i = allocate_info; sh_offset_total >= (u32)(allocate_info->read_buffer_offset); i = allocate_info ) fileio_reader_function(flhs->fd, i, 0); sh_size_for_offset = sh_offset_total - rbc->buffer_offset; - sh_size_for_alignment = sh_size; - if ( rbc->buffer_length - sh_size_for_offset < sh_size ) - sh_size_for_alignment = rbc->buffer_length - sh_size_for_offset; + sh_size_for_alignment = ( rbc->buffer_length - sh_size_for_offset < sh_size ) ? (rbc->buffer_length - sh_size_for_offset) : sh_size; dmat.src = &rbc->buffer_base[sh_size_for_offset]; sh_size -= sh_size_for_alignment; dmat.size = sh_size_for_alignment; @@ -660,19 +602,11 @@ static int elf_load_common( int loadfile_elfload_innerproc( const char *filename, int epc, const char *section_name, int *result_out, int *result_module_out) { - if ( IsIllegalBootDevice(filename) != 0 ) - { - return KE_ILLEGAL_OBJECT; - } - return elf_load_common(filename, epc, section_name, result_out, result_module_out, 0); + return ( IsIllegalBootDevice(filename) != 0 ) ? KE_ILLEGAL_OBJECT : elf_load_common(filename, epc, section_name, result_out, result_module_out, 0); } int loadfile_mg_elfload_proc( const char *filename, int epc, const char *section_name, int *result_out, int *result_module_out) { - if ( strcmp(section_name, "all") != 0 ) - { - return KE_ILLEGAL_MODE; - } - return elf_load_common(filename, epc, section_name, result_out, result_module_out, 1); + return ( strcmp(section_name, "all") != 0 ) ? KE_ILLEGAL_MODE : elf_load_common(filename, epc, section_name, result_out, result_module_out, 1); } diff --git a/iop/system/loadfile/src/loadfile.c b/iop/system/loadfile/src/loadfile.c index 1bbe9749fa76..17433314c14a 100644 --- a/iop/system/loadfile/src/loadfile.c +++ b/iop/system/loadfile/src/loadfile.c @@ -103,14 +103,13 @@ static int *loadfile_elfload(const struct _lf_elf_load_arg *in_packet, int lengt if ( outbuffer[0] >= 0 ) { outbuffer[2] = 0; - outbuffer[0] = result_out; outbuffer[1] = result_module_out; } else { outbuffer[3] = outbuffer[0]; - outbuffer[0] = 0; } + outbuffer[0] = ( outbuffer[0] >= 0 ) ? result_out : 0; } return outbuffer; } @@ -188,13 +187,9 @@ static int *loadfile_mg_elfload(const struct _lf_elf_load_arg *in_packet, int le if ( outbuffer[0] >= 0 ) { outbuffer[2] = 0; - outbuffer[0] = result_out; outbuffer[1] = result_module_out; } - else - { - outbuffer[0] = 0; - } + outbuffer[0] = ( outbuffer[0] >= 0 ) ? result_out : 0; return outbuffer; } @@ -206,14 +201,7 @@ static int *loadfile_loadmodulebuffer(const struct _lf_module_buffer_load_arg *i (void)length; ModuleBuffer = LoadModuleBuffer(in_packet->p.ptr); - if ( ModuleBuffer >= 0 ) - { - outbuffer[0] = StartModule(ModuleBuffer, "LBbyEE", in_packet->q.arg_len, in_packet->args, &outbuffer[1]); - } - else - { - outbuffer[0] = ModuleBuffer; - } + outbuffer[0] = ( ModuleBuffer >= 0 ) ? StartModule(ModuleBuffer, "LBbyEE", in_packet->q.arg_len, in_packet->args, &outbuffer[1]) : ModuleBuffer; return outbuffer; } diff --git a/iop/system/modload/src/modload.c b/iop/system/modload/src/modload.c index d2081a5aa7ab..e33ced550c16 100644 --- a/iop/system/modload/src/modload.c +++ b/iop/system/modload/src/modload.c @@ -378,9 +378,7 @@ int LoadModuleWithOption(const char *filename, const LMWOoption *option) mltargs.access = option->access & 0xFF; mltargs.distaddr = option->distaddr; mltargs.distoffset = option->distoffset; - functable = option->functable; - if ( !functable ) - functable = &default_filefunc_functable; + functable = option->functable ? option->functable : &default_filefunc_functable; mltargs.functable = functable; mltargs.funcopt = option->funcopt; return ModuleLoaderThread(&mltargs); @@ -391,10 +389,7 @@ int LoadModuleAddress(const char *name, void *addr, int offset) module_thread_args_t mltargs; mltargs.command = 0; - if ( addr ) - mltargs.position = 2; - else - mltargs.position = 0; + mltargs.position = addr ? 2 : 0; mltargs.access = 1; mltargs.filename = name; mltargs.buffer = 0; @@ -415,10 +410,7 @@ int LoadModuleBufferAddress(void *buffer, void *addr, int offset) module_thread_args_t mltargs; mltargs.command = 2; - if ( addr ) - mltargs.position = 2; - else - mltargs.position = 0; + mltargs.position = addr ? 2 : 0; mltargs.buffer = buffer; mltargs.access = 0; mltargs.filename = 0; @@ -594,9 +586,7 @@ int SearchModuleByName(const char *name) modid = i->id; } CpuResumeIntr(state); - if ( !modid ) - return KE_UNKNOWN_MODULE; - return modid; + return ( !modid ) ? KE_UNKNOWN_MODULE : modid; } int SearchModuleByAddress(const void *addr) @@ -607,9 +597,7 @@ int SearchModuleByAddress(const void *addr) CpuSuspendIntr(&state); image_info = SearchModuleCBByAddr((void *)addr); CpuResumeIntr(state); - if ( !image_info ) - return KE_UNKNOWN_MODULE; - return image_info->id; + return ( !image_info ) ? KE_UNKNOWN_MODULE : image_info->id; } int LoadStartKelfModule(const char *name, int arglen, const char *args, int *result) @@ -649,15 +637,8 @@ int LoadStartKelfModule(const char *name, int arglen, const char *args, int *res { iop_exec_buffer = SecrDiskBootFile_func_ptr(iop_exec_encrypted_buffer); } - ret_tmp = KE_ILLEGAL_OBJECT; - if ( iop_exec_buffer ) - { - ret_tmp = LoadModuleBuffer(iop_exec_buffer); - } - if ( ret_tmp > 0 ) - { - ret_tmp = StartModule(ret_tmp, name, arglen, args, result); - } + ret_tmp = ( iop_exec_buffer ) ? LoadModuleBuffer(iop_exec_buffer) : KE_ILLEGAL_OBJECT; + ret_tmp = ( ret_tmp > 0 ) ? StartModule(ret_tmp, name, arglen, args, result) : ret_tmp; CpuSuspendIntr(&state); FreeSysMemory(iop_exec_encrypted_buffer); CpuResumeIntr(state); @@ -811,18 +792,7 @@ static void ExecModuleLoad(void *userdata) default: break; } - if ( res_tmp ) - { - *mltargs->ret_ptr = res_tmp; - } - else if ( !mi ) - { - *mltargs->ret_ptr = KE_UNKNOWN_MODULE; - } - else - { - *mltargs->ret_ptr = mi->id; - } + *mltargs->ret_ptr = res_tmp ? res_tmp : (!mi ? KE_UNKNOWN_MODULE : mi->id); if ( mltargs->thread_ef ) { ChangeThreadPriority(0, 1); @@ -1148,9 +1118,7 @@ stop_module(ModuleInfo_t *module_info, int command, int modid_2, int arglen, con return KE_NOT_REMOVABLE; if ( command == 4 && modid_2 == module_info->id ) return KE_CAN_NOT_STOP; - data = "self"; - if ( command == 4 ) - data = "other"; + data = ( command == 4 ) ? "other" : "self"; in_argc = 1; data_strlen = strlen(data) + 1; in_argv_size_strs = data_strlen; @@ -1180,8 +1148,7 @@ stop_module(ModuleInfo_t *module_info, int command, int modid_2, int arglen, con module_info->newflags &= 0xFFF0u; module_info->newflags |= 4; - if ( command != 4 ) - module_info->newflags |= 1; + module_info->newflags |= ( command != 4 ) ? 1 : 0; // TODO: save/restore gp register module_result = ((int (*)(int argc, char **argv, elf_header_t **eh, ModuleInfo_t *mi))module_info->entry)(-in_argc, in_argv_ptrs, 0, module_info); @@ -1199,8 +1166,7 @@ stop_module(ModuleInfo_t *module_info, int command, int modid_2, int arglen, con case 1: { module_info->newflags |= 6; - if ( command != 4 ) - module_info->newflags |= 1; + module_info->newflags |= ( command != 4 ) ? 1 : 0; break; } case 2: @@ -1370,14 +1336,12 @@ do_load_seek(module_thread_args_t *mltargs, int module_fd, FileInfo_t *fi, int * fi->EntryPoint = &relocate_offset[(u32)(u8 *)fi->EntryPoint]; fi->gp = &relocate_offset[(u32)(u8 *)fi->gp]; mod_id = fi->mod_id; - if ( mod_id != (IopModuleID_t *)-1 ) - fi->mod_id = (IopModuleID_t *)&relocate_offset[(u32)(u8 *)mod_id]; + fi->mod_id = ( mod_id != (IopModuleID_t *)-1 ) ? (IopModuleID_t *)&relocate_offset[(u32)(u8 *)mod_id] : mod_id; size = 0; for ( i = 1; i < lshdr.elfhdr.shnum; i += 1 ) { type = elfshdr[i].type; - if ( (type == 9 || type == 4) && size < elfshdr[i].size ) - size = elfshdr[i].size; + size = ( (type == 9 || type == 4) && size < elfshdr[i].size ) ? elfshdr[i].size : size; } switch ( mltargs->access ) { @@ -1434,10 +1398,7 @@ do_load_seek(module_thread_args_t *mltargs, int module_fd, FileInfo_t *fi, int * for ( j = 0; j < shdrcnt; j += relnumi1 ) { relnumi1 = 1; - if ( (elfrelhdr[0].info & 0xFF) == 5 || (elfrelhdr[0].info & 0xFF) == 250 ) - { - relnumi1 += 1; - } + relnumi1 += ( (elfrelhdr[0].info & 0xFF) == 5 || (elfrelhdr[0].info & 0xFF) == 250 ) ? 1 : 0; { int k; for ( k = 0; k < relnumi1; k += 1 ) @@ -1666,9 +1627,7 @@ static int load_memory_helper_cmpinner(modload_ll_t *a1, int a2, modload_ll_t *a } v4 = (char *)a1 + a2; v6 = v4 - 1; - if ( v6 < (char *)a3 ) - return 0; - return v6 < (char *)a4 + (int)a3; + return ( v6 < (char *)a3 ) ? 0 : (v6 < (char *)a4 + (int)a3); } static modload_ll_t * @@ -1734,10 +1693,7 @@ static int allocate_module_block( allocaddr1 = (char *)(((unsigned int)(text_start_tmp - 0x30) >> 8 << 8) & 0x1FFFFFFF); if ( AllocSysMemory(2, &text_start_tmp[fi->MemSize] - allocaddr1, allocaddr1) != 0 ) return 1; - if ( (int)QueryBlockTopAddress(allocaddr1) <= 0 ) - *result_out = KE_NO_MEMORY; - else - *result_out = KE_MEMINUSE; + *result_out = ( (int)QueryBlockTopAddress(allocaddr1) <= 0 ) ? KE_NO_MEMORY : KE_MEMINUSE; return 0; } case 4: @@ -1758,14 +1714,7 @@ static int allocate_module_block( { modload_load_memory_t *allocaddr2; - if ( memalloctype == 2 ) - { - allocaddr2 = loadmem; - } - else - { - allocaddr2 = 0; - } + allocaddr2 = ( memalloctype == 2 ) ? loadmem : 0; fi->text_start = AllocSysMemory(memalloctype, fi->MemSize + 0x30, allocaddr2); } if ( !fi->text_start ) @@ -2066,20 +2015,14 @@ static void TerminateResidentEntriesDI(const char *command, unsigned int options char *command_ptr; iopboot_entrypoint = GetFileDataFromImage((const void *)0xBFC00000, (const void *)0xBFC10000, "IOPBOOT"); + ram_size_in_mb = (QueryMemSize() + 0x100) >> 20; // Unofficial: Check if command is NULL befire checking its contents - if ( command && command[0] ) - { - ml_strcpy((char *)0x480, command); - ram_size_in_mb = (QueryMemSize() + 0x100) >> 20; - flagstmp = (options & 0xFF00) | 2; - command_ptr = (char *)0x480; - } - else + command_ptr = ( command && command[0] ) ? (char *)0x480 : 0; + if ( command_ptr ) { - ram_size_in_mb = (QueryMemSize() + 0x100) >> 20; - flagstmp = 1; - command_ptr = 0; + ml_strcpy(command_ptr, command); } + flagstmp = command_ptr ? ((options & 0xFF00) | 2) : 1; ((int (*)(u32 ram_mb, int flags, char *cmdptr, u32 xunk))iopboot_entrypoint)(ram_size_in_mb, flagstmp, command_ptr, 0); } } diff --git a/iop/system/msifrpc/src/msifrpc.c b/iop/system/msifrpc/src/msifrpc.c index 9b87927dbc4d..6e4d0410e009 100644 --- a/iop/system/msifrpc/src/msifrpc.c +++ b/iop/system/msifrpc/src/msifrpc.c @@ -391,10 +391,7 @@ static void sif_cmdh_unbindrpc_8000001D(struct msif_cmd_unbindrpc_8000001D *data static void sif_cmdh_callrpc_8000001A(struct msif_cmd_callrpc_8000001A *data, struct msif_data *harg) { (void)harg; - if ( data->m_sd->base->start ) - data->m_sd->base->end->next = data->m_sd; - else - data->m_sd->base->start = data->m_sd; + *(data->m_sd->base->start ? &(data->m_sd->base->end->next) : &(data->m_sd->base->start)) = data->m_sd; data->m_sd->base->end = data->m_sd; data->m_sd->paddr = data->m_paddr; data->m_sd->client = data->m_cd; @@ -502,10 +499,7 @@ static struct _sifm_serve_data *do_msif_get_next_request(sceSifMQueueData *qd) CpuSuspendIntr(&state); start = qd->start; qd->active = start ? 1 : 0; - if ( start ) - { - qd->start = start->next; - } + qd->start = start ? start->next : start; CpuResumeIntr(state); return start; } @@ -518,10 +512,8 @@ static void do_msif_exec_request(sceSifMServeData *sd) int adddmat; int state; - size_extra = 0; sentry_ret = sd->sentry->func(sd->fno, sd->func_buff, sd->size); - if ( sentry_ret ) - size_extra = sd->rsize; + size_extra = ( sentry_ret ) ? sd->rsize : 0; CpuSuspendIntr(&state); fpacket2 = (sd->rid & 4) ? (SifMRpcRendPkt_t *)sif_mrpc_get_fpacket2(&g_msif_data, (sd->rid >> 16) & 0xFFFF) : (SifMRpcRendPkt_t *)sif_mrpc_get_fpacket(&g_msif_data); @@ -773,10 +765,7 @@ int sceSifMTermRpc(int request, int flags) } if ( cur_entry ) { - if ( tmp_entry ) - tmp_entry->next = cur_entry->next; - else - g_msif_data.g_mserv_entries_ll = cur_entry->next; + *(tmp_entry ? &(tmp_entry->next) : &(g_msif_data.g_mserv_entries_ll)) = cur_entry->next; } CpuResumeIntr(state); if ( cur_entry ) diff --git a/iop/system/sifcmd/src/sifcmd.c b/iop/system/sifcmd/src/sifcmd.c index 15954909c39a..026521cff2dd 100644 --- a/iop/system/sifcmd/src/sifcmd.c +++ b/iop/system/sifcmd/src/sifcmd.c @@ -76,13 +76,9 @@ sif_cmd_data_t *sif_cmd_get_internal_data() static void sif_sys_cmd_handler_init_from_ee(const SifCmdChgAddrData_t *pkt, sif_cmd_data_t *sci) { - if ( pkt->header.opt ) + iSetEventFlag(sci->ef, pkt->header.opt ? 0x800u : 0x100u); + if ( !pkt->header.opt ) { - iSetEventFlag(sci->ef, 0x800u); - } - else - { - iSetEventFlag(sci->ef, 0x100u); sceSifSetMSFlag(SIF_STAT_CMDINIT); sci->sif_send_eebuf = pkt->newaddr; } @@ -195,24 +191,13 @@ void sceSifSetSysCmdBuffer(SifCmdSysHandlerData_t *db, int size) void sceSifAddCmdHandler(int cid, SifCmdHandler_t handler, void *harg) { - if ( cid >= 0 ) - { - sif_cmd_data.usr_cmd_handlers[cid].handler = handler; - sif_cmd_data.usr_cmd_handlers[cid].harg = harg; - } - else - { - sif_cmd_data.sys_cmd_handlers[cid + (cid & 0x7FFFFFFF)].handler = handler; - sif_cmd_data.sys_cmd_handlers[cid + (cid & 0x7FFFFFFF)].harg = harg; - } + *(( cid >= 0 ) ? &(sif_cmd_data.usr_cmd_handlers[cid].handler) : &(sif_cmd_data.sys_cmd_handlers[cid + (cid & 0x7FFFFFFF)].handler)) = handler; + *(( cid >= 0 ) ? &(sif_cmd_data.usr_cmd_handlers[cid].harg) : &(sif_cmd_data.sys_cmd_handlers[cid + (cid & 0x7FFFFFFF)].harg)) = harg; } void sceSifRemoveCmdHandler(int cid) { - if ( cid >= 0 ) - sif_cmd_data.usr_cmd_handlers[cid].handler = NULL; - else - sif_cmd_data.sys_cmd_handlers[cid + (cid & 0x7FFFFFFF)].handler = NULL; + *(( cid >= 0 ) ? &(sif_cmd_data.usr_cmd_handlers[cid].handler) : &(sif_cmd_data.sys_cmd_handlers[cid + (cid & 0x7FFFFFFF)].handler)) = NULL; } static int sif_send_cmd_common( @@ -230,7 +215,7 @@ static int sif_send_cmd_common( SifDmaTransfer_t *dmatp; int dmatc2; int sif_send_eebuf; - unsigned int dmar1; + SifDmaTransfer_t dmat[2]; int state; @@ -269,24 +254,17 @@ static int sif_send_cmd_common( dmatp->dest = (void *)sif_send_eebuf; if ( (flags & 1) != 0 ) { - if ( (flags & 8) != 0 ) - return sceSifSetDmaIntr(dmat, dmatc2, completion_cb, completion_cb_userdata); - else - return sceSifSetDma(dmat, dmatc2); + return ( (flags & 8) != 0 ) ? sceSifSetDmaIntr(dmat, dmatc2, completion_cb, completion_cb_userdata) : sceSifSetDma(dmat, dmatc2); } else { - unsigned int dmar2; + unsigned int dmar1; CpuSuspendIntr(&state); - if ( (flags & 8) != 0 ) - dmar2 = sceSifSetDmaIntr(dmat, dmatc2, completion_cb, completion_cb_userdata); - else - dmar2 = sceSifSetDma(dmat, dmatc2); - dmar1 = dmar2; + dmar1 = ( (flags & 8) != 0 ) ? sceSifSetDmaIntr(dmat, dmatc2, completion_cb, completion_cb_userdata) : sceSifSetDma(dmat, dmatc2); CpuResumeIntr(state); + return dmar1; } - return dmar1; } unsigned int sceSifSendCmd(int cid, void *packet, int packet_size, void *src_extra, void *dest_extra, int size_extra) @@ -380,10 +358,8 @@ static int sif_cmd_int_handler(void *userdata) return 1; } *(u8 *)pktbuf1 = 0; - size_calc1 = size + 3; pktbuf2 = pktbuf1; - if ( size + 3 < 0 ) - size_calc1 = size + 6; + size_calc1 = ( size + 3 < 0 ) ? (size + 6) : (size + 3); pktwords = size_calc1 >> 2; i = 0; tmpbuf1[2] = 0; diff --git a/iop/system/sifcmd/src/sifrpc.c b/iop/system/sifcmd/src/sifrpc.c index bae86e33c2b5..f44770e4a4ad 100644 --- a/iop/system/sifcmd/src/sifrpc.c +++ b/iop/system/sifcmd/src/sifrpc.c @@ -185,10 +185,7 @@ static void *sif_rpc_get_fpacket(sif_rpc_data_t *rpc_data) static void *sif_rpc_get_fpacket2(sif_rpc_data_t *rpc_data, int rid) { - if ( rid >= 0 && rid < rpc_data->client_table_len ) - return &rpc_data->client_table[64 * rid]; - else - return sif_rpc_get_fpacket(rpc_data); + return ( rid >= 0 && rid < rpc_data->client_table_len ) ? &rpc_data->client_table[64 * rid] : sif_rpc_get_fpacket(rpc_data); } static void sif_cmd_handler_end(SifRpcRendPkt_t *data, sif_rpc_data_t *harg) @@ -227,9 +224,7 @@ static unsigned int sif_cmd_handler_rdata_alarm_retry(void *userdata) SifRpcRendPkt_t *a1; a1 = (SifRpcRendPkt_t *)userdata; - if ( isceSifSendCmd(SIF_CMD_RPC_END, a1, 64, a1->sd, a1->buf, (int)a1->cbuf) != 0 ) - return 0; - return 0xF000; + return ( isceSifSendCmd(SIF_CMD_RPC_END, a1, 64, a1->sd, a1->buf, (int)a1->cbuf) != 0 ) ? 0 : 0xF000; } static void sif_cmd_handler_rdata(SifRpcOtherDataPkt_t *data, sif_rpc_data_t *harg) @@ -240,10 +235,7 @@ static void sif_cmd_handler_rdata(SifRpcOtherDataPkt_t *data, sif_rpc_data_t *ha iop_sys_clock_t clk; rec_id = data->rec_id; - if ( (rec_id & 4) != 0 ) - fpacket2 = (SifRpcRendPkt_t *)sif_rpc_get_fpacket2(harg, (rec_id >> 16) & 0xFFFF); - else - fpacket2 = (SifRpcRendPkt_t *)sif_rpc_get_fpacket(harg); + fpacket2 = ( (rec_id & 4) != 0 ) ? (SifRpcRendPkt_t *)sif_rpc_get_fpacket2(harg, (rec_id >> 16) & 0xFFFF) : (SifRpcRendPkt_t *)sif_rpc_get_fpacket(harg); fpacket2->pkt_addr = data->pkt_addr; recvbuf = (SifRpcClientData_t *)data->recvbuf; fpacket2->cid = SIF_CMD_RPC_RDATA; @@ -338,9 +330,7 @@ static SifRpcServerData_t *sif_search_svdata(int sid, const sif_rpc_data_t *rpc_ static unsigned int sif_cmd_handler_bind_alarm_retry(void *a1) { - if ( isceSifSendCmd(SIF_CMD_RPC_END, a1, 64, 0, 0, 0) != 0 ) - return 0; - return 0xF000; + return ( isceSifSendCmd(SIF_CMD_RPC_END, a1, 64, 0, 0, 0) != 0 ) ? 0 : 0xF000; } static void sif_cmd_handler_bind(SifRpcBindPkt_t *data, sif_rpc_data_t *harg) @@ -356,16 +346,8 @@ static void sif_cmd_handler_bind(SifRpcBindPkt_t *data, sif_rpc_data_t *harg) fpacket->cid = SIF_CMD_RPC_BIND; fpacket->cd = cd; sd = sif_search_svdata(data->sid, harg); - if ( sd ) - { - fpacket->sd = sd; - fpacket->buf = sd->buf; - } - else - { - fpacket->sd = 0; - fpacket->buf = 0; - } + fpacket->sd = sd ? sd : 0; + fpacket->buf = sd ? sd->buf : 0; if ( !isceSifSendCmd(SIF_CMD_RPC_END, fpacket, 64, 0, 0, 0) ) { clk.hi = 0; @@ -439,10 +421,7 @@ static void sif_cmd_handler_call(SifRpcCallPkt_t *data, sif_rpc_data_t *harg) sd = data->sd; base = sd->base; - if ( base->start ) - base->end->next = sd; - else - base->start = sd; + *(base->start ? &(base->end->next) : &(base->start)) = sd; base->end = sd; sd->pkt_addr = data->pkt_addr; sd->client = data->cd; @@ -490,10 +469,7 @@ int sceSifCallRpc( { void *dest_extra; - if ( end_function ) - call->rmode = 1; - else - call->rmode = 0; + call->rmode = end_function ? 1 : 0; dest_extra = cd->buf; cd->hdr.sema_id = -1; if ( sceSifSendCmd(SIF_CMD_RPC_CALL, call, 64, sendbuf, dest_extra, ssize) == 0 ) @@ -669,15 +645,8 @@ SifRpcServerData_t *sceSifGetNextRequest(SifRpcDataQueue_t *qd) CpuSuspendIntr(&state); sd = qd->start; - if ( sd ) - { - qd->active = 1; - qd->start = sd->next; - } - else - { - qd->active = 0; - } + qd->active = sd ? 1 : 0; + qd->start = sd ? sd->next : sd; CpuResumeIntr(state); return sd; } @@ -696,16 +665,11 @@ void sceSifExecRequest(SifRpcServerData_t *sd) SifDmaTransfer_t dmat2[2]; int state[2]; - size_extra = 0; rec = (void *)sd->func(sd->rpc_number, sd->buf, sd->size); - if ( rec ) - size_extra = sd->rsize; + size_extra = rec ? sd->rsize : 0; CpuSuspendIntr(state); rid = sd->rid; - if ( (rid & 4) != 0 ) - fpacket2 = (SifRpcRendPkt_t *)sif_rpc_get_fpacket2(&sif_rpc_data, (rid >> 16) & 0xFFFF); - else - fpacket2 = (SifRpcRendPkt_t *)sif_rpc_get_fpacket(&sif_rpc_data); + fpacket2 = ( (rid & 4) != 0 ) ? (SifRpcRendPkt_t *)sif_rpc_get_fpacket2(&sif_rpc_data, (rid >> 16) & 0xFFFF) : (SifRpcRendPkt_t *)sif_rpc_get_fpacket(&sif_rpc_data); rend = fpacket2; CpuResumeIntr(state[0]); cd = sd->client; diff --git a/iop/system/sifman/src/sifman.c b/iop/system/sifman/src/sifman.c index f60c03da50ca..30cd973592c8 100644 --- a/iop/system/sifman/src/sifman.c +++ b/iop/system/sifman/src/sifman.c @@ -207,7 +207,6 @@ static int sifman_interrupt_handler(void *userdata) void (*dma_intr_handler)(void *userdata); sif_completion_cb_info_arr_t *sif_otherbufcom; int v4; - sif_completion_cb_info_arr_t *p_sif_bufcom1; sifman_internals_t *smi; USE_IOP_MMIO_HWPORT(); USE_SIF_MMIO_HWPORT(); @@ -241,19 +240,9 @@ static int sifman_interrupt_handler(void *userdata) sif_mmio_hwport->controlreg = 32; ++smi->dma_count; smi->dmatag_index = 0; - if ( smi->sif_curbuf == smi->sif_buf1 ) - { - smi->sif_curbuf = smi->sif_buf2; - smi->sif_curbufcom = &smi->sif_bufcom2; - p_sif_bufcom1 = &smi->sif_bufcom1; - } - else - { - smi->sif_curbufcom = &smi->sif_bufcom1; - p_sif_bufcom1 = &smi->sif_bufcom2; - smi->sif_curbuf = smi->sif_buf1; - } - smi->sif_otherbufcom = p_sif_bufcom1; + smi->sif_curbufcom = ( smi->sif_curbuf == smi->sif_buf1 ) ? &smi->sif_bufcom2 : &smi->sif_bufcom1; + smi->sif_otherbufcom = ( smi->sif_curbuf == smi->sif_buf1 ) ? &smi->sif_bufcom1 : &smi->sif_bufcom2; + smi->sif_curbuf = ( smi->sif_curbuf == smi->sif_buf1 ) ? smi->sif_buf2 : smi->sif_buf1; iop_mmio_hwport->dmac2.newch[2].chcr = 0x1000701; } return 1; @@ -290,15 +279,13 @@ static int sif_dma_setup_tag(SifDmaTransfer_t *a1) v3 = a1->size + 3; v1->data = v2; v4 = v3 >> 2; - if ( (a1->attr & 2) != 0 ) - v1->data = v2 | 0x40000000; + v1->data |= ( (a1->attr & 2) != 0 ) ? 0x40000000 : 0; v1->words = v4 & 0xFFFFFF; v5 = v3 >> 4; if ( (v4 & 3) != 0 ) ++v5; v1->count = v5 | 0x10000000; - if ( (a1->attr & 4) != 0 ) - v1->count |= 0x80000000; + v1->count |= ( (a1->attr & 4) != 0 ) ? 0x80000000 : 0; v1->addr = (int)a1->dest & 0x1FFFFFFF; return ++sifman_internals.dmatag_index; } @@ -309,7 +296,6 @@ static int set_dma_inner(SifDmaTransfer_t *dmat, int count, void (*func)(void *u int dma_count; int i; int v14; - sif_completion_cb_info_arr_t *p_sif_bufcom1; USE_IOP_MMIO_HWPORT(); USE_SIF_MMIO_HWPORT(); @@ -346,19 +332,9 @@ static int set_dma_inner(SifDmaTransfer_t *dmat, int count, void (*func)(void *u iop_mmio_hwport->dmac2.newch[2].bcr = (iop_mmio_hwport->dmac2.newch[2].bcr & 0xFFFF0000) | 32; sifman_internals.dmatag_index = 0; ++sifman_internals.dma_count; - if ( sifman_internals.sif_curbuf == sifman_internals.sif_buf1 ) - { - sifman_internals.sif_curbuf = sifman_internals.sif_buf2; - sifman_internals.sif_curbufcom = &sifman_internals.sif_bufcom2; - p_sif_bufcom1 = &sifman_internals.sif_bufcom1; - } - else - { - sifman_internals.sif_curbuf = sifman_internals.sif_buf1; - sifman_internals.sif_curbufcom = &sifman_internals.sif_bufcom1; - p_sif_bufcom1 = &sifman_internals.sif_bufcom2; - } - sifman_internals.sif_otherbufcom = p_sif_bufcom1; + sifman_internals.sif_curbufcom = ( sifman_internals.sif_curbuf == sifman_internals.sif_buf1 ) ? &sifman_internals.sif_bufcom2 : &sifman_internals.sif_bufcom1; + sifman_internals.sif_otherbufcom = ( sifman_internals.sif_curbuf == sifman_internals.sif_buf1 ) ? &sifman_internals.sif_bufcom1 : &sifman_internals.sif_bufcom2; + sifman_internals.sif_curbuf = ( sifman_internals.sif_curbuf == sifman_internals.sif_buf1 ) ? sifman_internals.sif_buf2 : sifman_internals.sif_buf1; iop_mmio_hwport->dmac2.newch[2].chcr = 0x1000701; v14 = dma_count << 16; } @@ -381,18 +357,7 @@ static int dma_stat_inner(unsigned int a1) { USE_IOP_MMIO_HWPORT(); - if ( (iop_mmio_hwport->dmac2.newch[2].chcr & 0x1000000) == 0 && !iop_mmio_hwport->dmac2.new_unusedch.madr ) - { - if ( (iop_mmio_hwport->dmac2.dicr2 & 0x4000000) == 0 ) - return -1; - } - if ( sifman_internals.dma_count != ((a1 >> 16) & 0xFFFF) ) - { - if ( sifman_internals.dma_count == (u16)(((a1 >> 16) & 0xFFFF) + 1) ) - return 0; - return -1; - } - return 1; + return ( (iop_mmio_hwport->dmac2.newch[2].chcr & 0x1000000) == 0 && !iop_mmio_hwport->dmac2.new_unusedch.madr && (iop_mmio_hwport->dmac2.dicr2 & 0x4000000) == 0 ) ? -1 : (( sifman_internals.dma_count != ((a1 >> 16) & 0xFFFF) ) ? (( sifman_internals.dma_count == (u16)(((a1 >> 16) & 0xFFFF) + 1) ) ? 0 : -1) : 1); } int sceSifDmaStat(int trid) @@ -426,8 +391,7 @@ void sceSifSetOneDma(SifDmaTransfer_t dmat) if ( (v2 & 3) != 0 ) ++v3; sifman_internals.one.count = v3 | 0x10000000; - if ( (dmat.attr & 4) != 0 ) - sifman_internals.one.count |= 0x80000000; + sifman_internals.one.count |= ( (dmat.attr & 4) != 0 ) ? 0x80000000 : 0; sifman_internals.one.addr = (int)dmat.dest & 0xFFFFFFF; if ( (sif_mmio_hwport->controlreg & 0x20) == 0 ) sif_mmio_hwport->controlreg = 32; @@ -466,10 +430,7 @@ void sceSifDma0Transfer(void *addr, int size, int mode) sif_mmio_hwport->controlreg = 32; iop_mmio_hwport->dmac2.newch[2].chcr = 0; iop_mmio_hwport->dmac2.newch[2].madr = (unsigned int)addr & 0xFFFFFF; - if ( (v4 & 0x1F) != 0 ) - v5 = (v4 >> 5) + 1; - else - v5 = v4 >> 5; + v5 = ( (v4 & 0x1F) != 0 ) ? ((v4 >> 5) + 1) : (v4 >> 5); iop_mmio_hwport->dmac2.newch[2].bcr = ((v5 & 0xFFFF) << 16) | 32; iop_mmio_hwport->dmac2.newch[2].chcr = 0x1000201; } @@ -502,15 +463,9 @@ void sceSifDma1Transfer(void *addr, int size, int mode) sif_mmio_hwport->controlreg = 64; iop_mmio_hwport->dmac2.newch[3].chcr = 0; iop_mmio_hwport->dmac2.newch[3].madr = (unsigned int)addr & 0xFFFFFF; - if ( (v4 & 0x1F) != 0 ) - v5 = (v4 >> 5) + 1; - else - v5 = v4 >> 5; + v5 = ( (v4 & 0x1F) != 0 ) ? ((v4 >> 5) + 1) : (v4 >> 5); iop_mmio_hwport->dmac2.newch[3].bcr = ((v5 & 0xFFFF) << 16) | 32; - if ( (mode & 0x10) != 0 ) - v6 = 0x41000000; - else - v6 = 0x1000000; + v6 = ( (mode & 0x10) != 0 ) ? 0x41000000 : 0x1000000; iop_mmio_hwport->dmac2.newch[3].chcr = v6 | 0x200; } @@ -534,7 +489,6 @@ void sceSifDma2Transfer(void *addr, int size, int mode) unsigned int v4; u16 v5; int v6; - int v7; USE_IOP_MMIO_HWPORT(); USE_SIF_MMIO_HWPORT(); @@ -546,26 +500,9 @@ void sceSifDma2Transfer(void *addr, int size, int mode) iop_mmio_hwport->dmac1.oldch[2].madr = (unsigned int)addr & 0xFFFFFF; if ( v4 >= 0x21 ) v5 = 32; - if ( (v4 & 0x1F) != 0 ) - v6 = (v4 >> 5) + 1; - else - v6 = v4 >> 5; + v6 = ( (v4 & 0x1F) != 0 ) ? ((v4 >> 5) + 1) : (v4 >> 5); iop_mmio_hwport->dmac1.oldch[2].bcr = ((v6 & 0xFFFF) << 16) | (v5 & 0xFFFF); - if ( (mode & 1) != 0 ) - { - v7 = 0x1000201; - } - else - { - int v8; - - if ( (mode & 0x10) != 0 ) - v8 = 0x41000000; - else - v8 = 0x1000000; - v7 = v8 | 0x200; - } - iop_mmio_hwport->dmac1.oldch[2].chcr = v7; + iop_mmio_hwport->dmac1.oldch[2].chcr = ( (mode & 1) != 0 ) ? 0x1000201 : ((( (mode & 0x10) != 0 ) ? 0x41000000 : 0x1000000) | 0x200); } void sceSifDma2Sync() diff --git a/iop/system/ssbusc/src/ssbusc.c b/iop/system/ssbusc/src/ssbusc.c index e87c00b81825..fa4891bbe1f9 100644 --- a/iop/system/ssbusc/src/ssbusc.c +++ b/iop/system/ssbusc/src/ssbusc.c @@ -66,10 +66,7 @@ int GetDelay(int device) return -1; } v1 = delay_table[device]; - if (v1 == NULL) { - return -1; - } - return *v1; + return (v1 == NULL) ? -1 : *v1; } static vu32 *base_address_table[13] = @@ -112,10 +109,7 @@ int GetBaseAddress(int device) return -1; } v1 = base_address_table[device]; - if (v1 == NULL) { - return -1; - } - return *v1; + return (v1 == NULL) ? -1 : *v1; } int SetRecoveryTime(unsigned int value) diff --git a/iop/system/stdio/src/stdio.c b/iop/system/stdio/src/stdio.c index 8dc0ab336f08..cb689b5b4aa7 100644 --- a/iop/system/stdio/src/stdio.c +++ b/iop/system/stdio/src/stdio.c @@ -26,10 +26,7 @@ IRX_ID("Stdio", 1, 1); int _start(int argc, char *argv[]) { - if (RegisterLibraryEntries(&_exp_stdio) != 0) { - return MODULE_NO_RESIDENT_END; - } - return MODULE_RESIDENT_END; + return (RegisterLibraryEntries(&_exp_stdio) != 0) ? MODULE_NO_RESIDENT_END : MODULE_RESIDENT_END; } void stdio_prnt_callback(void *userdata, int c) @@ -57,9 +54,8 @@ void stdio_prnt_callback(void *userdata, int c) tmp_buf[current_length] = c; current_length += 1; - context->current_length = current_length; + context->current_length = (current_length == 64) ? 0 : current_length; if (current_length == 64) { - context->current_length = 0; write_now: io_write(context->fd, tmp_buf, current_length); } @@ -116,9 +112,7 @@ int fdputc(int c, int fd) io_write(fd, "\r\n", 2); tab_stop_padding = 0; } else { - if (isprint(c) != 0) { - tab_stop_padding += 1; - } + tab_stop_padding += (isprint(c) != 0) ? 1 : 0; io_write(fd, buf, 1); } return c; @@ -133,10 +127,7 @@ int fdputs(const char *s, int fd) { const char *s_s; - s_s = s; - if (s == NULL) { - s_s = ""; - } + s_s = (s == NULL) ? "" : s; while (*s_s != '\x00') { fdputc(*s_s, fd); s_s += 1; @@ -169,11 +160,7 @@ char *fdgets(char *buf, int fd) char v6; int v7; char v8; - int v9; int v10; - int v11; - int v13; - int v14; v4 = buf; v5 = buf + 125; @@ -184,33 +171,22 @@ char *fdgets(char *buf, int fd) } if (v6 < '\v') { if (v6 != '\b') { - if (v6 == '\t') { - v6 = ' '; - v7 = ' '; - } else { - v7 = v6; - } + v6 = (v6 == '\t') ? ' ' : v6; + v7 = v6; goto LABEL_31; } goto LABEL_21; } if (v6 == '\x16') { v8 = fdgetc(fd); - v9 = fd; if (v4 >= v5) { - if (!fd) { - v9 = 1; - } v10 = 7; goto LABEL_29; } *v4++ = v8; v10 = v8; - if (!fd) { - v9 = 1; - } LABEL_29: - fdputc(v10, v9); + fdputc(v10, (!fd) ? 1 : fd); } else { if (v6 < '\x17') { if (v6 == '\r') { @@ -223,52 +199,28 @@ char *fdgets(char *buf, int fd) v7 = v6; LABEL_31: if (isprint(v7) == 0) { - v9 = fd; LABEL_37: - if (!v9) { - v9 = 1; - } v10 = 7; goto LABEL_29; } - v9 = fd; if (v4 >= v5) { goto LABEL_37; } *v4++ = v6; - if (!fd) { - v9 = 1; - } v10 = v7; goto LABEL_29; } LABEL_21: if (buf < v4) { --v4; - v13 = fd; - if (!fd) { - v13 = 1; - } - fdputc('\b', v13); - v14 = fd; - if (!fd) { - v14 = 1; - } - fdputc(' ', v14); - v9 = fd; - if (!fd) { - v9 = 1; - } + fdputc('\b', (!fd) ? 1 : fd); + fdputc(' ', (!fd) ? 1 : fd); v10 = 8; goto LABEL_29; } } } - v11 = fd; - if (!fd) { - v11 = 1; - } - fdputc('\n', v11); + fdputc('\n', (!fd) ? 1 : fd); *v4 = 0; return buf; } diff --git a/iop/system/sysmem/src/sysmem.c b/iop/system/sysmem/src/sysmem.c index 59544a47322c..843b1585f7b8 100644 --- a/iop/system/sysmem/src/sysmem.c +++ b/iop/system/sysmem/src/sysmem.c @@ -117,10 +117,7 @@ int sysmem_reinit(void) u32 QueryMemSize() { - if ( sysmem_internals.alloclist ) - return sysmem_internals.memsize; - else - return 0; + return sysmem_internals.alloclist ? sysmem_internals.memsize : 0; } u32 QueryMaxFreeMemSize() @@ -165,8 +162,7 @@ u32 QueryTotalFreeMemSize() unsigned int info; info = list->info; - if ( (info & 1) == 0 ) - v0 += info >> 17; + v0 += ( (info & 1) == 0 ) ? (info >> 17) : 0; list = list->next; } while ( list ); } @@ -225,10 +221,7 @@ void *QueryBlockTopAddress(void *address) unsigned int info; info = v3->info; - if ( (info & 1) != 0 ) - v2 = (u16)info >> 1 << 8; - else - v2 = ((u16)info >> 1 << 8) + 0x80000000; + v2 = ( (info & 1) != 0 ) ? ((u16)info >> 1 << 8) : (((u16)info >> 1 << 8) + 0x80000000); } cCpuResumeIntr(state); return (void *)v2; @@ -249,8 +242,7 @@ int QueryBlockSize(void *address) info = v3->info; v2 = info >> 17 << 8; - if ( (info & 1) == 0 ) - v2 |= 0x80000000; + v2 |= ( (info & 1) == 0 ) ? 0x80000000 : 0; } cCpuResumeIntr(state); return v2; @@ -304,19 +296,14 @@ void GetSysMemoryInfo(int flag, sysmem_info_t *info) { alloclist = alloclist->next; } - if ( alloclist ) - { - info->blockinfo.flags_memsize |= 2u; - } + info->blockinfo.flags_memsize |= ( alloclist ) ? 2u : 0; } else { info->blockinfo.flags_memsize |= 1; } next = info->blockinfo.table_info->next; - info->blockinfo.table_info = next; - if ( !((unsigned int)next->list[0].next >> 17) ) - info->blockinfo.table_info = 0; + info->blockinfo.table_info = ( !((unsigned int)next->list[0].next >> 17) ) ? 0 : next; cCpuResumeIntr(state); } @@ -708,29 +695,20 @@ static sysmem_alloc_element_t *search_block(void *a1) static int cCpuSuspendIntr(int *state) { intrman_callbacks_t *intrman_callbacks = (intrman_callbacks_t *)(sysmem_internals.intr_suspend_tbl); - if ( intrman_callbacks && intrman_callbacks->cbCpuSuspendIntr ) - return intrman_callbacks->cbCpuSuspendIntr(state); - else - return 0; + return ( intrman_callbacks && intrman_callbacks->cbCpuSuspendIntr ) ? intrman_callbacks->cbCpuSuspendIntr(state) : 0; } static int cCpuResumeIntr(int state) { intrman_callbacks_t *intrman_callbacks = (intrman_callbacks_t *)(sysmem_internals.intr_suspend_tbl); - if ( intrman_callbacks && intrman_callbacks->cbCpuResumeIntr ) - return intrman_callbacks->cbCpuResumeIntr(state); - else - return 0; + return ( intrman_callbacks && intrman_callbacks->cbCpuResumeIntr ) ? intrman_callbacks->cbCpuResumeIntr(state) : 0; } #if 0 static int cQueryIntrContext(void) { intrman_callbacks_t *intrman_callbacks = (intrman_callbacks_t *)(sysmem_internals.intr_suspend_tbl); - if ( intrman_callbacks && intrman_callbacks->cbQueryIntrContext ) - return intrman_callbacks->cbQueryIntrContext(); - else - return 0; + return ( intrman_callbacks && intrman_callbacks->cbQueryIntrContext ) ? intrman_callbacks->cbQueryIntrContext() : 0; } #endif diff --git a/iop/system/threadman/src/thbase.c b/iop/system/threadman/src/thbase.c index bf301c682a9b..2cb783cf1670 100644 --- a/iop/system/threadman/src/thbase.c +++ b/iop/system/threadman/src/thbase.c @@ -528,9 +528,7 @@ int iRotateThreadReadyQueue(int priority) } } else { priority = readyq_highest(); - if (thread->priority < priority) { - priority = thread->priority; - } + priority = (thread->priority < priority) ? thread->priority : priority; } if (list_empty(&thctx.ready_queue[priority])) { @@ -1107,13 +1105,7 @@ int ReferSystemStatus(iop_sys_status_t *info, size_t size) ret = CpuSuspendIntr(&state); - if (QueryIntrContext()) { - info->status = TSS_NOTHREAD; - } else if (ret == KE_CPUDI) { - info->status = TSS_DISABLEINTR; - } else { - info->status = TSS_THREAD; - } + info->status = QueryIntrContext() ? TSS_NOTHREAD : ((ret == KE_CPUDI) ? TSS_DISABLEINTR : TSS_THREAD); info->systemLowTimerWidth = 32; info->idleClocks.hi = thctx.idle_thread->run_clocks_hi; @@ -1453,11 +1445,7 @@ static void thread_get_status(struct thread *thread, iop_thread_info_t *info) } info->wakeupCount = thread->wakeup_count; - if (thread->status == THS_DORMANT || thread->status == THS_RUN) { - info->regContext = 0; - } else { - info->regContext = (long *)thread->saved_regs; - } + info->regContext = (thread->status == THS_DORMANT || thread->status == THS_RUN) ? 0 : (long *)thread->saved_regs; } static void thread_get_run_stats(struct thread *thread, iop_thread_run_status_t *stat) diff --git a/iop/system/threadman/src/thcommon.c b/iop/system/threadman/src/thcommon.c index c23521bbc1d4..c96dfb5a82d5 100644 --- a/iop/system/threadman/src/thcommon.c +++ b/iop/system/threadman/src/thcommon.c @@ -79,7 +79,7 @@ void waitlist_insert(struct thread *thread, struct event *event, s32 priority) void update_timer_compare(int timid, u64 time, struct list_head *alarm_list) { struct alarm *prev, *i; - u32 counter, new_compare = 0; + u32 new_compare = 0; // what if list is empty? (luckily its not but....) prev = list_first_entry(alarm_list, struct alarm, alarm_list); @@ -94,12 +94,7 @@ void update_timer_compare(int timid, u64 time, struct list_head *alarm_list) } } - if (prev->target - time >= thctx.unk4c8) { - new_compare = prev->target; - } else { - counter = GetTimerCounter(timid); - new_compare = counter + thctx.unk4c8; - } + new_compare = (prev->target - time >= thctx.unk4c8) ? prev->target : (GetTimerCounter(timid) + thctx.unk4c8); SetTimerCompare(timid, new_compare); } @@ -163,11 +158,7 @@ int thread_leave(int ret1, int ret2, int intr_state, int release) register u32 a2 __asm__("a2") = intr_state; register s32 result __asm__("v0"); - if (!release) { - thctx.current_thread->reason_counter = &thctx.current_thread->thread_preemption_count; - } else { - thctx.current_thread->reason_counter = &thctx.current_thread->release_count; - } + thctx.current_thread->reason_counter = !release ? &thctx.current_thread->thread_preemption_count : &thctx.current_thread->release_count; __asm__ __volatile__("li $v0, 0x20\n" "syscall\n" diff --git a/iop/system/threadman/src/thevent.c b/iop/system/threadman/src/thevent.c index 9f949ee68a70..19ff39db85c6 100644 --- a/iop/system/threadman/src/thevent.c +++ b/iop/system/threadman/src/thevent.c @@ -114,9 +114,7 @@ int SetEventFlag(int ef, u32 bits) } shared_bits = thread->event_bits & evt->bits; - if ((thread->event_mode & WEF_OR) == 0) { - shared_bits = shared_bits == thread->event_bits; - } + shared_bits = ((thread->event_mode & WEF_OR) == 0) ? (shared_bits == thread->event_bits) : shared_bits; if (shared_bits) { // We stored the WaitEventFlag resbits arg @@ -182,9 +180,7 @@ int iSetEventFlag(int ef, u32 bits) } shared_bits = thread->event_bits & evt->bits; - if ((thread->event_mode & WEF_OR) == 0) { - shared_bits = shared_bits == thread->event_bits; - } + shared_bits = ((thread->event_mode & WEF_OR) == 0) ? (shared_bits == thread->event_bits) : shared_bits; if (shared_bits) { // We stored the WaitEventFlag resbits arg @@ -289,11 +285,7 @@ int WaitEventFlag(int ef, u32 bits, int mode, u32 *resbits) return KE_EVF_MULTI; } - if (mode & WEF_OR) { - shared_bits = evt->bits & bits; - } else { - shared_bits = (evt->bits & bits) == bits; - } + shared_bits = (mode & WEF_OR) ? (evt->bits & bits) : ((evt->bits & bits) == bits); if (shared_bits) { if (resbits) { @@ -354,11 +346,7 @@ int PollEventFlag(int ef, u32 bits, int mode, u32 *resbits) return KE_EVF_MULTI; } - if (mode & WEF_OR) { - shared_bits = evt->bits & bits; - } else { - shared_bits = (evt->bits & bits) == bits; - } + shared_bits = (mode & WEF_OR) ? (evt->bits & bits) : ((evt->bits & bits) == bits); if (shared_bits == 0) { CpuResumeIntr(state); diff --git a/iop/system/timrman/src/timrman.c b/iop/system/timrman/src/timrman.c index 132f97fe4039..54aee126193b 100644 --- a/iop/system/timrman/src/timrman.c +++ b/iop/system/timrman/src/timrman.c @@ -352,11 +352,7 @@ u32 GetTimerCounter(int timid) { u32 addr = timid << 4; - if (addr & 0x400) { - return _lw(addr); - } else { - return _lh(addr); - } + return (addr & 0x400) ? _lw(addr) : _lh(addr); } void SetTimerCompare(int timid, u32 compare) @@ -374,11 +370,7 @@ u32 GetTimerCompare(int timid) { u32 addr = timid << 4; - if (addr & 0x400) { - return _lw(addr + 8); - } else { - return _lh(addr + 8); - } + return (addr & 0x400) ? _lw(addr + 8) : _lh(addr + 8); } void SetHoldMode(int holdnum, int mode) @@ -451,11 +443,7 @@ int SetTimerHandler(int timid, unsigned long comparevalue, unsigned int (*timeup timer->compare_value = comparevalue; timer->timeup_handler = timeuphandler; timer->timeup_common = common; - if (timeuphandler) { - timer->timeup_flags = TMR_CTRL_ZERO_RETURN | TMR_CTRL_CMP_IRQ_ENABLE | TMR_CTRL_IRQ_REPEAT; - } else { - timer->timeup_flags = 0; - } + timer->timeup_flags = timeuphandler ? (TMR_CTRL_ZERO_RETURN | TMR_CTRL_CMP_IRQ_ENABLE | TMR_CTRL_IRQ_REPEAT) : 0; CpuResumeIntr(oldstat); return 0; @@ -481,11 +469,7 @@ int SetOverflowHandler(int timid, unsigned int (*handler)(void *userdata), void timer->overflow_handler = handler; timer->overflow_common = common; - if (handler != NULL) { - timer->overflow_flags = TMR_CTRL_OVFL_IRQ_ENABLE | TMR_CTRL_IRQ_REPEAT; - } else { - timer->overflow_flags = 0; - } + timer->overflow_flags = handler ? (TMR_CTRL_OVFL_IRQ_ENABLE | TMR_CTRL_IRQ_REPEAT) : 0; return 0; } diff --git a/iop/system/udnl/src/udnl.c b/iop/system/udnl/src/udnl.c index ad5cdc3f7ffe..5addcde7b850 100644 --- a/iop/system/udnl/src/udnl.c +++ b/iop/system/udnl/src/udnl.c @@ -772,13 +772,7 @@ static void *ParseStartAddress(const char **line) character = *ptr; ptr++; - if (character < ':') { - character -= 0x30; - } else if (character < 'a') { - character -= 0x4B; - } else { - character -= 0x6B; - } + character -= (character < ':') ? 0x30 : ((character < 'a') ? 0x4B : 0x6B); address = (void *)(((unsigned int)address << 4) + character); } @@ -825,7 +819,6 @@ static struct RomdirFileStat *SelectModuleFromImages(const struct ImageData *Ima { char filename[32]; int count, NumFilesRemaining, ImageFileIndexNumber; - struct RomdirFileStat *result; const struct ImageData *ImageDataPtr; struct RomdirFileStat stat; const struct ExtInfoField *ExtInfofield; @@ -874,12 +867,7 @@ static struct RomdirFileStat *SelectModuleFromImages(const struct ImageData *Ima } while (--NumFilesRemaining >= 0); } - if (ImageFileIndexNumber >= 0) { - result = GetFileStatFromImage(&ImageDataBuffer[ImageFileIndexNumber].stat, filename, stat_out); - } else - result = NULL; - - return result; + return (ImageFileIndexNumber >= 0) ? GetFileStatFromImage(&ImageDataBuffer[ImageFileIndexNumber].stat, filename, stat_out) : NULL; } // Code for debugging only - not originally present. diff --git a/iop/system/vblank/src/vblank.c b/iop/system/vblank/src/vblank.c index b0a14dedc5b4..7c279e722fc6 100644 --- a/iop/system/vblank/src/vblank.c +++ b/iop/system/vblank/src/vblank.c @@ -90,9 +90,7 @@ int RegisterVblankHandler(int startend, int priority, int (*handler)(void *userd CpuResumeIntr(state); return KE_NO_MEMORY; } - list = &vblank_internals.list_11; - if ( !startend ) - list = &vblank_internals.list_00; + list = ( !startend ) ? &vblank_internals.list_00 : &vblank_internals.list_11; item = list->next; if ( list->next != list ) { @@ -140,9 +138,7 @@ int ReleaseVblankHandler(int startend, int (*handler)(void *userdata)) return KE_ILLEGAL_CONTEXT; } CpuSuspendIntr(&state); - list = &vblank_internals.list_11; - if ( !startend ) - list = &vblank_internals.list_00; + list = ( !startend ) ? &vblank_internals.list_00 : &vblank_internals.list_11; item = list->next; if ( list->next == list ) { diff --git a/iop/tcpip/tcpip-netman/src/ps2ip.c b/iop/tcpip/tcpip-netman/src/ps2ip.c index c365436b00d0..46f781f148c3 100644 --- a/iop/tcpip/tcpip-netman/src/ps2ip.c +++ b/iop/tcpip/tcpip-netman/src/ps2ip.c @@ -84,16 +84,8 @@ ps2ip_getconfig(char* pszName,t_ip_info* pInfo) #if LWIP_DHCP struct dhcp *dhcp = netif_dhcp_data(pNetIF); - if ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) - { - pInfo->dhcp_enabled=1; - pInfo->dhcp_status=dhcp->state; - } - else - { - pInfo->dhcp_enabled=0; - pInfo->dhcp_status=DHCP_STATE_OFF; - } + pInfo->dhcp_enabled = ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) ? 1 : 0; + pInfo->dhcp_status = (dhcp != NULL) ? dhcp->state : DHCP_STATE_OFF; #else @@ -273,9 +265,8 @@ static int NextTxPacket(void **payload) if(TxTail != NULL) { *payload = TxTail->payload; - len = TxTail->len; - } else - len = 0; + } + len = (TxTail != NULL) ? TxTail->len : 0; return len; } @@ -294,11 +285,9 @@ static void DeQTxPacket(void) if(TxTail == TxHead) { //Last in queue. - TxTail = NULL; TxHead = NULL; - } else { - TxTail = TxTail->next; } + TxTail = (TxTail == TxHead) ? NULL : TxTail->next; } CpuResumeIntr(OldState); diff --git a/iop/tcpip/tcpip/src/ps2ip.c b/iop/tcpip/tcpip/src/ps2ip.c index cc238eb50c9a..62ec1e505f7f 100644 --- a/iop/tcpip/tcpip/src/ps2ip.c +++ b/iop/tcpip/tcpip/src/ps2ip.c @@ -81,16 +81,8 @@ ps2ip_getconfig(char* pszName,t_ip_info* pInfo) #if LWIP_DHCP struct dhcp *dhcp = netif_dhcp_data(pNetIF); - if ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) - { - pInfo->dhcp_enabled=1; - pInfo->dhcp_status=dhcp->state; - } - else - { - pInfo->dhcp_enabled=0; - pInfo->dhcp_status=DHCP_STATE_OFF; - } + pInfo->dhcp_enabled = ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) ? 1 : 0; + pInfo->dhcp_status = (dhcp != NULL) ? dhcp->state : DHCP_STATE_OFF; #else diff --git a/iop/tcpip/tcpips/src/ps2ips.c b/iop/tcpip/tcpips/src/ps2ips.c index e893f722a703..a3a842d345e8 100644 --- a/iop/tcpip/tcpips/src/ps2ips.c +++ b/iop/tcpip/tcpips/src/ps2ips.c @@ -129,17 +129,7 @@ static void do_recv( void * rpcBuffer, int size ) (void)size; - if(recv_pkt->length <= 64) - { - srest = recv_pkt->length; - - } else { - - if( ((int)recv_pkt->ee_addr & 0x3F) == 0 ) // ee address is aligned - srest = 0; - else - srest = RDOWN_64((int)recv_pkt->ee_addr) - (int)recv_pkt->ee_addr + 64; - } + srest = (recv_pkt->length <= 64) ? recv_pkt->length : (( ((int)recv_pkt->ee_addr & 0x3F) == 0 ) /* ee address is aligned */ ? 0 : (RDOWN_64((int)recv_pkt->ee_addr) - (int)recv_pkt->ee_addr + 64)); s_offset = 64 - srest; recvlen = MIN(BUFF_SIZE, recv_pkt->length); @@ -225,17 +215,7 @@ static void do_recvfrom( void * rpcBuffer, int size ) (void)size; - if(recv_pkt->length <= 64) - { - srest = recv_pkt->length; - - } else { - - if( ((int)recv_pkt->ee_addr & 0x3F) == 0 ) // ee address is aligned - srest = 0; - else - srest = RDOWN_64((int)recv_pkt->ee_addr) - (int)recv_pkt->ee_addr + 64; - } + srest = (recv_pkt->length <= 64) ? recv_pkt->length : (( ((int)recv_pkt->ee_addr & 0x3F) == 0 ) /* ee address is aligned */ ? 0 : (RDOWN_64((int)recv_pkt->ee_addr) - (int)recv_pkt->ee_addr + 64)); s_offset = 64 - srest; recvlen = MIN(BUFF_SIZE, recv_pkt->length); @@ -319,14 +299,12 @@ static void do_send( void * rpcBuffer, int size ) (void)size; - if(pkt->malign) + s_offset = 64 - pkt->malign; + if (pkt->malign) { -// printf("send: misaligned = %d\n", pkt->malign); - - s_offset = 64 - pkt->malign; +// printf("send: misaligned = %d\n", pkt->malign); memcpy((void *)(lwip_buffer + s_offset), pkt->malign_buff, pkt->malign); - - } else s_offset = 64; + } ee_pos = pkt->ee_addr + pkt->malign; @@ -352,14 +330,12 @@ static void do_sendto( void * rpcBuffer, int size ) (void)size; - if(pkt->malign) + s_offset = 64 - pkt->malign; + if (pkt->malign) { -// printf("send: misaligned = %d\n", pkt->malign); - - s_offset = 64 - pkt->malign; +// printf("send: misaligned = %d\n", pkt->malign); memcpy((void *)(lwip_buffer + s_offset), pkt->malign_buff, pkt->malign); - - } else s_offset = 64; + } ee_pos = pkt->ee_addr + pkt->malign; diff --git a/iop/usb/camera/src/ps2cam.c b/iop/usb/camera/src/ps2cam.c index 3b2c6decfc4e..ec83de50b810 100644 --- a/iop/usb/camera/src/ps2cam.c +++ b/iop/usb/camera/src/ps2cam.c @@ -1015,9 +1015,7 @@ int PS2CamOpenDevice(int device_index) //see the error code to return if((i+1) == (MAX_CAM_DEVICE)) { - if(index == 0)return CAM_ERROR_NODEVICE; - if(index < device_index)return CAM_ERROR_BADRANGE; - return CAM_ERROR_UNKNOWN; + return (index == 0) ? CAM_ERROR_NODEVICE : ((index < device_index) ? CAM_ERROR_BADRANGE : CAM_ERROR_UNKNOWN); } } @@ -1154,18 +1152,7 @@ int PS2CamGetDeviceInfo(int handle,int *info) PS2CamGetDeviceSring(cam, dev->iProduct, (char *)&inf.product_name[0], 32); - if(dev->idProduct == PS2CAM_PROD_EYETOY) - { - strcpy((char *)&inf.model[0],"SLEH-00030\0"); - } - else if(dev->idProduct == PS2CAM_PROD_EYETOY2) - { - strcpy((char *)&inf.model[0],"SLEH-00031\0"); - } - else - { - strcpy((char *)&inf.model[0],"UNKNOWN\0"); - } + strcpy((char *)&inf.model[0],(dev->idProduct == PS2CAM_PROD_EYETOY) ? "SLEH-00030\0" : ((dev->idProduct == PS2CAM_PROD_EYETOY2) ? "SLEH-00031\0" : "UNKNOWN\0")); /**/ memcpy(info, &inf, size); diff --git a/iop/usb/keyboard/src/ps2kbd.c b/iop/usb/keyboard/src/ps2kbd.c index 20afbaefdd2a..93ff5d894719 100644 --- a/iop/usb/keyboard/src/ps2kbd.c +++ b/iop/usb/keyboard/src/ps2kbd.c @@ -482,14 +482,7 @@ void ps2kbd_getkeys(u8 keyMods, u8 ledStatus, const u8 *keys, kbd_dev *dev) int byteCount = 0; u8 currChars[2]; - if(lineStartP < lineEndP) - { - tempPos = lineStartP + lineSize; - } - else - { - tempPos = lineStartP; - } + tempPos = (lineStartP < lineEndP) ? (lineStartP + lineSize) : lineStartP; for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++) { @@ -549,27 +542,13 @@ void ps2kbd_getkeys(u8 keyMods, u8 ledStatus, const u8 *keys, kbd_dev *dev) } else if(keyMods & PS2KBD_SHIFT) /* SHIFT */ { - if((ledStatus & PS2KBD_LED_CAPSLOCK) && (keycap[currKey])) - { - currChars[0] = keymap[currKey]; - } - else - { - currChars[0] = shiftkeymap[currKey]; - } + currChars[0] = ((ledStatus & PS2KBD_LED_CAPSLOCK) && (keycap[currKey])) ? keymap[currKey] : shiftkeymap[currKey]; } else /* Normal key */ { if(keymap[keys[loopKey]]) { - if((ledStatus & PS2KBD_LED_CAPSLOCK) && (keycap[currKey])) - { - currChars[0] = shiftkeymap[currKey]; - } - else - { - currChars[0] = keymap[currKey]; - } + currChars[0] = ((ledStatus & PS2KBD_LED_CAPSLOCK) && (keycap[currKey])) ? shiftkeymap[currKey] : keymap[currKey]; } } } @@ -627,14 +606,7 @@ void ps2kbd_getkeys_raw(u8 newKeyMods, u8 oldKeyMods, const u8 *new_, const u8 * int tempPos = 0; int byteCount = 0; - if(lineStartP < lineEndP) - { - tempPos = lineStartP + lineSize; - } - else - { - tempPos = lineStartP; - } + tempPos = (lineStartP < lineEndP) ? (lineStartP + lineSize) : lineStartP; for(loopKey = 0; loopKey < 8; loopKey++) { @@ -648,16 +620,8 @@ void ps2kbd_getkeys_raw(u8 newKeyMods, u8 oldKeyMods, const u8 *new_, const u8 * currKey = keyModValue[loopKey]; - if(keyModsMap & currMod) /* If key pressed */ - { - lineBuffer[lineEndP++] = PS2KBD_RAWKEY_DOWN; - //printf("Key down\n"); - } - else - { - lineBuffer[lineEndP++] = PS2KBD_RAWKEY_UP; - //printf("Key up\n"); - } + lineBuffer[lineEndP++] = (keyModsMap & currMod) /* If key pressed */ ? PS2KBD_RAWKEY_DOWN : PS2KBD_RAWKEY_UP; + //printf((keyModsMap & currMod) ? "Key down\n" : "Key up\n"); lineEndP %= lineSize; lineBuffer[lineEndP++] = currKey; @@ -1169,14 +1133,7 @@ void repeat_thread(void *arg) int tempPos = 0; WaitSema(lineSema); - if(lineStartP < lineEndP) - { - tempPos = lineStartP + lineSize; - } - else - { - tempPos = lineStartP; - } + tempPos = (lineStartP < lineEndP) ? (lineStartP + lineSize) : lineStartP; if((devices[devLoop]->repeatkeys[0]) && (devices[devLoop]->repeatkeys[1])) { diff --git a/iop/usb/mouse/src/ps2mouse.c b/iop/usb/mouse/src/ps2mouse.c index 6d63d81a7bd7..5018678ebc90 100644 --- a/iop/usb/mouse/src/ps2mouse.c +++ b/iop/usb/mouse/src/ps2mouse.c @@ -259,10 +259,7 @@ int ps2mouse_connect(int devId) currDev->configEndp = sceUsbdOpenPipe(devId, NULL); currDev->dataEndp = sceUsbdOpenPipe(devId, endp); currDev->packetSize = endp->wMaxPacketSizeLB | ((int) endp->wMaxPacketSizeHB << 8); - if((unsigned int)(currDev->packetSize) > sizeof(mouse_data_recv)) - { - currDev->packetSize = sizeof(mouse_data_recv); - } + currDev->packetSize = ((unsigned int)(currDev->packetSize) > sizeof(mouse_data_recv)) ? sizeof(mouse_data_recv) : currDev->packetSize; currDev->devId = devId; @@ -486,10 +483,10 @@ void ps2mouse_data_recv(int resultCode, int bytes, void *arg) mouse.buttons = dev->data.buttons | buttonData; if(mouse_readmode == PS2MOUSE_READMODE_ABS) { - if(mouse.x < mousex_min) mouse.x = mousex_min; - if(mouse.x > mousex_max) mouse.x = mousex_max; - if(mouse.y < mousey_min) mouse.y = mousey_min; - if(mouse.y > mousey_max) mouse.y = mousey_max; + mouse.x = (mouse.x < mousex_min) ? mousex_min : mouse.x; + mouse.x = (mouse.x > mousex_max) ? mousex_max : mouse.x; + mouse.y = (mouse.y < mousey_min) ? mousey_min : mouse.y; + mouse.y = (mouse.y > mousey_max) ? mousey_max : mouse.y; } SignalSema(mouse_sema); @@ -678,31 +675,8 @@ void do_ps2mouse_setposition(const s32 *data, int size) WaitSema(mouse_sema); - if(data[0] < mousex_min) - { - mouse.x = mousex_min; - } - else if(data[0] > mousex_max) - { - mouse.x = mousex_max; - } - else - { - mouse.x = data[0]; - } - - if(data[1] < mousey_min) - { - mouse.y = mousey_min; - } - else if(data[1] > mousey_max) - { - mouse.y = mousey_max; - } - else - { - mouse.y = data[1]; - } + mouse.x = (data[0] < mousex_min) ? mousex_min : ((data[0] > mousex_max) ? mousex_max : data[0]); + mouse.y = (data[1] < mousey_min) ? mousey_min : ((data[1] > mousey_max) ? mousey_max : data[1]); SignalSema(mouse_sema); } diff --git a/iop/usb/usbd/src/device.c b/iop/usb/usbd/src/device.c index 6535faf94d03..fd6f9b10eacd 100644 --- a/iop/usb/usbd/src/device.c +++ b/iop/usb/usbd/src/device.c @@ -62,20 +62,12 @@ int doGetDeviceLocation(UsbdDevice_t *dev, u8 *path) UsbdEndpoint_t *doOpenEndpoint(UsbdDevice_t *dev, const UsbEndpointDescriptor *endpDesc, u32 alignFlag) { - if ( !dev->m_parent ) - { - return NULL; - } - if ( !endpDesc ) - return dev->m_endpointListStart; // default control EP was already opened - return openDeviceEndpoint(dev, endpDesc, alignFlag); + return ( !dev->m_parent ) ? NULL : (( !endpDesc ) ? dev->m_endpointListStart /* default control EP was already opened */ : openDeviceEndpoint(dev, endpDesc, alignFlag)); } int doCloseEndpoint(UsbdEndpoint_t *ep) { - if ( ep->m_correspDevice->m_endpointListStart == ep ) - return 0; - return removeEndpointFromDevice(ep->m_correspDevice, ep); + return ( ep->m_correspDevice->m_endpointListStart == ep ) ? 0 : removeEndpointFromDevice(ep->m_correspDevice, ep); } int attachIoReqToEndpoint(UsbdEndpoint_t *ep, UsbdIoRequest_t *req, void *destdata, u16 length, void *callback) @@ -95,10 +87,7 @@ int attachIoReqToEndpoint(UsbdEndpoint_t *ep, UsbdIoRequest_t *req, void *destda req->m_resultCode = USB_RC_OK; req->m_callbackProc = (InternCallback)callback; req->m_prev = ep->m_ioReqListEnd; - if ( ep->m_ioReqListEnd ) - ep->m_ioReqListEnd->m_next = req; - else - ep->m_ioReqListStart = req; + *(ep->m_ioReqListEnd ? &(ep->m_ioReqListEnd->m_next) : &(ep->m_ioReqListStart)) = req; req->m_next = NULL; ep->m_ioReqListEnd = req; handleIoReqList(ep); @@ -387,14 +376,8 @@ void flushPort(UsbdDevice_t *dev) } for ( desc = dev->m_reportDescriptorStart; desc; desc = dev->m_reportDescriptorStart ) { - if ( desc->m_next ) - desc->m_next->m_prev = desc->m_prev; - else - dev->m_reportDescriptorEnd = desc->m_prev; - if ( desc->m_prev ) - desc->m_prev->m_next = desc->m_next; - else - dev->m_reportDescriptorStart = desc->m_next; + *(desc->m_next ? &(desc->m_next->m_prev) : &(dev->m_reportDescriptorEnd)) = desc->m_prev; + *(desc->m_prev ? &(desc->m_prev->m_next) : &(dev->m_reportDescriptorStart)) = desc->m_next; CpuSuspendIntr(&state); FreeSysMemory(desc); CpuResumeIntr(state); @@ -402,14 +385,8 @@ void flushPort(UsbdDevice_t *dev) while ( dev->m_childListStart ) { child = dev->m_childListStart; - if ( child->m_next ) - child->m_next->m_prev = child->m_prev; - else - dev->m_childListEnd = child->m_prev; - if ( child->m_prev ) - child->m_prev->m_next = child->m_next; - else - dev->m_childListStart = child->m_next; + *(child->m_next ? &(child->m_next->m_prev) : &(dev->m_childListEnd)) = child->m_prev; + *(child->m_prev ? &(child->m_prev->m_next) : &(dev->m_childListStart)) = child->m_next; flushPort(child); freeDevice(child); } @@ -427,7 +404,5 @@ int usbdInitInner(void) if ( initHcdStructs() < 0 ) return -1; dbg_printf("Hub driver...\n"); - if ( initHubDriver() < 0 ) - return -1; - return 0; + return ( initHubDriver() < 0 ) ? -1 : 0; } diff --git a/iop/usb/usbd/src/device_driver.c b/iop/usb/usbd/src/device_driver.c index e3c900b4906e..5af98d8de838 100644 --- a/iop/usb/usbd/src/device_driver.c +++ b/iop/usb/usbd/src/device_driver.c @@ -66,10 +66,7 @@ int doRegisterDriver(sceUsbdLddOps *drv, void *drvGpSeg) } drv->gp = drvGpSeg; drv->prev = drvListEnd; - if ( drvListEnd ) - drvListEnd->next = drv; - else - drvListStart = drv; + *(drvListEnd ? &(drvListEnd->next) : &(drvListStart)) = drv; drv->next = NULL; drvListEnd = drv; if ( drv->probe ) @@ -133,14 +130,8 @@ int doUnregisterDriver(sceUsbdLddOps *drv) } if ( !pos ) return USB_RC_BADDRIVER; - if ( drv->next ) - drv->next->prev = drv->prev; - else - drvListEnd = drv->prev; - if ( drv->prev ) - drv->prev->next = drv->next; - else - drvListStart = drv->next; + *(drv->next ? &(drv->next->prev) : &(drvListEnd)) = drv->prev; + *(drv->prev ? &(drv->prev->next) : &(drvListStart)) = drv->next; disconnectDriver(getDeviceTreeRoot(), drv); return USB_RC_OK; } diff --git a/iop/usb/usbd/src/endpoint.c b/iop/usb/usbd/src/endpoint.c index f2a3d03edb2b..d465786a5641 100644 --- a/iop/usb/usbd/src/endpoint.c +++ b/iop/usb/usbd/src/endpoint.c @@ -110,9 +110,7 @@ setupBandwidthInterruptScheduling(UsbdEndpoint_t *ep, const UsbEndpointDescripto } endpType += schedulingIndex; } - packetSizeForScheduling = maxPacketSize + 13; - if ( maxPacketSize >= 65 ) - packetSizeForScheduling = 77; + packetSizeForScheduling = ( maxPacketSize >= 65 ) ? 77 : (maxPacketSize + 13); ep->m_schedulingIndex = schedulingIndex; ep->m_waitHigh = waitHigh; ep->m_waitLow = waitLow; @@ -137,8 +135,7 @@ static void removeEndpointFromQueue(const UsbdEndpoint_t *ep, int isLowSpeedDevi for ( i = 0; i < ep->m_waitHigh; i += 1 ) { *value_ptr -= (ep->m_packetSizeForScheduling * (isLowSpeedDevice ? 8 : 1)); - if ( (int)*value_ptr < 0 ) - *value_ptr = 0; + *value_ptr = ( (int)*value_ptr < 0 ) ? 0 : *value_ptr; value_ptr += ep->m_waitLow; } } @@ -207,10 +204,8 @@ UsbdEndpoint_t *openDeviceEndpoint(UsbdDevice_t *dev, const UsbEndpointDescripto hcMaxPktSize = 62; } flags = (hcMaxPktSize << 16) & 0x7FF0000; - if ( endpType == TYPE_ISOCHRON ) - flags |= HCED_ISOC; - if ( dev->m_isLowSpeedDevice ) - flags |= HCED_SPEED; + flags |= ( endpType == TYPE_ISOCHRON ) ? HCED_ISOC : 0; + flags |= ( dev->m_isLowSpeedDevice ) ? HCED_SPEED : 0; flags |= ((endpDesc->bEndpointAddress & 0x1F) << 7) | ((endpDesc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN ? HCED_DIR_IN : HCED_DIR_OUT); newEp->m_hcEd->m_hcArea.asu32 = flags | (dev->m_functionAddress & 0x7F); @@ -276,34 +271,19 @@ static void killEndpoint(UsbdEndpoint_t *ep) hcEd->m_tdHead = NULL; for ( req = ep->m_ioReqListStart; req; req = ep->m_ioReqListStart ) { - if ( req->m_next ) - req->m_next->m_prev = req->m_prev; - else - ep->m_ioReqListEnd = req->m_prev; - if ( req->m_prev ) - req->m_prev->m_next = req->m_next; - else - ep->m_ioReqListStart = req->m_next; + *( req->m_next ? &(req->m_next->m_prev) : &(ep->m_ioReqListEnd) ) = req->m_prev; + *( req->m_prev ? &(req->m_prev->m_next) : &(ep->m_ioReqListStart) ) = req->m_next; freeIoRequest(req); } removeEndpointFromQueue(ep, ep->m_correspDevice->m_isLowSpeedDevice); if ( ep->m_inTdQueue != NOTIN_QUEUE ) { - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - else - memPool->m_tdQueueStart = ep->m_busyNext; + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; } ep->m_prev = memPool->m_freeEpListEnd; - if ( memPool->m_freeEpListEnd ) - memPool->m_freeEpListEnd->m_next = ep; - else - memPool->m_freeEpListStart = ep; + *( memPool->m_freeEpListEnd ? &(memPool->m_freeEpListEnd->m_next) : &(memPool->m_freeEpListStart) ) = ep; ep->m_next = NULL; memPool->m_freeEpListEnd = ep; } @@ -312,14 +292,8 @@ int removeEndpointFromDevice(UsbdDevice_t *dev, UsbdEndpoint_t *ep) { ep->m_hcEd->m_hcArea.stru.m_hcArea |= HCED_SKIP; removeHcEdFromList(ep->m_endpointType, ep->m_hcEd); - if ( ep->m_next ) - ep->m_next->m_prev = ep->m_prev; - else - dev->m_endpointListEnd = ep->m_prev; - if ( ep->m_prev ) - ep->m_prev->m_next = ep->m_next; - else - dev->m_endpointListStart = ep->m_next; + *( ep->m_next ? &(ep->m_next->m_prev) : &(dev->m_endpointListEnd) ) = ep->m_prev; + *( ep->m_prev ? &(ep->m_prev->m_next) : &(dev->m_endpointListStart) ) = ep->m_next; ep->m_correspDevice = NULL; addTimerCallback(&ep->m_timer, (TimerCallback)killEndpoint, ep, 200); return 0; diff --git a/iop/usb/usbd/src/hcd.c b/iop/usb/usbd/src/hcd.c index 3bdcb20f5727..c09453a4ece4 100644 --- a/iop/usb/usbd/src/hcd.c +++ b/iop/usb/usbd/src/hcd.c @@ -235,10 +235,7 @@ int initHcdStructs(void) endpointBuf[i].m_id = i; endpointBuf[i].m_hcEd = &hcEdBufForEndpoint[i]; endpointBuf[i].m_prev = memPool->m_freeEpListEnd; - if ( memPool->m_freeEpListEnd ) - memPool->m_freeEpListEnd->m_next = &endpointBuf[i]; - else - memPool->m_freeEpListStart = &endpointBuf[i]; + *(memPool->m_freeEpListEnd ? &(memPool->m_freeEpListEnd->m_next) : &(memPool->m_freeEpListStart)) = &endpointBuf[i]; endpointBuf[i].m_next = NULL; memPool->m_freeEpListEnd = &endpointBuf[i]; } @@ -251,10 +248,7 @@ int initHcdStructs(void) deviceTreeBuf[i].m_id = (u8)i; deviceTreeBuf[i].m_staticDeviceDescPtr = (u8 *)devDescBuf + (usbConfig.m_maxStaticDescSize * i); deviceTreeBuf[i].m_prev = memPool->m_freeDeviceListEnd; - if ( memPool->m_freeDeviceListEnd ) - memPool->m_freeDeviceListEnd->m_next = &deviceTreeBuf[i]; - else - memPool->m_freeDeviceListStart = &deviceTreeBuf[i]; + *(memPool->m_freeDeviceListEnd ? &(memPool->m_freeDeviceListEnd->m_next) : &(memPool->m_freeDeviceListStart)) = &deviceTreeBuf[i]; deviceTreeBuf[i].m_next = NULL; memPool->m_freeDeviceListEnd = &deviceTreeBuf[i]; } @@ -267,10 +261,7 @@ int initHcdStructs(void) { ioReqBuf[i].m_id = i; ioReqBuf[i].m_prev = memPool->m_freeIoReqListEnd; - if ( memPool->m_freeIoReqListEnd ) - memPool->m_freeIoReqListEnd->m_next = &ioReqBuf[i]; - else - memPool->m_freeIoReqList = &ioReqBuf[i]; + *(memPool->m_freeIoReqListEnd ? &(memPool->m_freeIoReqListEnd->m_next) : &(memPool->m_freeIoReqList)) = &ioReqBuf[i]; ioReqBuf[i].m_next = NULL; memPool->m_freeIoReqListEnd = &ioReqBuf[i]; } diff --git a/iop/usb/usbd/src/hub.c b/iop/usb/usbd/src/hub.c index a26f92b73a28..b95efece126a 100644 --- a/iop/usb/usbd/src/hub.c +++ b/iop/usb/usbd/src/hub.c @@ -233,22 +233,12 @@ static void hubCalculateMagicPowerValue(UsbdUsbHub_t *hubDevice) { if ( (int)dev->m_magicPowerValue >= 0 && (int)dev->m_magicPowerValue < 6 && (int)dev->m_magicPowerValue >= 3 ) { - if ( (hubDevice->m_hubStatus & 1) != 0 ) - dev->m_magicPowerValue = 4; - else - dev->m_magicPowerValue = 5; + dev->m_magicPowerValue = ( (hubDevice->m_hubStatus & 1) != 0 ) ? 4 : 5; } } - else if ( hubDevice->m_isSelfPowered ) - { - if ( (int)hubDevice->m_maxPower <= 0 ) - dev->m_magicPowerValue = 2; - else - dev->m_magicPowerValue = 3; - } else { - dev->m_magicPowerValue = (int)hubDevice->m_maxPower > 0; + dev->m_magicPowerValue = ( hubDevice->m_isSelfPowered ) ? (( (int)hubDevice->m_maxPower <= 0 ) ? 2 : 3) : ((int)hubDevice->m_maxPower > 0); } } diff --git a/iop/usb/usbd/src/io_request.c b/iop/usb/usbd/src/io_request.c index dc5d518828ea..15b1df5a9e2b 100644 --- a/iop/usb/usbd/src/io_request.c +++ b/iop/usb/usbd/src/io_request.c @@ -22,18 +22,8 @@ static int setupControlTransfer(UsbdEndpoint_t *ep) // endpoint error if ( ep->m_inTdQueue == NOTIN_QUEUE ) return 0; - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - { - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - } - else - { - memPool->m_tdQueueStart = ep->m_busyNext; - } + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; return 0; } @@ -47,14 +37,7 @@ static int setupControlTransfer(UsbdEndpoint_t *ep) if ( ep->m_inTdQueue != NOTIN_QUEUE ) return 0; ep->m_busyPrev = memPool->m_tdQueueEnd; - if ( memPool->m_tdQueueEnd ) - { - memPool->m_tdQueueEnd->m_busyNext = ep; - } - else - { - memPool->m_tdQueueStart = ep; - } + *( memPool->m_tdQueueEnd ? &(memPool->m_tdQueueEnd->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep; ep->m_busyNext = NULL; memPool->m_tdQueueEnd = ep; ep->m_inTdQueue = GENTD_QUEUE; @@ -71,27 +54,14 @@ static int setupControlTransfer(UsbdEndpoint_t *ep) if ( ep->m_inTdQueue != NOTIN_QUEUE ) return 0; ep->m_busyPrev = memPool->m_tdQueueEnd; - if ( memPool->m_tdQueueEnd ) - { - memPool->m_tdQueueEnd->m_busyNext = ep; - } - else - { - memPool->m_tdQueueStart = ep; - } + *( memPool->m_tdQueueEnd ? &(memPool->m_tdQueueEnd->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep; ep->m_busyNext = NULL; memPool->m_tdQueueEnd = ep; ep->m_inTdQueue = GENTD_QUEUE; return 0; } - if ( curIoReq->m_next ) - curIoReq->m_next->m_prev = curIoReq->m_prev; - else - ep->m_ioReqListEnd = curIoReq->m_prev; - if ( curIoReq->m_prev ) - curIoReq->m_prev->m_next = curIoReq->m_next; - else - ep->m_ioReqListStart = curIoReq->m_next; + *( curIoReq->m_next ? &(curIoReq->m_next->m_prev) : &(ep->m_ioReqListEnd) ) = curIoReq->m_prev; + *( curIoReq->m_prev ? &(curIoReq->m_prev->m_next) : &(ep->m_ioReqListStart) ) = curIoReq->m_next; // first stage: setup ep->m_hcEd->m_tdTail->m_hcArea = TD_HCAREA(USB_RC_NOTACCESSED, 2, 7, TD_SETUP, 0) << 16; ep->m_hcEd->m_tdTail->m_curBufPtr = &curIoReq->m_devReq; @@ -128,14 +98,8 @@ static int setupControlTransfer(UsbdEndpoint_t *ep) return 1; } // remove endpoint from busy list if there are no IoRequests left - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - else - memPool->m_tdQueueStart = ep->m_busyNext; + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; return 1; } @@ -154,18 +118,8 @@ static int setupIsocronTransfer(UsbdEndpoint_t *ep) // endpoint error if ( ep->m_inTdQueue == NOTIN_QUEUE ) return 0; - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - { - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - } - else - { - memPool->m_tdQueueStart = ep->m_busyNext; - } + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; return 0; } @@ -177,61 +131,34 @@ static int setupIsocronTransfer(UsbdEndpoint_t *ep) if ( ep->m_inTdQueue != NOTIN_QUEUE ) return 0; ep->m_busyPrev = memPool->m_tdQueueEnd; - if ( memPool->m_tdQueueEnd ) - memPool->m_tdQueueEnd->m_busyNext = ep; - else - memPool->m_tdQueueStart = ep; + *( memPool->m_tdQueueEnd ? &(memPool->m_tdQueueEnd->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep; ep->m_busyNext = NULL; memPool->m_tdQueueEnd = ep; ep->m_inTdQueue = ISOTD_QUEUE; return 0; } - if ( curIoReq->m_next ) - curIoReq->m_next->m_prev = curIoReq->m_prev; - else - ep->m_ioReqListEnd = curIoReq->m_prev; - if ( curIoReq->m_prev ) - curIoReq->m_prev->m_next = curIoReq->m_next; - else - ep->m_ioReqListStart = curIoReq->m_next; - if ( (UsbdHcTD_t *)((uiptr)ed->m_tdHead & ~0xF) == ed->m_tdTail ) - frameNo = (memPool->m_hcHCCA->FrameNumber + 2) & 0xFFFF; - else - frameNo = (ep->m_isochronLastFrameNum) & 0xFFFF; + *( curIoReq->m_next ? &(curIoReq->m_next->m_prev) : &(ep->m_ioReqListEnd) ) = curIoReq->m_prev; + *( curIoReq->m_prev ? &(curIoReq->m_prev->m_next) : &(ep->m_ioReqListStart) ) = curIoReq->m_next; + frameNo = ( (UsbdHcTD_t *)((uiptr)ed->m_tdHead & ~0xF) == ed->m_tdTail ) ? ((memPool->m_hcHCCA->FrameNumber + 2) & 0xFFFF) : ((ep->m_isochronLastFrameNum) & 0xFFFF); frameNo = (u16)(frameNo + (curIoReq->m_waitFrames & 0xFFFF)); ep->m_isochronLastFrameNum = (curIoReq->m_req.bNumPackets ? (curIoReq->m_req.bNumPackets & 0xFFFF) : 1) + frameNo; + curTd->m_hcArea = (curIoReq->m_req.bNumPackets ? ((curIoReq->m_req.bNumPackets - 1) << 24) : 0) | frameNo | (USB_RC_NOTACCESSED << 28); + curTd->m_next = newTd; + curTd->m_bufferPage0 = (void *)((uiptr)curIoReq->m_destPtr & ~0xFFF); + curTd->m_bufferEnd = ( curIoReq->m_destPtr && (int)(curIoReq->m_length) > 0 ) ? ((u8 *)curIoReq->m_destPtr + ((int)curIoReq->m_length - 1)) : NULL; + curTd->m_psw[0] = ((uiptr)curIoReq->m_destPtr & 0xFFF) | (USB_RC_NOTACCESSED << 12); if ( curIoReq->m_req.bNumPackets ) { int psw0_tmp; int i; - curTd->m_hcArea = ((curIoReq->m_req.bNumPackets - 1) << 24) | frameNo | (USB_RC_NOTACCESSED << 28); - curTd->m_next = newTd; - curTd->m_bufferPage0 = (void *)((uiptr)curIoReq->m_destPtr & ~0xFFF); - curTd->m_bufferEnd = NULL; - if ( curIoReq->m_destPtr && (int)(curIoReq->m_length) > 0 ) - { - curTd->m_bufferEnd = (u8 *)curIoReq->m_destPtr + ((int)curIoReq->m_length - 1); - } - psw0_tmp = ((uiptr)curIoReq->m_destPtr & 0xFFF) | (USB_RC_NOTACCESSED << 12); + psw0_tmp = curTd->m_psw[0]; for ( i = 0; i < (int)curIoReq->m_req.bNumPackets; i += 1 ) { curTd->m_psw[i] = psw0_tmp; psw0_tmp += curIoReq->m_req.Packets[i].bLength; } } - else - { - curTd->m_hcArea = frameNo | (USB_RC_NOTACCESSED << 28); - curTd->m_next = newTd; - curTd->m_bufferPage0 = (void *)((uiptr)curIoReq->m_destPtr & ~0xFFF); - curTd->m_bufferEnd = NULL; - if ( curIoReq->m_destPtr && (int)(curIoReq->m_length) > 0 ) - { - curTd->m_bufferEnd = (u8 *)curIoReq->m_destPtr + ((int)curIoReq->m_length - 1); - } - curTd->m_psw[0] = ((uiptr)curIoReq->m_destPtr & 0xFFF) | (USB_RC_NOTACCESSED << 12); - } memPool->m_hcIsoTdToIoReqLUT[curTd - memPool->m_hcIsoTdBuf] = curIoReq; ed->m_tdTail = (UsbdHcTD_t *)newTd; if ( ep->m_ioReqListStart ) @@ -243,14 +170,8 @@ static int setupIsocronTransfer(UsbdEndpoint_t *ep) return 1; } // remove endpoint from busy list if there are no IoRequests left - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - else - memPool->m_tdQueueStart = ep->m_busyNext; + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; return 1; } @@ -269,18 +190,8 @@ static int setupBulkTransfer(UsbdEndpoint_t *ep) dbg_printf("ERROR UsbdEndpoint_t error\n"); if ( ep->m_inTdQueue == NOTIN_QUEUE ) return 0; - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - { - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - } - else - { - memPool->m_tdQueueStart = ep->m_busyNext; - } + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; return 0; } @@ -292,31 +203,18 @@ static int setupBulkTransfer(UsbdEndpoint_t *ep) if ( ep->m_inTdQueue != NOTIN_QUEUE ) return 0; ep->m_busyPrev = memPool->m_tdQueueEnd; - if ( memPool->m_tdQueueEnd ) - memPool->m_tdQueueEnd->m_busyNext = ep; - else - memPool->m_tdQueueStart = ep; + *( memPool->m_tdQueueEnd ? &(memPool->m_tdQueueEnd->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep; ep->m_busyNext = NULL; memPool->m_tdQueueEnd = ep; ep->m_inTdQueue = GENTD_QUEUE; return 0; } - if ( curIoReq->m_next ) - curIoReq->m_next->m_prev = curIoReq->m_prev; - else - ep->m_ioReqListEnd = curIoReq->m_prev; - if ( curIoReq->m_prev ) - curIoReq->m_prev->m_next = curIoReq->m_next; - else - ep->m_ioReqListStart = curIoReq->m_next; + *( curIoReq->m_next ? &(curIoReq->m_next->m_prev) : &(ep->m_ioReqListEnd) ) = curIoReq->m_prev; + *( curIoReq->m_prev ? &(curIoReq->m_prev->m_next) : &(ep->m_ioReqListStart) ) = curIoReq->m_next; curTd->m_hcArea = TD_HCAREA(USB_RC_NOTACCESSED, 0, 0, 3, 1) << 16; curTd->m_next = newTd; curTd->m_curBufPtr = curIoReq->m_destPtr; - curTd->m_bufferEnd = NULL; - if ( curIoReq->m_destPtr && (int)curIoReq->m_length > 0 ) - { - curTd->m_bufferEnd = (u8 *)curIoReq->m_destPtr + ((int)curIoReq->m_length - 1); - } + curTd->m_bufferEnd = ( curIoReq->m_destPtr && (int)curIoReq->m_length > 0 ) ? ((u8 *)curIoReq->m_destPtr + ((int)curIoReq->m_length - 1)) : NULL; memPool->m_hcTdToIoReqLUT[curTd - memPool->m_hcTdBuf] = curIoReq; ed->m_tdTail = newTd; if ( ep->m_endpointType == TYPE_BULK ) @@ -330,14 +228,8 @@ static int setupBulkTransfer(UsbdEndpoint_t *ep) return 1; } // remove endpoint from busy list if there are no IoRequests left - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - else - memPool->m_tdQueueStart = ep->m_busyNext; + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; return 1; } diff --git a/iop/usb/usbd/src/mem.c b/iop/usb/usbd/src/mem.c index a852a38e5179..c1276b54f51a 100644 --- a/iop/usb/usbd/src/mem.c +++ b/iop/usb/usbd/src/mem.c @@ -23,9 +23,7 @@ UsbdDevice_t *fetchDeviceById(int devId) return NULL; } dev = &memPool->m_deviceTreeBuf[devId]; - if ( !dev->m_parent ) - return NULL; - return dev; + return ( !dev->m_parent ) ? NULL : dev; } UsbdEndpoint_t *fetchEndpointById(int id) @@ -41,9 +39,7 @@ UsbdEndpoint_t *fetchEndpointById(int id) return NULL; } ep = &memPool->m_endpointBuf[id]; - if ( !ep->m_correspDevice ) - return NULL; - return ep; + return ( !ep->m_correspDevice ) ? NULL : ep; } UsbdDevice_t *getDeviceTreeRoot(void) @@ -61,14 +57,8 @@ UsbdDevice_t *attachChildDevice(UsbdDevice_t *parent, u32 portNum) dbg_printf("Ran out of device handles\n"); return NULL; } - if ( newDev->m_next ) - newDev->m_next->m_prev = newDev->m_prev; - else - memPool->m_freeDeviceListEnd = newDev->m_prev; - if ( newDev->m_prev ) - newDev->m_prev->m_next = newDev->m_next; - else - memPool->m_freeDeviceListStart = newDev->m_next; + *( newDev->m_next ? &(newDev->m_next->m_prev) : &(memPool->m_freeDeviceListEnd) ) = newDev->m_prev; + *( newDev->m_prev ? &(newDev->m_prev->m_next) : &(memPool->m_freeDeviceListStart) ) = newDev->m_next; newDev->m_endpointListEnd = NULL; newDev->m_endpointListStart = NULL; newDev->m_devDriver = NULL; @@ -83,10 +73,7 @@ UsbdDevice_t *attachChildDevice(UsbdDevice_t *parent, u32 portNum) if ( parent ) { newDev->m_prev = parent->m_childListEnd; - if ( parent->m_childListEnd ) - parent->m_childListEnd->m_next = newDev; - else - parent->m_childListStart = newDev; + *( parent->m_childListEnd ? &(parent->m_childListEnd->m_next) : &(parent->m_childListStart) ) = newDev; newDev->m_next = NULL; parent->m_childListEnd = newDev; } @@ -101,10 +88,7 @@ void freeDevice(UsbdDevice_t *dev) return; } dev->m_prev = memPool->m_freeDeviceListEnd; - if ( memPool->m_freeDeviceListEnd ) - memPool->m_freeDeviceListEnd->m_next = dev; - else - memPool->m_freeDeviceListStart = dev; + *( memPool->m_freeDeviceListEnd ? &(memPool->m_freeDeviceListEnd->m_next) : &(memPool->m_freeDeviceListStart) ) = dev; dev->m_next = NULL; memPool->m_freeDeviceListEnd = dev; dev->m_parent = NULL; @@ -120,14 +104,8 @@ UsbdIoRequest_t *allocIoRequest(void) dbg_printf("ran out of IoReqs\n"); return NULL; } - if ( res->m_next ) - res->m_next->m_prev = res->m_prev; - else - memPool->m_freeIoReqListEnd = res->m_prev; - if ( res->m_prev ) - res->m_prev->m_next = res->m_next; - else - memPool->m_freeIoReqList = res->m_next; + *( res->m_next ? &(res->m_next->m_prev) : &(memPool->m_freeIoReqListEnd) ) = res->m_prev; + *( res->m_prev ? &(res->m_prev->m_next) : &(memPool->m_freeIoReqList) ) = res->m_next; return res; } @@ -154,10 +132,7 @@ void freeIoRequest(UsbdIoRequest_t *req) } req->m_busyFlag = 0; req->m_prev = memPool->m_freeIoReqListEnd; - if ( memPool->m_freeIoReqListEnd ) - memPool->m_freeIoReqListEnd->m_next = req; - else - memPool->m_freeIoReqList = req; + *( memPool->m_freeIoReqListEnd ? &(memPool->m_freeIoReqListEnd->m_next) : &(memPool->m_freeIoReqList) ) = req; req->m_next = NULL; memPool->m_freeIoReqListEnd = req; } @@ -171,14 +146,8 @@ UsbdEndpoint_t *allocEndpointForDevice(UsbdDevice_t *dev, u32 align) { return NULL; } - if ( newEp->m_next ) - newEp->m_next->m_prev = newEp->m_prev; - else - memPool->m_freeEpListEnd = newEp->m_prev; - if ( newEp->m_prev ) - newEp->m_prev->m_next = newEp->m_next; - else - memPool->m_freeEpListStart = newEp->m_next; + *( newEp->m_next ? &(newEp->m_next->m_prev) : &(memPool->m_freeEpListEnd) ) = newEp->m_prev; + *( newEp->m_prev ? &(newEp->m_prev->m_next) : &(memPool->m_freeEpListStart) ) = newEp->m_next; newEp->m_correspDevice = dev; newEp->m_ioReqListEnd = NULL; newEp->m_ioReqListStart = NULL; @@ -187,10 +156,7 @@ UsbdEndpoint_t *allocEndpointForDevice(UsbdDevice_t *dev, u32 align) newEp->m_inTdQueue = 0; newEp->m_alignFlag = align; newEp->m_prev = dev->m_endpointListEnd; - if ( dev->m_endpointListEnd ) - dev->m_endpointListEnd->m_next = newEp; - else - dev->m_endpointListStart = newEp; + *( dev->m_endpointListEnd ? &(dev->m_endpointListEnd->m_next) : &(dev->m_endpointListStart) ) = newEp; newEp->m_next = NULL; dev->m_endpointListEnd = newEp; return newEp; @@ -204,29 +170,14 @@ int cleanUpFunc(UsbdDevice_t *dev, UsbdEndpoint_t *ep) } if ( ep->m_inTdQueue != NOTIN_QUEUE ) { - if ( ep->m_busyNext ) - ep->m_busyNext->m_busyPrev = ep->m_busyPrev; - else - memPool->m_tdQueueEnd = ep->m_busyPrev; - if ( ep->m_busyPrev ) - ep->m_busyPrev->m_busyNext = ep->m_busyNext; - else - memPool->m_tdQueueStart = ep->m_busyNext; + *( ep->m_busyNext ? &(ep->m_busyNext->m_busyPrev) : &(memPool->m_tdQueueEnd) ) = ep->m_busyPrev; + *( ep->m_busyPrev ? &(ep->m_busyPrev->m_busyNext) : &(memPool->m_tdQueueStart) ) = ep->m_busyNext; ep->m_inTdQueue = NOTIN_QUEUE; } - if ( ep->m_next ) - ep->m_next->m_prev = ep->m_prev; - else - dev->m_endpointListEnd = ep->m_prev; - if ( ep->m_prev ) - ep->m_prev->m_next = ep->m_next; - else - dev->m_endpointListStart = ep->m_next; + *( ep->m_next ? &(ep->m_next->m_prev) : &(dev->m_endpointListEnd) ) = ep->m_prev; + *( ep->m_prev ? &(ep->m_prev->m_next) : &(dev->m_endpointListStart) ) = ep->m_next; ep->m_prev = memPool->m_freeEpListEnd; - if ( memPool->m_freeEpListEnd ) - memPool->m_freeEpListEnd->m_next = ep; - else - memPool->m_freeEpListStart = ep; + *( memPool->m_freeEpListEnd ? &(memPool->m_freeEpListEnd->m_next) : &(memPool->m_freeEpListStart) ) = ep; ep->m_next = NULL; memPool->m_freeEpListEnd = ep; ep->m_correspDevice = NULL; diff --git a/iop/usb/usbd/src/report_descriptor_init.c b/iop/usb/usbd/src/report_descriptor_init.c index aacc35cc61d9..600b68e7f54b 100644 --- a/iop/usb/usbd/src/report_descriptor_init.c +++ b/iop/usb/usbd/src/report_descriptor_init.c @@ -99,10 +99,7 @@ int handleStaticDeviceDescriptor(UsbdDevice_t *dev, UsbDeviceDescriptor *devDesc hidDescriptor->m_length = wItemLength; hidDescriptor->m_cfgNum = cfgNum; hidDescriptor->m_prev = dev->m_reportDescriptorEnd; - if ( dev->m_reportDescriptorEnd ) - dev->m_reportDescriptorEnd->m_next = hidDescriptor; - else - dev->m_reportDescriptorStart = hidDescriptor; + *(dev->m_reportDescriptorEnd ? &(dev->m_reportDescriptorEnd->m_next) : &(dev->m_reportDescriptorStart)) = hidDescriptor; hidDescriptor->m_next = NULL; dev->m_reportDescriptorEnd = hidDescriptor; } diff --git a/iop/usb/usbd/src/td_queue.c b/iop/usb/usbd/src/td_queue.c index 0079dcf186c7..8b748edc5c1e 100644 --- a/iop/usb/usbd/src/td_queue.c +++ b/iop/usb/usbd/src/td_queue.c @@ -98,10 +98,7 @@ void processDoneQueue_GenTd(UsbdHcTD_t *arg) } req_2->m_resultCode = USB_RC_ABORTED; req_2->m_prev = lastElem; - if ( lastElem ) - lastElem->m_next = req_2; - else - firstElem = req_2; + *(lastElem ? &(lastElem->m_next) : &(firstElem)) = req_2; req_2->m_next = NULL; lastElem = req_2; } @@ -176,20 +173,10 @@ void processDoneQueue_IsoTd(UsbdHcIsoTD_t *arg) bcopy(arg->m_psw, req_1->m_req.Packets, 16); freeIsoTd(arg); req_1->m_transferedBytes = 0; - if ( req_1->m_req.bNumPackets ) - { - req_1->m_resultCode = tdHcRes; - } - else + req_1->m_resultCode = req_1->m_req.bNumPackets ? tdHcRes : (tdHcRes | (pswRes << 4)); + if ( !req_1->m_req.bNumPackets && tdHcRes == USB_RC_OK && (pswRes == USB_RC_OK || pswRes == USB_RC_DATAUNDER) ) { - req_1->m_resultCode = tdHcRes | (pswRes << 4); - if ( tdHcRes == USB_RC_OK && (pswRes == USB_RC_OK || pswRes == USB_RC_DATAUNDER) ) - { - if ( (req_1->m_correspEndpoint->m_hcEd->m_hcArea.stru.m_hcArea & HCED_DIR_MASK) == HCED_DIR_IN ) - req_1->m_transferedBytes = pswOfs; - else - req_1->m_transferedBytes = req_1->m_length; - } + req_1->m_transferedBytes = ( (req_1->m_correspEndpoint->m_hcEd->m_hcArea.stru.m_hcArea & HCED_DIR_MASK) == HCED_DIR_IN ) ? pswOfs : req_1->m_length; } req_1->m_prev = NULL; listStart = req_1; @@ -220,10 +207,7 @@ void processDoneQueue_IsoTd(UsbdHcIsoTD_t *arg) } req_2->m_resultCode = USB_RC_ABORTED; req_2->m_prev = listEnd; - if ( listEnd ) - listEnd->m_next = req_2; - else - listStart = req_2; + *(listEnd ? &(listEnd->m_next) : &(listStart)) = req_2; req_2->m_next = NULL; listEnd = req_2; } diff --git a/iop/usb/usbd/src/timer.c b/iop/usb/usbd/src/timer.c index 4e176bc63d85..76e915b15b5e 100644 --- a/iop/usb/usbd/src/timer.c +++ b/iop/usb/usbd/src/timer.c @@ -17,34 +17,24 @@ int addTimerCallback(UsbdTimerCbStruct_t *arg, TimerCallback func, void *cbArg, if ( arg->m_isActive ) return -1; arg->m_isActive = 1; - if ( delay > 0 ) - delay -= 1; + delay -= ( delay > 0 ) ? 1 : 0; arg->m_callbackProc = func; arg->m_callbackArg = cbArg; for ( pos = memPool->m_timerListStart; pos && delay >= (int)pos->m_delayCount; delay -= pos->m_delayCount, pos = pos->m_prev ) { } + arg->m_next = pos ? pos->m_next : memPool->m_timerListEnd; + *( pos ? (pos->m_next ? &(pos->m_next->m_prev) : &(memPool->m_timerListStart)) : (memPool->m_timerListEnd ? &(memPool->m_timerListEnd->m_prev) : &(memPool->m_timerListStart)) ) = arg; + arg->m_prev = pos; if ( pos ) { - arg->m_next = pos->m_next; - if ( pos->m_next ) - pos->m_next->m_prev = arg; - else - memPool->m_timerListStart = arg; - arg->m_prev = pos; pos->m_next = arg; pos->m_delayCount -= delay; } else { - arg->m_next = memPool->m_timerListEnd; - if ( memPool->m_timerListEnd ) - memPool->m_timerListEnd->m_prev = arg; - else - memPool->m_timerListStart = arg; memPool->m_timerListEnd = arg; - arg->m_prev = NULL; } arg->m_delayCount = delay; memPool->m_ohciRegs->HcInterruptEnable = OHCI_INT_SF; @@ -57,14 +47,8 @@ int cancelTimerCallback(UsbdTimerCbStruct_t *arg) { return -1; } - if ( arg->m_prev ) - arg->m_prev->m_next = arg->m_next; - else - memPool->m_timerListEnd = arg->m_next; - if ( arg->m_next ) - arg->m_next->m_prev = arg->m_prev; - else - memPool->m_timerListStart = arg->m_prev; + *( arg->m_prev ? &(arg->m_prev->m_next) : &(memPool->m_timerListEnd) ) = arg->m_next; + *( arg->m_next ? &(arg->m_next->m_prev) : &(memPool->m_timerListStart) ) = arg->m_prev; arg->m_isActive = 0; arg->m_next = NULL; arg->m_prev = NULL; @@ -78,8 +62,7 @@ void handleTimerList(void) timer = memPool->m_timerListStart; if ( timer ) { - if ( timer->m_delayCount > 0 ) - timer->m_delayCount -= 1; + timer->m_delayCount -= ( timer->m_delayCount > 0 ) ? 1 : 0; while ( 1 ) { timer = memPool->m_timerListStart; @@ -87,10 +70,7 @@ void handleTimerList(void) break; dbg_printf("timer expired\n"); memPool->m_timerListStart = timer->m_prev; - if ( timer->m_prev ) - timer->m_prev->m_next = NULL; - else - memPool->m_timerListEnd = NULL; + *( timer->m_prev ? &(timer->m_prev->m_next) : &(memPool->m_timerListEnd) ) = NULL; timer->m_next = NULL; timer->m_prev = NULL; timer->m_isActive = 0; diff --git a/iop/usb/usbd/src/usbd_api.c b/iop/usb/usbd/src/usbd_api.c index c1732bc38556..41e9d6feba7d 100644 --- a/iop/usb/usbd/src/usbd_api.c +++ b/iop/usb/usbd/src/usbd_api.c @@ -337,10 +337,7 @@ static void signalCallbackThreadFunc(UsbdIoRequest_t *req) CpuSuspendIntr(&state); req->m_prev = cbListEnd; - if ( !cbListEnd ) - cbListStart = req; - else - cbListEnd->m_next = req; + *(cbListEnd ? &(cbListEnd->m_next) : &(cbListStart)) = req; req->m_next = NULL; cbListEnd = req; CpuResumeIntr(state); @@ -476,15 +473,11 @@ static int usbdTransferPipeImpl( { case TYPE_ISOCHRON: { + req->m_waitFrames = request ? request->bRelStartFrame : (u32)option; if ( request ) { - req->m_waitFrames = request->bRelStartFrame; memcpy(&(req->m_req), request, sizeof(sceUsbdMultiIsochronousRequest)); } - else - { - req->m_waitFrames = (u32)option; - } res = attachIoReqToEndpoint(ep, req, data, length, signalCallbackThreadFunc); break; } diff --git a/iop/usb/usbd/src/usbd_main.c b/iop/usb/usbd/src/usbd_main.c index b511a5d08688..17c8624b4c71 100644 --- a/iop/usb/usbd/src/usbd_main.c +++ b/iop/usb/usbd/src/usbd_main.c @@ -113,14 +113,8 @@ static void callbackThreadFunc(void *arg) req = cbListStart; if ( req ) { - if ( req->m_next ) - req->m_next->m_prev = req->m_prev; - else - cbListEnd = req->m_prev; - if ( req->m_prev ) - req->m_prev->m_next = req->m_next; - else - cbListStart = req->m_next; + *(req->m_next ? &(req->m_next->m_prev) : &(cbListEnd)) = req->m_prev; + *(req->m_prev ? &(req->m_prev->m_next) : &(cbListStart)) = req->m_next; } CpuResumeIntr(state); if ( !req ) diff --git a/iop/usb/usbmass_bd/src/usb_mass.c b/iop/usb/usbmass_bd/src/usb_mass.c index 8e11032d716d..8350b9c03d5e 100644 --- a/iop/usb/usbmass_bd/src/usb_mass.c +++ b/iop/usb/usbmass_bd/src/usb_mass.c @@ -477,10 +477,7 @@ int usb_queue_cmd(struct scsi_interface *scsi, const unsigned char *cmd, unsigne #ifndef ASYNC result = -EIO; if (usb_bulk_command(dev, &ucmd.cbw) == USB_RC_OK) { - if (data_len > 0) - rcode = usb_bulk_transfer(dev, data_wr ? USB_BLK_EP_OUT : USB_BLK_EP_IN, data, data_len); - else - rcode = USB_RC_OK; + rcode = (data_len > 0) ? usb_bulk_transfer(dev, data_wr ? USB_BLK_EP_OUT : USB_BLK_EP_IN, data, data_len) : USB_RC_OK; result = usb_bulk_manage_status(dev, tag); @@ -787,12 +784,7 @@ static void usb_mass_update(void *arg) } sceUsbdGetDeviceLocation(dev->devId, path); - if (path[0] == 2) - dev->scsi.devNr = 0; // first USB port - else if (path[0] == 1) - dev->scsi.devNr = 1; // second USB port - else - dev->scsi.devNr = 2; // hub? + dev->scsi.devNr = (path[0] == 2) ? 0 /* first USB port */ : ((path[0] == 1) ? 1 /* second USB port */ : 2 /* hub? */); dev->status |= USBMASS_DEV_STAT_CONF; scsi_connect(&dev->scsi); diff --git a/iop/usb/usbmload/src/usbmload.c b/iop/usb/usbmload/src/usbmload.c index 0be68593dfb9..b15a9777d6f6 100644 --- a/iop/usb/usbmload/src/usbmload.c +++ b/iop/usb/usbmload/src/usbmload.c @@ -294,10 +294,7 @@ static int do_parse_config_file(const char *fn) { if ( devstr ) { - if ( g_usbm_entry_list_cur ) - g_usbm_entry_list_cur->forw = devstr; - else - g_usbm_entry_list_end = devstr; + *(g_usbm_entry_list_cur ? &(g_usbm_entry_list_cur->forw) : &(g_usbm_entry_list_end)) = devstr; devstr->forw = 0; g_usbm_entry_list_cur = devstr; if ( g_param_debug > 0 ) @@ -458,10 +455,7 @@ static int do_parse_config_file(const char *fn) } if ( devstr ) { - if ( g_usbm_entry_list_cur ) - g_usbm_entry_list_cur->forw = devstr; - else - g_usbm_entry_list_end = devstr; + *(g_usbm_entry_list_cur ? &(g_usbm_entry_list_cur->forw) : &(g_usbm_entry_list_end)) = devstr; devstr->forw = 0; g_usbm_entry_list_cur = devstr; if ( g_param_debug > 0 ) @@ -964,10 +958,7 @@ int sceUsbmlRegisterDevice(USBDEV_t *device) } return -1; } - if ( g_usbm_entry_list_cur ) - g_usbm_entry_list_cur->forw = devinfo; - else - g_usbm_entry_list_end = devinfo; + *(g_usbm_entry_list_cur ? &(g_usbm_entry_list_cur->forw) : &(g_usbm_entry_list_end)) = devinfo; devinfo->forw = 0; g_usbm_entry_list_cur = devinfo; return 0; diff --git a/tools/adpenc/src/adpcm.c b/tools/adpenc/src/adpcm.c index a446aaf85150..1ea49184c1e2 100644 --- a/tools/adpenc/src/adpcm.c +++ b/tools/adpenc/src/adpcm.c @@ -150,10 +150,7 @@ int adpcm_encode(FILE* fp, FILE* sad, int offset, int sample_len, int flag_loop, if ( sample_len < 28 ) { - if(flag_loop == 2) - flags = 3; - else - flags = 1; + flags = (flag_loop == 2) ? 3 : 1; } } } @@ -195,10 +192,8 @@ static void find_predict( short *samples, double *d_samples, int *predict_nr, in s_2 = _s_2; for ( j = 0; j < 28; j ++ ) { s_0 = (double) samples[j]; // s[t-0] - if ( s_0 > 30719.0 ) - s_0 = 30719.0; - if ( s_0 < - 30720.0 ) - s_0 = -30720.0; + s_0 = ( s_0 > 30719.0 ) ? 30719.0 : s_0; + s_0 = ( s_0 < - 30720.0 ) ? -30720.0 : s_0; ds = s_0 + s_1 * f[i][0] + s_2 * f[i][1]; buffer[j][i] = ds; if ( fabs( ds ) > max[i] ) @@ -260,10 +255,8 @@ static void pack( const double *d_samples, short *four_bit, int predict_nr, int di = ( (int) ds + 0x800 ) & 0xfffff000; - if ( di > 32767 ) - di = 32767; - if ( di < -32768 ) - di = -32768; + di = ( di > 32767 ) ? 32767 : di; + di = ( di < -32768 ) ? -32768 : di; four_bit[i] = (short) di; diff --git a/tools/ps2-irxgen/src/ps2-irxgen.c b/tools/ps2-irxgen/src/ps2-irxgen.c index 320026282e48..24c0bc526cf4 100644 --- a/tools/ps2-irxgen/src/ps2-irxgen.c +++ b/tools/ps2-irxgen/src/ps2-irxgen.c @@ -467,14 +467,11 @@ int process_relocs(void) pReloc = &g_elfsections[i]; if((pReloc->iLink < g_elfhead.iShnum) && (g_elfsections[pReloc->iLink].iType == SHT_SYMTAB)) { - struct ElfSection *pStrings = NULL; + struct ElfSection *pStrings; struct ElfSection *pSymbols; pSymbols = &g_elfsections[pReloc->iLink]; - if((pSymbols->iLink < g_elfhead.iShnum) && (g_elfsections[pSymbols->iLink].iType == SHT_STRTAB)) - { - pStrings = &g_elfsections[pSymbols->iLink]; - } + pStrings = ((pSymbols->iLink < g_elfhead.iShnum) && (g_elfsections[pSymbols->iLink].iType == SHT_STRTAB)) ? &g_elfsections[pSymbols->iLink] : NULL; if(!remove_weak_relocs(pReloc, pSymbols, pStrings)) { @@ -768,10 +765,7 @@ void output_sh(unsigned char *data) if(g_elfsections[i].iType == SHT_REL) { SW(&shdr->sh_type, SHT_REL); - if (g_elfsections[i].pRef) - SW(&shdr->sh_info, g_elfsections[i].pRef->iIndex); - else - SW(&shdr->sh_info, 0); + SW(&shdr->sh_info, g_elfsections[i].pRef ? g_elfsections[i].pRef->iIndex : 0); SW(&shdr->sh_offset, reloc_ofs); reloc_ofs += g_elfsections[i].iSize; } diff --git a/tools/ps2adpcm/src/adpcm.c b/tools/ps2adpcm/src/adpcm.c index b3f50f4c48ff..5f94316702dd 100644 --- a/tools/ps2adpcm/src/adpcm.c +++ b/tools/ps2adpcm/src/adpcm.c @@ -53,10 +53,7 @@ AdpcmSetup *AdpcmCreate(AdpcmGetPCMfunc get, void *getpriv, AdpcmPutADPCMfunc pu set->curblock = 0; - if (loopstart<0) /* disable looping (single shot) */ - set->loopstart = -1; - else - set->loopstart = loopstart; + set->loopstart = (loopstart<0) /* disable looping (single shot) */ ? -1 : loopstart; set->GetPCM = get; set->getpriv = getpriv; diff --git a/tools/ps2adpcm/src/main.c b/tools/ps2adpcm/src/main.c index 2f05a9e98d43..03be54d3a5a8 100644 --- a/tools/ps2adpcm/src/main.c +++ b/tools/ps2adpcm/src/main.c @@ -117,16 +117,11 @@ int main(int argc, char *argv[]) } - if (!strcmp(infile, "-")) - fi = stdin; - else + fi = (!strcmp(infile, "-")) ? stdin : fopen(infile, "rb"); + if (fi==NULL) { - fi = fopen(infile, "rb"); - if (fi==NULL) - { - dprintf("Failed to open input file '%s' (%s)\n", infile, strerror(errno)); - return(1); - } + dprintf("Failed to open input file '%s' (%s)\n", infile, strerror(errno)); + return(1); } fo = fopen(outfile, "wb"); diff --git a/tools/romimg/src/platform.c b/tools/romimg/src/platform.c index 14e4a6c6c162..16910488cc21 100644 --- a/tools/romimg/src/platform.c +++ b/tools/romimg/src/platform.c @@ -109,10 +109,7 @@ int GetCurrentWorkingDirectory(char *buffer, unsigned int BufferSize) #if defined(_WIN32) || defined(WIN32) return (GetCurrentDirectoryA(BufferSize, buffer) == 0 ? EIO : 0); #else - if (getcwd(buffer, BufferSize) != NULL) - return 0; - else - return EIO; + return (getcwd(buffer, BufferSize) != NULL) ? 0 : EIO; #endif } diff --git a/tools/romimg/src/romimg.c b/tools/romimg/src/romimg.c index a1c7f5e193c3..fdd40fd6f2e2 100644 --- a/tools/romimg/src/romimg.c +++ b/tools/romimg/src/romimg.c @@ -100,11 +100,9 @@ static int GetExtInfoStat(const struct ROMImgStat *ImageStat, struct RomDirFileF BytesToCopy = ExtInfoEntry->ExtLength; result = 0; } else { - if (*buffer != NULL) { - BytesToCopy = nbytes; - } else { + BytesToCopy = *buffer ? nbytes : ExtInfoEntry->ExtLength; + if (*buffer == NULL) { *buffer = malloc(ExtInfoEntry->ExtLength); - BytesToCopy = ExtInfoEntry->ExtLength; } result = ExtInfoEntry->ExtLength; } diff --git a/tools/srxfixup/src/anaarg.c b/tools/srxfixup/src/anaarg.c index a0ac56b3c4e3..9beb25e46d9a 100644 --- a/tools/srxfixup/src/anaarg.c +++ b/tools/srxfixup/src/anaarg.c @@ -64,19 +64,9 @@ int analize_arguments(const Opttable *dopttable, int argc, char **argv) opt = 0; for ( i = 0; opttable[i].option; i += 1 ) { - if ( opttable[i].havearg == ARG_HAVEARG_UNK3 ) + if ( (opttable[i].havearg == ARG_HAVEARG_UNK3 ) ? (!strcmp(opttable[i].option, *argva)) : (!strncmp(opttable[i].option, *argva, strlen(opttable[i].option))) ) { - if ( !strcmp(opttable[i].option, *argva) ) - { - break; - } - } - else - { - if ( !strncmp(opttable[i].option, *argva, strlen(opttable[i].option)) ) - { - break; - } + break; } } if ( !opttable[i].option ) @@ -102,14 +92,7 @@ int analize_arguments(const Opttable *dopttable, int argc, char **argv) { case 'F': case 'f': - if ( (*argva)[strlen(opttable[i].option)] ) - { - *(uint32_t *)opttable[i].var = strtoul(&(*argva)[strlen(opttable[i].option)], NULL, 16); - } - else - { - *(uint32_t *)opttable[i].var = (opttable[i].vartype == 'f') ? 1 : 0; - } + *(uint32_t *)opttable[i].var = ( (*argva)[strlen(opttable[i].option)] ) ? strtoul(&(*argva)[strlen(opttable[i].option)], NULL, 16) : ((opttable[i].vartype == 'f') ? 1 : 0); break; case 'h': if ( opt != NULL ) diff --git a/tools/srxfixup/src/elfdump.c b/tools/srxfixup/src/elfdump.c index 87606484b6c3..b373ecbe3c40 100644 --- a/tools/srxfixup/src/elfdump.c +++ b/tools/srxfixup/src/elfdump.c @@ -332,16 +332,7 @@ void print_elf_sections(const elf_file *elf, unsigned int flag) { if ( (elf->scp[i]->shr.sh_flags & SHF_EXECINSTR) != 0 && elf->ehp->e_machine == EM_MIPS ) { - if ( - ((elf->ehp->e_flags & EF_MIPS_MACH) == EF_MIPS_MACH_5900) - && ((elf->ehp->e_flags & EF_MIPS_ARCH) == EF_MIPS_ARCH_3) ) - { - initdisasm(2, -1, 0, 0, 0); - } - else - { - initdisasm(1, -1, 0, 0, 0); - } + initdisasm(( ((elf->ehp->e_flags & EF_MIPS_MACH) == EF_MIPS_MACH_5900) && ((elf->ehp->e_flags & EF_MIPS_ARCH) == EF_MIPS_ARCH_3) ) ? 2 : 1, -1, 0, 0, 0); print_elf_disasm(elf, elf->scp[i], flag); } else @@ -517,11 +508,11 @@ static void search_rel_section( break; } } + *result = ( i < elf->ehp->e_shnum ) ? (elf_rel *)relscp->data : 0; + *relentries = ( i < elf->ehp->e_shnum ) ? (relscp->shr.sh_size / relscp->shr.sh_entsize) : 0; + *baseoff = 0; if ( i < elf->ehp->e_shnum ) { - *result = (elf_rel *)relscp->data; - *relentries = relscp->shr.sh_size / relscp->shr.sh_entsize; - *baseoff = 0; switch ( elf->ehp->e_type ) { case ET_SCE_IOPRELEXEC: @@ -534,12 +525,6 @@ static void search_rel_section( break; } } - else - { - *result = 0; - *relentries = 0; - *baseoff = 0; - } } static void search_rel_data(const elf_rel *rpbase, unsigned int relentries, unsigned int addr, struct rellink *result) @@ -586,18 +571,9 @@ static void dumpb(const char *head, unsigned int address, unsigned int size, con if ( data[off1] > 0x1F && data[off1] <= 0x7E ) { unsigned int v4; - uint8_t *v5; v4 = addr & 0xF; - if ( v4 <= 7 ) - { - v5 = &cbuf[v4]; - } - else - { - v5 = &cbuf[v4 + 1]; - } - *v5 = data[off1]; + cbuf[v4 + (( v4 <= 7 ) ? 0 : 1)] = data[off1]; } } if ( (((uint8_t)addr + 1) & 3) == 0 ) @@ -610,10 +586,7 @@ static void dumpb(const char *head, unsigned int address, unsigned int size, con printf("\n"); strcpy((char *)cbuf, "........ ........"); } - if ( address <= addr ) - { - off1 += 1; - } + off1 += ( address <= addr ) ? 1 : 0; } for ( ; (addr & 0xF) != 0; addr += 1 ) { @@ -662,10 +635,7 @@ static void dumph(const char *head, unsigned int address, unsigned int size, con { printf("\n"); } - if ( address <= off2 ) - { - off1 += 2; - } + off1 += ( address <= off2 ) ? 2 : 0; } for ( ; (off2 & 0xF) != 0; off2 += 2 ) { @@ -706,10 +676,7 @@ static void dumpw(const char *head, unsigned int address, unsigned int size, con { printf("\n"); } - if ( address <= addr ) - { - off1 += 4; - } + off1 += ( address <= addr ) ? 4 : 0; } for ( ; (addr & 0xF) != 0; addr += 4 ) { diff --git a/tools/srxfixup/src/elflib.c b/tools/srxfixup/src/elflib.c index 502d121ea46d..736c46623334 100644 --- a/tools/srxfixup/src/elflib.c +++ b/tools/srxfixup/src/elflib.c @@ -367,11 +367,7 @@ elf_file *read_elf(const char *filename) static int is_in_range(unsigned int top, unsigned int size, unsigned int pos) { - if ( pos >= top && pos < size + top ) - { - return 1; - } - return 0; + return ( pos >= top && pos < size + top ) ? 1 : 0; } static void read_symtab(elf_file *elf, int sctindex, FILE *fp) @@ -396,19 +392,8 @@ static void read_symtab(elf_file *elf, int sctindex, FILE *fp) swapmemory(result[i], "lllccs", 1); result[i]->bind = result[i]->sym.st_info >> 4; result[i]->type = result[i]->sym.st_info & 0xF; - result[i]->name = 0; - if ( result[i]->sym.st_name ) - { - result[i]->name = strdup((char *)&sp_x->link->data[result[i]->sym.st_name]); - } - if ( result[i]->sym.st_shndx && result[i]->sym.st_shndx <= 0xFEFF ) - { - result[i]->shptr = elf->scp[result[i]->sym.st_shndx]; - } - else - { - result[i]->shptr = 0; - } + result[i]->name = ( result[i]->sym.st_name ) ? strdup((char *)&sp_x->link->data[result[i]->sym.st_name]) : 0; + result[i]->shptr = ( result[i]->sym.st_shndx && result[i]->sym.st_shndx <= 0xFEFF ) ? elf->scp[result[i]->sym.st_shndx] : 0; } } @@ -1098,19 +1083,7 @@ elf_syment *search_global_symbol(const char *name, elf_file *elf) int is_defined_symbol(const elf_syment *sym) { - if ( !sym ) - { - return 0; - } - if ( !sym->sym.st_shndx ) - { - return 0; - } - if ( sym->sym.st_shndx <= 0xFEFF ) - { - return 1; - } - return sym->sym.st_shndx == SHN_ABS; + return ( !sym || !sym->sym.st_shndx ) ? 0 : (( sym->sym.st_shndx <= 0xFEFF ) ? 1 : (sym->sym.st_shndx == SHN_ABS)); } elf_syment *add_symbol(elf_file *elf, const char *name, int bind, int type, int value, elf_section *scp, int st_shndx) @@ -1140,28 +1113,13 @@ elf_syment *add_symbol(elf_file *elf, const char *name, int bind, int type, int sym->sym.st_info = (type & 0xF) + 16 * bind; sym->sym.st_value = value; sym->shptr = scp; - if ( scp ) - { - sym->sym.st_shndx = 1; - } - else - { - sym->sym.st_shndx = st_shndx; - } + sym->sym.st_shndx = scp ? 1 : st_shndx; return sym; } unsigned int get_symbol_value(const elf_syment *sym, const elf_file *elf) { - if ( !is_defined_symbol(sym) ) - { - return 0; - } - if ( sym->sym.st_shndx != SHN_ABS && elf->ehp->e_type == ET_REL ) - { - return sym->shptr->shr.sh_addr + sym->sym.st_value; - } - return sym->sym.st_value; + return ( !is_defined_symbol(sym) ) ? 0 : (( sym->sym.st_shndx != SHN_ABS && elf->ehp->e_type == ET_REL ) ? (sym->shptr->shr.sh_addr + sym->sym.st_value) : sym->sym.st_value); } static void reorder_an_symtab(elf_file *elf, elf_section *scp) @@ -1368,71 +1326,7 @@ static int comp_Elf_file_slot(const void *a1, const void *a2) p1 = a1; p2 = a2; - if ( p1->type == EFS_TYPE_ELF_HEADER && p2->type == EFS_TYPE_ELF_HEADER ) - { - return 0; - } - if ( p1->type == EFS_TYPE_ELF_HEADER ) - { - return -1; - } - if ( p2->type == EFS_TYPE_ELF_HEADER ) - { - return 1; - } - if ( p1->type == EFS_TYPE_PROGRAM_HEADER_TABLE && p2->type == EFS_TYPE_PROGRAM_HEADER_TABLE ) - { - return 0; - } - if ( p1->type == EFS_TYPE_PROGRAM_HEADER_TABLE ) - { - return -1; - } - if ( p2->type == EFS_TYPE_PROGRAM_HEADER_TABLE ) - { - return 1; - } - if ( !p1->type && !p2->type ) - { - return 0; - } - if ( !p1->type ) - { - return 1; - } - if ( !p2->type ) - { - return -1; - } - if ( p1->type == EFS_TYPE_END && p2->type == EFS_TYPE_END ) - { - return 0; - } - if ( p1->type == EFS_TYPE_END ) - { - return 1; - } - if ( p2->type == EFS_TYPE_END ) - { - return -1; - } - if ( p1->type == EFS_TYPE_PROGRAM_HEADER_ENTRY && p2->type == EFS_TYPE_SECTION_HEADER_TABLE ) - { - return -1; - } - if ( p1->type == EFS_TYPE_SECTION_HEADER_TABLE && p2->type == EFS_TYPE_PROGRAM_HEADER_ENTRY ) - { - return 1; - } - if ( p2->offset == p1->offset ) - { - return 0; - } - if ( p2->offset >= p1->offset ) - { - return -1; - } - return 1; + return ( p1->type == EFS_TYPE_ELF_HEADER && p2->type == EFS_TYPE_ELF_HEADER ) ? 0 : (( p1->type == EFS_TYPE_ELF_HEADER ) ? -1 : (( p2->type == EFS_TYPE_ELF_HEADER ) ? 1 : (( p1->type == EFS_TYPE_PROGRAM_HEADER_TABLE && p2->type == EFS_TYPE_PROGRAM_HEADER_TABLE ) ? 0 : (( p1->type == EFS_TYPE_PROGRAM_HEADER_TABLE ) ? -1 : (( p2->type == EFS_TYPE_PROGRAM_HEADER_TABLE ) ? 1 : (( !p1->type && !p2->type ) ? 0 : (( !p1->type ) ? 1 : (( !p2->type ) ? -1 : (( p1->type == EFS_TYPE_END && p2->type == EFS_TYPE_END ) ? 0 : (( p1->type == EFS_TYPE_END ) ? 1 : (( p2->type == EFS_TYPE_END ) ? -1 : (( p1->type == EFS_TYPE_PROGRAM_HEADER_ENTRY && p2->type == EFS_TYPE_SECTION_HEADER_TABLE ) ? -1 : (( p1->type == EFS_TYPE_SECTION_HEADER_TABLE && p2->type == EFS_TYPE_PROGRAM_HEADER_ENTRY ) ? 1 : (( p2->offset == p1->offset ) ? 0 : (( p2->offset >= p1->offset ) ? -1 : 1))))))))))))))); } Elf_file_slot *build_file_order_list(const elf_file *elf) @@ -1448,11 +1342,7 @@ Elf_file_slot *build_file_order_list(const elf_file *elf) sections = elf->ehp->e_shnum; scp = (elf_section **)calloc(sections + 1, sizeof(elf_section *)); memcpy(scp, elf->scp, sections * sizeof(elf_section *)); - maxent = elf->ehp->e_shnum + 2; - if ( elf->ehp->e_phnum ) - { - maxent = elf->ehp->e_phnum + elf->ehp->e_shnum + 3; - } + maxent = ( elf->ehp->e_phnum ) ? (elf->ehp->e_phnum + elf->ehp->e_shnum + 3) : (elf->ehp->e_shnum + 2); resolt = (Elf_file_slot *)calloc(maxent, sizeof(Elf_file_slot)); resolt->type = EFS_TYPE_ELF_HEADER; resolt->offset = 0; @@ -1555,10 +1445,7 @@ void writeback_file_order_list(elf_file *elf, Elf_file_slot *efs) segoffset = scp[i]->shr.sh_addr + efs->offset - (*scp)->shr.sh_addr; } scp[i]->shr.sh_offset = segoffset; - if ( scp[i]->shr.sh_type != SHT_NOBITS ) - { - segoffset += scp[i]->shr.sh_size; - } + segoffset += ( scp[i]->shr.sh_type != SHT_NOBITS ) ? scp[i]->shr.sh_size : 0; } break; case EFS_TYPE_SECTION_HEADER_TABLE: @@ -1594,14 +1481,7 @@ void dump_file_order_list(const elf_file *elf, const Elf_file_slot *efs) oldend_1 = slot->size; startpos_1 = slot->offset; - if ( oldend_1 == 0 ) - { - offset = slot->offset; - } - else - { - offset = oldend_1 + startpos_1 - 1; - } + offset = ( oldend_1 == 0 ) ? slot->offset : (oldend_1 + startpos_1 - 1); size_1 = offset; switch ( slot->type ) { @@ -1643,14 +1523,7 @@ void dump_file_order_list(const elf_file *elf, const Elf_file_slot *efs) unsigned int size_2; unsigned int startpos_2; - if ( scp[i]->shr.sh_type == SHT_NOBITS ) - { - oldend_2 = 0; - } - else - { - oldend_2 = scp[i]->shr.sh_size; - } + oldend_2 = ( scp[i]->shr.sh_type == SHT_NOBITS ) ? 0 : scp[i]->shr.sh_size; startpos_2 = scp[i]->shr.sh_offset; size_2 = (oldend_2 == 0) ? (scp[i]->shr.sh_offset) : (Elf32_Off)(oldend_2 + startpos_2 - 1); snprintf(tmp, sizeof(tmp), "(%s)", scp[i]->name); diff --git a/tools/srxfixup/src/mipsdis.c b/tools/srxfixup/src/mipsdis.c index 48be26046e68..92e90ef130e8 100644 --- a/tools/srxfixup/src/mipsdis.c +++ b/tools/srxfixup/src/mipsdis.c @@ -427,14 +427,7 @@ static void getczfs(unsigned int data, Operand *opr) static void getbroff(unsigned int addr, unsigned int data, Operand *opr) { opr->tag = OprTag_jtarget; - if ( (data & 0x8000) != 0 ) - { - opr->data = 4 * (uint16_t)data - 0x40000; - } - else - { - opr->data = 4 * (uint16_t)data; - } + opr->data = ( (data & 0x8000) != 0 ) ? (4 * (uint16_t)data - 0x40000) : (4 * (uint16_t)data); opr->data += 4 + addr; } @@ -504,14 +497,7 @@ static void Rsseimm(Disasm_result *result) unsigned int imm; getrs(result->data, result->operands); - if ( (int16_t)(result->data & 0xFFFF) < 0 ) - { - imm = (result->data & 0xFFFF) - 0x10000; - } - else - { - imm = (result->data & 0xFFFF); - } + imm = ( (int16_t)(result->data & 0xFFFF) < 0 ) ? ((result->data & 0xFFFF) - 0x10000) : (result->data & 0xFFFF); result->operands[1].tag = OprTag_imm; result->operands[1].data = imm; } @@ -522,14 +508,7 @@ static void Rtrsseimm(Disasm_result *result) getrt(result->data, result->operands); getrs(result->data, &result->operands[1]); - if ( (int16_t)(result->data & 0xFFFF) < 0 ) - { - imm = (result->data & 0xFFFF) - 0x10000; - } - else - { - imm = (result->data & 0xFFFF); - } + imm = ( (int16_t)(result->data & 0xFFFF) < 0 ) ? ((result->data & 0xFFFF) - 0x10000) : (result->data & 0xFFFF); result->operands[2].tag = OprTag_imm; result->operands[2].data = imm; } @@ -582,14 +561,7 @@ static void Rtoffbase(Disasm_result *result) { unsigned int off; - if ( (int16_t)(result->data & 0xFFFF) < 0 ) - { - off = (result->data & 0xFFFF) - 0x10000; - } - else - { - off = (result->data & 0xFFFF); - } + off = ( (int16_t)(result->data & 0xFFFF) < 0 ) ? ((result->data & 0xFFFF) - 0x10000) : (result->data & 0xFFFF); getrt(result->data, result->operands); result->operands[1].tag = OprTag_regoffset; result->operands[1].data = off; @@ -644,22 +616,8 @@ static void Bcft(Disasm_result *result) result->mnemonic[0] = 'b'; result->mnemonic[1] = 'c'; result->mnemonic[2] = result->mnemonic[3]; - if ( (result->data & 0x10000) != 0 ) - { - result->mnemonic[3] = 't'; - } - else - { - result->mnemonic[3] = 'f'; - } - if ( (result->data & 0x20000) != 0 ) - { - result->mnemonic[4] = 'l'; - } - else - { - result->mnemonic[4] = '\x00'; - } + result->mnemonic[3] = ( (result->data & 0x10000) != 0 ) ? 't' : 'f'; + result->mnemonic[4] = ( (result->data & 0x20000) != 0 ) ? 'l' : '\x00'; result->mnemonic[5] = '\x00'; getbroff(result->addr, result->data, result->operands); } diff --git a/tools/srxfixup/src/readconf.c b/tools/srxfixup/src/readconf.c index fb0e25033ed1..6a718acd677b 100644 --- a/tools/srxfixup/src/readconf.c +++ b/tools/srxfixup/src/readconf.c @@ -184,10 +184,7 @@ static void bungetc(struct fstrbuf *fb) { fb->cp -= 1; fb->col -= 1; - if ( *fb->cp == '\n' ) - { - fb->line -= 1; - } + fb->line -= ( *fb->cp == '\n' ) ? 1 : 0; } } @@ -705,16 +702,8 @@ static Srx_gen_table *make_srx_gen_table(TokenTree *tokentree) result->section_list = (SectConf *)calloc(1, sizeof(SectConf)); for ( ; ttp->tkcode; ) { - if ( ttp[1].tkcode == TC_VECTOR ) - { - ttp1 = ttp[1].value.subtree; - nttp = ttp + 2; - } - else - { - ttp1 = 0; - nttp = ttp + 1; - } + ttp1 = ( ttp[1].tkcode == TC_VECTOR ) ? ttp[1].value.subtree : 0; + nttp = ( ttp[1].tkcode == TC_VECTOR ) ? (ttp + 2) : (ttp + 1); switch ( ttp->tkcode ) { case TC_STRING: diff --git a/tools/srxfixup/src/ring.c b/tools/srxfixup/src/ring.c index 36778e8e4ade..3b6f67797e10 100644 --- a/tools/srxfixup/src/ring.c +++ b/tools/srxfixup/src/ring.c @@ -34,15 +34,7 @@ SLink *add_ring_tail(SLink *tailp, SLink *elementp) SLink *tailpa; tailpa = add_ring_top(tailp, elementp); - if ( !elementp ) - { - return tailpa; - } - if ( tailpa ) - { - return tailpa->next; - } - return 0; + return ( !elementp ) ? tailpa : (( tailpa ) ? tailpa->next : 0); } SLink *joint_ring(SLink *tailp, SLink *otherring) diff --git a/tools/srxfixup/src/srxfixup.c b/tools/srxfixup/src/srxfixup.c index b7410c2838e5..bc8f345d7019 100644 --- a/tools/srxfixup/src/srxfixup.c +++ b/tools/srxfixup/src/srxfixup.c @@ -133,26 +133,9 @@ int main(int argc, char **argv) const char *source; myname_1 = strrchr(*argv, '/'); - if ( !myname_1 ) - { - myname_1 = strrchr(*argv, '\\'); - } - if ( myname_1 ) - { - myname_2 = myname_1 + 1; - } - else - { - myname_2 = *argv; - } - if ( (strncmp(myname_2, "ee", 2) != 0) && (strncmp(myname_2, "EE", 2) != 0) ) - { - defaultconf = iop_defaultconf; - } - else - { - defaultconf = ee_defaultconf; - } + myname_1 = ( !myname_1 ) ? strrchr(*argv, '\\') : myname_1; + myname_2 = myname_1 ? (myname_1 + 1) : *argv; + defaultconf = ( (strncmp(myname_2, "ee", 2) != 0) && (strncmp(myname_2, "EE", 2) != 0) ) ? iop_defaultconf : ee_defaultconf; if ( strlen(*argv) > 5 && !strcmp(&(*argv)[strlen(*argv) - 5], "strip") ) { int argca; @@ -227,16 +210,7 @@ int main(int argc, char **argv) { exit(1); } - if ( - ((elf->ehp->e_flags & EF_MIPS_MACH) == EF_MIPS_MACH_5900) - && ((elf->ehp->e_flags & EF_MIPS_ARCH) == EF_MIPS_ARCH_3) ) - { - srxgen_1 = read_conf(ee_defaultconf, conffile, print_config); - } - else - { - srxgen_1 = read_conf(iop_defaultconf, conffile, print_config); - } + srxgen_1 = read_conf(( ((elf->ehp->e_flags & EF_MIPS_MACH) == EF_MIPS_MACH_5900) && ((elf->ehp->e_flags & EF_MIPS_ARCH) == EF_MIPS_ARCH_3) ) ? ee_defaultconf : iop_defaultconf, conffile, print_config); if ( !srxgen_1 ) { exit(1); diff --git a/tools/srxfixup/src/srxgen.c b/tools/srxfixup/src/srxgen.c index 8bb6fa04740a..a63dfa93b00a 100644 --- a/tools/srxfixup/src/srxgen.c +++ b/tools/srxfixup/src/srxgen.c @@ -115,10 +115,7 @@ int convert_rel2srx(elf_file *elf, const char *entrysym, int needoutput, int cau module_info_symbol = "Module"; syp = search_global_symbol("_irx_id", elf); - if ( is_defined_symbol(syp) != 0 ) - { - module_info_symbol = "_irx_id"; - } + module_info_symbol = ( is_defined_symbol(syp) != 0 ) ? "_irx_id" : module_info_symbol; setup_module_info(elf, modinfo, module_info_symbol); } return layout_srx_file(elf); @@ -141,10 +138,7 @@ static int setup_start_entry(elf_file *elf, const char *entrysym, elf_section *m else { syp = search_global_symbol("start", elf); - if ( !syp ) - { - syp = search_global_symbol("_start", elf); - } + syp = ( !syp ) ? search_global_symbol("_start", elf) : syp; if ( !is_defined_symbol(syp) ) { if ( modinfo->shr.sh_type == SHT_SCE_EEMOD ) @@ -539,10 +533,7 @@ void fixlocation_elf(elf_file *elf, unsigned int startaddr) Elf32_IopMod *iopmodinfo; iopmodinfo = (Elf32_IopMod *)modsect_1->data; - if ( iopmodinfo->moduleinfo != (Elf32_Word)(-1) ) - { - iopmodinfo->moduleinfo += startaddr; - } + iopmodinfo->moduleinfo += ( iopmodinfo->moduleinfo != (Elf32_Word)(-1) ) ? startaddr : 0; iopmodinfo->entry += startaddr; iopmodinfo->gp_value += startaddr; } @@ -552,10 +543,7 @@ void fixlocation_elf(elf_file *elf, unsigned int startaddr) Elf32_EeMod *eemodinfo; eemodinfo = (Elf32_EeMod *)modsect_2->data; - if ( eemodinfo->moduleinfo != (Elf32_Word)(-1) ) - { - eemodinfo->moduleinfo += startaddr; - } + eemodinfo->moduleinfo += ( eemodinfo->moduleinfo != (Elf32_Word)(-1) ) ? startaddr : 0; eemodinfo->entry += startaddr; eemodinfo->gp_value += startaddr; } @@ -589,10 +577,7 @@ void fixlocation_elf(elf_file *elf, unsigned int startaddr) syp = (elf_syment **)scp->data; for ( k = 1; k < entrise; k += 1 ) { - if ( syp[k]->sym.st_shndx == SHN_RADDR || (syp[k]->sym.st_shndx && syp[k]->sym.st_shndx <= 0xFEFF) ) - { - syp[k]->sym.st_value += startaddr; - } + syp[k]->sym.st_value += ( syp[k]->sym.st_shndx == SHN_RADDR || (syp[k]->sym.st_shndx && syp[k]->sym.st_shndx <= 0xFEFF) ) ? startaddr : 0; if ( syp[k]->sym.st_shndx == SHN_RADDR ) { syp[k]->sym.st_shndx = -15; @@ -602,21 +587,12 @@ void fixlocation_elf(elf_file *elf, unsigned int startaddr) static void save_org_addrs(elf_file *elf) { - Elf32_RegInfo *data; const Elf32_RegInfo *reginfop; elf_section *reginfosec; int i; reginfosec = search_section(elf, SHT_MIPS_REGINFO); - if ( reginfosec ) - { - data = (Elf32_RegInfo *)reginfosec->data; - } - else - { - data = 0; - } - reginfop = data; + reginfop = reginfosec ? (Elf32_RegInfo *)reginfosec->data : 0; for ( i = 1; i < elf->ehp->e_shnum; i += 1 ) { Sect_org_data *org; @@ -683,27 +659,11 @@ static void modify_eemod(elf_file *elf, elf_section *eemod) } moddata = (Elf32_EeMod *)eemod->data; scp_1 = search_section_by_name(elf, ".erx.lib"); - if ( scp_1 ) - { - moddata->erx_lib_addr = scp_1->shr.sh_addr; - moddata->erx_lib_size = scp_1->shr.sh_size; - } - else - { - moddata->erx_lib_addr = -1; - moddata->erx_lib_size = 0; - } + moddata->erx_lib_addr = scp_1 ? scp_1->shr.sh_addr : -1; + moddata->erx_lib_size = scp_1 ? scp_1->shr.sh_size : 0; scp_2 = search_section_by_name(elf, ".erx.stub"); - if ( scp_2 ) - { - moddata->erx_stub_addr = scp_2->shr.sh_addr; - moddata->erx_stub_size = scp_2->shr.sh_size; - } - else - { - moddata->erx_stub_addr = -1; - moddata->erx_stub_size = 0; - } + moddata->erx_stub_addr = scp_2 ? scp_2->shr.sh_addr : -1; + moddata->erx_stub_size = scp_2 ? scp_2->shr.sh_size : 0; } static void add_reserved_symbol_table( @@ -868,11 +828,7 @@ static int sect_name_match(const char *pattern, const char *name) return strcmp(pattern, name); } pattern += 1; - if ( strlen(name) < strlen(pattern) ) - { - return strcmp(pattern, name); - } - return strcmp(pattern, &name[strlen(name) - strlen(pattern)]); + return ( strlen(name) < strlen(pattern) ) ? strcmp(pattern, name) : strcmp(pattern, &name[strlen(name) - strlen(pattern)]); } static int reorder_section_table(elf_file *elf) @@ -1010,13 +966,7 @@ static void segment_end_setup(SegConf *seglist, unsigned int bitid, unsigned int { if ( (seglist->bitid & bitid) != 0 ) { - if ( ee ) - { - if ( !strcmp(seglist->name, "TEXT") ) - { - *moffset += 32; - } - } + *moffset += ( ee && !strcmp(seglist->name, "TEXT") ) ? 32 : 0; seglist->size = *moffset - seglist->addr; } } @@ -1355,10 +1305,7 @@ static int check_undef_symboles(elf_file *elf) err = 0; for ( s = 1; s < elf->ehp->e_shnum; s += 1 ) { - if ( elf->scp[s]->shr.sh_type == SHT_REL ) - { - err += check_undef_symboles_an_reloc(elf->scp[s]); - } + err += ( elf->scp[s]->shr.sh_type == SHT_REL ) ? check_undef_symboles_an_reloc(elf->scp[s]) : 0; } return err; } @@ -1436,10 +1383,7 @@ static int create_reserved_symbols(elf_file *elf) #endif { sym->bind = csyms->bind; - if ( !sym->type ) - { - sym->type = csyms->type; - } + sym->type = ( !sym->type ) ? csyms->type : sym->type; sym->sym.st_info = ((csyms->bind & 0xFF) << 4) + (csyms->type & 0xF); if ( csyms->shindex > 0xFEFF ) { @@ -1526,13 +1470,7 @@ static void symbol_value_update(elf_file *elf) syp = (elf_syment **)scp->data; for ( i = 1; i < entrise; i += 1 ) { - if ( syp[i]->sym.st_shndx ) - { - if ( syp[i]->sym.st_shndx <= 0xFEFF ) - { - syp[i]->sym.st_value += syp[i]->shptr->shr.sh_addr; - } - } + syp[i]->sym.st_value += ( syp[i]->sym.st_shndx && syp[i]->sym.st_shndx <= 0xFEFF ) ? syp[i]->shptr->shr.sh_addr : 0; } } @@ -1745,14 +1683,7 @@ static void rebuild_an_relocation(elf_section *relsect, unsigned int gpvalue, in break; case R_MIPS_26: data_2 = *(uint32_t *)daddr_1; - if ( rp->symptr && rp->symptr->bind != STB_LOCAL ) - { - data_33 = data_2 << 6 >> 4; - } - else - { - data_33 = ((relsect->info->shr.sh_addr + rp->rel.r_offset) & 0xF0000000) | (4 * (data_2 & 0x3FFFFFF)); - } + data_33 = ( rp->symptr && rp->symptr->bind != STB_LOCAL ) ? (data_2 << 6 >> 4) : (((relsect->info->shr.sh_addr + rp->rel.r_offset) & 0xF0000000) | (4 * (data_2 & 0x3FFFFFF))); *(uint32_t *)daddr_1 &= 0xFC000000; *(uint32_t *)daddr_1 |= (16 * (symvalue + data_33)) >> 6; if ( !v4 )