From d666191d67a2c362733955e53b282c66281b4deb Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Fri, 26 Aug 2016 22:09:34 -0700
Subject: [PATCH] Sign fixes

---
 src/ext_nvml.c | 42 +++++++++++++++++++++---------------------
 src/shared.c   |  6 +++---
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/ext_nvml.c b/src/ext_nvml.c
index 6c3b6b48c..03e378ffe 100644
--- a/src/ext_nvml.c
+++ b/src/ext_nvml.c
@@ -113,9 +113,9 @@ const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, nvmlReturn_t nvml_rc)
 
 nvmlReturn_t hm_NVML_nvmlInit (NVML_PTR *nvml)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
-  nvmlReturn_t nvml_rc = nvml->nvmlInit ();
+  nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlInit ();
 
   if (nvml_rc != NVML_SUCCESS)
   {
@@ -129,9 +129,9 @@ nvmlReturn_t hm_NVML_nvmlInit (NVML_PTR *nvml)
 
 nvmlReturn_t hm_NVML_nvmlShutdown (NVML_PTR *nvml)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
-  nvmlReturn_t nvml_rc = nvml->nvmlShutdown ();
+  nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlShutdown ();
 
   if (nvml_rc != NVML_SUCCESS)
   {
@@ -145,7 +145,7 @@ nvmlReturn_t hm_NVML_nvmlShutdown (NVML_PTR *nvml)
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetName (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, char *name, unsigned int length)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetName (device, name, length);
 
@@ -164,7 +164,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetName (NVML_PTR *nvml, int skip_warnings, nvmlD
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetHandleByIndex (NVML_PTR *nvml, int skip_warnings, unsigned int index, nvmlDevice_t *device)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (index, device);
 
@@ -183,7 +183,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetHandleByIndex (NVML_PTR *nvml, int skip_warnin
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp);
 
@@ -202,7 +202,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, int skip_warnings
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *speed)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed);
 
@@ -221,7 +221,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int skip_warnings, n
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *power)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerUsage (device, power);
 
@@ -240,7 +240,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, int skip_warnings,
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlUtilization_t *utilization)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization);
 
@@ -259,7 +259,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, int skip_war
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clock);
 
@@ -278,7 +278,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, int skip_warnings,
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp);
 
@@ -297,7 +297,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, int skip
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkGen)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkGeneration (device, currLinkGen);
 
@@ -316,7 +316,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, int sk
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkWidth)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth);
 
@@ -335,7 +335,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, int skip_wa
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *clocksThrottleReasons)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrentClocksThrottleReasons (device, clocksThrottleReasons);
 
@@ -354,7 +354,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (NVML_PTR *nvml,
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetSupportedClocksThrottleReasons (device, supportedClocksThrottleReasons);
 
@@ -373,7 +373,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (NVML_PTR *nvml
 
 nvmlReturn_t hm_NVML_nvmlDeviceSetComputeMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlComputeMode_t mode)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetComputeMode (device, mode);
 
@@ -392,7 +392,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceSetComputeMode (NVML_PTR *nvml, int skip_warnings
 
 nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlGpuOperationMode_t mode)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetGpuOperationMode (device, mode);
 
@@ -411,7 +411,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int skip_war
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimitConstraints (device, minLimit, maxLimit);
 
@@ -430,7 +430,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvm
 
 nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int limit)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetPowerManagementLimit (device, limit);
 
@@ -449,7 +449,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip
 
 nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *limit)
 {
-  if (!nvml) return -1;
+  if (!nvml) return -1u;
 
   nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimit (device, limit);
 
diff --git a/src/shared.c b/src/shared.c
index aad299f5e..b8742c527 100644
--- a/src/shared.c
+++ b/src/shared.c
@@ -106,7 +106,7 @@ int log_final (FILE *fp, const char *fmt, va_list ap)
 
   int max_len = (int) sizeof (s);
 
-  int len = vsnprintf (s, max_len, fmt, ap);
+  int len = vsnprintf (s, (size_t)max_len, fmt, ap);
 
   if (len > max_len) len = max_len;
 
@@ -3583,7 +3583,7 @@ void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, int css_cnt)
   {
     uint u = in_buf[i] & 0xff;
 
-    if (data.opts_type & OPTS_TYPE_PT_UPPER) u = toupper (u);
+    if (data.opts_type & OPTS_TYPE_PT_UPPER) u = (uint) toupper (u);
 
     if (css_uniq[u] == 1) continue;
 
@@ -5456,7 +5456,7 @@ void handle_left_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int inpu
 
   // only show the hash part which is still not cracked
 
-  uint user_len = input_len - 32u;
+  uint user_len = (uint)input_len - 32u;
 
   char *hash_output = (char *) mymalloc (33);