Fix for CI error in test code on epel6 platform.
authorWojciech Andralojc <wojciechx.andralojc@intel.com>
Mon, 6 Aug 2018 12:43:02 +0000 (13:43 +0100)
committerAleksinski, MichalX <michalx.aleksinski@intel.com>
Wed, 6 Mar 2019 07:04:16 +0000 (07:04 +0000)
Signed-off-by: Wojciech Andralojc <wojciechx.andralojc@intel.com>
Change-Id: I325ea0728dd1eb65776f239b0d7977cc02f9c8db

src/utils_proc_pids_test.c

index b7e6c3b..e9571f2 100644 (file)
@@ -56,6 +56,7 @@ static const char *proc_fs = "/tmp/procfs_stub";
  *   0 on success.
  *   -1 on base dir creation error.
  *   -2 on comm file creation error.
  *   0 on success.
  *   -1 on base dir creation error.
  *   -2 on comm file creation error.
+ *   -3 on comm file write error.
  */
 int stub_procfs_setup(const stub_proc_pid_t *proc_pids_array,
                       const size_t proc_pids_array_length) {
  */
 int stub_procfs_setup(const stub_proc_pid_t *proc_pids_array,
                       const size_t proc_pids_array_length) {
@@ -73,9 +74,13 @@ int stub_procfs_setup(const stub_proc_pid_t *proc_pids_array,
     FILE *fp = fopen(path, "w");
     if (!fp)
       return -2;
     FILE *fp = fopen(path, "w");
     if (!fp)
       return -2;
-    fwrite(proc_pids_array[i].comm, sizeof(char),
-           strlen(proc_pids_array[i].comm), fp);
+
+    size_t slen = strlen(proc_pids_array[i].comm);
+    size_t wlen = fwrite(proc_pids_array[i].comm, sizeof(char), slen, fp);
     fclose(fp);
     fclose(fp);
+
+    if (slen != wlen)
+      return -3;
   }
   return 0;
 }
   }
   return 0;
 }