Browse Source

Add cast to rand() return value.

Resolves implicit integer conversion warnings, e.g., Visual Studio C4244.
Jason Valenzuela 4 years ago
parent
commit
fc0179e996
3 changed files with 3 additions and 3 deletions
  1. 1 1
      source/src/ports/MINGW/main.c
  2. 1 1
      source/src/ports/POSIX/main.c
  3. 1 1
      source/src/ports/WIN32/main.c

+ 1 - 1
source/src/ports/MINGW/main.c

@@ -80,7 +80,7 @@ int main(int argc,
    *  the PRNG to ensure we don't get the same value on every startup.
    */
   srand(time(NULL));
-  EipUint16 unique_connection_id = rand();
+  EipUint16 unique_connection_id = (EipUint16)rand();
 
   /* Setup the CIP Layer. All objects are initialized with the default
    * values for the attribute contents. */

+ 1 - 1
source/src/ports/POSIX/main.c

@@ -95,7 +95,7 @@ int main(int argc,
    *  the PRNG to ensure we don't get the same value on every startup.
    */
   srand(time(NULL));
-  EipUint16 unique_connection_id = rand();
+  EipUint16 unique_connection_id = (EipUint16)rand();
 
   /* Setup the CIP Layer. All objects are initialized with the default
    * values for the attribute contents. */

+ 1 - 1
source/src/ports/WIN32/main.c

@@ -79,7 +79,7 @@ int main(int argc, char *arg[]) {
 	*  the PRNG to ensure we don't get the same value on every startup.
 	*/
 	srand(time(NULL));
-	EipUint16 unique_connection_id = rand();
+	EipUint16 unique_connection_id = (EipUint16)rand();
 
 	/* Setup the CIP Layer. All objects are initialized with the default
 	* values for the attribute contents. */