Просмотр исходного кода

Merge pull request #296 from EIPStackGroup/SonarCloudIssues

Fix regarding fscanf data types
Martin Melik-Merkumians 5 лет назад
Родитель
Сommit
8c6b87a702
1 измененных файлов с 25 добавлено и 18 удалено
  1. 25 18
      source/src/ports/nvdata/nvqos.c

+ 25 - 18
source/src/ports/nvdata/nvqos.c

@@ -18,6 +18,7 @@
 #include <string.h>
 
 #include "conffile.h"
+#include "ciptypes.h"
 
 #define QOS_CFG_NAME  "qos.cfg"
 
@@ -27,24 +28,27 @@
  *  @param  p_qos pointer to the QoS object's data structure
  *  @return       0: success; -1: failure
  */
-int NvQosLoad(CipQosObject *p_qos)
-{
+int NvQosLoad(CipQosObject *p_qos) {
   FILE  *p_file;
-  int   rd_cnt = 0;
-  int   rc;
+  int rd_cnt = 0;
+  int rc;
 
-  uint64_t dscp_urgent = 0;
-  uint64_t dscp_scheduled = 0;
-  uint64_t dscp_high = 0;
-  uint64_t dscp_low = 0;
-  uint64_t dscp_explicit = 0;
+  CipUsint dscp_urgent = 0;
+  CipUsint dscp_scheduled = 0;
+  CipUsint dscp_high = 0;
+  CipUsint dscp_low = 0;
+  CipUsint dscp_explicit = 0;
 
   rc = ConfFileOpen(false, QOS_CFG_NAME, &p_file);
   if (0 == rc) {
     /* Read input data */
-    rd_cnt = fscanf(p_file, " %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 "\n",
-                    &dscp_urgent, &dscp_scheduled, &dscp_high,
-                    &dscp_low, &dscp_explicit);
+    rd_cnt = fscanf(p_file,
+                    " %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 "\n",
+                    &dscp_urgent,
+                    &dscp_scheduled,
+                    &dscp_high,
+                    &dscp_low,
+                    &dscp_explicit);
 
     /* Need to try to close all stuff in any case. */
     rc = ConfFileClose(&p_file);
@@ -67,17 +71,20 @@ int NvQosLoad(CipQosObject *p_qos)
  *  @param  p_qos pointer to the QoS object's data structure
  *  @return       0: success; -1: failure
  */
-int NvQosStore(const CipQosObject *p_qos)
-{
+int NvQosStore(const CipQosObject *p_qos) {
   FILE  *p_file;
-  int   rc;
+  int rc;
 
   rc = ConfFileOpen(true, QOS_CFG_NAME, &p_file);
   if (rc >= 0) {
     /* Print output data */
-    rc = fprintf(p_file, " %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 "\n",
-                 p_qos->dscp.urgent, p_qos->dscp.scheduled, p_qos->dscp.high,
-                 p_qos->dscp.low, p_qos->dscp.explicit);
+    rc = fprintf(p_file,
+                 " %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 "\n",
+                 p_qos->dscp.urgent,
+                 p_qos->dscp.scheduled,
+                 p_qos->dscp.high,
+                 p_qos->dscp.low,
+                 p_qos->dscp.explicit);
     if (rc > 0) {
       rc = 0;
     }