From 8959de9f679cfd0436d731fd91b88a68b9a75fa6 Mon Sep 17 00:00:00 2001 From: zwelch Date: Tue, 23 Jun 2009 22:44:17 +0000 Subject: [PATCH] - Fixes '+' whitespace - Replace ')\(+\)(' with ') \1 ('. - Replace ')\(+\)\(\w\)' with ') \1 \2'. - Replace '\(\w\)\(+\)(' with '\1 \2 ('. - Replace '\(\w\)\(+\)\(\w\)' with '\1 \2 \3'. git-svn-id: svn://svn.berlios.de/openocd/trunk@2373 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/flash/at91sam7.c | 20 +- src/flash/cfi.c | 4 +- src/flash/ecos.c | 20 +- src/flash/flash.c | 2 +- src/flash/mflash.c | 2 +- src/flash/mflash.h | 2 +- src/flash/nand.c | 10 +- src/flash/ocl.c | 4 +- src/flash/ocl/at91sam7x/main.c | 6 +- src/flash/ocl/at91sam7x/samflash.c | 40 ++-- src/flash/pic32mx.c | 2 +- src/flash/pic32mx.h | 4 +- src/flash/stellaris.c | 8 +- src/flash/str7x.c | 2 +- src/flash/str9x.c | 2 +- src/flash/tms470.c | 2 +- src/helper/binarybuffer.h | 4 +- src/helper/command.c | 6 +- src/helper/configuration.c | 4 +- src/helper/ioutil.c | 2 +- src/helper/jim-eventloop.c | 2 +- src/helper/jim.c | 372 ++++++++++++++--------------- src/helper/jim.h | 2 +- src/helper/log.c | 4 +- src/helper/log.h | 2 +- src/helper/replacements.c | 2 +- src/jtag/arm-jtag-ew.c | 10 +- src/jtag/ft2232.c | 2 +- src/jtag/jlink.c | 2 +- src/jtag/jtag.h | 2 +- src/jtag/presto.c | 2 +- src/jtag/tcl.c | 14 +- src/jtag/vsllink.c | 2 +- src/jtag/zy1000/jtag_minidriver.h | 30 +-- src/jtag/zy1000/zy1000.c | 66 ++--- src/server/gdb_server.c | 26 +- src/server/telnet_server.c | 2 +- src/target/arm11.c | 2 +- src/target/arm7_9_common.c | 6 +- src/target/arm7tdmi.c | 6 +- src/target/arm9tdmi.c | 2 +- src/target/arm_adi_v5.c | 2 +- src/target/armv4_5.c | 2 +- src/target/etb.c | 52 ++-- src/target/fa526.c | 2 +- src/target/image.c | 4 +- src/target/mips32_dmaacc.c | 12 +- src/target/mips32_pracc.c | 18 +- src/target/oocd_trace.c | 16 +- src/target/target.c | 46 ++-- src/target/xscale.c | 24 +- src/xsvf/xsvf.c | 4 +- 52 files changed, 443 insertions(+), 443 deletions(-) diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index 6fb3440d..2ab1cd3f 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -213,19 +213,19 @@ static void at91sam7_set_flash_mode(flash_bank_t *bank, int mode) if (at91sam7_info->cidr_arch == 0x60) { /* AT91SAM7A3 uses master clocks in 100 ns */ - fmcn = (at91sam7_info->mck_freq/10000000ul)+1; + fmcn = (at91sam7_info->mck_freq/10000000ul) + 1; } else { /* master clocks in 1uS for ARCH 0x7 types */ - fmcn = (at91sam7_info->mck_freq/1000000ul)+1; + fmcn = (at91sam7_info->mck_freq/1000000ul) + 1; } } else if (mode == FMR_TIMING_FLASH) { /* main clocks in 1.5uS */ fmcn = (at91sam7_info->mck_freq/1000000ul)+ - (at91sam7_info->mck_freq/2000000ul)+1; + (at91sam7_info->mck_freq/2000000ul) + 1; } /* hard overclocking */ @@ -282,7 +282,7 @@ static int at91sam7_flash_command(struct flash_bank_s *bank, uint8_t cmd, uint16 fcr = (0x5A << 24) | ((pagen&0x3FF) << 8) | cmd; target_write_u32(target, MC_FCR[bank->bank_number], fcr); - LOG_DEBUG("Flash command: 0x%" PRIx32 ", flash bank: %i, page number: %u", fcr, bank->bank_number+1, pagen); + LOG_DEBUG("Flash command: 0x%" PRIx32 ", flash bank: %i, page number: %u", fcr, bank->bank_number + 1, pagen); if ((at91sam7_info->cidr_arch == 0x60) && ((cmd == SLB)|(cmd == CLB))) { @@ -641,7 +641,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) fast_check = 1; for (nSector = 0; nSectornum_sectors; nSector++) { - retval = target_blank_check_memory(target, bank->base+bank->sectors[nSector].offset, + retval = target_blank_check_memory(target, bank->base + bank->sectors[nSector].offset, bank->sectors[nSector].size, &blank); if (retval != ERROR_OK) { @@ -665,7 +665,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) for (nSector = 0; nSectornum_sectors; nSector++) { bank->sectors[nSector].is_erased = 1; - retval = target_read_memory(target, bank->base+bank->sectors[nSector].offset, 4, + retval = target_read_memory(target, bank->base + bank->sectors[nSector].offset, 4, bank->sectors[nSector].size/4, buffer); if (retval != ERROR_OK) return retval; @@ -707,7 +707,7 @@ static int at91sam7_protect_check(struct flash_bank_s *bank) at91sam7_info->num_lockbits_on = 0; for (lock_pos = 0; lock_posnum_sectors; lock_pos++) { - if ( ((status >> (16+lock_pos))&(0x0001)) == 1) + if ( ((status >> (16 + lock_pos))&(0x0001)) == 1) { at91sam7_info->num_lockbits_on++; bank->sectors[lock_pos].is_protected = 1; @@ -725,7 +725,7 @@ static int at91sam7_protect_check(struct flash_bank_s *bank) at91sam7_info->num_nvmbits_on = 0; for (gpnvm_pos = 0; gpnvm_posnum_nvmbits; gpnvm_pos++) { - if ( ((status >> (8+gpnvm_pos))&(0x01)) == 1) + if ( ((status >> (8 + gpnvm_pos))&(0x01)) == 1) { at91sam7_info->num_nvmbits_on++; } @@ -803,7 +803,7 @@ static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char * page_size = atoi(args[11]); num_nvmbits = atoi(args[12]); - target_name = calloc(strlen(args[7])+1, sizeof(char)); + target_name = calloc(strlen(args[7]) + 1, sizeof(char)); strcpy(target_name, args[7]); /* calculate bank size */ @@ -1027,7 +1027,7 @@ static int at91sam7_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t o /* Write one block to the PageWriteBuffer */ buffer_pos = (pagen-first_page)*dst_min_alignment; wcount = CEIL(count,4); - if ((retval = target_write_memory(target, bank->base+pagen*dst_min_alignment, 4, wcount, buffer+buffer_pos)) != ERROR_OK) + if ((retval = target_write_memory(target, bank->base + pagen*dst_min_alignment, 4, wcount, buffer + buffer_pos)) != ERROR_OK) { return retval; } diff --git a/src/flash/cfi.c b/src/flash/cfi.c index 1f6043e4..60d1834d 100644 --- a/src/flash/cfi.c +++ b/src/flash/cfi.c @@ -213,7 +213,7 @@ static uint16_t cfi_query_u16(flash_bank_t *bank, int sector, uint32_t offset) { uint8_t i; for (i = 0;i<2;i++) - target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, + target_read_memory(target, flash_address(bank, sector, offset + i), bank->bus_width, 1, &data[i*bank->bus_width] ); } else @@ -235,7 +235,7 @@ static uint32_t cfi_query_u32(flash_bank_t *bank, int sector, uint32_t offset) { uint8_t i; for (i = 0;i<4;i++) - target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, + target_read_memory(target, flash_address(bank, sector, offset + i), bank->bus_width, 1, &data[i*bank->bus_width] ); } else diff --git a/src/flash/ecos.c b/src/flash/ecos.c index 686a63fb..1a2aa68d 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -274,8 +274,8 @@ static int eCosBoard_erase(ecosflash_flash_bank_t *info, uint32_t address, uint3 uint32_t flashErr; retval = runCode(info, - info->start_address+OFFSET_ERASE, - info->start_address+OFFSET_ERASE+OFFSET_ERASE_SIZE, + info->start_address + OFFSET_ERASE, + info->start_address + OFFSET_ERASE + OFFSET_ERASE_SIZE, address, len, 0, @@ -307,8 +307,8 @@ static int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, uint32_t ad uint32_t buffer; retval = runCode(info, - info->start_address+OFFSET_GET_WORKAREA, - info->start_address+OFFSET_GET_WORKAREA+OFFSET_GET_WORKAREA_SIZE, + info->start_address + OFFSET_GET_WORKAREA, + info->start_address + OFFSET_GET_WORKAREA + OFFSET_GET_WORKAREA_SIZE, 0, 0, 0, @@ -328,16 +328,16 @@ static int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, uint32_t ad } int retval; - retval = target_write_buffer(target, buffer, t, ((uint8_t *)data)+i); + retval = target_write_buffer(target, buffer, t, ((uint8_t *)data) + i); if (retval != ERROR_OK) return retval; uint32_t flashErr; retval = runCode(info, - info->start_address+OFFSET_FLASH, - info->start_address+OFFSET_FLASH+OFFSET_FLASH_SIZE, + info->start_address + OFFSET_FLASH, + info->start_address + OFFSET_FLASH + OFFSET_FLASH_SIZE, buffer, - address+i, + address + i, t, &flashErr, timeout); @@ -410,7 +410,7 @@ static int ecosflash_erase(struct flash_bank_s *bank, int first, int last) { struct flash_bank_s *c = bank; ecosflash_flash_bank_t *info = bank->driver_priv; - return eCosBoard_erase(info, c->base+first*sectorSize, sectorSize*(last-first+1)); + return eCosBoard_erase(info, c->base + first*sectorSize, sectorSize*(last-first + 1)); } static int ecosflash_protect(struct flash_bank_s *bank, int set, int first, int last) @@ -422,7 +422,7 @@ static int ecosflash_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t { ecosflash_flash_bank_t *info = bank->driver_priv; struct flash_bank_s *c = bank; - return eCosBoard_flash(info, buffer, c->base+offset, count); + return eCosBoard_flash(info, buffer, c->base + offset, count); } static int ecosflash_protect_check(struct flash_bank_s *bank) diff --git a/src/flash/flash.c b/src/flash/flash.c index 61dc4a6a..d93c4efa 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -1110,7 +1110,7 @@ int flash_write(target_t *target, image_t *image, uint32_t *written, int erase) /* see if we need to pad the section */ while (padding[section]--) - (buffer+buffer_size)[size_read++] = 0xff; + (buffer + buffer_size)[size_read++] = 0xff; buffer_size += size_read; section_offset += size_read; diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 328e9578..25b9f096 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -923,7 +923,7 @@ static double mg_do_calc_pll(double XIN, mg_pll_t * p_pll_val, int is_approximat CLK_OUT = XIN * ((double)M / N) / NO; - if ((int)((CLK_OUT+ROUND) / DIV) + if ((int)((CLK_OUT + ROUND) / DIV) == (int)(MG_PLL_CLK_OUT / DIV)) { if (mg_is_valid_pll(XIN, N, CLK_OUT, NO) == ERROR_OK) { diff --git a/src/flash/mflash.h b/src/flash/mflash.h index 04eb99a9..bfaf743e 100644 --- a/src/flash/mflash.h +++ b/src/flash/mflash.h @@ -294,7 +294,7 @@ typedef enum _mg_vcmd typedef enum _mg_opmode { mg_op_mode_xip = 1, /* TRUE XIP */ - mg_op_mode_snd = 2, /* BOOT+Storage */ + mg_op_mode_snd = 2, /* BOOT + Storage */ mg_op_mode_stg = 0 /* Only Storage */ } mg_opmode; diff --git a/src/flash/nand.c b/src/flash/nand.c index 79858d63..9851e789 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -518,9 +518,9 @@ int nand_probe(struct nand_device_s *device) { if (device->bus_width == 8) { - device->controller->read_data(device, id_buff+3); - device->controller->read_data(device, id_buff+4); - device->controller->read_data(device, id_buff+5); + device->controller->read_data(device, id_buff + 3); + device->controller->read_data(device, id_buff + 4); + device->controller->read_data(device, id_buff + 5); } else { @@ -1420,7 +1420,7 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm uint8_t ecc[3]; memset(oob, 0xff, oob_size); for (i = 0, j = 0; i < page_size; i += 256) { - nand_calculate_ecc(p, page+i, ecc); + nand_calculate_ecc(p, page + i, ecc); oob[eccpos[j++]] = ecc[0]; oob[eccpos[j++]] = ecc[1]; oob[eccpos[j++]] = ecc[2]; @@ -1437,7 +1437,7 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm uint8_t *ecc = oob + oob_size - page_size/512 * 10; memset(oob, 0xff, oob_size); for (i = 0; i < page_size; i += 512) { - nand_calculate_ecc_kw(p, page+i, ecc); + nand_calculate_ecc_kw(p, page + i, ecc); ecc += 10; } } diff --git a/src/flash/ocl.c b/src/flash/ocl.c index 17b57a87..06cbbaad 100644 --- a/src/flash/ocl.c +++ b/src/flash/ocl.c @@ -139,7 +139,7 @@ static int ocl_erase(struct flash_bank_s *bank, int first, int last) } /* receive response */ - if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer+1, 1) != ERROR_OK)) + if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer + 1, 1) != ERROR_OK)) return retval; if (dcc_buffer[1] != OCL_CMD_DONE) @@ -182,7 +182,7 @@ static int ocl_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset } /* allocate buffer for max. ocl buffer + overhead */ - dcc_buffer = malloc(sizeof(uint32_t)*(ocl->buflen/4+3)); + dcc_buffer = malloc(sizeof(uint32_t)*(ocl->buflen/4 + 3)); while (count) { diff --git a/src/flash/ocl/at91sam7x/main.c b/src/flash/ocl/at91sam7x/main.c index c65a171d..2d6ba0a5 100644 --- a/src/flash/ocl/at91sam7x/main.c +++ b/src/flash/ocl/at91sam7x/main.c @@ -43,7 +43,7 @@ void cmd_flash(uint32 cmd) len = cmd&0xffff; ofs = adr%flash_page_size; bi_start = ofs/4; - bi_end = (ofs+len+3)/4; + bi_end = (ofs + len + 3)/4; if (bi_end>BUFSIZE) { dcc_wr(OCL_BUFF_OVER); @@ -65,12 +65,12 @@ void cmd_flash(uint32 cmd) result = 0; pagenum = adr/flash_page_size; for (bi = 0; bi> 16; + lockbits = inr(MC_FSR + efc_ofs) >> 16; while (lockbits) { if (lockbits&1) { /* wait until FLASH is ready, just for sure */ - while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0); + while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0); - outr(MC_FCR+efc_ofs, ((page_num&0x3ff) << 8) | 0x5a000004); + outr(MC_FCR + efc_ofs, ((page_num&0x3ff) << 8) | 0x5a000004); /* wait until it's done */ - while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0); + while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0); /* check for errors */ - if ((inr(MC_FSR+efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE; - if ((inr(MC_FSR+efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE; + if ((inr(MC_FSR + efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE; + if ((inr(MC_FSR + efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE; } if ((page_num += flash_lock_pages)>flash_page_count) break; @@ -151,20 +151,20 @@ int flash_erase_plane(int efc_ofs) } /* wait until FLASH is ready, just for sure */ - while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0); + while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0); /* erase all command to FCR */ - outr(MC_FCR+efc_ofs, 0x5a000008); + outr(MC_FCR + efc_ofs, 0x5a000008); /* wait until it's done */ - while ((inr(MC_FSR+efc_ofs)&MC_FRDY) == 0); + while ((inr(MC_FSR + efc_ofs)&MC_FRDY) == 0); /* check for errors */ - if ((inr(MC_FSR+efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE; - if ((inr(MC_FSR+efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE; + if ((inr(MC_FSR + efc_ofs)&MC_PROGE)) return FLASH_STAT_PROGE; + if ((inr(MC_FSR + efc_ofs)&MC_LOCKE)) return FLASH_STAT_LOCKE; /* set no erase before programming */ - outr(MC_FMR+efc_ofs, inr(MC_FMR+efc_ofs)|0x80); + outr(MC_FMR + efc_ofs, inr(MC_FMR + efc_ofs)|0x80); return FLASH_STAT_OK; } @@ -188,7 +188,7 @@ int flash_verify(uint32 adr, unsigned int len, uint8 *src) { unsigned char *flash_ptr; - flash_ptr = (uint8 *)FLASH_AREA_ADDR+adr; + flash_ptr = (uint8 *)FLASH_AREA_ADDR + adr; for ( ;len; len--) { if (*(flash_ptr++)!=*(src++)) return FLASH_STAT_VERIFE; } diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c index 5112482c..3ed2bf5d 100644 --- a/src/flash/pic32mx.c +++ b/src/flash/pic32mx.c @@ -923,7 +923,7 @@ static int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, ch command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[2]); return ERROR_OK; } - if (address < bank->base || address >= (bank->base+bank->size)) + if (address < bank->base || address >= (bank->base + bank->size)) { command_print(cmd_ctx, "flash address '%s' is out of bounds", args[0]); return ERROR_OK; diff --git a/src/flash/pic32mx.h b/src/flash/pic32mx.h index 49a9bb40..b1c4ef2f 100644 --- a/src/flash/pic32mx.h +++ b/src/flash/pic32mx.h @@ -62,9 +62,9 @@ typedef struct pic32mx_flash_bank_s * Note: These macros only work for KSEG0/KSEG1 addresses. */ #define KS1Virt2Phys(vaddr) ((vaddr)-0xA0000000) -#define Phys2KS1Virt(paddr) ((paddr)+0xA0000000) +#define Phys2KS1Virt(paddr) ((paddr) + 0xA0000000) #define KS0Virt2Phys(vaddr) ((vaddr)-0x80000000) -#define Phys2KS0Virt(paddr) ((paddr)+0x80000000) +#define Phys2KS0Virt(paddr) ((paddr) + 0x80000000) /* pic32mx configuration register locations */ diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index 09d7f0dd..9cf862a4 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -309,8 +309,8 @@ static int stellaris_info(struct flash_bank_s *bank, char *buf, int buf_size) stellaris_info->did1, stellaris_info->did1, "ARMV7M", - (int)((1+((stellaris_info->dc0 >> 16) & 0xFFFF))/4), - (int)((1+(stellaris_info->dc0 & 0xFFFF))*2)); + (int)((1 + ((stellaris_info->dc0 >> 16) & 0xFFFF))/4), + (int)((1 + (stellaris_info->dc0 & 0xFFFF))*2)); buf += printed; buf_size -= printed; @@ -396,7 +396,7 @@ static void stellaris_read_clock_info(flash_bank_t *bank) mainfreq = 200000000; /* PLL out frec */ if (usesysdiv) - stellaris_info->mck_freq = mainfreq/(1+sysdiv); + stellaris_info->mck_freq = mainfreq/(1 + sysdiv); else stellaris_info->mck_freq = mainfreq; @@ -499,7 +499,7 @@ static int stellaris_read_part_info(struct flash_bank_s *bank) stellaris_info->did1 = did1; stellaris_info->num_lockbits = 1 + (stellaris_info->dc0 & 0xFFFF); - stellaris_info->num_pages = 2 *(1+(stellaris_info->dc0 & 0xFFFF)); + stellaris_info->num_pages = 2 *(1 + (stellaris_info->dc0 & 0xFFFF)); stellaris_info->pagesize = 1024; bank->size = 1024 * stellaris_info->num_pages; stellaris_info->pages_in_lockregion = 2; diff --git a/src/flash/str7x.c b/src/flash/str7x.c index 4068ad33..b6fef22c 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -703,7 +703,7 @@ static int str7x_handle_disable_jtag_command(struct command_context_s *cmd_ctx, flash_cmd = FLASH_SPR; target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), flash_cmd); target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), 0x4010DFBC); - target_write_u32(target, str7x_get_flash_adr(bank, FLASH_DR0), ~(1 << (15+ProtectionLevel))); + target_write_u32(target, str7x_get_flash_adr(bank, FLASH_DR0), ~(1 << (15 + ProtectionLevel))); flash_cmd = FLASH_SPR | FLASH_WMS; target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), flash_cmd); } diff --git a/src/flash/str9x.c b/src/flash/str9x.c index 880dac4d..cfd37b9d 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -145,7 +145,7 @@ static int str9x_build_block_list(struct flash_bank_s *bank) if (str9x_info->variant) str9x_info->sector_bits[num_sectors++] = (1 << i); else - str9x_info->sector_bits[num_sectors++] = (1 << (i+8)); + str9x_info->sector_bits[num_sectors++] = (1 << (i + 8)); } return ERROR_OK; diff --git a/src/flash/tms470.c b/src/flash/tms470.c index 5ed36588..26fcadda 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -593,7 +593,7 @@ static int tms470_flash_initialize_internal_state_machine(struct flash_bank_s *b LOG_DEBUG("set fmmaxpp = 50"); /* - * MAXCP = 0xf000+2000 + * MAXCP = 0xf000 + 2000 */ target_write_u32(target, 0xFFE8A084, 0xf000 + 2000); LOG_DEBUG("set fmmaxcp = 0x%04x", 0xf000 + 2000); diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index a49d5d53..9421b4c3 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -42,7 +42,7 @@ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int { unsigned int i; - for (i = first; i> (i-first))&1) == 1) buffer[i/8] |= 1 << (i%8); @@ -61,7 +61,7 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, un uint32_t result = 0; unsigned int i; - for (i = first; i>(i%8))&1) == 1) result |= 1 << (i-first); diff --git a/src/helper/command.c b/src/helper/command.c index 231c2999..b49f5470 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -495,14 +495,14 @@ int command_run_line(command_context_t *context, char *line) if (reslen>0) { int i; - char buff[256+1]; + char buff[256 + 1]; for (i = 0; i < reslen; i += 256) { int chunk; chunk = reslen - i; if (chunk > 256) chunk = 256; - strncpy(buff, result+i, chunk); + strncpy(buff, result + i, chunk); buff[chunk] = 0; LOG_USER_N("%s", buff); } @@ -599,7 +599,7 @@ static size_t openocd_jim_fwrite(const void *_ptr, size_t size, size_t n, void * } /* GRR we must chunk - not null terminated */ while (nbytes) { - char chunk[128+1]; + char chunk[128 + 1]; int x; x = nbytes; diff --git a/src/helper/configuration.c b/src/helper/configuration.c index 9485a7eb..c1e541cb 100644 --- a/src/helper/configuration.c +++ b/src/helper/configuration.c @@ -37,7 +37,7 @@ static char** script_search_dirs; void add_script_search_dir (const char *dir) { num_script_dirs++; - script_search_dirs = (char **)realloc(script_search_dirs, (num_script_dirs+1) * sizeof (char *)); + script_search_dirs = (char **)realloc(script_search_dirs, (num_script_dirs + 1) * sizeof (char *)); script_search_dirs[num_script_dirs-1] = strdup(dir); script_search_dirs[num_script_dirs] = NULL; @@ -46,7 +46,7 @@ void add_script_search_dir (const char *dir) void add_config_command (const char *cfg) { num_config_files++; - config_file_names = (char **)realloc(config_file_names, (num_config_files+1) * sizeof (char *)); + config_file_names = (char **)realloc(config_file_names, (num_config_files + 1) * sizeof (char *)); config_file_names[num_config_files-1] = strdup(cfg); config_file_names[num_config_files] = NULL; diff --git a/src/helper/ioutil.c b/src/helper/ioutil.c index 390d50e9..2a74ab31 100644 --- a/src/helper/ioutil.c +++ b/src/helper/ioutil.c @@ -274,7 +274,7 @@ int handle_cp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, chunk = maxChunk; } - if ((retval == ERROR_OK) && (fwrite(((char *)data)+pos, 1, chunk, f) != chunk)) + if ((retval == ERROR_OK) && (fwrite(((char *)data) + pos, 1, chunk, f) != chunk)) retval = ERROR_INVALID_ARGUMENTS; if (retval != ERROR_OK) diff --git a/src/helper/jim-eventloop.c b/src/helper/jim-eventloop.c index 29402536..9d15ddd0 100644 --- a/src/helper/jim-eventloop.c +++ b/src/helper/jim-eventloop.c @@ -310,7 +310,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags) // fprintf(stderr,"No Event\n"); } - retval = select(maxfd+1, &rfds, &wfds, &efds, tvp); + retval = select(maxfd + 1, &rfds, &wfds, &efds, tvp); if (retval < 0) { switch (errno) { case EINTR: fprintf(stderr,"select EINTR\n"); break; diff --git a/src/helper/jim.c b/src/helper/jim.c index 7c459d57..1dbe4958 100644 --- a/src/helper/jim.c +++ b/src/helper/jim.c @@ -255,7 +255,7 @@ static int JimStringMatch(const char *pattern, int patternLen, if (patternLen == 1) return 1; /* match */ while (stringLen) { - if (JimStringMatch(pattern+1, patternLen-1, + if (JimStringMatch(pattern + 1, patternLen-1, string, stringLen, nocase)) return 1; /* match */ string++; @@ -457,7 +457,7 @@ int Jim_StringToIndex(const char *str, int *intPtr) * in length, this allows to avoid to check every object with a string * repr < 32, and usually there are many of this objects. */ -#define JIM_REFERENCE_SPACE (35+JIM_REFERENCE_TAGLEN) +#define JIM_REFERENCE_SPACE (35 + JIM_REFERENCE_TAGLEN) static int JimFormatReference(char *buf, Jim_Reference *refPtr, jim_wide id) { @@ -485,7 +485,7 @@ int Jim_DoubleToString(char *buf, double doubleValue) s[0] = '.'; s[1] = '0'; s[2] = '\0'; - return len+2; + return len + 2; } return len; } @@ -594,17 +594,17 @@ void *Jim_Realloc(void *ptr, int size) char *Jim_StrDup(const char *s) { int l = strlen(s); - char *copy = Jim_Alloc(l+1); + char *copy = Jim_Alloc(l + 1); - memcpy(copy, s, l+1); + memcpy(copy, s, l + 1); return copy; } char *Jim_StrDupLen(const char *s, int l) { - char *copy = Jim_Alloc(l+1); + char *copy = Jim_Alloc(l + 1); - memcpy(copy, s, l+1); + memcpy(copy, s, l + 1); copy[l] = 0; /* Just to be sure, original could be substring */ return copy; } @@ -956,7 +956,7 @@ static unsigned int JimStringCopyHTHashFunction(const void *key) static const void *JimStringCopyHTKeyDup(void *privdata, const void *key) { int len = strlen(key); - char *copy = Jim_Alloc(len+1); + char *copy = Jim_Alloc(len + 1); JIM_NOTUSED(privdata); memcpy(copy, key, len); @@ -967,7 +967,7 @@ static const void *JimStringCopyHTKeyDup(void *privdata, const void *key) static void *JimStringKeyValCopyHTValDup(void *privdata, const void *val) { int len = strlen(val); - char *copy = Jim_Alloc(len+1); + char *copy = Jim_Alloc(len + 1); JIM_NOTUSED(privdata); memcpy(copy, val, len); @@ -1072,7 +1072,7 @@ int Jim_StackLen(Jim_Stack *stack) } void Jim_StackPush(Jim_Stack *stack, void *element) { - int neededLen = stack->len+1; + int neededLen = stack->len + 1; if (neededLen > stack->maxlen) { stack->maxlen = neededLen*2; stack->vector = Jim_Realloc(stack->vector, sizeof(void*)*stack->maxlen); @@ -1191,7 +1191,7 @@ int JimParseScript(struct JimParserCtx *pc) } switch (*(pc->p)) { case '\\': - if (*(pc->p+1) == '\n') + if (*(pc->p + 1) == '\n') return JimParseSep(pc); else { pc->comment = 0; @@ -1251,7 +1251,7 @@ int JimParseSep(struct JimParserCtx *pc) pc->tstart = pc->p; pc->tline = pc->linenr; while (*pc->p == ' ' || *pc->p == '\t' || *pc->p == '\r' || - (*pc->p == '\\' && *(pc->p+1) == '\n')) { + (*pc->p == '\\' && *(pc->p + 1) == '\n')) { if (*pc->p == '\\') { pc->p++; pc->len--; pc->linenr++; @@ -1430,7 +1430,7 @@ int JimParseStr(struct JimParserCtx *pc) switch (*pc->p) { case '\\': if (pc->state == JIM_PS_DEF && - *(pc->p+1) == '\n') { + *(pc->p + 1) == '\n') { pc->tend = pc->p-1; pc->tt = JIM_TT_ESC; return JIM_OK; @@ -1520,7 +1520,7 @@ static int JimEscape(char *dest, const char *s, int slen) for (i = 0; i < slen; i++) { switch (s[i]) { case '\\': - switch (s[i+1]) { + switch (s[i + 1]) { case 'a': *p++ = 0x7; i++; break; case 'b': *p++ = 0x8; i++; break; case 'f': *p++ = 0xc; i++; break; @@ -1531,48 +1531,48 @@ static int JimEscape(char *dest, const char *s, int slen) case '\0': *p++ = '\\'; i++; break; case '\n': *p++ = ' '; i++; break; default: - if (s[i+1] == 'x') { + if (s[i + 1] == 'x') { int val = 0; - int c = xdigitval(s[i+2]); + int c = xdigitval(s[i + 2]); if (c == -1) { *p++ = 'x'; i++; break; } val = c; - c = xdigitval(s[i+3]); + c = xdigitval(s[i + 3]); if (c == -1) { *p++ = val; i += 2; break; } - val = (val*16)+c; + val = (val*16) + c; *p++ = val; i += 3; break; - } else if (s[i+1] >= '0' && s[i+1] <= '7') + } else if (s[i + 1] >= '0' && s[i + 1] <= '7') { int val = 0; - int c = odigitval(s[i+1]); + int c = odigitval(s[i + 1]); val = c; - c = odigitval(s[i+2]); + c = odigitval(s[i + 2]); if (c == -1) { *p++ = val; i ++; break; } - val = (val*8)+c; - c = odigitval(s[i+3]); + val = (val*8) + c; + c = odigitval(s[i + 3]); if (c == -1) { *p++ = val; i += 2; break; } - val = (val*8)+c; + val = (val*8) + c; *p++ = val; i += 3; } else { - *p++ = s[i+1]; + *p++ = s[i + 1]; i++; } break; @@ -1625,8 +1625,8 @@ char *JimParserGetToken(struct JimParserCtx *pc, token[0] = '\0'; return token; } - len = (end-start)+1; - token = Jim_Alloc(len+1); + len = (end-start) + 1; + token = Jim_Alloc(len + 1); if (JimParserTtype(pc) != JIM_TT_ESC) { /* No escape conversion needed? Just copy it. */ memcpy(token, start, len); @@ -1879,7 +1879,7 @@ void Jim_InitStringRep(Jim_Obj *objPtr, const char *bytes, int length) objPtr->bytes = JimEmptyStringRep; objPtr->length = 0; } else { - objPtr->bytes = Jim_Alloc(length+1); + objPtr->bytes = Jim_Alloc(length + 1); objPtr->length = length; memcpy(objPtr->bytes, bytes, length); objPtr->bytes[length] = '\0'; @@ -1987,7 +1987,7 @@ Jim_Obj *Jim_NewStringObj(Jim_Interp *interp, const char *s, int len) objPtr->bytes = JimEmptyStringRep; objPtr->length = 0; } else { - objPtr->bytes = Jim_Alloc(len+1); + objPtr->bytes = Jim_Alloc(len + 1); objPtr->length = len; memcpy(objPtr->bytes, s, len); objPtr->bytes[len] = '\0'; @@ -2023,14 +2023,14 @@ void StringAppendString(Jim_Obj *objPtr, const char *str, int len) if (objPtr->internalRep.strValue.maxLength < needlen || objPtr->internalRep.strValue.maxLength == 0) { if (objPtr->bytes == JimEmptyStringRep) { - objPtr->bytes = Jim_Alloc((needlen*2)+1); + objPtr->bytes = Jim_Alloc((needlen*2) + 1); } else { - objPtr->bytes = Jim_Realloc(objPtr->bytes, (needlen*2)+1); + objPtr->bytes = Jim_Realloc(objPtr->bytes, (needlen*2) + 1); } objPtr->internalRep.strValue.maxLength = needlen*2; } memcpy(objPtr->bytes + objPtr->length, str, len); - objPtr->bytes[objPtr->length+len] = '\0'; + objPtr->bytes[objPtr->length + len] = '\0'; objPtr->length += len; } @@ -2163,7 +2163,7 @@ static void JimRelToAbsRange(int len, int first, int last, if (first > last) { rangeLen = 0; } else { - rangeLen = last-first+1; + rangeLen = last-first + 1; if (rangeLen) { if (first < 0) { rangeLen += first; @@ -2196,7 +2196,7 @@ Jim_Obj *Jim_StringRangeObj(Jim_Interp *interp, first = JimRelToAbsIndex(len, first); last = JimRelToAbsIndex(len, last); JimRelToAbsRange(len, first, last, &first, &last, &rangeLen); - return Jim_NewStringObj(interp, str+first, rangeLen); + return Jim_NewStringObj(interp, str + first, rangeLen); } static Jim_Obj *JimStringToLower(Jim_Interp *interp, Jim_Obj *strObjPtr) @@ -2207,9 +2207,9 @@ static Jim_Obj *JimStringToLower(Jim_Interp *interp, Jim_Obj *strObjPtr) SetStringFromAny(interp, strObjPtr); } - buf = Jim_Alloc(strObjPtr->length+1); + buf = Jim_Alloc(strObjPtr->length + 1); - memcpy(buf, strObjPtr->bytes, strObjPtr->length+1); + memcpy(buf, strObjPtr->bytes, strObjPtr->length + 1); for (i = 0; i < strObjPtr->length; i++) buf[i] = tolower(buf[i]); return Jim_NewStringObjNoAlloc(interp, buf, strObjPtr->length); @@ -2223,9 +2223,9 @@ static Jim_Obj *JimStringToUpper(Jim_Interp *interp, Jim_Obj *strObjPtr) SetStringFromAny(interp, strObjPtr); } - buf = Jim_Alloc(strObjPtr->length+1); + buf = Jim_Alloc(strObjPtr->length + 1); - memcpy(buf, strObjPtr->bytes, strObjPtr->length+1); + memcpy(buf, strObjPtr->bytes, strObjPtr->length + 1); for (i = 0; i < strObjPtr->length; i++) buf[i] = toupper(buf[i]); return Jim_NewStringObjNoAlloc(interp, buf, strObjPtr->length); @@ -2606,11 +2606,11 @@ int Jim_GetEnum(Jim_Interp *interp, Jim_Obj *objPtr, memcpy(tablePtrSorted, tablePtr, sizeof(char*)*count); qsort(tablePtrSorted, count, sizeof(char*), qsortCompareStringPointers); for (i = 0; i < count; i++) { - if (i+1 == count && count > 1) + if (i + 1 == count && count > 1) Jim_AppendString(interp, Jim_GetResult(interp), "or ", -1); Jim_AppendString(interp, Jim_GetResult(interp), tablePtrSorted[i], -1); - if (i+1 != count) + if (i + 1 != count) Jim_AppendString(interp, Jim_GetResult(interp), ", ", -1); } Jim_Free(tablePtrSorted); @@ -2888,7 +2888,7 @@ static void ScriptObjAddToken(Jim_Interp *interp, struct ScriptObj *script, script->token = Jim_Realloc(script->token, sizeof(ScriptToken)*script->len); /* Initialize the new token */ - token = script->token+(script->len-1); + token = script->token + (script->len-1); token->type = type; /* Every object is intially as a string, but the * internal type may be specialized during execution of the @@ -3060,8 +3060,8 @@ int SetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr) token[end-1].type == JIM_TT_EOL) { if (token[end].type == JIM_TT_STR && - token[end+1].type != JIM_TT_SEP && - token[end+1].type != JIM_TT_EOL && + token[end + 1].type != JIM_TT_SEP && + token[end + 1].type != JIM_TT_EOL && (!strcmp(token[end].objPtr->bytes, "expand") || !strcmp(token[end].objPtr->bytes, "*"))) expand++; @@ -3070,7 +3070,7 @@ int SetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr) args++; end++; } - interpolation = !((end-start+1) == args*2); + interpolation = !((end-start + 1) == args*2); /* Add the 'number of arguments' info into cmdstruct. * Negative value if there is list expansion involved. */ if (expand) @@ -3796,15 +3796,15 @@ static void JimDictSugarParseVarKey(Jim_Interp *interp, Jim_Obj *objPtr, str = Jim_GetString(objPtr, &len); p = strchr(str, '('); p++; - keyLen = len-((p-str)+1); + keyLen = len-((p-str) + 1); nameLen = (p-str)-1; /* Create the objects with the variable name and key. */ - t = Jim_Alloc(nameLen+1); + t = Jim_Alloc(nameLen + 1); memcpy(t, str, nameLen); t[nameLen] = '\0'; varObjPtr = Jim_NewStringObjNoAlloc(interp, t, nameLen); - t = Jim_Alloc(keyLen+1); + t = Jim_Alloc(keyLen + 1); memcpy(t, p, keyLen); t[keyLen] = '\0'; keyObjPtr = Jim_NewStringObjNoAlloc(interp, t, keyLen); @@ -4078,13 +4078,13 @@ static Jim_ObjType referenceObjType = { void UpdateStringOfReference(struct Jim_Obj *objPtr) { int len; - char buf[JIM_REFERENCE_SPACE+1]; + char buf[JIM_REFERENCE_SPACE + 1]; Jim_Reference *refPtr; refPtr = objPtr->internalRep.refValue.refPtr; len = JimFormatReference(buf, refPtr, objPtr->internalRep.refValue.id); - objPtr->bytes = Jim_Alloc(len+1); - memcpy(objPtr->bytes, buf, len+1); + objPtr->bytes = Jim_Alloc(len + 1); + memcpy(objPtr->bytes, buf, len + 1); objPtr->length = len; } @@ -4112,19 +4112,19 @@ int SetReferenceFromAny(Jim_Interp *interp, Jim_Obj *objPtr) if (len < JIM_REFERENCE_SPACE) goto badformat; /* Trim spaces */ start = str; - end = str+len-1; + end = str + len-1; while (*start == ' ') start++; while (*end == ' ' && end > start) end--; - if (end-start+1 != JIM_REFERENCE_SPACE) goto badformat; + if (end-start + 1 != JIM_REFERENCE_SPACE) goto badformat; /* .%020> */ if (memcmp(start, "val; if (refPtr->finalizerCmdNamePtr) { - char *refstr = Jim_Alloc(JIM_REFERENCE_SPACE+1); + char *refstr = Jim_Alloc(JIM_REFERENCE_SPACE + 1); Jim_Obj *objv[3], *oldResult; JimFormatReference(refstr, refPtr, *refId); @@ -4575,7 +4575,7 @@ int Jim_GetCallFrameByLevel(Jim_Interp *interp, Jim_Obj *levelObjPtr, return JIM_OK; } - level = strtol(str+1, &endptr, 0); + level = strtol(str + 1, &endptr, 0); if (str[1] == '\0' || endptr[0] != '\0' || level < 0) goto badlevel; /* An 'absolute' level is converted into the @@ -4792,11 +4792,11 @@ static Jim_ObjType intObjType = { void UpdateStringOfInt(struct Jim_Obj *objPtr) { int len; - char buf[JIM_INTEGER_SPACE+1]; + char buf[JIM_INTEGER_SPACE + 1]; len = Jim_WideToString(buf, objPtr->internalRep.wideValue); - objPtr->bytes = Jim_Alloc(len+1); - memcpy(objPtr->bytes, buf, len+1); + objPtr->bytes = Jim_Alloc(len + 1); + memcpy(objPtr->bytes, buf, len + 1); objPtr->length = len; } @@ -4904,11 +4904,11 @@ static Jim_ObjType doubleObjType = { void UpdateStringOfDouble(struct Jim_Obj *objPtr) { int len; - char buf[JIM_DOUBLE_SPACE+1]; + char buf[JIM_DOUBLE_SPACE + 1]; len = Jim_DoubleToString(buf, objPtr->internalRep.doubleValue); - objPtr->bytes = Jim_Alloc(len+1); - memcpy(objPtr->bytes, buf, len+1); + objPtr->bytes = Jim_Alloc(len + 1); + memcpy(objPtr->bytes, buf, len + 1); objPtr->length = len; } @@ -5063,10 +5063,10 @@ testbrace: if (level < 0) return JIM_ELESTR_QUOTE; break; case '\\': - if (s[i+1] == '\n') + if (s[i + 1] == '\n') return JIM_ELESTR_QUOTE; else - if (s[i+1] != '\0') i++; + if (s[i + 1] != '\0') i++; break; } } @@ -5099,7 +5099,7 @@ testbrace: * using backslash to quote special chars. */ char *BackslashQuoteString(const char *s, int len, int *qlenPtr) { - char *q = Jim_Alloc(len*2+1), *p; + char *q = Jim_Alloc(len*2 + 1), *p; p = q; while (*s) { @@ -5140,7 +5140,7 @@ void UpdateStringOfList(struct Jim_Obj *objPtr) Jim_Obj **ele = objPtr->internalRep.listValue.ele; /* (Over) Estimate the space needed. */ - quotingType = Jim_Alloc(sizeof(int)*objPtr->internalRep.listValue.len+1); + quotingType = Jim_Alloc(sizeof(int)*objPtr->internalRep.listValue.len + 1); bufLen = 0; for (i = 0; i < objPtr->internalRep.listValue.len; i++) { int len; @@ -5149,7 +5149,7 @@ void UpdateStringOfList(struct Jim_Obj *objPtr) quotingType[i] = ListElementQuotingType(strRep, len); switch (quotingType[i]) { case JIM_ELESTR_SIMPLE: bufLen += len; break; - case JIM_ELESTR_BRACE: bufLen += len+2; break; + case JIM_ELESTR_BRACE: bufLen += len + 2; break; case JIM_ELESTR_QUOTE: bufLen += len*2; break; } bufLen++; /* elements separator. */ @@ -5157,7 +5157,7 @@ void UpdateStringOfList(struct Jim_Obj *objPtr) bufLen++; /* Generate the string rep. */ - p = objPtr->bytes = Jim_Alloc(bufLen+1); + p = objPtr->bytes = Jim_Alloc(bufLen + 1); realLength = 0; for (i = 0; i < objPtr->internalRep.listValue.len; i++) { int len, qlen; @@ -5175,7 +5175,7 @@ void UpdateStringOfList(struct Jim_Obj *objPtr) memcpy(p, strRep, len); p += len; *p++ = '}'; - realLength += len+2; + realLength += len + 2; break; case JIM_ELESTR_QUOTE: q = BackslashQuoteString(strRep, len, &qlen); @@ -5186,7 +5186,7 @@ void UpdateStringOfList(struct Jim_Obj *objPtr) break; } /* Add a separating space */ - if (i+1 != objPtr->internalRep.listValue.len) { + if (i + 1 != objPtr->internalRep.listValue.len) { *p++ = ' '; realLength ++; } @@ -5365,7 +5365,7 @@ void ListInsertElements(Jim_Obj *listPtr, int index, int elemc, listPtr->internalRep.listValue.maxLen = maxLen; } point = listPtr->internalRep.listValue.ele + index; - memmove(point+elemc, point, (currentLen-index) * sizeof(Jim_Obj*)); + memmove(point + elemc, point, (currentLen-index) * sizeof(Jim_Obj*)); for (i = 0; i < elemc; ++i) { point[i] = elemVec[i]; Jim_IncrRefCount(point[i]); @@ -5391,7 +5391,7 @@ void ListAppendList(Jim_Obj *listPtr, Jim_Obj *appendListPtr) } for (i = 0; i < appendLen; i++) { Jim_Obj *objPtr = appendListPtr->internalRep.listValue.ele[i]; - listPtr->internalRep.listValue.ele[oldLen+i] = objPtr; + listPtr->internalRep.listValue.ele[oldLen + i] = objPtr; Jim_IncrRefCount(objPtr); } listPtr->internalRep.listValue.len += appendLen; @@ -5453,7 +5453,7 @@ int Jim_ListIndex(Jim_Interp *interp, Jim_Obj *listPtr, int index, return JIM_ERR; } if (index < 0) - index = listPtr->internalRep.listValue.len+index; + index = listPtr->internalRep.listValue.len + index; *objPtrPtr = listPtr->internalRep.listValue.ele[index]; return JIM_OK; } @@ -5472,7 +5472,7 @@ static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int index, return JIM_ERR; } if (index < 0) - index = listPtr->internalRep.listValue.len+index; + index = listPtr->internalRep.listValue.len + index; Jim_DecrRefCount(interp, listPtr->internalRep.listValue.ele[index]); listPtr->internalRep.listValue.ele[index] = newObjPtr; Jim_IncrRefCount(newObjPtr); @@ -5552,7 +5552,7 @@ Jim_Obj *Jim_ConcatObj(Jim_Interp *interp, int objc, Jim_Obj *const *objv) } if (objc) len += objc-1; /* Create the string rep, and a stinrg object holding it. */ - p = bytes = Jim_Alloc(len+1); + p = bytes = Jim_Alloc(len + 1); for (i = 0; i < objc; i++) { const char *s = Jim_GetString(objv[i], &objLen); while (objLen && (*s == ' ' || *s == '\t' || *s == '\n')) @@ -5565,9 +5565,9 @@ Jim_Obj *Jim_ConcatObj(Jim_Interp *interp, int objc, Jim_Obj *const *objv) } memcpy(p, s, objLen); p += objLen; - if (objLen && i+1 != objc) { + if (objLen && i + 1 != objc) { *p++ = ' '; - } else if (i+1 != objc) { + } else if (i + 1 != objc) { /* Drop the space calcuated for this * element that is instead null. */ len--; @@ -5594,7 +5594,7 @@ Jim_Obj *Jim_ListRange(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_Obj *firstOb last = JimRelToAbsIndex(len, last); JimRelToAbsRange(len, first, last, &first, &last, &rangeLen); return Jim_NewListObj(interp, - listObjPtr->internalRep.listValue.ele+first, rangeLen); + listObjPtr->internalRep.listValue.ele + first, rangeLen); } /* ----------------------------------------------------------------------------- @@ -5724,7 +5724,7 @@ void UpdateStringOfDict(struct Jim_Obj *objPtr) quotingType[i] = ListElementQuotingType(strRep, len); switch (quotingType[i]) { case JIM_ELESTR_SIMPLE: bufLen += len; break; - case JIM_ELESTR_BRACE: bufLen += len+2; break; + case JIM_ELESTR_BRACE: bufLen += len + 2; break; case JIM_ELESTR_QUOTE: bufLen += len*2; break; } bufLen++; /* elements separator. */ @@ -5732,7 +5732,7 @@ void UpdateStringOfDict(struct Jim_Obj *objPtr) bufLen++; /* Generate the string rep. */ - p = objPtr->bytes = Jim_Alloc(bufLen+1); + p = objPtr->bytes = Jim_Alloc(bufLen + 1); realLength = 0; for (i = 0; i < objc; i++) { int len, qlen; @@ -5750,7 +5750,7 @@ void UpdateStringOfDict(struct Jim_Obj *objPtr) memcpy(p, strRep, len); p += len; *p++ = '}'; - realLength += len+2; + realLength += len + 2; break; case JIM_ELESTR_QUOTE: q = BackslashQuoteString(strRep, len, &qlen); @@ -5761,7 +5761,7 @@ void UpdateStringOfDict(struct Jim_Obj *objPtr) break; } /* Add a separating space */ - if (i+1 != objc) { + if (i + 1 != objc) { *p++ = ' '; realLength ++; } @@ -5886,7 +5886,7 @@ Jim_Obj *Jim_NewDictObj(Jim_Interp *interp, Jim_Obj *const *elements, int len) objPtr->internalRep.ptr = Jim_Alloc(sizeof(Jim_HashTable)); Jim_InitHashTable(objPtr->internalRep.ptr, &JimDictHashTableType, interp); for (i = 0; i < len; i += 2) - DictAddElement(interp, objPtr, elements[i], elements[i+1]); + DictAddElement(interp, objPtr, elements[i], elements[i + 1]); return objPtr; } @@ -6025,17 +6025,17 @@ static Jim_ObjType indexObjType = { void UpdateStringOfIndex(struct Jim_Obj *objPtr) { int len; - char buf[JIM_INTEGER_SPACE+1]; + char buf[JIM_INTEGER_SPACE + 1]; if (objPtr->internalRep.indexValue >= 0) len = sprintf(buf, "%d", objPtr->internalRep.indexValue); else if (objPtr->internalRep.indexValue == -1) len = sprintf(buf, "end"); else { - len = sprintf(buf, "end%d", objPtr->internalRep.indexValue+1); + len = sprintf(buf, "end%d", objPtr->internalRep.indexValue + 1); } - objPtr->bytes = Jim_Alloc(len+1); - memcpy(objPtr->bytes, buf, len+1); + objPtr->bytes = Jim_Alloc(len + 1); + memcpy(objPtr->bytes, buf, len + 1); objPtr->length = len; } @@ -6067,7 +6067,7 @@ int SetIndexFromAny(Jim_Interp *interp, Jim_Obj *objPtr) if (index < 0) index = INT_MAX; else - index = -(index+1); + index = -(index + 1); } else if (!end && index < 0) index = -INT_MAX; /* Free the old internal repr and set the new one. */ @@ -6280,7 +6280,7 @@ int JimParseExpression(struct JimParserCtx *pc) *(pc->p) == '\t' || *(pc->p) == '\r' || *(pc->p) == '\n' || - (*(pc->p) == '\\' && *(pc->p+1) == '\n')) { + (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) { pc->p++; pc->len--; } @@ -6315,7 +6315,7 @@ int JimParseExpression(struct JimParserCtx *pc) break; case '-': if ((pc->tt == JIM_TT_NONE || pc->tt == JIM_TT_EXPR_OPERATOR) && - isdigit((int)*(pc->p+1))) + isdigit((int)*(pc->p + 1))) return JimParseExprNumber(pc); else return JimParseExprOperator(pc); @@ -6366,7 +6366,7 @@ int JimParseExprNumber(struct JimParserCtx *pc) if (*pc->p == '.') allowdot = 0; pc->p++; pc->len--; - if (!allowdot && *pc->p == 'e' && *(pc->p+1) == '-') { + if (!allowdot && *pc->p == 'e' && *(pc->p + 1) == '-') { pc->p += 2; pc->len -= 2; } } @@ -6490,8 +6490,8 @@ void DupExprInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr) static void ExprObjAddInstr(Jim_Interp *interp, ExprByteCode *expr, int opcode, char *str, int len) { - expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len+1)); - expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len+1)); + expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len + 1)); + expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len + 1)); expr->opcode[expr->len] = opcode; expr->obj[expr->len] = Jim_NewStringObjNoAlloc(interp, str, len); Jim_IncrRefCount(expr->obj[expr->len]); @@ -6644,32 +6644,32 @@ static void ExprMakeLazy(Jim_Interp *interp, ExprByteCode *expr) leftindex--; } leftindex++; - expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len+2)); - expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len+2)); - memmove(&expr->opcode[leftindex+2], &expr->opcode[leftindex], + expr->opcode = Jim_Realloc(expr->opcode, sizeof(int)*(expr->len + 2)); + expr->obj = Jim_Realloc(expr->obj, sizeof(Jim_Obj*)*(expr->len + 2)); + memmove(&expr->opcode[leftindex + 2], &expr->opcode[leftindex], sizeof(int)*(expr->len-leftindex)); - memmove(&expr->obj[leftindex+2], &expr->obj[leftindex], + memmove(&expr->obj[leftindex + 2], &expr->obj[leftindex], sizeof(Jim_Obj*)*(expr->len-leftindex)); expr->len += 2; index += 2; offset = (index-leftindex)-1; Jim_DecrRefCount(interp, expr->obj[index]); if (expr->opcode[index] == JIM_EXPROP_LOGICAND) { - expr->opcode[leftindex+1] = JIM_EXPROP_LOGICAND_LEFT; + expr->opcode[leftindex + 1] = JIM_EXPROP_LOGICAND_LEFT; expr->opcode[index] = JIM_EXPROP_LOGICAND_RIGHT; - expr->obj[leftindex+1] = Jim_NewStringObj(interp, "&L", -1); + expr->obj[leftindex + 1] = Jim_NewStringObj(interp, "&L", -1); expr->obj[index] = Jim_NewStringObj(interp, "&R", -1); } else { - expr->opcode[leftindex+1] = JIM_EXPROP_LOGICOR_LEFT; + expr->opcode[leftindex + 1] = JIM_EXPROP_LOGICOR_LEFT; expr->opcode[index] = JIM_EXPROP_LOGICOR_RIGHT; - expr->obj[leftindex+1] = Jim_NewStringObj(interp, "|L", -1); + expr->obj[leftindex + 1] = Jim_NewStringObj(interp, "|L", -1); expr->obj[index] = Jim_NewStringObj(interp, "|R", -1); } expr->opcode[leftindex] = JIM_EXPROP_NUMBER; expr->obj[leftindex] = Jim_NewIntObj(interp, offset); Jim_IncrRefCount(expr->obj[index]); Jim_IncrRefCount(expr->obj[leftindex]); - Jim_IncrRefCount(expr->obj[leftindex+1]); + Jim_IncrRefCount(expr->obj[leftindex + 1]); } } @@ -6950,7 +6950,7 @@ int Jim_EvalExpression(Jim_Interp *interp, Jim_Obj *exprObjPtr, Jim_DecrRefCount(interp, A); Jim_DecrRefCount(interp, B); switch (expr->opcode[i]) { - case JIM_EXPROP_ADD: wC = wA+wB; break; + case JIM_EXPROP_ADD: wC = wA + wB; break; case JIM_EXPROP_SUB: wC = wA-wB; break; case JIM_EXPROP_MUL: wC = wA*wB; break; case JIM_EXPROP_LT: wC = wAsize = approxSize; fmtObj->maxPos = 0; - fmtObj->scratch = (char*)&fmtObj->descr[maxCount+1]; + fmtObj->scratch = (char*)&fmtObj->descr[maxCount + 1]; fmtObj->stringRep = fmtObj->scratch + maxFmtLen + 3 + 1; memcpy(fmtObj->stringRep, fmt, maxFmtLen); buffer = fmtObj->stringRep + maxFmtLen + 1; @@ -7442,11 +7442,11 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr) /* In case a range fence was given "backwards", swap it */ while (swapped) { swapped = 0; - for (j = beg+1; j < end-1; ++j) { - if (buffer[j] == '-' && buffer[j-1] > buffer[j+1]) { + for (j = beg + 1; j < end-1; ++j) { + if (buffer[j] == '-' && buffer[j-1] > buffer[j + 1]) { char tmp = buffer[j-1]; - buffer[j-1] = buffer[j+1]; - buffer[j+1] = tmp; + buffer[j-1] = buffer[j + 1]; + buffer[j + 1] = tmp; swapped = 1; } } @@ -7525,8 +7525,8 @@ JimScanAString(Jim_Interp *interp, const char *sdescr, const char *str) { size_t i; Jim_Obj *result; - char charset[256/8+1]; /* A Charset may contain max 256 chars */ - char *buffer = Jim_Alloc(strlen(str)+1), *anchor = buffer; + char charset[256/8 + 1]; /* A Charset may contain max 256 chars */ + char *buffer = Jim_Alloc(strlen(str) + 1), *anchor = buffer; /* First init charset to nothing or all, depending if a specified * or an unspecified string has to be parsed */ @@ -7838,13 +7838,13 @@ static void JimRandomBytes(Jim_Interp *interp, void *dest, unsigned int len) prng = interp->prngState; /* generates 'len' bytes of pseudo-random numbers */ for (x = 0; x < len; x++) { - prng->i = (prng->i+1) & 0xff; + prng->i = (prng->i + 1) & 0xff; si = prng->sbox[prng->i]; prng->j = (prng->j + si) & 0xff; sj = prng->sbox[prng->j]; prng->sbox[prng->i] = sj; prng->sbox[prng->j] = si; - *destByte++ = prng->sbox[(si+sj)&0xff]; + *destByte++ = prng->sbox[(si + sj)&0xff]; } } @@ -7939,7 +7939,7 @@ int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName) &prefixObjPtr, JIM_NONE) != JIM_OK) continue; prefix = Jim_GetString(prefixObjPtr, &prefixlen); - if (prefixlen+strlen(pathName)+1 >= JIM_PATH_LEN) + if (prefixlen + strlen(pathName) + 1 >= JIM_PATH_LEN) continue; if (*pathName == '/') { strcpy(buf, pathName); @@ -8000,7 +8000,7 @@ int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName) #define JIM_PKG_ANY_VERSION -1 /* Convert a string of the type "1.2" into an integer. - * MAJOR.MINOR is converted as MAJOR*100+MINOR, so "1.2" is converted + * MAJOR.MINOR is converted as MAJOR*100 + MINOR, so "1.2" is converted * to the integer with value 102 */ static int JimPackageVersionToInt(Jim_Interp *interp, const char *v, int *intPtr, int flags) @@ -8019,12 +8019,12 @@ static int JimPackageVersionToInt(Jim_Interp *interp, const char *v, if (p == NULL) goto badfmt; *p = '\0'; majorStr = copy; - minorStr = p+1; + minorStr = p + 1; if (Jim_StringToWide(majorStr, &major, 10) != JIM_OK || Jim_StringToWide(minorStr, &minor, 10) != JIM_OK) goto badfmt; - *intPtr = (int)(major*100+minor); + *intPtr = (int)(major*100 + minor); Jim_Free(copy); return JIM_OK; @@ -8190,20 +8190,20 @@ static char *JimFindBestPackage(Jim_Interp *interp, char **prefixes, int fileNameLen = strlen(fileName); if (strncmp(fileName, "jim-", 4) == 0 && - strncmp(fileName+4, pkgName, pkgNameLen) == 0 && - *(fileName+4+pkgNameLen) == '-' && + strncmp(fileName + 4, pkgName, pkgNameLen) == 0 && + *(fileName + 4+pkgNameLen) == '-' && fileNameLen > 4 && /* note that this is not really useful */ - (strncmp(fileName+fileNameLen-4, ".tcl", 4) == 0 || - strncmp(fileName+fileNameLen-4, ".dll", 4) == 0 || - strncmp(fileName+fileNameLen-3, ".so", 3) == 0)) + (strncmp(fileName + fileNameLen-4, ".tcl", 4) == 0 || + strncmp(fileName + fileNameLen-4, ".dll", 4) == 0 || + strncmp(fileName + fileNameLen-3, ".so", 3) == 0)) { char ver[6]; /* xx.yy */ char *p = strrchr(fileName, '.'); int verLen, fileVer; - verLen = p - (fileName+4+pkgNameLen+1); + verLen = p - (fileName + 4+pkgNameLen + 1); if (verLen < 3 || verLen > 5) continue; - memcpy(ver, fileName+4+pkgNameLen+1, verLen); + memcpy(ver, fileName + 4+pkgNameLen + 1, verLen); ver[verLen] = '\0'; if (JimPackageVersionToInt(interp, ver, &fileVer, JIM_NONE) != JIM_OK) continue; @@ -8212,7 +8212,7 @@ static char *JimFindBestPackage(Jim_Interp *interp, char **prefixes, { bestVer = fileVer; Jim_Free(bestPackage); - bestPackage = Jim_Alloc(strlen(buf)+strlen(fileName)+2); + bestPackage = Jim_Alloc(strlen(buf) + strlen(fileName) + 2); sprintf(bestPackage, "%s/%s", buf, fileName); } } @@ -8368,19 +8368,19 @@ static int JimUnknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) * the "unknown" string, it is used in order to * avoid to lookup the unknown command every time * but instread to cache the result. */ - if (argc+1 <= JIM_EVAL_SARGV_LEN) + if (argc + 1 <= JIM_EVAL_SARGV_LEN) v = sv; else - v = Jim_Alloc(sizeof(Jim_Obj*)*(argc+1)); + v = Jim_Alloc(sizeof(Jim_Obj*)*(argc + 1)); /* Make a copy of the arguments vector, but shifted on * the right of one position. The command name of the * command will be instead the first argument of the * [unknonw] call. */ - memcpy(v+1, argv, sizeof(Jim_Obj*)*argc); + memcpy(v + 1, argv, sizeof(Jim_Obj*)*argc); v[0] = interp->unknown; /* Call it */ interp->unknown_called++; - retCode = Jim_EvalObjVector(interp, argc+1, v); + retCode = Jim_EvalObjVector(interp, argc + 1, v); interp->unknown_called--; /* Clean up */ @@ -8496,7 +8496,7 @@ int Jim_InterpolateTokens(Jim_Interp *interp, ScriptToken *token, * object. */ objPtr = Jim_NewStringObjNoAlloc(interp, NULL, 0); - s = objPtr->bytes = Jim_Alloc(totlen+1); + s = objPtr->bytes = Jim_Alloc(totlen + 1); objPtr->length = totlen; for (i = 0; i < tokens; i++) { memcpy(s, intv[i]->bytes, intv[i]->length); @@ -8527,7 +8527,7 @@ void Jim_ExpandArgument(Jim_Interp *interp, Jim_Obj ***argv, int *argcPtr, int expand, Jim_Obj *objPtr) { if (!expand) { - (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr)+1)); + (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr) + 1)); /* refcount of objPtr not incremented because * we are actually transfering a reference from * the old 'argv' to the expanded one. */ @@ -8537,7 +8537,7 @@ void Jim_ExpandArgument(Jim_Interp *interp, Jim_Obj ***argv, int len, i; Jim_ListLength(interp, objPtr, &len); - (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr)+len)); + (*argv) = Jim_Realloc(*argv, sizeof(Jim_Obj*)*((*argcPtr) + len)); for (i = 0; i < len; i++) { (*argv)[*argcPtr] = objPtr->internalRep.listValue.ele[i]; Jim_IncrRefCount(objPtr->internalRep.listValue.ele[i]); @@ -8668,13 +8668,13 @@ int Jim_EvalObj(Jim_Interp *interp, Jim_Obj *scriptObjPtr) /* For interpolation we call an helper * function doing the work for us. */ if ((retcode = Jim_InterpolateTokens(interp, - token+i, tokens, &tmpObjPtr)) != JIM_OK) + token + i, tokens, &tmpObjPtr)) != JIM_OK) { goto err; } argv[j] = tmpObjPtr; Jim_IncrRefCount(argv[j]); - i += tokens+1; + i += tokens + 1; } } /* Handle {expand} expansion */ @@ -8840,7 +8840,7 @@ int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_ListIndex(interp, argObjPtr, 1, &valueObjPtr, JIM_NONE); } else { - valueObjPtr = argv[i+1]; + valueObjPtr = argv[i + 1]; } Jim_SetVariable(interp, nameObjPtr, valueObjPtr); } @@ -8849,7 +8849,7 @@ int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_Obj *listObjPtr, *objPtr; i++; - listObjPtr = Jim_NewListObj(interp, argv+i, argc-i); + listObjPtr = Jim_NewListObj(interp, argv + i, argc-i); Jim_ListIndex(interp, cmd->argListObjPtr, num_args, &objPtr, JIM_NONE); Jim_SetVariable(interp, objPtr, listObjPtr); } @@ -8974,12 +8974,12 @@ int Jim_EvalFile(Jim_Interp *interp, const char *filename) buflen = 1024; maxlen = totread = 0; while (1) { - if (maxlen < totread+buflen+1) { - maxlen = totread+buflen+1; + if (maxlen < totread + buflen + 1) { + maxlen = totread + buflen + 1; prg = Jim_Realloc(prg, maxlen); } /* do not use Jim_fread() - this is really a file */ - if ((nread = fread(prg+totread, 1, buflen, fp)) == 0) break; + if ((nread = fread(prg + totread, 1, buflen, fp)) == 0) break; totread += nread; } prg[totread] = '\0'; @@ -9045,7 +9045,7 @@ static int JimParseSubst(struct JimParserCtx *pc, int flags) pc->tt = JIM_TT_ESC; if (*pc->tstart == '{') { pc->tstart--; - if (*(pc->tend+1)) + if (*(pc->tend + 1)) pc->tend++; } } @@ -9404,7 +9404,7 @@ void Jim_WrongNumArgs(Jim_Interp *interp, int argc, Jim_Obj *const *argv, Jim_AppendString(interp, objPtr, "wrong # args: should be \"", -1); for (i = 0; i < argc; i++) { Jim_AppendObj(interp, objPtr, argv[i]); - if (!(i+1 == argc && msg[0] == '\0')) + if (!(i + 1 == argc && msg[0] == '\0')) Jim_AppendString(interp, objPtr, " ", 1); } Jim_AppendString(interp, objPtr, msg, -1); @@ -9723,13 +9723,13 @@ static int Jim_IncrCoreCommand(Jim_Interp *interp, int argc, if (Jim_GetWide(interp, intObjPtr, &wideValue) != JIM_OK) return JIM_ERR; if (Jim_IsShared(intObjPtr)) { - intObjPtr = Jim_NewIntObj(interp, wideValue+increment); + intObjPtr = Jim_NewIntObj(interp, wideValue + increment); if (Jim_SetVariable(interp, argv[1], intObjPtr) != JIM_OK) { Jim_FreeNewObj(interp, intObjPtr); return JIM_ERR; } } else { - Jim_SetWide(interp, intObjPtr, wideValue+increment); + Jim_SetWide(interp, intObjPtr, wideValue + increment); /* The following step is required in order to invalidate the * string repr of "FOO" if the var name is on the form of "FOO(IDX)" */ if (Jim_SetVariable(interp, argv[1], intObjPtr) != JIM_OK) { @@ -10116,7 +10116,7 @@ static int Jim_ForCoreCommand(Jim_Interp *interp, int argc, Jim_DecrRefCount(interp, varNamePtr); goto evalnext; } - auxObjPtr = Jim_NewIntObj(interp, currentVal+1); + auxObjPtr = Jim_NewIntObj(interp, currentVal + 1); if (Jim_SetVariable(interp, varNamePtr, auxObjPtr) == JIM_ERR) { if (stopVarNamePtr) Jim_DecrRefCount(interp, stopVarNamePtr); @@ -10206,13 +10206,13 @@ static int JimForeachMapHelper(Jim_Interp *interp, int argc, for (i = 0; i < nbrOfLists*2; i += 2) { div_t cnt; int count; - Jim_ListLength(interp, argv[i+1], &listsEnd[i]); - Jim_ListLength(interp, argv[i+2], &listsEnd[i+1]); + Jim_ListLength(interp, argv[i + 1], &listsEnd[i]); + Jim_ListLength(interp, argv[i + 2], &listsEnd[i + 1]); if (listsEnd[i] == 0) { Jim_SetResultString(interp, "foreach varlist is empty", -1); goto err; } - cnt = div(listsEnd[i+1], listsEnd[i]); + cnt = div(listsEnd[i + 1], listsEnd[i]); count = cnt.quot + (cnt.rem ? 1 : 0); if (count > nbrOfLoops) nbrOfLoops = count; @@ -10223,11 +10223,11 @@ static int JimForeachMapHelper(Jim_Interp *interp, int argc, while (varIdx < listsEnd[var]) { Jim_Obj *varName, *ele; int lst = i * 2 + 1; - if (Jim_ListIndex(interp, argv[var+1], varIdx, &varName, JIM_ERRMSG) + if (Jim_ListIndex(interp, argv[var + 1], varIdx, &varName, JIM_ERRMSG) != JIM_OK) goto err; if (listsIdx[i] < listsEnd[lst]) { - if (Jim_ListIndex(interp, argv[lst+1], listsIdx[i], &ele, JIM_ERRMSG) + if (Jim_ListIndex(interp, argv[lst + 1], listsIdx[i], &ele, JIM_ERRMSG) != JIM_OK) goto err; if (Jim_SetVariable(interp, varName, ele) != JIM_OK) { @@ -10379,11 +10379,11 @@ static int Jim_SwitchCoreCommand(Jim_Interp *interp, int argc, switch (matchOpt) { case SWITCH_EXACT: if (Jim_StringEqObj(strObj, patObj, 0)) - script = caseList[i+1]; + script = caseList[i + 1]; break; case SWITCH_GLOB: if (Jim_StringMatchObj(patObj, strObj, 0)) - script = caseList[i+1]; + script = caseList[i + 1]; break; case SWITCH_RE: command = Jim_NewStringObj(interp, "regexp", -1); @@ -10412,7 +10412,7 @@ static int Jim_SwitchCoreCommand(Jim_Interp *interp, int argc, goto err; } if (matching) - script = caseList[i+1]; + script = caseList[i + 1]; break; } default: @@ -10422,12 +10422,12 @@ static int Jim_SwitchCoreCommand(Jim_Interp *interp, int argc, goto err; } } else { - script = caseList[i+1]; + script = caseList[i + 1]; } } for (; i < patCount && Jim_CompareStringImmediate(interp, script, "-"); i += 2) - script = caseList[i+1]; + script = caseList[i + 1]; if (script && Jim_CompareStringImmediate(interp, script, "-")) { Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); Jim_AppendStrings(interp, Jim_GetResult(interp), @@ -10454,7 +10454,7 @@ static int Jim_ListCoreCommand(Jim_Interp *interp, int argc, { Jim_Obj *listObjPtr; - listObjPtr = Jim_NewListObj(interp, argv+1, argc-1); + listObjPtr = Jim_NewListObj(interp, argv + 1, argc-1); Jim_SetResult(interp, listObjPtr); return JIM_OK; } @@ -10589,7 +10589,7 @@ static int Jim_LsetCoreCommand(Jim_Interp *interp, int argc, Jim_SetResult(interp, argv[2]); return JIM_OK; } - if (Jim_SetListIndex(interp, argv[1], argv+2, argc-3, argv[argc-1]) + if (Jim_SetListIndex(interp, argv[1], argv + 2, argc-3, argv[argc-1]) == JIM_ERR) return JIM_ERR; return JIM_OK; } @@ -10841,7 +10841,7 @@ static int Jim_EvalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *objPtr; int retcode; - objPtr = Jim_ConcatObj(interp, argc-1, argv+1); + objPtr = Jim_ConcatObj(interp, argc-1, argv + 1); Jim_IncrRefCount(objPtr); retcode = Jim_EvalObj(interp, objPtr); Jim_DecrRefCount(interp, objPtr); @@ -10895,7 +10895,7 @@ static int Jim_UplevelCoreCommand(Jim_Interp *interp, int argc, if (argc == 2) { retcode = Jim_EvalObj(interp, argv[1]); } else { - objPtr = Jim_ConcatObj(interp, argc-1, argv+1); + objPtr = Jim_ConcatObj(interp, argc-1, argv + 1); Jim_IncrRefCount(objPtr); retcode = Jim_EvalObj(interp, objPtr); Jim_DecrRefCount(interp, objPtr); @@ -10921,7 +10921,7 @@ static int Jim_ExprCoreCommand(Jim_Interp *interp, int argc, } else if (argc > 2) { Jim_Obj *objPtr; - objPtr = Jim_ConcatObj(interp, argc-1, argv+1); + objPtr = Jim_ConcatObj(interp, argc-1, argv + 1); Jim_IncrRefCount(objPtr); retcode = Jim_EvalExpression(interp, objPtr, &exprResultPtr); Jim_DecrRefCount(interp, objPtr); @@ -10988,7 +10988,7 @@ static int Jim_TailcallCoreCommand(Jim_Interp *interp, int argc, { Jim_Obj *objPtr; - objPtr = Jim_NewListObj(interp, argv+1, argc-1); + objPtr = Jim_NewListObj(interp, argv + 1, argc-1); Jim_SetResult(interp, objPtr); return JIM_EVAL; } @@ -11005,7 +11005,7 @@ static int Jim_ProcCoreCommand(Jim_Interp *interp, int argc, return JIM_ERR; } Jim_ListLength(interp, argv[2], &argListLen); - arityMin = arityMax = argListLen+1; + arityMin = arityMax = argListLen + 1; if (argListLen) { const char *str; @@ -11045,7 +11045,7 @@ static int Jim_ProcCoreCommand(Jim_Interp *interp, int argc, static int Jim_ConcatCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - Jim_SetResult(interp, Jim_ConcatObj(interp, argc-1, argv+1)); + Jim_SetResult(interp, Jim_ConcatObj(interp, argc-1, argv + 1)); return JIM_OK; } @@ -11079,7 +11079,7 @@ static int Jim_UpvarCoreCommand(Jim_Interp *interp, int argc, } /* Now... for every other/local couple: */ for (i = 1; i < argc; i += 2) { - if (Jim_SetVariableLink(interp, argv[i+1], argv[i], + if (Jim_SetVariableLink(interp, argv[i + 1], argv[i], targetCallFrame) != JIM_OK) return JIM_ERR; } return JIM_OK; @@ -11133,7 +11133,7 @@ static Jim_Obj *JimStringMap(Jim_Interp *interp, Jim_Obj *mapListObjPtr, Jim_ListIndex(interp, mapListObjPtr, i*2, &eleObjPtr, JIM_NONE); key[i] = Jim_GetString(eleObjPtr, &keyLen[i]); - Jim_ListIndex(interp, mapListObjPtr, i*2+1, &eleObjPtr, JIM_NONE); + Jim_ListIndex(interp, mapListObjPtr, i*2 + 1, &eleObjPtr, JIM_NONE); value[i] = eleObjPtr; } str = Jim_GetString(objPtr, &strLen); @@ -11312,7 +11312,7 @@ static int Jim_StringCoreCommand(Jim_Interp *interp, int argc, Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); return JIM_OK; } else { - Jim_SetResult(interp, Jim_NewStringObj(interp, str+index, 1)); + Jim_SetResult(interp, Jim_NewStringObj(interp, str + index, 1)); return JIM_OK; } } else if (option == OPT_FIRST) { @@ -11560,13 +11560,13 @@ static int Jim_DictCoreCommand(Jim_Interp *interp, int argc, Jim_WrongNumArgs(interp, 2, argv, "?key value ...?"); return JIM_ERR; } - objPtr = Jim_NewDictObj(interp, argv+2, argc-2); + objPtr = Jim_NewDictObj(interp, argv + 2, argc-2); Jim_SetResult(interp, objPtr); return JIM_OK; } else if (option == OPT_GET) { Jim_Obj *objPtr; - if (Jim_DictKeysVector(interp, argv[2], argv+3, argc-3, &objPtr, + if (Jim_DictKeysVector(interp, argv[2], argv + 3, argc-3, &objPtr, JIM_ERRMSG) != JIM_OK) return JIM_ERR; Jim_SetResult(interp, objPtr); @@ -11576,20 +11576,20 @@ static int Jim_DictCoreCommand(Jim_Interp *interp, int argc, Jim_WrongNumArgs(interp, 2, argv, "varName key ?key ...? value"); return JIM_ERR; } - return Jim_SetDictKeysVector(interp, argv[2], argv+3, argc-4, + return Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc-4, argv[argc-1]); } else if (option == OPT_UNSET) { if (argc < 4) { Jim_WrongNumArgs(interp, 2, argv, "varName key ?key ...?"); return JIM_ERR; } - return Jim_SetDictKeysVector(interp, argv[2], argv+3, argc-3, + return Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc-3, NULL); } else if (option == OPT_EXIST) { Jim_Obj *objPtr; int exists; - if (Jim_DictKeysVector(interp, argv[2], argv+3, argc-3, &objPtr, + if (Jim_DictKeysVector(interp, argv[2], argv + 3, argc-3, &objPtr, JIM_ERRMSG) == JIM_OK) exists = 1; else @@ -11631,19 +11631,19 @@ static int Jim_SubstCoreCommand(Jim_Interp *interp, int argc, } i = argc-2; while (i--) { - if (Jim_CompareStringImmediate(interp, argv[i+1], + if (Jim_CompareStringImmediate(interp, argv[i + 1], "-nobackslashes")) flags |= JIM_SUBST_NOESC; - else if (Jim_CompareStringImmediate(interp, argv[i+1], + else if (Jim_CompareStringImmediate(interp, argv[i + 1], "-novariables")) flags |= JIM_SUBST_NOVAR; - else if (Jim_CompareStringImmediate(interp, argv[i+1], + else if (Jim_CompareStringImmediate(interp, argv[i + 1], "-nocommands")) flags |= JIM_SUBST_NOCMD; else { Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); Jim_AppendStrings(interp, Jim_GetResult(interp), - "bad option \"", Jim_GetString(argv[i+1], NULL), + "bad option \"", Jim_GetString(argv[i + 1], NULL), "\": must be -nobackslashes, -nocommands, or " "-novariables", NULL); return JIM_ERR; @@ -11802,7 +11802,7 @@ static int Jim_SplitCoreCommand(Jim_Interp *interp, int argc, objPtr = Jim_NewStringObj(interp, noMatchStart, (str-noMatchStart)); Jim_ListAppendElement(interp, resObjPtr, objPtr); - noMatchStart = str+1; + noMatchStart = str + 1; break; } } @@ -11821,7 +11821,7 @@ static int Jim_SplitCoreCommand(Jim_Interp *interp, int argc, int c = u[i]; if (objCache[c] == NULL) - objCache[c] = Jim_NewStringObj(interp, (char*)u+i, 1); + objCache[c] = Jim_NewStringObj(interp, (char*)u + i, 1); Jim_ListAppendElement(interp, resObjPtr, objCache[c]); } } @@ -11856,7 +11856,7 @@ static int Jim_JoinCoreCommand(Jim_Interp *interp, int argc, Jim_ListIndex(interp, argv[1], i, &objPtr, JIM_NONE); Jim_AppendObj(interp, resObjPtr, objPtr); - if (i+1 != listLen) { + if (i + 1 != listLen) { Jim_AppendString(interp, resObjPtr, joinStr, joinStrLen); } } @@ -11874,7 +11874,7 @@ static int Jim_FormatCoreCommand(Jim_Interp *interp, int argc, Jim_WrongNumArgs(interp, 1, argv, "formatString ?arg arg ...?"); return JIM_ERR; } - objPtr = Jim_FormatString(interp, argv[1], argc-2, argv+2); + objPtr = Jim_FormatString(interp, argv[1], argc-2, argv + 2); if (objPtr == NULL) return JIM_ERR; Jim_SetResult(interp, objPtr); @@ -11929,7 +11929,7 @@ static int Jim_ScanCoreCommand(Jim_Interp *interp, int argc, for (i = 0; i < outc; ++i) { if (Jim_Length(outVec[i]) > 0) { ++count; - if (Jim_SetVariable(interp, argv[3+i], outVec[i]) != JIM_OK) + if (Jim_SetVariable(interp, argv[3 + i], outVec[i]) != JIM_OK) goto err; } } @@ -12107,7 +12107,7 @@ static int Jim_RangeCoreCommand(Jim_Interp *interp, int argc, } objPtr = Jim_NewListObj(interp, NULL, 0); for (i = 0; i < len; i++) - ListAppendElement(objPtr, Jim_NewIntObj(interp, start+i*step)); + ListAppendElement(objPtr, Jim_NewIntObj(interp, start + i*step)); Jim_SetResult(interp, objPtr); return JIM_OK; } @@ -12144,7 +12144,7 @@ static int Jim_RandCoreCommand(Jim_Interp *interp, int argc, JimRandomBytes(interp, &r, sizeof(jim_wide)); if (r < 0 || r >= maxMul) continue; r = (len == 0) ? 0 : r%len; - Jim_SetResult(interp, Jim_NewIntObj(interp, min+r)); + Jim_SetResult(interp, Jim_NewIntObj(interp, min + r)); return JIM_OK; } } @@ -12313,10 +12313,10 @@ void Jim_PrintErrorMessage(Jim_Interp *interp) Jim_ListIndex(interp, interp->stackTrace, i, &objPtr, JIM_NONE); proc = Jim_GetString(objPtr, NULL); - Jim_ListIndex(interp, interp->stackTrace, i+1, &objPtr, + Jim_ListIndex(interp, interp->stackTrace, i + 1, &objPtr, JIM_NONE); file = Jim_GetString(objPtr, NULL); - Jim_ListIndex(interp, interp->stackTrace, i+2, &objPtr, + Jim_ListIndex(interp, interp->stackTrace, i + 2, &objPtr, JIM_NONE); line = Jim_GetString(objPtr, NULL); if (*proc) { @@ -12796,7 +12796,7 @@ Jim_SetResult_NvpUnknown( Jim_Interp *interp, const char *a; const char *b; - if ( (nvp+1)->name ){ + if ( (nvp + 1)->name ){ a = nvp->name; b = ", "; } else { diff --git a/src/helper/jim.h b/src/helper/jim.h index 97846f14..1ba5117a 100644 --- a/src/helper/jim.h +++ b/src/helper/jim.h @@ -563,7 +563,7 @@ typedef struct Jim_Interp { typedef struct Jim_Reference { Jim_Obj *objPtr; Jim_Obj *finalizerCmdNamePtr; - char tag[JIM_REFERENCE_TAGLEN+1]; + char tag[JIM_REFERENCE_TAGLEN + 1]; } Jim_Reference; /** Name Value Pairs, aka: NVP diff --git a/src/helper/log.c b/src/helper/log.c index 68b29a20..c65c2fb1 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -103,7 +103,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch #ifdef _DEBUG_FREE_SPACE_ " %d" #endif - ": %s", log_strings[level+1], count, t, file, line, function, + ": %s", log_strings[level + 1], count, t, file, line, function, #ifdef _DEBUG_FREE_SPACE_ info.fordblks, #endif @@ -117,7 +117,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch { /* print human readable output - but skip empty lines */ fprintf(log_output, "%s%s", - (level > LOG_LVL_USER)?log_strings[level+1]:"", string); + (level > LOG_LVL_USER)?log_strings[level + 1]:"", string); } } } else diff --git a/src/helper/log.h b/src/helper/log.h index 1a032b26..cfdc8aa5 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -29,7 +29,7 @@ #include "command.h" /* logging priorities - * LOG_LVL_SILENT - turn off all output. In lieu of try+catch this can be used as a + * LOG_LVL_SILENT - turn off all output. In lieu of try + catch this can be used as a * feeble ersatz. * LOG_LVL_USER - user messages. Could be anything from information * to progress messags. These messages do not represent diff --git a/src/helper/replacements.c b/src/helper/replacements.c index 5705c03a..d7e6254e 100644 --- a/src/helper/replacements.c +++ b/src/helper/replacements.c @@ -218,7 +218,7 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time tvslice.tv_sec = 0; tvslice.tv_usec = 100000; - retcode = select(sock_max_fd+1, &aread, &awrite, &aexcept, &tvslice); + retcode = select(sock_max_fd + 1, &aread, &awrite, &aexcept, &tvslice); } if (n_handles > 0) { /* check handles */ diff --git a/src/jtag/arm-jtag-ew.c b/src/jtag/arm-jtag-ew.c index 7616fe70..3068a15f 100644 --- a/src/jtag/arm-jtag-ew.c +++ b/src/jtag/arm-jtag-ew.c @@ -207,7 +207,7 @@ static int armjtagew_speed(int speed) usb_out_buffer[0] = CMD_SET_TCK_FREQUENCY; - buf_set_u32(usb_out_buffer+1, 0, 32, speed); + buf_set_u32(usb_out_buffer + 1, 0, 32, speed); result = armjtagew_usb_message(armjtagew_jtag_handle, 4, 4); @@ -500,7 +500,7 @@ static int armjtagew_get_version_info(void) /* query hardware version */ usb_out_buffer[0] = CMD_GET_VERSION; - result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4+15+256); + result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4 + 15 + 256); if (result != 0) { @@ -509,9 +509,9 @@ static int armjtagew_get_version_info(void) } - memcpy(sn, usb_in_buffer+4, 15); + memcpy(sn, usb_in_buffer + 4, 15); sn[15] = '\0'; - memcpy(auxinfo, usb_in_buffer+4+15, 256); + memcpy(auxinfo, usb_in_buffer + 4+15, 256); auxinfo[256] = '\0'; LOG_INFO("ARM-JTAG-EW firmware version %d.%d, hardware revision %c, SN=%s, Additional info: %s", \ @@ -651,7 +651,7 @@ static int armjtagew_tap_execute(void) byte_length = tap_length / 8; usb_out_buffer[0] = CMD_TAP_SHIFT; - buf_set_u32(usb_out_buffer+1, 0, 16, byte_length); + buf_set_u32(usb_out_buffer + 1, 0, 16, byte_length); tms_offset = 3; for (i = 0; i < byte_length; i++) diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c index 80de04f9..c56d309e 100644 --- a/src/jtag/ft2232.c +++ b/src/jtag/ft2232.c @@ -188,7 +188,7 @@ static jtag_command_t* first_unsent; /* next command that has to be sent static int require_send; -/* http://urjtag.wiki.sourceforge.net/Cable+FT2232 says: +/* http://urjtag.wiki.sourceforge.net/Cable + FT2232 says: "There is a significant difference between libftdi and libftd2xx. The latter one allows to schedule up to 64*64 bytes of result data while libftdi fails diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c index bab1a31c..42787db1 100644 --- a/src/jtag/jlink.c +++ b/src/jtag/jlink.c @@ -50,7 +50,7 @@ static unsigned int jlink_hw_jtag_version = 2; //#define JLINK_TAP_BUFFER_SIZE 384 #define JLINK_IN_BUFFER_SIZE 2048 -#define JLINK_OUT_BUFFER_SIZE 2*2048+4 +#define JLINK_OUT_BUFFER_SIZE 2*2048 + 4 #define JLINK_EMU_RESULT_BUFFER_SIZE 64 /* Global USB buffers */ diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 37adac76..1564ca65 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -633,7 +633,7 @@ extern void jtag_execute_queue_noclear(void); int jtag_get_flush_queue_count(void); -/* can be implemented by hw+sw */ +/* can be implemented by hw + sw */ extern int jtag_power_dropout(int* dropout); extern int jtag_srst_asserted(int* srst_asserted); diff --git a/src/jtag/presto.c b/src/jtag/presto.c index b1ca3bdd..fceae34a 100644 --- a/src/jtag/presto.c +++ b/src/jtag/presto.c @@ -712,7 +712,7 @@ static int presto_jtag_khz(int khz, int *jtag_speed) } if (khz >= 3000) *jtag_speed = 0; - else *jtag_speed = (1000+khz-1)/khz; + else *jtag_speed = (1000 + khz-1)/khz; return 0; } diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 64396df9..d3bd72d1 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -532,7 +532,7 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv context = Jim_GetAssocData(interp, "context"); /* go past the command */ - Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 ); + Jim_GetOpt_Setup( &goi, interp, argc-1, argv + 1 ); e = Jim_GetOpt_Nvp( &goi, jtag_cmds, &n ); if ( e != JIM_OK ){ @@ -1286,7 +1286,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args } /* Not valid.. are we at the end? */ - if ( ((i+2) != argc) ){ + if ( ((i + 2) != argc) ){ /* nope, then error */ return e; } @@ -1301,7 +1301,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args /* is it the magic? */ if ( 0 == strcmp( "-endstate", cp ) ){ /* is the statename valid? */ - cp = Jim_GetString( args[i+1], NULL ); + cp = Jim_GetString( args[i + 1], NULL ); /* see if it is a valid state name */ endstate = tap_state_by_name(cp); @@ -1340,7 +1340,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args const char *str; Jim_GetLong(interp, args[i], &bits); - str = Jim_GetString(args[i+1], &len); + str = Jim_GetString(args[i + 1], &len); fields[field_count].tap = tap; fields[field_count].num_bits = bits; @@ -1387,7 +1387,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar { tap_state_t states[8]; - if ((argc < 2) || ((size_t)argc > (sizeof(states)/sizeof(*states)+1))) + if ((argc < 2) || ((size_t)argc > (sizeof(states)/sizeof(*states) + 1))) { Jim_WrongNumArgs(interp, 1, args, "wrong arguments"); return JIM_ERR; @@ -1399,7 +1399,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar for (i = 0; i> ((len_all+i)%8)) & 1); + vsllink_tap_append_step(((len_all + i) < length-1 ? 0 : 1), (buffer[(len_all + i)/8] >> ((len_all + i)%8)) & 1); } pending_scan_results_length++; diff --git a/src/jtag/zy1000/jtag_minidriver.h b/src/jtag/zy1000/jtag_minidriver.h index 9606a2dd..66debe39 100644 --- a/src/jtag/zy1000/jtag_minidriver.h +++ b/src/jtag/zy1000/jtag_minidriver.h @@ -40,7 +40,7 @@ static __inline__ void waitIdle(void) cyg_uint32 empty; do { - ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, empty); + ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, empty); } while ((empty & 0x100) == 0); } @@ -54,7 +54,7 @@ static void sampleShiftRegister(void) #if 0 cyg_uint32 dummy; waitIdle(); - ZY1000_PEEK(ZY1000_JTAG_BASE+0xc, dummy); + ZY1000_PEEK(ZY1000_JTAG_BASE + 0xc, dummy); #endif } @@ -74,7 +74,7 @@ static void setCurrentState(enum tap_state state) } waitQueue(); sampleShiftRegister(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|a); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|a); } @@ -89,7 +89,7 @@ static __inline__ void shiftValueInner(const enum tap_state state, const enum ta b = endState; waitQueue(); sampleShiftRegister(); - ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value); + ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value); #if 1 #if TEST_MANUAL() if ((state == TAP_DRSHIFT) && (endState != TAP_DRSHIFT)) @@ -106,21 +106,21 @@ static __inline__ void shiftValueInner(const enum tap_state state, const enum ta } /* shift out value */ waitIdle(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x28, (((value >> i)&1) << 1)|tms); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, (((value >> i)&1) << 1)|tms); } waitIdle(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x28, 0); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, 0); waitIdle(); - //ZY1000_POKE(ZY1000_JTAG_BASE+0x20, TAP_DRSHIFT); // set this state and things break => expected - ZY1000_POKE(ZY1000_JTAG_BASE+0x20, TAP_DRPAUSE); // set this and things will work => expected. Not setting this is not sufficient to make things break. + //ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_DRSHIFT); // set this state and things break => expected + ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_DRPAUSE); // set this and things will work => expected. Not setting this is not sufficient to make things break. setCurrentState(endState); } else { - ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|b); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|b); } #else /* fast version */ - ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|b); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|b); #endif #else /* maximum debug version */ @@ -131,16 +131,16 @@ static __inline__ void shiftValueInner(const enum tap_state state, const enum ta for (i = 0; i> i); - ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (1 << 8)|(a << 4)|a); + ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value >> i); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 8)|(a << 4)|a); } sampleShiftRegister(); - ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value >> (repeat-1)); - ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (1 << 8)|(a << 4)|b); + ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value >> (repeat-1)); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 8)|(a << 4)|b); } else { sampleShiftRegister(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (repeat << 8)|(a << 4)|b); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (repeat << 8)|(a << 4)|b); } sampleShiftRegister(); #endif diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index c5239ee8..17620371 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -78,8 +78,8 @@ static bool readPowerDropout(void) { cyg_uint32 state; // sample and clear power dropout - HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x80); - HAL_READ_UINT32(ZY1000_JTAG_BASE+0x10, state); + HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x80); + HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state); bool powerDropout; powerDropout = (state & 0x80) != 0; return powerDropout; @@ -90,8 +90,8 @@ static bool readSRST(void) { cyg_uint32 state; // sample and clear SRST sensing - HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x00000040); - HAL_READ_UINT32(ZY1000_JTAG_BASE+0x10, state); + HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x00000040); + HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state); bool srstAsserted; srstAsserted = (state & 0x40) != 0; return srstAsserted; @@ -129,35 +129,35 @@ void zy1000_reset(int trst, int srst) LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst); if (!srst) { - ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000001); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000001); } else { /* Danger!!! if clk != 0 when in * idle in TAP_IDLE, reset halt on str912 will fail. */ - ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000001); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000001); } if (!trst) { - ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000002); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000002); } else { /* assert reset */ - ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000002); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000002); } if (trst||(srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST))) { waitIdle(); /* we're now in the RESET state until trst is deasserted */ - ZY1000_POKE(ZY1000_JTAG_BASE+0x20, TAP_RESET); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_RESET); } else { /* We'll get RCLK failure when we assert TRST, so clear any false positives here */ - ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x400); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400); } /* wait for srst to float back up */ @@ -192,7 +192,7 @@ int zy1000_speed(int speed) { /*0 means RCLK*/ speed = 0; - ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x100); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x100); LOG_DEBUG("jtag_speed using RCLK"); } else @@ -204,8 +204,8 @@ int zy1000_speed(int speed) } LOG_USER("jtag_speed %d => JTAG clk=%f", speed, 64.0/(float)speed); - ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x100); - ZY1000_POKE(ZY1000_JTAG_BASE+0x1c, speed&~1); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x100); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x1c, speed&~1); } return ERROR_OK; } @@ -218,10 +218,10 @@ static void setPower(bool power) savePower = power; if (power) { - HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x14, 0x8); + HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x14, 0x8); } else { - HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x8); + HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x8); } } @@ -271,7 +271,7 @@ static int jim_zy1000_version(Jim_Interp *interp, int argc, Jim_Obj *const *argv if (strcmp("openocd", str) == 0) { int revision; - revision = atol(ZYLIN_OPENOCD+strlen("XRevision: ")); + revision = atol(ZYLIN_OPENOCD + strlen("XRevision: ")); sprintf(buff, "%d", revision); version_str = buff; } @@ -307,7 +307,7 @@ zylinjtag_Jim_Command_powerstatus(Jim_Interp *interp, } cyg_uint32 status; - ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, status); + ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, status); Jim_SetResult(interp, Jim_NewIntObj(interp, (status&0x80) != 0)); @@ -334,7 +334,7 @@ int zy1000_init(void) { LOG_USER("%s", ZYLIN_OPENOCD_VERSION); - ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x30); // Turn on LED1 & LED2 + ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x30); // Turn on LED1 & LED2 setPower(true); // on by default @@ -359,9 +359,9 @@ int interface_jtag_execute_queue(void) cyg_uint32 empty; waitIdle(); - ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, empty); + ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, empty); /* clear JTAG error register */ - ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x400); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400); if ((empty&0x400) != 0) { @@ -382,7 +382,7 @@ static cyg_uint32 getShiftValue(void) { cyg_uint32 value; waitIdle(); - ZY1000_PEEK(ZY1000_JTAG_BASE+0xc, value); + ZY1000_PEEK(ZY1000_JTAG_BASE + 0xc, value); VERBOSE(LOG_INFO("getShiftValue %08x", value)); return value; } @@ -391,7 +391,7 @@ static cyg_uint32 getShiftValueFlip(void) { cyg_uint32 value; waitIdle(); - ZY1000_PEEK(ZY1000_JTAG_BASE+0x18, value); + ZY1000_PEEK(ZY1000_JTAG_BASE + 0x18, value); VERBOSE(LOG_INFO("getShiftValue %08x (flipped)", value)); return value; } @@ -404,8 +404,8 @@ static void shiftValueInnerFlip(const tap_state_t state, const tap_state_t endSt cyg_uint32 a,b; a = state; b = endState; - ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value); - ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (1 << 15)|(repeat << 8)|(a << 4)|b); + ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 15)|(repeat << 8)|(a << 4)|b); VERBOSE(getShiftValueFlip()); } #endif @@ -450,14 +450,14 @@ static __inline void scanFields(int num_fields, const scan_field_t *fields, tap_ pause_state = end_state; } - // we have (num_bits+7)/8 bytes of bits to toggle out. + // we have (num_bits + 7)/8 bytes of bits to toggle out. // bits are pushed out LSB to MSB value = 0; if (fields[i].out_value != NULL) { for (l = 0; l> l)&0xff; + inBuffer[(j + l)/8]=(value >> l)&0xff; } } j += k; @@ -517,7 +517,7 @@ int interface_jtag_add_ir_scan(int num_fields, const scan_field_t *fields, tap_s { found = 1; - scanFields(1, fields+j, TAP_IRSHIFT, end_state); + scanFields(1, fields + j, TAP_IRSHIFT, end_state); /* update device information */ buf_cpy(fields[j].out_value, tap->cur_instr, scan_size); @@ -582,7 +582,7 @@ int interface_jtag_add_dr_scan(int num_fields, const scan_field_t *fields, tap_s { found = 1; - scanFields(1, fields+j, TAP_DRSHIFT, end_state); + scanFields(1, fields + j, TAP_DRSHIFT, end_state); } } if (!found) @@ -659,10 +659,10 @@ static int zy1000_jtag_add_clocks(int num_cycles, tap_state_t state, tap_state_t { tms = (tms_scan >> i) & 1; waitIdle(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x28, tms); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms); } waitIdle(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x20, state); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, state); #endif @@ -714,7 +714,7 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path) } waitIdle(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x28, tms); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms); cur_state = path[state_count]; state_count++; @@ -722,7 +722,7 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path) } waitIdle(); - ZY1000_POKE(ZY1000_JTAG_BASE+0x20, cur_state); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, cur_state); return ERROR_OK; } diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 4cf18757..1c217838 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -345,7 +345,7 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len) if ((size_t)len + 4 <= sizeof(local_buffer)) { /* performance gain on smaller packets by only a single call to gdb_write() */ - memcpy(local_buffer+1, buffer, len++); + memcpy(local_buffer + 1, buffer, len++); local_buffer[len++] = '#'; local_buffer[len++] = DIGITS[(my_checksum >> 4) & 0xf]; local_buffer[len++] = DIGITS[my_checksum & 0xf]; @@ -369,7 +369,7 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len) { return retval; } - if ((retval = gdb_write(connection, local_buffer+1, 3)) != ERROR_OK) + if ((retval = gdb_write(connection, local_buffer + 1, 3)) != ERROR_OK) { return retval; } @@ -461,7 +461,7 @@ static __inline__ int fetch_packet(connection_t *connection, int *checksum_ok, i * We need to leave at least 2 bytes in the buffer to have * gdb_get_char() update various bits and bobs correctly. */ - if ((gdb_con->buf_cnt > 2) && ((gdb_con->buf_cnt+count) < *len)) + if ((gdb_con->buf_cnt > 2) && ((gdb_con->buf_cnt + count) < *len)) { /* The compiler will struggle a bit with constant propagation and * aliasing, so we help it by showing that these values do not @@ -651,7 +651,7 @@ int gdb_output_con(connection_t *connection, const char* line) hex_buffer[0] = 'O'; for (i = 0; i>4) & 0xf]; - tstr[i*2+1] = DIGITS[buf[j]&0xf]; + tstr[i*2 + 1] = DIGITS[buf[j]&0xf]; } } @@ -926,7 +926,7 @@ void gdb_target_to_reg(target_t *target, char *tstr, int str_len, uint8_t *bin) for (i = 0; i < str_len; i += 2) { uint8_t t = hextoint(tstr[i]) << 4; - t |= hextoint(tstr[i+1]); + t |= hextoint(tstr[i + 1]); int j = gdb_reg_pos(target, i/2, str_len/2); bin[j] = t; @@ -1182,7 +1182,7 @@ int gdb_read_memory_packet(connection_t *connection, target_t *target, char *pac return ERROR_SERVER_REMOTE_CLOSED; } - len = strtoul(separator+1, NULL, 16); + len = strtoul(separator + 1, NULL, 16); buffer = malloc(len); @@ -1256,7 +1256,7 @@ int gdb_write_memory_packet(connection_t *connection, target_t *target, char *pa return ERROR_SERVER_REMOTE_CLOSED; } - len = strtoul(separator+1, &separator, 16); + len = strtoul(separator + 1, &separator, 16); if (*(separator++) != ':') { @@ -1310,7 +1310,7 @@ int gdb_write_memory_binary_packet(connection_t *connection, target_t *target, c return ERROR_SERVER_REMOTE_CLOSED; } - len = strtoul(separator+1, &separator, 16); + len = strtoul(separator + 1, &separator, 16); if (*(separator++) != ':') { @@ -1408,7 +1408,7 @@ int gdb_breakpoint_watchpoint_packet(connection_t *connection, target_t *target, return ERROR_SERVER_REMOTE_CLOSED; } - address = strtoul(separator+1, &separator, 16); + address = strtoul(separator + 1, &separator, 16); if (*separator != ',') { @@ -1416,7 +1416,7 @@ int gdb_breakpoint_watchpoint_packet(connection_t *connection, target_t *target, return ERROR_SERVER_REMOTE_CLOSED; } - size = strtoul(separator+1, &separator, 16); + size = strtoul(separator + 1, &separator, 16); switch (type) { @@ -1533,7 +1533,7 @@ static int decode_xfer_read(char *buf, char **annex, int *ofs, unsigned int *len if (*separator != ',') return -1; - *len = strtoul(separator+1, NULL, 16); + *len = strtoul(separator + 1, NULL, 16); return 0; } @@ -1736,7 +1736,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i "0x%x\n" \ "\n", \ p->base, p->size, blocksize); - ram_start = p->base+p->size; + ram_start = p->base + p->size; } if (ram_start != 0) { diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 82b7330e..bb888aa5 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -86,7 +86,7 @@ int telnet_outputline(connection_t *connection, const char *line) if (line_end) { telnet_write(connection, "\r\n", 2); - line += len+1; + line += len + 1; } else { diff --git a/src/target/arm11.c b/src/target/arm11.c index 29f11573..54289d7c 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1399,7 +1399,7 @@ int arm11_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t LOG_DEBUG("Save %zi: 0x%" PRIx32 "",i,context[i]); } - cpsr = buf_get_u32((uint8_t*)(arm11->reg_values+ARM11_RC_CPSR),0,32); + cpsr = buf_get_u32((uint8_t*)(arm11->reg_values + ARM11_RC_CPSR),0,32); LOG_DEBUG("Save CPSR: 0x%" PRIx32 "", cpsr); for (int i = 0; i < num_mem_params; i++) diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index c4b7c6a1..e8023c86 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -2672,14 +2672,14 @@ int arm7_9_bulk_write_memory(target_t *target, uint32_t address, uint32_t count, dcc_count = count; dcc_buffer = buffer; retval = armv4_5_run_algorithm_inner(target, 0, NULL, 1, reg_params, - arm7_9->dcc_working_area->address, arm7_9->dcc_working_area->address+6*4, 20*1000, &armv4_5_info, arm7_9_dcc_completion); + arm7_9->dcc_working_area->address, arm7_9->dcc_working_area->address + 6*4, 20*1000, &armv4_5_info, arm7_9_dcc_completion); if (retval == ERROR_OK) { uint32_t endaddress = buf_get_u32(reg_params[0].value, 0, 32); - if (endaddress != (address+count*4)) + if (endaddress != (address + count*4)) { - LOG_ERROR("DCC write failed, expected end address 0x%08" PRIx32 " got 0x%0" PRIx32 "", (address+count*4), endaddress); + LOG_ERROR("DCC write failed, expected end address 0x%08" PRIx32 " got 0x%0" PRIx32 "", (address + count*4), endaddress); retval = ERROR_FAIL; } } diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c index 03c49663..ba533a41 100644 --- a/src/target/arm7tdmi.c +++ b/src/target/arm7tdmi.c @@ -383,7 +383,7 @@ void arm7tdmi_read_core_regs(target_t *target, uint32_t mask, uint32_t* core_reg for (i = 0; i <= 15; i++) { if (mask & (1 << i)) - /* nothing fetched, STM still in EXECUTE (1+i cycle) */ + /* nothing fetched, STM still in EXECUTE (1 + i cycle) */ arm7tdmi_clock_data_in(jtag_info, core_regs[i]); } } @@ -412,7 +412,7 @@ void arm7tdmi_read_core_regs_target_buffer(target_t *target, uint32_t mask, void for (i = 0; i <= 15; i++) { - /* nothing fetched, STM still in EXECUTE (1+i cycle), read databus */ + /* nothing fetched, STM still in EXECUTE (1 + i cycle), read databus */ if (mask & (1 << i)) { switch (size) @@ -522,7 +522,7 @@ void arm7tdmi_write_core_regs(target_t *target, uint32_t mask, uint32_t core_reg for (i = 0; i <= 15; i++) { if (mask & (1 << i)) - /* nothing fetched, LDM still in EXECUTE (1+i cycle) */ + /* nothing fetched, LDM still in EXECUTE (1 + i cycle) */ arm7tdmi_clock_out_inner(jtag_info, core_regs[i], 0); } arm7tdmi_clock_out_inner(jtag_info, ARMV4_5_NOP, 0); diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index fac0c8db..3179a613 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -587,7 +587,7 @@ void arm9tdmi_write_core_regs(target_t *target, uint32_t mask, uint32_t core_reg for (i = 0; i <= 15; i++) { if (mask & (1 << i)) - /* nothing fetched, LDM still in EXECUTE (1+i cycle) */ + /* nothing fetched, LDM still in EXECUTE (1 + i cycle) */ arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, core_regs[i], NULL, 0); } arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0); diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index 57f6603b..126d9557 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -1093,7 +1093,7 @@ int dap_info_command(struct command_context_s *cmd_ctx, swjdp_common_t *swjdp, i if (romentry&0x01) { uint32_t c_cid0,c_cid1,c_cid2,c_cid3,c_pid0,c_pid1,c_pid2,c_pid3,c_pid4,component_start; - uint32_t component_base = (uint32_t)((dbgbase&0xFFFFF000)+(int)(romentry&0xFFFFF000)); + uint32_t component_base = (uint32_t)((dbgbase&0xFFFFF000) + (int)(romentry&0xFFFFF000)); mem_ap_read_atomic_u32(swjdp, (component_base&0xFFFFF000)|0xFE0, &c_pid0); mem_ap_read_atomic_u32(swjdp, (component_base&0xFFFFF000)|0xFE4, &c_pid1); mem_ap_read_atomic_u32(swjdp, (component_base&0xFFFFF000)|0xFE8, &c_pid2); diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index f5e906a8..33f1a518 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -71,7 +71,7 @@ char * armv4_5_mode_strings_list[] = }; /* Hack! Yuk! allow -1 index, which simplifies codepaths elsewhere in the code */ -char** armv4_5_mode_strings = armv4_5_mode_strings_list+1; +char** armv4_5_mode_strings = armv4_5_mode_strings_list + 1; char* armv4_5_state_strings[] = { diff --git a/src/target/etb.c b/src/target/etb.c index 979d7a70..ad6eb03e 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -204,10 +204,10 @@ static int etb_read_ram(etb_t *etb, uint32_t *data, int num_frames) else buf_set_u32(fields[1].out_value, 0, 7, 0); - fields[0].in_value = (uint8_t *)(data+i); + fields[0].in_value = (uint8_t *)(data + i); jtag_add_dr_scan(3, fields, jtag_get_end_state()); - jtag_add_callback(etb_getbuf, (jtag_callback_data_t)(data+i)); + jtag_add_callback(etb_getbuf, (jtag_callback_data_t)(data + i)); } jtag_execute_queue(); @@ -550,32 +550,32 @@ static int etb_read_trace(etm_context_t *etm_ctx) etm_ctx->trace_data[j].flags |= ETMV1_TRIGGER_CYCLE; } - /* trace word j+1 */ - etm_ctx->trace_data[j+1].pipestat = (trace_data[i] & 0x100) >> 8; - etm_ctx->trace_data[j+1].packet = (trace_data[i] & 0x7800) >> 11; - etm_ctx->trace_data[j+1].flags = 0; + /* trace word j + 1 */ + etm_ctx->trace_data[j + 1].pipestat = (trace_data[i] & 0x100) >> 8; + etm_ctx->trace_data[j + 1].packet = (trace_data[i] & 0x7800) >> 11; + etm_ctx->trace_data[j + 1].flags = 0; if ((trace_data[i] & 0x8000) >> 15) { - etm_ctx->trace_data[j+1].flags |= ETMV1_TRACESYNC_CYCLE; + etm_ctx->trace_data[j + 1].flags |= ETMV1_TRACESYNC_CYCLE; } - if (etm_ctx->trace_data[j+1].pipestat == STAT_TR) + if (etm_ctx->trace_data[j + 1].pipestat == STAT_TR) { - etm_ctx->trace_data[j+1].pipestat = etm_ctx->trace_data[j+1].packet & 0x7; - etm_ctx->trace_data[j+1].flags |= ETMV1_TRIGGER_CYCLE; + etm_ctx->trace_data[j + 1].pipestat = etm_ctx->trace_data[j + 1].packet & 0x7; + etm_ctx->trace_data[j + 1].flags |= ETMV1_TRIGGER_CYCLE; } - /* trace word j+2 */ - etm_ctx->trace_data[j+2].pipestat = (trace_data[i] & 0x10000) >> 16; - etm_ctx->trace_data[j+2].packet = (trace_data[i] & 0x780000) >> 19; - etm_ctx->trace_data[j+2].flags = 0; + /* trace word j + 2 */ + etm_ctx->trace_data[j + 2].pipestat = (trace_data[i] & 0x10000) >> 16; + etm_ctx->trace_data[j + 2].packet = (trace_data[i] & 0x780000) >> 19; + etm_ctx->trace_data[j + 2].flags = 0; if ((trace_data[i] & 0x800000) >> 23) { - etm_ctx->trace_data[j+2].flags |= ETMV1_TRACESYNC_CYCLE; + etm_ctx->trace_data[j + 2].flags |= ETMV1_TRACESYNC_CYCLE; } - if (etm_ctx->trace_data[j+2].pipestat == STAT_TR) + if (etm_ctx->trace_data[j + 2].pipestat == STAT_TR) { - etm_ctx->trace_data[j+2].pipestat = etm_ctx->trace_data[j+2].packet & 0x7; - etm_ctx->trace_data[j+2].flags |= ETMV1_TRIGGER_CYCLE; + etm_ctx->trace_data[j + 2].pipestat = etm_ctx->trace_data[j + 2].packet & 0x7; + etm_ctx->trace_data[j + 2].flags |= ETMV1_TRIGGER_CYCLE; } j += 3; @@ -596,18 +596,18 @@ static int etb_read_trace(etm_context_t *etm_ctx) etm_ctx->trace_data[j].flags |= ETMV1_TRIGGER_CYCLE; } - /* trace word j+1 */ - etm_ctx->trace_data[j+1].pipestat = (trace_data[i] & 0x7000) >> 12; - etm_ctx->trace_data[j+1].packet = (trace_data[i] & 0x7f8000) >> 15; - etm_ctx->trace_data[j+1].flags = 0; + /* trace word j + 1 */ + etm_ctx->trace_data[j + 1].pipestat = (trace_data[i] & 0x7000) >> 12; + etm_ctx->trace_data[j + 1].packet = (trace_data[i] & 0x7f8000) >> 15; + etm_ctx->trace_data[j + 1].flags = 0; if ((trace_data[i] & 0x800000) >> 23) { - etm_ctx->trace_data[j+1].flags |= ETMV1_TRACESYNC_CYCLE; + etm_ctx->trace_data[j + 1].flags |= ETMV1_TRACESYNC_CYCLE; } - if (etm_ctx->trace_data[j+1].pipestat == STAT_TR) + if (etm_ctx->trace_data[j + 1].pipestat == STAT_TR) { - etm_ctx->trace_data[j+1].pipestat = etm_ctx->trace_data[j+1].packet & 0x7; - etm_ctx->trace_data[j+1].flags |= ETMV1_TRIGGER_CYCLE; + etm_ctx->trace_data[j + 1].pipestat = etm_ctx->trace_data[j + 1].packet & 0x7; + etm_ctx->trace_data[j + 1].flags |= ETMV1_TRIGGER_CYCLE; } j += 2; diff --git a/src/target/fa526.c b/src/target/fa526.c index bfc91a58..eee9e50b 100644 --- a/src/target/fa526.c +++ b/src/target/fa526.c @@ -269,7 +269,7 @@ void fa526_write_core_regs(target_t *target, uint32_t mask, uint32_t core_regs[1 for (i = 0; i <= 15; i++) { if (mask & (1 << i)) - /* nothing fetched, LDM still in EXECUTE (1+i cycle) */ + /* nothing fetched, LDM still in EXECUTE (1 + i cycle) */ arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, core_regs[i], NULL, 0); } arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0); diff --git a/src/target/image.c b/src/target/image.c index 5cc7b0d8..40b320fa 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -454,9 +454,9 @@ static int image_elf_read_section(image_t *image, int section, uint32_t offset, /* maximal size present in file for the current segment */ read_size = MIN(size, field32(elf,segment->p_filesz)-offset); LOG_DEBUG("read elf: size = 0x%" PRIx32 " at 0x%" PRIx32 "",read_size, - field32(elf,segment->p_offset)+offset); + field32(elf,segment->p_offset) + offset); /* read initialized area of the segment */ - if ((retval = fileio_seek(&elf->fileio, field32(elf,segment->p_offset)+offset)) != ERROR_OK) + if ((retval = fileio_seek(&elf->fileio, field32(elf,segment->p_offset) + offset)) != ERROR_OK) { LOG_ERROR("cannot find ELF segment content, seek failed"); return retval; diff --git a/src/target/mips32_dmaacc.c b/src/target/mips32_dmaacc.c index ab082cf2..6c57e783 100644 --- a/src/target/mips32_dmaacc.c +++ b/src/target/mips32_dmaacc.c @@ -370,7 +370,7 @@ int mips32_dmaacc_read_mem32(mips_ejtag_t *ejtag_info, uint32_t addr, int count, int retval; for (i = 0; iportmode & ETM_PORT_MODE_MASK) != ETM_PORT_NORMAL) || ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) != ETM_PORT_4BIT)) { - LOG_DEBUG("OpenOCD+trace only supports normal 4-bit ETM mode"); + LOG_DEBUG("OpenOCD + trace only supports normal 4-bit ETM mode"); return ERROR_ETM_PORTMODE_NOT_SUPPORTED; } @@ -251,7 +251,7 @@ static int oocd_trace_start_capture(etm_context_t *etm_ctx) control |= 0x2; /* half rate clock, capture at twice the clock rate */ } - /* OpenOCD+trace holds up to 16 million samples, + /* OpenOCD + trace holds up to 16 million samples, * but trigger counts is set in multiples of 16 */ trigger_count = (1048576 * etm_ctx->trigger_percent) / 100; @@ -316,12 +316,12 @@ static int handle_oocd_trace_config_command(struct command_context_s *cmd_ctx, c arm7_9->etm_ctx->capture_driver_priv = oocd_trace; oocd_trace->etm_ctx = arm7_9->etm_ctx; - /* copy name of TTY device used to communicate with OpenOCD+trace */ + /* copy name of TTY device used to communicate with OpenOCD + trace */ oocd_trace->tty = strndup(args[1], 256); } else { - LOG_ERROR("target has no ETM defined, OpenOCD+trace left unconfigured"); + LOG_ERROR("target has no ETM defined, OpenOCD + trace left unconfigured"); } return ERROR_OK; @@ -412,12 +412,12 @@ int oocd_trace_register_commands(struct command_context_s *cmd_ctx) { command_t *oocd_trace_cmd; - oocd_trace_cmd = register_command(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD+trace"); + oocd_trace_cmd = register_command(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD + trace"); register_command(cmd_ctx, oocd_trace_cmd, "config", handle_oocd_trace_config_command, COMMAND_CONFIG, NULL); - register_command(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD+trace status"); - register_command(cmd_ctx, oocd_trace_cmd, "resync", handle_oocd_trace_resync_command, COMMAND_EXEC, "resync OpenOCD+trace capture clock"); + register_command(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD + trace status"); + register_command(cmd_ctx, oocd_trace_cmd, "resync", handle_oocd_trace_resync_command, COMMAND_EXEC, "resync OpenOCD + trace capture clock"); return ERROR_OK; } diff --git a/src/target/target.c b/src/target/target.c index ac2528f7..ca21f7f6 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -246,7 +246,7 @@ static int max_target_number(void) t = all_targets; while ( t ){ if ( x < t->target_number ){ - x = (t->target_number)+1; + x = (t->target_number) + 1; } t = t->next; } @@ -268,7 +268,7 @@ static int new_target_number(void) } t = t->next; } - return x+1; + return x + 1; } static int target_continuous_poll = 1; @@ -492,7 +492,7 @@ static int jtag_enable_callback(enum jtag_event event, void *priv) } -/* Targets that correctly implement init+examine, i.e. +/* Targets that correctly implement init + examine, i.e. * no communication with target during init: * * XScale @@ -1118,7 +1118,7 @@ int target_write_buffer(struct target_s *target, uint32_t address, uint32_t size if ((address + size - 1) < address) { /* GDB can request this when e.g. PC is 0xfffffffc*/ - LOG_ERROR("address+size wrapped(0x%08x, 0x%08x)", + LOG_ERROR("address + size wrapped(0x%08x, 0x%08x)", (unsigned)address, (unsigned)size); return ERROR_FAIL; @@ -1200,7 +1200,7 @@ int target_read_buffer(struct target_s *target, uint32_t address, uint32_t size, if ((address + size - 1) < address) { /* GDB can request this when e.g. PC is 0xfffffffc*/ - LOG_ERROR("address+size wrapped(0x%08" PRIx32 ", 0x%08" PRIx32 ")", + LOG_ERROR("address + size wrapped(0x%08" PRIx32 ", 0x%08" PRIx32 ")", address, size); return ERROR_FAIL; @@ -2279,7 +2279,7 @@ static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cm /* DANGER!!! beware of unsigned comparision here!!! */ - if ((image.sections[i].base_address+buf_cnt >= min_address)&& + if ((image.sections[i].base_address + buf_cnt >= min_address)&& (image.sections[i].base_addressmax_address) + if (image.sections[i].base_address + buf_cnt>max_address) { - length -= (image.sections[i].base_address+buf_cnt)-max_address; + length -= (image.sections[i].base_address + buf_cnt)-max_address; } - if ((retval = target_write_buffer(target, image.sections[i].base_address+offset, length, buffer+offset)) != ERROR_OK) + if ((retval = target_write_buffer(target, image.sections[i].base_address + offset, length, buffer + offset)) != ERROR_OK) { free(buffer); break; @@ -2302,7 +2302,7 @@ static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cm image_size += length; command_print(cmd_ctx, "%u byte written at address 0x%8.8" PRIx32 "", (unsigned int)length, - image.sections[i].base_address+offset); + image.sections[i].base_address + offset); } free(buffer); @@ -2834,7 +2834,7 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, char *filename) } } - int addressSpace = (max-min+1); + int addressSpace = (max-min + 1); static const uint32_t maxBuckets = 256 * 1024; /* maximum buckets. */ uint32_t length = addressSpace; @@ -2883,7 +2883,7 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, char *filename) val = 65535; } data[i*2]=val&0xff; - data[i*2+1]=(val >> 8)&0xff; + data[i*2 + 1]=(val >> 8)&0xff; } free(buckets); writeData(f, data, length * 2); @@ -3028,7 +3028,7 @@ static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_ERR; } - return target_mem2array(interp, target, argc-1, argv+1); + return target_mem2array(interp, target, argc-1, argv + 1); } static int target_mem2array(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv) @@ -3215,7 +3215,7 @@ static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_ERR; } - return target_array2mem( interp,target, argc-1, argv+1 ); + return target_array2mem( interp,target, argc-1, argv + 1 ); } static int target_array2mem(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv) @@ -3749,7 +3749,7 @@ static int tcl_target_func( Jim_Interp *interp, int argc, Jim_Obj *const *argv ) }; /* go past the "command" */ - Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 ); + Jim_GetOpt_Setup( &goi, interp, argc-1, argv + 1 ); target = Jim_CmdPrivData( goi.interp ); cmd_ctx = Jim_GetAssocData(goi.interp, "context"); @@ -4141,7 +4141,7 @@ static int target_create( Jim_GetOptInfo *goi ) if ( target_types[x] == NULL ){ Jim_SetResult_sprintf( goi->interp, "Unknown target type %s, try one of ", cp ); for ( x = 0 ; target_types[x] ; x++ ){ - if ( target_types[x+1] ){ + if ( target_types[x + 1] ){ Jim_AppendStrings( goi->interp, Jim_GetResult(goi->interp), target_types[x]->name, @@ -4283,7 +4283,7 @@ static int jim_target( Jim_Interp *interp, int argc, Jim_Obj *const *argv ) cmd_ctx = Jim_GetAssocData( interp, "context" ); - Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 ); + Jim_GetOpt_Setup( &goi, interp, argc-1, argv + 1 ); if ( goi.argc == 0 ){ Jim_WrongNumArgs(interp, 1, argv, "missing: command ..."); @@ -4460,7 +4460,7 @@ static int handle_fast_load_image_command(struct command_context_s *cmd_ctx, cha /* DANGER!!! beware of unsigned comparision here!!! */ - if ((image.sections[i].base_address+buf_cnt >= min_address)&& + if ((image.sections[i].base_address + buf_cnt >= min_address)&& (image.sections[i].base_addressmax_address) + if (image.sections[i].base_address + buf_cnt>max_address) { - length -= (image.sections[i].base_address+buf_cnt)-max_address; + length -= (image.sections[i].base_address + buf_cnt)-max_address; } - fastload[i].address = image.sections[i].base_address+offset; + fastload[i].address = image.sections[i].base_address + offset; fastload[i].data = malloc(length); if (fastload[i].data == NULL) { free(buffer); break; } - memcpy(fastload[i].data, buffer+offset, length); + memcpy(fastload[i].data, buffer + offset, length); fastload[i].length = length; image_size += length; command_print(cmd_ctx, "%u byte written at address 0x%8.8x", (unsigned int)length, - ((unsigned int)(image.sections[i].base_address+offset))); + ((unsigned int)(image.sections[i].base_address + offset))); } free(buffer); diff --git a/src/target/xscale.c b/src/target/xscale.c index e07000d5..8c206537 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -264,8 +264,8 @@ int xscale_read_dcsr(target_t *target) jtag_add_dr_scan(3, fields, jtag_get_end_state()); - jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask); - jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask); + jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask); + jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask); if ((retval = jtag_execute_queue()) != ERROR_OK) { @@ -362,11 +362,11 @@ int xscale_receive(target_t *target, uint32_t *buffer, int num_words) jtag_add_pathmove(3, path); - fields[1].in_value = (uint8_t *)(field1+i); + fields[1].in_value = (uint8_t *)(field1 + i); jtag_add_dr_scan_check(3, fields, jtag_set_end_state(TAP_IDLE)); - jtag_add_callback(xscale_getbuf, (jtag_callback_data_t)(field1+i)); + jtag_add_callback(xscale_getbuf, (jtag_callback_data_t)(field1 + i)); words_scheduled++; } @@ -386,8 +386,8 @@ int xscale_receive(target_t *target, uint32_t *buffer, int num_words) int j; for (j = i; j < num_words - 1; j++) { - field0[j] = field0[j+1]; - field1[j] = field1[j+1]; + field0[j] = field0[j + 1]; + field1[j] = field1[j + 1]; } words_scheduled--; } @@ -480,8 +480,8 @@ int xscale_read_tx(target_t *target, int consume) jtag_add_dr_scan(3, fields, jtag_set_end_state(TAP_IDLE)); - jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask); - jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask); + jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask); + jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask); if ((retval = jtag_execute_queue()) != ERROR_OK) { @@ -563,8 +563,8 @@ int xscale_write_rx(target_t *target) { jtag_add_dr_scan(3, fields, jtag_set_end_state(TAP_IDLE)); - jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask); - jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask); + jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask); + jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask); if ((retval = jtag_execute_queue()) != ERROR_OK) { @@ -728,8 +728,8 @@ int xscale_write_dcsr(target_t *target, int hold_rst, int ext_dbg_brk) jtag_add_dr_scan(3, fields, jtag_get_end_state()); - jtag_check_value_mask(fields+0, &field0_check_value, &field0_check_mask); - jtag_check_value_mask(fields+2, &field2_check_value, &field2_check_mask); + jtag_check_value_mask(fields + 0, &field0_check_value, &field0_check_mask); + jtag_check_value_mask(fields + 2, &field2_check_value, &field2_check_mask); if ((retval = jtag_execute_queue()) != ERROR_OK) { diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index dba38dc7..09491c23 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -82,7 +82,7 @@ ! Set the maximum loop count to 25. LCOUNT 25; -! Step to DRPAUSE give 5 clocks and wait for 1.00e+000 SEC. +! Step to DRPAUSE give 5 clocks and wait for 1.00e + 000 SEC. LDELAY DRPAUSE 5 TCK 1.00E-003 SEC; ! Test for the completed status. Match means pass. ! Loop back to LDELAY line if not match and loop count less than 25. @@ -605,7 +605,7 @@ static int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, cha LOG_DEBUG("XSIR2 %d", bitcount); } - ir_buf = malloc((bitcount+7) / 8); + ir_buf = malloc((bitcount + 7) / 8); if (xsvf_read_buffer(bitcount, xsvf_fd, ir_buf) != ERROR_OK) do_abort = 1; -- 2.39.5