A random grab bag of minor fixes to enable -Werror for this port.
Cast address vars to long when the format was using %l.
Use %zu with sizeof operations.
Add const to a bunch of strings.
Trim unused variables.
Fix sizeof call to calculate target storage and not the pointer itself.
+2021-05-15 Mike Frysinger <vapier@gentoo.org>
+
+ * Makefile.in (WERROR_CFLAGS): Define.
+ (STD_CFLAGS): Add $(WERROR_CFLAGS).
+ * configure.ac: Add --enable-werror.
+ * device.c (device_full_name): Delete full_name variable.
+ (device_clean): Delete system variable.
+ * emul_chirp.c (chirp_emul_getprop): Cast vars to unsigned long.
+ (chirp_emul_seek): Likewise.
+ * hw_glue.c (hw_glue_init_address): Use %zu format.
+ * hw_ide.c (hw_ide_io_read_buffer): Cast vars to unsigned long.
+ (hw_ide_io_write_buffer): Likewise.
+ * hw_init.c (update_for_binary_section): Cast vars to unsigned long.
+ * hw_phb.c (hw_phb_dma_read_buffer): Likewise.
+ (hw_phb_dma_write_buffer): Likewise.
+ * hw_shm.c (hw_shm_init_data): Delete d variable.
+ (hw_shm_attach_address_callback): Delete shm variable.
+ * igen.c (gen_semantics_c): Include tree.h.
+ * interrupts.c (alignment_interrupt): Cast vars to unsigned long.
+ * ld-insn.c (dump_insn_field): Cast vars to unsigned long.
+ * main.c (main): Add const to argv.
+ * options.c (print_options): Cast var to int.
+ * ppc-instructions: Add %s to format. Delete shifted variable. Add
+ parenthesis to binary operations.
+ * psim.c (find_arg): Add const to return and argv.
+ (is_num): Add const to string.
+ (psim_options): Add const to return and argv, and p & param.
+ (psim_command): Add const to argv, device, and media.
+ (psim_stack): Add const to argv and envp.
+ * psim.h: Add const to psim_options, psim_command, and psim_stack.
+ * tree.c (parse_reg_property): Delete & from sizeof.
+ * vm.c (om_virtual_to_real): Const vars to long.
+ * vm_n.h (vm_data_map_read_N): Change format to %zu.
+ (vm_data_map_write_N): Likewise.
+ * configure: Regenerate.
+
2021-05-14 Mike Frysinger <vapier@gentoo.org>
* Makefile.in: Update path.
AR_FLAGS = rc
CC = @CC@
CFLAGS = @CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
BISON = bison
$(DEVZERO_CFLAGS)
SIM_FPU_CFLAGS = @sim_fpu_cflags@
-STD_CFLAGS = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(WARNING_CFLAGS) $(INCLUDES) $(INTL_CFLAGS) $(SIM_FPU_CFLAGS)
+STD_CFLAGS = $(CFLAGS) $(WERROR_CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(WARNING_CFLAGS) $(INCLUDES) $(INTL_CFLAGS) $(SIM_FPU_CFLAGS)
NOWARN_CFLAGS = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(INCLUDES) $(SIM_FPU_CFLAGS)
BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(INCLUDES) $(WARNING_CFLAGS)
REPORT_BUGS_TEXI
REPORT_BUGS_TO
PKGVERSION
+WERROR_CFLAGS
EGREP
GREP
CPP
enable_sim_switch
enable_sim_timebase
enable_sim_trace
+enable_werror
enable_sim_warnings
enable_sim_xor_endian
with_pkgversion
--enable-sim-switch Use a switch instead of a table for instruction call.
--enable-sim-timebase Specify whether the PPC timebase is supported.
--enable-sim-trace Specify whether tracing is supported.
+ --enable-werror treat compile warnings as errors
--enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o
--enable-sim-xor-endian=n Specify number bytes involved in PowerPC XOR bi-endian mode (default 8).
--enable-plugins Enable support for plugins
$as_echo "$sim_trace" >&6; }
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+ enableval=$enable_werror; case "${enableval}" in
+ yes | y) ERROR_ON_WARNING="yes" ;;
+ no | n) ERROR_ON_WARNING="no" ;;
+ *) as_fn_error $? "bad value ${enableval} for --enable-werror" "$LINENO" 5 ;;
+ esac
+fi
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ ERROR_ON_WARNING=yes
+fi
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+ WERROR_CFLAGS="-Werror"
+fi
+
+
# Check whether --enable-sim-warnings was given.
if test "${enable_sim_warnings+set}" = set; then :
enableval=$enable_sim_warnings; case "${enableval}" in
AC_MSG_RESULT($sim_trace)
+AC_ARG_ENABLE(werror,
+ AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
+ [case "${enableval}" in
+ yes | y) ERROR_ON_WARNING="yes" ;;
+ no | n) ERROR_ON_WARNING="no" ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
+ esac])
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ ERROR_ON_WARNING=yes
+fi
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+ WERROR_CFLAGS="-Werror"
+fi
+AC_SUBST(WERROR_CFLAGS)
+
AC_ARG_ENABLE(sim-warnings,
[ --enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
[case "${enableval}" in
unsigned sizeof_buf)
{
/* get a buffer */
- char full_name[1024];
- if (buf == (char*)0) {
- buf = full_name;
- sizeof_buf = sizeof(full_name);
+ if (buf == NULL) {
+ sizeof_buf = 1024;
+ buf = malloc(sizeof_buf);
}
/* construct a name */
strcat (buf, unit);
}
- /* return it usefully */
- if (buf == full_name)
- buf = (char *) strdup(full_name);
return buf;
}
device_clean(device *me,
void *data)
{
- psim *system;
- system = (psim*)data;
TRACE(trace_device_init, ("device_clean - initializing %s", me->path));
clean_device_interrupt_edges(&me->interrupt_destinations);
clean_device_instances(me);
break;
case ihandle_property:
TRACE(trace_os_emul, ("getprop - ihandle=0x%lx(0x%lx`%s')\n",
- BE2H_cell(*(unsigned_cell*)prop->array),
+ (unsigned long)BE2H_cell(*(unsigned_cell*)prop->array),
(unsigned long)device_find_ihandle_property(phandle, name),
ihandle_name(device_find_ihandle_property(phandle, name))));
break;
(unsigned long)args.ihandle,
(unsigned long)ihandle,
ihandle_name(ihandle),
- args.pos_hi, args.pos_lo));
+ (unsigned long)args.pos_hi,
+ (unsigned long)args.pos_lo));
if (ihandle == NULL) {
/* OpenFirmware doesn't define this error */
error("chirp: invalid ihandle passed to seek method");
if (glue->sizeof_output == 0)
device_error(me, "at least one reg property size must be nonzero");
if (glue->sizeof_output % sizeof(unsigned_word) != 0)
- device_error(me, "reg property size must be %d aligned", sizeof(unsigned_word));
+ device_error(me, "reg property size must be %zu aligned", sizeof(unsigned_word));
/* and the address */
device_address_to_attach_address(device_parent(me),
&unit.address, &glue->space, &glue->address,
me);
if (glue->address % (sizeof(unsigned_word) * max_nr_interrupts) != 0)
- device_error(me, "reg property address must be %d aligned",
+ device_error(me, "reg property address must be %zu aligned",
sizeof(unsigned_word) * max_nr_interrupts);
glue->nr_outputs = glue->sizeof_output / sizeof(unsigned_word);
glue->output = zalloc(glue->sizeof_output);
*(unsigned8*)dest = controller->reg[reg];
break;
default:
- device_error(me, "bus-error at address 0x%lx", addr);
+ device_error(me, "bus-error at address 0x%lx", (unsigned long)addr);
break;
}
return nr_bytes;
controller->reg[reg] = *(unsigned8*)source;
break;
default:
- device_error(me, "bus-error at 0x%lx", addr);
+ device_error(me, "bus-error at 0x%lx", (unsigned long)addr);
break;
}
return nr_bytes;
mem_in[2] = section_vma;
if (device_instance_call_method(memory, "claim", 3, mem_in, 1, mem_out) < 0)
device_error(me, "failed to claim memory for section at 0x%lx (0x%lx",
- section_vma,
- section_size);
+ (unsigned long)section_vma,
+ (unsigned long)section_size);
if (mem_out[0] != section_vma)
device_error(me, "section address not as requested");
}
device_error(me, "Do not support DMA into own bus");
/* do it */
DTRACE(phb, ("dma read - %s:0x%lx (%d bytes)\n",
- pci_space->name, addr, nr_bytes));
+ pci_space->name, (unsigned long)addr, nr_bytes));
return device_dma_read_buffer(device_parent(me),
dest, pci_space->parent_space,
addr, nr_bytes);
device_error(me, "Do not support DMA into own bus");
/* do it */
DTRACE(phb, ("dma write - %s:0x%lx (%d bytes)\n",
- pci_space->name, addr, nr_bytes));
+ pci_space->name, (unsigned long)addr, nr_bytes));
return device_dma_write_buffer(device_parent(me),
source, pci_space->parent_space,
addr, nr_bytes,
hw_shm_init_data(device *me)
{
hw_shm_device *shm = (hw_shm_device*)device_data(me);
- const device_unit *d;
reg_property_spec reg;
int i;
access_type access,
device *client) /*callback/default*/
{
- hw_shm_device *shm = (hw_shm_device*)device_data(me);
-
if (space != 0)
error("shm_attach_address_callback() invalid address space\n");
lf_printf(file, "#include \"cpu.h\"\n");
lf_printf(file, "#include \"idecode.h\"\n");
lf_printf(file, "#include \"semantics.h\"\n");
+ lf_printf(file, "#include \"tree.h\"\n");
lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
lf_printf(file, "#include \"sim-inline.h\"\n");
lf_printf(file, "#include \"sim-fpu.h\"\n");
case USER_ENVIRONMENT:
case VIRTUAL_ENVIRONMENT:
- cpu_error(processor, cia, "alignment interrupt - ra=0x%lx", ra);
+ cpu_error(processor, cia, "alignment interrupt - ra=0x%lx", (unsigned long)ra);
case OPERATING_ENVIRONMENT:
DAR = (spreg)ra;
int indent)
{
- printf("(insn_field*)0x%x\n", (unsigned)field);
+ printf("(insn_field*)0x%lx\n", (unsigned long)field);
dumpf(indent, "(first %d)\n", field->first);
int
-main(int argc, char **argv)
+main(int argc, char * const *argv)
{
const char *name_of_file;
char *arg_;
(((i == ARRAY_SIZE (defines) - 1)
|| (((i + 1) % cols) == 0))
? 0
- : max_len + 4 - strlen (defines[i])),
+ : max_len + 4 - (int)strlen (defines[i])),
"");
}
printf_filtered ("\n");
}
}
if (busy->vscr_busy)
- TRACE(trace_model, ("VSCR Register is now available.\n", spr_name(busy->spr_busy)));
+ TRACE(trace_model, ("VSCR Register %s is now available.\n", spr_name(busy->spr_busy)));
# Trace making registers busy
void::model-static::model_trace_make_busy:model_data *model_ptr, unsigned32 int_mask, unsigned32 fp_mask, unsigned32 cr_mask
unsigned64 mask;
int n = MASKED(*rB, 59, 63);
signed32 source = (signed32)*rS; /* signed to keep sign bit */
- signed32 shifted = source >> n;
int S = (MASKED(*rS,32,32) != 0);
signed64 r = ((unsigned64) source);
r = ((unsigned64) source) << 32 | (unsigned32) source;
mask = (unsigned64) MASK64(n+32,63);
else
mask = (unsigned64) 0;
- *rA = (signed_word) (r & mask | ((signed64) -1*S) & ~mask); /* if 64bit will sign extend */
+ *rA = (signed_word) ((r & mask) | (((signed64) -1*S) & ~mask)); /* if 64bit will sign extend */
if (S && (MASKED(r & ~mask,32,63)!=0))
XER |= xer_carry;
else
}
STATIC_INLINE_PSIM\
-(char *)
-find_arg(char *err_msg,
+(const char *)
+find_arg(const char *err_msg,
int *ptr_to_argp,
- char **argv)
+ char * const *argv)
{
*ptr_to_argp += 1;
if (argv[*ptr_to_argp] == NULL)
/* Test "string" for containing a string of digits that form a number
between "min" and "max". The return value is the number or "err". */
static
-int is_num( char *string, int min, int max, int err)
+int is_num(const char *string, int min, int max, int err)
{
int result = 0;
}
INLINE_PSIM\
-(char **)
+(char * const *)
psim_options(device *root,
- char **argv,
+ char * const *argv,
SIM_OPEN_KIND kind)
{
device *current = root;
return NULL;
argp = 0;
while (argv[argp] != NULL && argv[argp][0] == '-') {
- char *p = argv[argp] + 1;
- char *param;
+ const char *p = argv[argp] + 1;
+ const char *param;
while (*p != '\0') {
switch (*p) {
default:
INLINE_PSIM\
(void)
psim_command(device *root,
- char **argv)
+ char * const *argv)
{
int argp = 0;
if (argv[argp] == NULL) {
trace_option(opt, 1);
}
else if (strcmp(*argv, "change-media") == 0) {
- char *device = find_arg("Missing device name", &argp, argv);
- char *media = argv[++argp];
+ const char *device = find_arg("Missing device name", &argp, argv);
+ const char *media = argv[++argp];
device_ioctl(tree_find_device(root, device), NULL, 0,
device_ioctl_change_media, media);
}
INLINE_PSIM\
(void)
psim_stack(psim *system,
- char **argv,
- char **envp)
+ char * const *argv,
+ char * const *envp)
{
/* pass the stack device the argv/envp and let it work out what to
do with it */
extern device *psim_tree
(void);
-extern char **psim_options
+extern char * const *psim_options
(device *root,
- char **argv,
+ char * const *argv,
SIM_OPEN_KIND kind);
extern void psim_command
(device *root,
- char **argv);
+ char * const *argv);
extern void psim_merge_device_file
extern void psim_stack
(psim *system,
- char **argv,
- char **envp);
+ char * const *argv,
+ char * const *envp);
/* Run/stop the system */
if (device_nr_size_cells(bus) > 0)
chp = parse_size(current, bus, chp, ®s[reg_nr].size);
else
- memset(®s[reg_nr].size, 0, sizeof (®s[reg_nr].size));
+ memset(®s[reg_nr].size, 0, sizeof (regs[reg_nr].size));
}
/* create it */
TRACE(trace_vm,
("ea=0x%lx - htab search %d - htab=0x%lx hash=0x%lx mask=0x%lx pteg=0x%lx\n",
(long)ea, current_hash,
- map->real_address_of_page_table,
- page_hash,
- map->page_table_hash_mask,
+ (long)map->real_address_of_page_table,
+ (long)page_hash,
+ (long)map->page_table_hash_mask,
(long)real_address_of_pte_group));
for (real_address_of_pte_0 = real_address_of_pte_group;
real_address_of_pte_0 < (real_address_of_pte_group
unsigned_N val;
if (vm_data_map_read_buffer(map, &val, ea, sizeof(unsigned_N), processor, cia)
!= sizeof(unsigned_N)) {
- cpu_error(processor, cia, "misaligned %d byte read to 0x%lx failed",
+ cpu_error(processor, cia, "misaligned %zu byte read to 0x%lx failed",
sizeof(unsigned_N), (unsigned long)ea);
}
val = T2H_N(val);
unsigned_N data = H2T_N(val);
if (vm_data_map_write_buffer(map, &data, ea, sizeof(unsigned_N), 0, processor, cia)
!= sizeof(unsigned_N)) {
- cpu_error(processor, cia, "misaligned %d byte write to 0x%lx failed",
+ cpu_error(processor, cia, "misaligned %zu byte write to 0x%lx failed",
sizeof(unsigned_N), (unsigned long)ea);
}
if (WITH_MON & MONITOR_LOAD_STORE_UNIT) {