Re: Probable boolean logic bug



Carlos Soriano Sanchez wrote:
I believe the code is correct. It checks whether the response is not
neither cancel or none, and then it can apply the "Apply this to all
files" check. It is wrong to set this value if the response was either
cancel or none.

Maybe I misunderstood something?

I think the logic you describe is the logic I introduce. The code
currently uses this:

if (response != GTK_RESPONSE_CANCEL || response != GTK_RESPONSE_NONE)

Which you can see as something like this:

if (x != 5 || x != 6)

Clearly, that's always true. In these cases, && is intended.

Does that make sense?

----- Original Message -----
| The below condition always evaluates to true. It seems likely that &&
| was intended rather than ||.
| 
| Thanks for your time,
| Michael
| 
| 
| --- libnautilus-private/nautilus-file-operations.c
| +++ /tmp/cocci-output-20444-aed54f-nautilus-file-operations.c
| @@ -4420,8 +4420,7 @@ do_run_conflict_dialog (gpointer _data)
|     if (response == CONFLICT_RESPONSE_RENAME) {
|             data->resp_data->new_name =
|                     nautilus_file_conflict_dialog_get_new_name (NAUTILUS_FILE_CONFLICT_DIALOG
|                     (dialog));
| -   } else if (response != GTK_RESPONSE_CANCEL ||
| -              response != GTK_RESPONSE_NONE) {
| +   } else if (response != GTK_RESPONSE_CANCEL && response !=
| GTK_RESPONSE_NONE) {
|                data->resp_data->apply_to_all =
|                        nautilus_file_conflict_dialog_get_apply_to_all
|                             (NAUTILUS_FILE_CONFLICT_DIALOG (dialog));
| --
| nautilus-list mailing list
| nautilus-list gnome org
| https://mail.gnome.org/mailman/listinfo/nautilus-list
| 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]