diff mbox series

pdbg: Tidy up putnia/putmsr

Message ID 20180524064303.4486-1-rashmica.g@gmail.com
State Accepted
Headers show
Series pdbg: Tidy up putnia/putmsr | expand

Commit Message

Rashmica Gupta May 24, 2018, 6:43 a.m. UTC
The number of arguments required for these functions is wrong -
it requires 2 arguments for putnia and putmsr, and the second one
is written. The code has obviously been copy/pasted from getgpr/getspr
functions where you need to supply which register and then the data.
---
 src/reg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/reg.c b/src/reg.c
index 002cfe9..21bec13 100644
--- a/src/reg.c
+++ b/src/reg.c
@@ -144,13 +144,13 @@  int handle_nia(int optind, int argc, char *argv[])
 	if (strcmp(argv[optind], "putnia") == 0) {
 		uint64_t data;
 
-		if (optind + 2 >= argc) {
+		if (optind + 1 >= argc) {
 			printf("%s: command '%s' requires data\n", argv[0], argv[optind]);
 			return -1;
 		}
 
 		errno = 0;
-		data = strtoull(argv[optind + 2], &endptr, 0);
+		data = strtoull(argv[optind + 1], &endptr, 0);
 		if (errno || *endptr != '\0') {
 			printf("%s: command '%s' couldn't parse data '%s'\n",
 				argv[0], argv[optind], argv[optind + 1]);
@@ -213,13 +213,13 @@  int handle_msr(int optind, int argc, char *argv[])
 	if (strcmp(argv[optind], "putmsr") == 0) {
 		uint64_t data;
 
-		if (optind + 2 >= argc) {
+		if (optind + 1 >= argc) {
 			printf("%s: command '%s' requires data\n", argv[0], argv[optind]);
 			return -1;
 		}
 
 		errno = 0;
-		data = strtoull(argv[optind + 2], &endptr, 0);
+		data = strtoull(argv[optind + 1], &endptr, 0);
 		if (errno || *endptr != '\0') {
 			printf("%s: command '%s' couldn't parse data '%s'\n",
 				argv[0], argv[optind], argv[optind + 1]);