about summary refs log tree commit diff stats
path: root/miasm2/jitter/JitCore.h
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2017-04-27 07:53:45 +0200
committerGitHub <noreply@github.com>2017-04-27 07:53:45 +0200
commitca1482ebc82e768f6113eac90cfe56e82a720cd7 (patch)
tree0f33cad14ba2dd46c967f9f37b226aab2d348b45 /miasm2/jitter/JitCore.h
parent968e8fff0b9caef2441d005787897d44efaf860a (diff)
parent87091c19c513022f05a44cb0601572155f6a74e1 (diff)
downloadmiasm-ca1482ebc82e768f6113eac90cfe56e82a720cd7.tar.gz
miasm-ca1482ebc82e768f6113eac90cfe56e82a720cd7.zip
Merge pull request #538 from serpilliere/fix_cpu_reg_int
Jitter: Error on reg set not int
Diffstat (limited to '')
-rw-r--r--miasm2/jitter/JitCore.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/miasm2/jitter/JitCore.h b/miasm2/jitter/JitCore.h
index 24feb9c0..f599d6ea 100644
--- a/miasm2/jitter/JitCore.h
+++ b/miasm2/jitter/JitCore.h
@@ -17,7 +17,7 @@
 	}								\
 
 
-#define PyGetInt_ret0(item, value)					\
+#define PyGetInt_retneg(item, value)					\
 	if (PyInt_Check(item)){						\
 		value = (uint64_t)PyInt_AsLong(item);			\
 	}								\
@@ -25,7 +25,8 @@
 		value = (uint64_t)PyLong_AsUnsignedLongLong(item);	\
 	}								\
 	else{								\
-		printf("error\n"); return 0;				\
+		PyErr_SetString(PyExc_TypeError, "Arg must be int");	\
+		return -1;						\
 	}								\
 
 
@@ -38,7 +39,7 @@
 	static int JitCpu_set_ ## regname  (JitCpu *self, PyObject *value, void *closure) \
 	{								\
 		uint64_t val;						\
-		PyGetInt_ret0(value, val);				\
+		PyGetInt_retneg(value, val);				\
 		((vm_cpu_t*)(self->cpu))->  regname   = val;		\
 		return 0;						\
 	}
@@ -51,7 +52,7 @@
 	static int JitCpu_set_ ## regname  (JitCpu *self, PyObject *value, void *closure) \
 	{								\
 		uint32_t val;						\
-		PyGetInt_ret0(value, val);				\
+		PyGetInt_retneg(value, val);				\
 		((vm_cpu_t*)(self->cpu))->  regname   = val;		\
 		return 0;						\
 	}
@@ -65,8 +66,8 @@
 	static int JitCpu_set_ ## regname  (JitCpu *self, PyObject *value, void *closure) \
 	{								\
 		uint16_t val;						\
-		PyGetInt_ret0(value, val);				\
-		((vm_cpu_t*)(self->cpu))->  regname   = val;				\
+		PyGetInt_retneg(value, val);				\
+		((vm_cpu_t*)(self->cpu))->  regname   = val;		\
 		return 0;						\
 	}