[patch] [gui] warning patrol in gtk-peer

Mark Wielaard mark@klomp.org
Thu Oct 21 19:58:00 GMT 2004


Hi,

On Thu, 2004-10-21 at 18:00, Andreas Tobler wrote:
> Hello all,
> 
> the following patch cleans up a few warnings from unused variables.
> 
> ok for gui?

I cannot approve it. But in general anything goes for the gui branch,
And I think this is actually obvious.

I would do one little thing different though.

>	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
> 	(Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFilenameFilter):
> 	Likewise.
> 	(filenameFilterCallback): Remove unused var.
> 	(handle_response): Initialize str_filename.

You initialize str_filename in the definition. But we can also make sure
that it is always defined in the function body. The code first checks
for responseId == GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL or 
GTK_RESPONSE_DELETE_EVENT. Then it handles GTK_RESPONSE_DELETE_EVENT and
returns. So the following if-then-else block could also be written as:

@@ -252,7 +251,7 @@
   if (responseId == GTK_RESPONSE_OK) {
     fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (GTK_WIDGET (ptr)));
     str_fileName = (*gdk_env)->NewStringUTF (gdk_env, fileName);
-  } else if (responseId == GTK_RESPONSE_CANCEL) {
+  } else /* responseId == GTK_RESPONSE_CANCEL */ {
     str_fileName = NULL;
   }

to get rid of that warning.

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20041021/df369677/attachment.sig>


More information about the Java-patches mailing list