This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Refactor observer.sh to cleanup unused vars (was: [RFC/PATCH] Clean up unused variables (and prepare for `-Wunused-variable' flag))


Hi,

As requested by Pedro, this is the change to `observer.sh' made to
cleanup the unused variable `args'.  I noticed that the variable is only
used as an argument for calling `notify', and in some cases `notify'
doesn't take arguments, thus leading to an unused `args' hanging
around.  This patch removes it by conditionally declaring the variable.

OK to apply?

-- 
Sergio

2012-04-24  Sergio Durigan Junior  <sergiodj@redhat.com>

	* observer.sh: Conditionally declare `args', thus cleaning up
	unused cases.

diff --git a/gdb/observer.sh b/gdb/observer.sh
index b5c49ac..2ff8b64 100755
--- a/gdb/observer.sh
+++ b/gdb/observer.sh
@@ -136,8 +136,17 @@ static void
 observer_${event}_notification_stub (const void *data, const void *args_data)
 {
   observer_${event}_ftype *notify = (observer_${event}_ftype *) data;
+EOF
+
+	notify_args=`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`
+
+	if test ! -z ${notify_args}; then
+	    cat<<EOF >>${otmp}
   const struct ${event}_args *args = args_data;
-  notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`);
+EOF
+	fi
+	cat <<EOF >>${otmp}
+  notify (${notify_args});
 }
 
 struct observer *


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]