File 0684-erts-Fix-clang-warnings.patch of Package erlang

From e7e44fdaefa1ba1aa00419aa6b1185d0b6439d78 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Fri, 10 Jan 2020 16:07:34 +0100
Subject: [PATCH] erts: Fix clang warnings

beam_bif_load.c: warning: unused function 'rla_bc_read'

erl_nif.c: warning: variable 'ci_pp' is used uninitialized
                    whenever '||' condition is true

erl_poll.c: warning: if statement has empty body
---
 erts/emulator/beam/beam_bif_load.c  |  2 ++
 erts/emulator/beam/erl_nif.c        | 17 ++++++-----------
 erts/emulator/sys/common/erl_poll.c | 18 ++++++++++--------
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c
index 857c929880..2a11c86730 100644
--- a/erts/emulator/beam/beam_bif_load.c
+++ b/erts/emulator/beam/beam_bif_load.c
@@ -1457,12 +1457,14 @@ rla_resume(void *literal_area)
 }
 
 
+#ifdef DEBUG
 static ERTS_INLINE Sint
 rla_bc_read(int sched_ix, int block_ix)
 {
     return (Sint) erts_atomic_read_nob(
         &release_literal_areas.bc[sched_ix].u.block.counter[block_ix]);
 }
+#endif
 
 static ERTS_INLINE Sint
 rla_bc_read_acqb(int sched_ix, int block_ix)
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 1fbe362330..e9ce0f212c 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -4276,17 +4276,12 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
 		ret = load_nif_error(BIF_P,bad_lib,"Function not found %T:%s/%u",
 				     mod_atom, f->name, f->arity);
 	    }
-	    else if (f->flags) {
-		/*
-		 * If the flags field is non-zero and this emulator was
-		 * built with dirty scheduler support, check that the flags
-		 * value is legal. But if this emulator was built without
-		 * dirty scheduler support, treat a non-zero flags field as
-		 * a load error.
-		 */
-		if (f->flags != ERL_NIF_DIRTY_JOB_IO_BOUND && f->flags != ERL_NIF_DIRTY_JOB_CPU_BOUND)
-		    ret = load_nif_error(BIF_P, bad_lib, "Illegal flags field value %d for NIF %T:%s/%u",
-					 f->flags, mod_atom, f->name, f->arity);
+	    else if (f->flags != 0 &&
+                     f->flags != ERL_NIF_DIRTY_JOB_IO_BOUND &&
+                     f->flags != ERL_NIF_DIRTY_JOB_CPU_BOUND) {
+                ret = load_nif_error(BIF_P, bad_lib,
+                                     "Illegal flags field value %d for NIF %T:%s/%u",
+                                     f->flags, mod_atom, f->name, f->arity);
 	    }
 	    else if (erts_codeinfo_to_code(ci_pp[1]) - erts_codeinfo_to_code(ci_pp[0])
                      < BEAM_NIF_MIN_FUNC_SZ)
diff --git a/erts/emulator/sys/common/erl_poll.c b/erts/emulator/sys/common/erl_poll.c
index 1b125056f5..941d64f5cd 100644
--- a/erts/emulator/sys/common/erl_poll.c
+++ b/erts/emulator/sys/common/erl_poll.c
@@ -2346,7 +2346,7 @@ uint32_t epoll_events(int kp_fd, int fd)
     char s[256];
     FILE *f;
     unsigned int pos, flags, mnt_id;
-    int line = 0;
+    int hdr_lines, line = 1;
     sprintf(fname,"/proc/%d/fdinfo/%d",getpid(), kp_fd);
     f = fopen(fname,"r");
     if (!f) {
@@ -2354,13 +2354,14 @@ uint32_t epoll_events(int kp_fd, int fd)
         ASSERT(0);
         return 0;
     }
-    if (fscanf(f,"pos:\t%x\nflags:\t%x", &pos, &flags) != 2) {
+    hdr_lines = fscanf(f,"pos:\t%x\nflags:\t%x\nmnt_id:\t%x\n",
+                       &pos, &flags, &mnt_id);
+    if (hdr_lines < 2) {
         fprintf(stderr,"failed to parse file %s, errno = %d\n", fname, errno);
         ASSERT(0);
         return 0;
     }
-    if (fscanf(f,"\nmnt_id:\t%x\n", &mnt_id));
-    line += 3;
+    line += hdr_lines;
     while (fgets(s, sizeof(s) / sizeof(*s), f)) {
         /* tfd:       10 events: 40000019 data:       180000000a */
         int ev_fd;
@@ -2414,7 +2415,7 @@ ERTS_POLL_EXPORT(erts_poll_get_selected_events)(ErtsPollSet *ps,
     char s[256];
     FILE *f;
     unsigned int pos, flags, mnt_id;
-    int line = 0;
+    int hdr_lines, line = 1;
     sprintf(fname,"/proc/%d/fdinfo/%d",getpid(), ps->kp_fd);
     for (fd = 0; fd < len; fd++)
         ev[fd] = ERTS_POLL_EV_NONE;
@@ -2423,14 +2424,15 @@ ERTS_POLL_EXPORT(erts_poll_get_selected_events)(ErtsPollSet *ps,
         fprintf(stderr,"failed to open file %s, errno = %d\n", fname, errno);
         return;
     }
-    if (fscanf(f,"pos:\t%x\nflags:\t%x", &pos, &flags) != 2) {
+    hdr_lines = fscanf(f,"pos:\t%x\nflags:\t%x\nmnt_id:\t%x\n",
+                       &pos, &flags, &mnt_id);
+    if (hdr_lines < 2) {
         fprintf(stderr,"failed to parse file %s, errno = %d\n", fname, errno);
         ASSERT(0);
         fclose(f);
         return;
     }
-    if (fscanf(f,"\nmnt_id:\t%x\n", &mnt_id));
-    line += 3;
+    line += hdr_lines;
     while (fgets(s, sizeof(s) / sizeof(*s), f)) {
         /* tfd:       10 events: 40000019 data:       180000000a */
         int fd;
-- 
2.16.4

openSUSE Build Service is sponsored by