From 6acc53b725ddd75772ea5f0777b2dcabf1583b50 Mon Sep 17 00:00:00 2001
From: Iztok Jeras <iztok.jeras@redpitaya.com>
Date: 摹曛, 08 10月 2015 03:00:34 +0800
Subject: [PATCH] integer parser: make buffer sizes more explicit, as sum of bitlength and NULL termination

---
 examples/common/scpi-def.cpp |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/examples/common/scpi-def.cpp b/examples/common/scpi-def.cpp
index d3b737c..720318e 100644
--- a/examples/common/scpi-def.cpp
+++ b/examples/common/scpi-def.cpp
@@ -151,7 +151,7 @@
     SCPI_ChoiceToName(trigger_source, param, &name);
     fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int)param);
 
-    SCPI_ResultInt(context, param);
+    SCPI_ResultInt32(context, param);
 
     return SCPI_RES_OK;
 }
@@ -167,8 +167,9 @@
     char buffer[100];
     size_t copy_len;
 
-    SCPI_ParamCopyText(context, buffer, sizeof(buffer), &copy_len, false);
-    buffer[copy_len] = '\0';
+    if(!SCPI_ParamCopyText(context, buffer, sizeof(buffer), &copy_len, false)) {
+        buffer[0] = '\0';
+    }
 
     fprintf(stderr, "TEXT: ***%s***\r\n", buffer);
 
@@ -196,7 +197,7 @@
  */
 scpi_result_t My_CoreTstQ(scpi_t * context) {
 
-    SCPI_ResultInt(context, 0);
+    SCPI_ResultInt32(context, 0);
 
     return SCPI_RES_OK;
 }

--
Gitblit v1.9.1