[easytag/wip/clang-analyzer: 13/14] Refactor ET_Detect_Changes_Of_File_Name()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/clang-analyzer: 13/14] Refactor ET_Detect_Changes_Of_File_Name()
- Date: Mon, 12 Aug 2013 15:46:18 +0000 (UTC)
commit 927415f0338a6c5262973ff19497239b1749264d
Author: David King <amigadave amigadave com>
Date: Mon Aug 12 16:42:00 2013 +0100
Refactor ET_Detect_Changes_Of_File_Name()
Express the conditional checks more clearly, and avoid a potential NULL
dereference found by the Clang static analyzer.
src/et_core.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/src/et_core.c b/src/et_core.c
index 6e7cbeb..57233f5 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -4113,30 +4113,30 @@ gboolean ET_Manage_Changes_Of_File_Data (ET_File *ETFile, File_Name *FileName, F
static gboolean
ET_Detect_Changes_Of_File_Name (File_Name *FileName1, File_Name *FileName2)
{
- gchar *filename1_ck;
- gchar *filename2_ck;
+ const gchar *filename1_ck;
+ const gchar *filename2_ck;
- if ( (!FileName1 && !FileName2)
- || (!FileName1->value && !FileName2->value) )
- return FALSE;
+ if (!FileName1 && !FileName2) return FALSE;
+ if (FileName1 && !FileName2) return TRUE;
+ if (!FileName1 && FileName2) return TRUE;
- if ( ( FileName1 && !FileName2)
- || (!FileName1 && FileName2)
- || ( FileName1->value && !FileName2->value)
- || (!FileName1->value && FileName2->value) )
- return TRUE;
+ /* Both FileName1 and FileName2 are != NULL. */
+ if (!FileName1->value && !FileName2->value) return FALSE;
+ if (FileName1->value && !FileName2->value) return TRUE;
+ if (!FileName1->value && FileName2->value) return TRUE;
- // Compare collate keys (with FileName->value converted to UTF-8 as it contains raw data)
+ /* Compare collate keys (with FileName->value converted to UTF-8 as it
+ * contains raw data). */
filename1_ck = FileName1->value_ck;
filename2_ck = FileName2->value_ck;
- // Filename changed ? (we check path + file)
- if ( strcmp(filename1_ck,filename2_ck) != 0 )
+ /* Filename changed ? (we check path + file). */
+ if (strcmp (filename1_ck, filename2_ck) != 0)
{
return TRUE;
- }else
+ }
+ else
{
- // No changes
return FALSE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]