Casting unsigned long to unsigned int to avoid compiler warnings
authorDaniel Giritzer <daniel@giritzer.eu>
Fri, 2 Jun 2017 18:59:21 +0000 (20:59 +0200)
committerDaniel Giritzer <daniel@giritzer.eu>
Fri, 2 Jun 2017 18:59:21 +0000 (20:59 +0200)
src/Makefile
src/devmem2.c
src/main.c

index ef8528c..551eef1 100644 (file)
@@ -25,7 +25,7 @@ PROJNAME = tvout
 CC = gcc
 CXX = g++
 AR = ar
-LD = g++
+LD = gcc
 WINDRES = windres
 
 INC =
index 1e8ec8c..20aecfb 100644 (file)
@@ -85,14 +85,22 @@ int writemem(char* address, char* value, int access_type)
     return EXIT_SUCCESS;
 }
 
-int readmem(char* address, int access_type, unsigned long read_result)
+int readmem(char* address, int access_type, unsigned long *result)
 {
     int fd;
     void *map_base, *virt_addr;
     off_t target;
+    unsigned long read_result = 0;
 
     target = strtoul(address, 0, 0);
 
+    if(result == NULL)
+    {
+        //Print error on failure
+        ERROR("Result Parameter is a nullpointer!");
+        return EXIT_FAILURE;
+    }
+
 
     // Try to open /dev/mem
     if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)
@@ -135,6 +143,8 @@ int readmem(char* address, int access_type, unsigned long read_result)
         return EXIT_FAILURE;
     }
 
+    *result = read_result;
+
     close(fd);
     return EXIT_SUCCESS;
 }
index 32a5ae6..136fd75 100644 (file)
@@ -8,6 +8,6 @@ int main()
 
     readmem("0x01E00130", 'w', readfrommemory);
 
-    printf("Value: 0x%X", readfrommemory);
+    printf("Value: 0x%X", (unsigned int)readfrommemory);
     return 0;
 }