From: Paul Eggert Date: Sun, 25 Jun 2017 19:52:37 +0000 (-0700) Subject: Omit null-pointer test in intervals.h FRAME X-Git-Tag: emacs-26.0.90~521^2~11^2~43 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b2bff45d0f27b3d8c3dfbf6df51dd7adbcb9d9fc;p=emacs.git Omit null-pointer test in intervals.h FRAME * src/intervals.h (ROOT_INTERVAL_P, ONLY_INTERVAL_P) (INTERVAL_LAST_POS): Omit unnecessary parens. (LENGTH): Omit test for null pointer. The argument is never null. The unnecessary test causes GCC 7.1.0 to assume that the argument might be null, and therefore to issue false alarms when the argument is dereferenced in other expressions. --- diff --git a/src/intervals.h b/src/intervals.h index db91b3f21a0..a0da6f37801 100644 --- a/src/intervals.h +++ b/src/intervals.h @@ -85,10 +85,10 @@ struct interval #define LEAF_INTERVAL_P(i) ((i)->left == NULL && (i)->right == NULL) /* True if this interval has no parent and is therefore the root. */ -#define ROOT_INTERVAL_P(i) (NULL_PARENT (i)) +#define ROOT_INTERVAL_P(i) NULL_PARENT (i) /* True if this interval is the only interval in the interval tree. */ -#define ONLY_INTERVAL_P(i) (ROOT_INTERVAL_P ((i)) && LEAF_INTERVAL_P ((i))) +#define ONLY_INTERVAL_P(i) (ROOT_INTERVAL_P (i) && LEAF_INTERVAL_P (i)) /* True if this interval has both left and right children. */ #define BOTH_KIDS_P(i) ((i)->left != NULL && (i)->right != NULL) @@ -98,13 +98,13 @@ struct interval #define TOTAL_LENGTH(i) ((i) == NULL ? 0 : (i)->total_length) /* The size of text represented by this interval alone. */ -#define LENGTH(i) ((i) == NULL ? 0 : (TOTAL_LENGTH ((i)) \ - - TOTAL_LENGTH ((i)->right) \ - - TOTAL_LENGTH ((i)->left))) +#define LENGTH(i) ((i)->total_length \ + - TOTAL_LENGTH ((i)->right) \ + - TOTAL_LENGTH ((i)->left)) /* The position of the character just past the end of I. Note that the position cache i->position must be valid for this to work. */ -#define INTERVAL_LAST_POS(i) ((i)->position + LENGTH ((i))) +#define INTERVAL_LAST_POS(i) ((i)->position + LENGTH (i)) /* The total size of the left subtree of this interval. */ #define LEFT_TOTAL_LENGTH(i) ((i)->left ? (i)->left->total_length : 0)