135u5 / tinyos-main

Automatically exported from code.google.com/p/tinyos-main
1 stars 0 forks source link

sim-sf deprecated warnings #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When compiling sim-sf with python2.6 I get quite a few deprecated warnings due 
to some missing char* casts

The following should solve the problem and also fix a printf warning when 
compiling with sim-sf

diff --git a/tos/lib/tossim/sf/Throttle.cpp b/tos/lib/tossim/sf/Throttle.cpp
index 2a5350c..01520cb 100644
--- a/tos/lib/tossim/sf/Throttle.cpp
+++ b/tos/lib/tossim/sf/Throttle.cpp
@@ -111,7 +111,7 @@ int Throttle::simSleep(double seconds) {

 void Throttle::printStatistics() {

-    printf("Number of throttle events %d\n", throttleCount);
+    printf("Number of throttle events %lu\n", throttleCount);

     if (simEndTime > 0.0) {
         printf("Total Sim Time: %.6f\n", simEndTime - simStartTime);
diff --git a/tos/lib/tossim/sf/tossim.c b/tos/lib/tossim/sf/tossim.c
index 5a07d71..73db9e6 100644
--- a/tos/lib/tossim/sf/tossim.c
+++ b/tos/lib/tossim/sf/tossim.c
@@ -123,8 +123,8 @@ variable_string_t Variable::getData() {
     memcpy(data, ptr, len);
   }
   else {
-    str.ptr = "<no such variable>";
-    str.type = "<no such variable>";
+    str.ptr = (char*)"<no such variable>";
+    str.type = (char*)"<no such variable>";
     str.len = strlen("<no such variable>");
     str.isArray = 0;
   }
@@ -176,7 +176,7 @@ void Mote::setID(unsigned long val) {
 }

 Variable* Mote::getVariable(char* name) {
-  char* typeStr = "";
+  char* typeStr = (char*)"";
   int isArray;
   Variable* var;

diff --git a/tos/lib/tossim/sf/tossim.i b/tos/lib/tossim/sf/tossim.i
index 7789c3b..509acab 100644
--- a/tos/lib/tossim/sf/tossim.i
+++ b/tos/lib/tossim/sf/tossim.i
@@ -312,8 +312,8 @@ PyObject* listFromArray(char* type, char* ptr, int len) {
         }
       }
       else {
-        app->variableNames[i] = "<bad string>";
-        app->variableTypes[i] = "<bad string>";
+        app->variableNames[i] = (char*)"<bad string>";
+        app->variableTypes[i] = (char*)"<bad string>";
       }
     }

Original issue reported on code.google.com by mortenthansen on 18 Nov 2010 at 1:31

GoogleCodeExporter commented 8 years ago
I applied these fixes, but there seem to be additional warnings stemming from 
sf support. I'll try to take a look next week.

Original comment by philip.l...@gmail.com on 19 Nov 2010 at 11:48