فهرست منبع

Add pragma statements to suppress fopen/fscanf depreciation warnings.

Resolves Visual Studio depreciation warning C4996 regarding these
functions. The reason they were not replaced with the secure _s variants
is those functions are optional extensions, and therefore not
particularly portable.
Jason Valenzuela 4 سال پیش
والد
کامیت
84decb4732
2فایلهای تغییر یافته به همراه22 افزوده شده و 0 حذف شده
  1. 11 0
      source/src/ports/nvdata/conffile.c
  2. 11 0
      source/src/ports/nvdata/nvqos.c

+ 11 - 0
source/src/ports/nvdata/conffile.c

@@ -83,7 +83,18 @@ static FILE *FopenMkdir(char *p_path,
     *sep = '/';
     VERBOSE(stdout, "%s", "\n");
   }
+
+/* Disable VS fopen depreciation warning. */
+#ifdef _MSC_VER
+#pragma warning(disable : 4996)
+#endif /* _MSC_VER */
+
   return fopen(p_path, mode);
+
+/* Restore default depreciation warning behavior. */
+#ifdef _MSC_VER
+#pragma warning(default : 4996)
+#endif /* _MSC_VER */
 }
 
 

+ 11 - 0
source/src/ports/nvdata/nvqos.c

@@ -40,6 +40,12 @@ int NvQosLoad(CipQosObject *p_qos) {
 
   FILE  *p_file = ConfFileOpen(false, QOS_CFG_NAME);
   if (NULL != p_file) {
+
+/* Disable VS fscanf depreciation warning. */
+#ifdef _MSC_VER
+#pragma warning(disable : 4996)
+#endif /* _MSC_VER */
+
     /* Read input data */
     rd_cnt = fscanf(p_file,
                     " %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 "\n",
@@ -49,6 +55,11 @@ int NvQosLoad(CipQosObject *p_qos) {
                     &dscp_low,
                     &dscp_explicit);
 
+/* Restore default depreciation warning behavior. */
+#ifdef _MSC_VER
+#pragma warning(default : 4996)
+#endif /* _MSC_VER */
+
     /* Need to try to close all stuff in any case. */
     eip_status = ConfFileClose(&p_file);
   }