On 02/18/2016 10:49 AM, Alistair Francis wrote:
On Thu, Feb 18, 2016 at 10:23 AM, Hollis Blanchard
<hollis_blanch...@mentor.com> wrote:
On 02/17/2016 01:04 PM, Alistair Francis wrote:
+static void generic_loader_reset(DeviceState *dev)
+{
+    GenericLoaderState *s = GENERIC_LOADER(dev);
+
+    if (s->cpu) {
+        CPUClass *cc = CPU_GET_CLASS(s->cpu);
+        cpu_reset(s->cpu);
+        cc->set_pc(s->cpu, s->addr);
+    }
+
+    if (s->data_len) {
+        dma_memory_write((s->cpu ? s->cpu : first_cpu)->as, s->addr,
&s->data,
+                         s->data_len);
+    }
+}

What happens if I accidentally make "data-len" bigger than sizeof(s->data)?
I think some bounds checking is needed?
Good point! I'll add an assert as it isn't a recoverable error.

Perhaps a more user-friendly error message would be, well, more user-friendly. :-) That could be done when reading the "data-len" property, in addition to an assert when using s->data_len.

Hollis Blanchard
Mentor Graphics Emulation Division

Reply via email to