about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-11-01 23:46:39 -0400
committerRich Felker <dalias@aerifal.cx>2012-11-01 23:46:39 -0400
commita617a8e2adaaac41dd1b662b6646e8392465801c (patch)
treef5adaf552d944be658e4f967c3f55cc2987fe12f
parent3a5aa8e49ce9a98725ceb311bb64f6168fc72d3e (diff)
downloadmusl-a617a8e2adaaac41dd1b662b6646e8392465801c.tar.gz
musl-a617a8e2adaaac41dd1b662b6646e8392465801c.tar.xz
musl-a617a8e2adaaac41dd1b662b6646e8392465801c.zip
fix more unused variable warnings
some of these were coming from stdio functions locking files without
unlocking them. I believe it's useful for this to throw a warning, so
I added a new macro that's self-documenting that the file will never
be unlocked to avoid the warning in the few places where it's wrong.
-rw-r--r--src/internal/stdio_impl.h1
-rw-r--r--src/ldso/dynlink.c5
-rw-r--r--src/stdio/__stdio_exit.c2
-rw-r--r--src/stdio/fclose.c3
4 files changed, 5 insertions, 6 deletions
diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h
index 80646f8c..e9045f27 100644
--- a/src/internal/stdio_impl.h
+++ b/src/internal/stdio_impl.h
@@ -24,6 +24,7 @@
 
 #define UNGET 8
 
+#define FFINALLOCK(f) ((f)->lock>=0 ? __lockfile((f)) : 0)
 #define FLOCK(f) int __need_unlock = ((f)->lock>=0 ? __lockfile((f)) : 0)
 #define FUNLOCK(f) if (__need_unlock) __unlockfile((f)); else
 
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 13bf16a5..25242051 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -435,7 +435,7 @@ static struct dso *load_library(const char *name)
 	char buf[2*NAME_MAX+2];
 	const char *pathname;
 	unsigned char *base, *map;
-	size_t dyno, map_len;
+	size_t map_len;
 	struct dso *p, temp_dso = {0};
 	int fd;
 	struct stat st;
@@ -866,7 +866,7 @@ void *__dynlink(int argc, char **argv)
 	} else {
 		int fd;
 		char *ldname = argv[0];
-		size_t dyno, l = strlen(ldname);
+		size_t l = strlen(ldname);
 		if (l >= 3 && !strcmp(ldname+l-3, "ldd")) ldd_mode = 1;
 		*argv++ = (void *)-1;
 		if (argv[0] && !strcmp(argv[0], "--")) *argv++ = (void *)-1;
@@ -962,7 +962,6 @@ void *__dynlink(int argc, char **argv)
 
 	update_tls_size();
 	if (tls_cnt) {
-		struct dso *p;
 		void *mem = mmap(0, libc.tls_size, PROT_READ|PROT_WRITE,
 			MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
 		if (mem==MAP_FAILED ||
diff --git a/src/stdio/__stdio_exit.c b/src/stdio/__stdio_exit.c
index 3f87e7ed..0fb33234 100644
--- a/src/stdio/__stdio_exit.c
+++ b/src/stdio/__stdio_exit.c
@@ -8,7 +8,7 @@ weak_alias(dummy_file, __stderr_used);
 static void close_file(FILE *f)
 {
 	if (!f) return;
-	FLOCK(f);
+	FFINALLOCK(f);
 	if (f->wpos > f->wbase) f->write(f, 0, 0);
 	if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
 }
diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c
index 92bf7ff8..38e8a1e3 100644
--- a/src/stdio/fclose.c
+++ b/src/stdio/fclose.c
@@ -5,8 +5,7 @@ int fclose(FILE *f)
 	int r;
 	int perm;
 	
-	/* This lock is not paired with any unlock. */
-	FLOCK(f);
+	FFINALLOCK(f);
 
 	if (!(perm = f->flags & F_PERM)) {
 		OFLLOCK();