diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_post.h | 7 | ||||
| -rw-r--r-- | src/editfns.c | 19 | ||||
| -rw-r--r-- | src/intervals.c | 12 | ||||
| -rw-r--r-- | src/intervals.h | 24 | ||||
| -rw-r--r-- | src/pdumper.c | 9 |
5 files changed, 42 insertions, 29 deletions
diff --git a/src/conf_post.h b/src/conf_post.h index 2f8d19fdca8..eb8fb18c00c 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -78,6 +78,7 @@ typedef bool bool_bf; | |||
| 78 | # define __has_attribute_no_address_safety_analysis false | 78 | # define __has_attribute_no_address_safety_analysis false |
| 79 | # define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0) | 79 | # define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0) |
| 80 | # define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0) | 80 | # define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0) |
| 81 | # define __has_attribute_returns_nonnull GNUC_PREREQ (4, 9, 0) | ||
| 81 | # define __has_attribute_warn_unused_result GNUC_PREREQ (3, 4, 0) | 82 | # define __has_attribute_warn_unused_result GNUC_PREREQ (3, 4, 0) |
| 82 | #endif | 83 | #endif |
| 83 | 84 | ||
| @@ -321,6 +322,12 @@ extern int emacs_setenv_TZ (char const *); | |||
| 321 | 322 | ||
| 322 | #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args) | 323 | #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args) |
| 323 | 324 | ||
| 325 | #if __has_attribute (returns_nonnull) | ||
| 326 | # define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((returns_nonnull)) | ||
| 327 | #else | ||
| 328 | # define ATTRIBUTE_RETURNS_NONNULL | ||
| 329 | #endif | ||
| 330 | |||
| 324 | /* Work around GCC bug 59600: when a function is inlined, the inlined | 331 | /* Work around GCC bug 59600: when a function is inlined, the inlined |
| 325 | code may have its addresses sanitized even if the function has the | 332 | code may have its addresses sanitized even if the function has the |
| 326 | no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and | 333 | no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and |
diff --git a/src/editfns.c b/src/editfns.c index ddf190b1752..eb15566fb48 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1262,14 +1262,17 @@ name, or nil if there is no such user. */) | |||
| 1262 | if (q) | 1262 | if (q) |
| 1263 | { | 1263 | { |
| 1264 | Lisp_Object login = Fuser_login_name (INT_TO_INTEGER (pw->pw_uid)); | 1264 | Lisp_Object login = Fuser_login_name (INT_TO_INTEGER (pw->pw_uid)); |
| 1265 | USE_SAFE_ALLOCA; | 1265 | if (!NILP (login)) |
| 1266 | char *r = SAFE_ALLOCA (strlen (p) + SBYTES (login) + 1); | 1266 | { |
| 1267 | memcpy (r, p, q - p); | 1267 | USE_SAFE_ALLOCA; |
| 1268 | char *s = lispstpcpy (&r[q - p], login); | 1268 | char *r = SAFE_ALLOCA (strlen (p) + SBYTES (login) + 1); |
| 1269 | r[q - p] = upcase ((unsigned char) r[q - p]); | 1269 | memcpy (r, p, q - p); |
| 1270 | strcpy (s, q + 1); | 1270 | char *s = lispstpcpy (&r[q - p], login); |
| 1271 | full = build_string (r); | 1271 | r[q - p] = upcase ((unsigned char) r[q - p]); |
| 1272 | SAFE_FREE (); | 1272 | strcpy (s, q + 1); |
| 1273 | full = build_string (r); | ||
| 1274 | SAFE_FREE (); | ||
| 1275 | } | ||
| 1273 | } | 1276 | } |
| 1274 | #endif /* AMPERSAND_FULL_NAME */ | 1277 | #endif /* AMPERSAND_FULL_NAME */ |
| 1275 | 1278 | ||
diff --git a/src/intervals.c b/src/intervals.c index a66594ceea2..594d8924ebc 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -298,7 +298,7 @@ rotate_right (INTERVAL A) | |||
| 298 | set_interval_parent (c, A); | 298 | set_interval_parent (c, A); |
| 299 | 299 | ||
| 300 | /* A's total length is decreased by the length of B and its left child. */ | 300 | /* A's total length is decreased by the length of B and its left child. */ |
| 301 | A->total_length -= B->total_length - TOTAL_LENGTH (c); | 301 | A->total_length -= TOTAL_LENGTH (B) - TOTAL_LENGTH0 (c); |
| 302 | eassert (TOTAL_LENGTH (A) > 0); | 302 | eassert (TOTAL_LENGTH (A) > 0); |
| 303 | eassert (LENGTH (A) > 0); | 303 | eassert (LENGTH (A) > 0); |
| 304 | 304 | ||
| @@ -349,7 +349,7 @@ rotate_left (INTERVAL A) | |||
| 349 | set_interval_parent (c, A); | 349 | set_interval_parent (c, A); |
| 350 | 350 | ||
| 351 | /* A's total length is decreased by the length of B and its right child. */ | 351 | /* A's total length is decreased by the length of B and its right child. */ |
| 352 | A->total_length -= B->total_length - TOTAL_LENGTH (c); | 352 | A->total_length -= TOTAL_LENGTH (B) - TOTAL_LENGTH0 (c); |
| 353 | eassert (TOTAL_LENGTH (A) > 0); | 353 | eassert (TOTAL_LENGTH (A) > 0); |
| 354 | eassert (LENGTH (A) > 0); | 354 | eassert (LENGTH (A) > 0); |
| 355 | 355 | ||
| @@ -723,13 +723,13 @@ previous_interval (register INTERVAL interval) | |||
| 723 | i->position - LEFT_TOTAL_LENGTH (i) \ | 723 | i->position - LEFT_TOTAL_LENGTH (i) \ |
| 724 | - LENGTH (INTERVAL_PARENT (i)) | 724 | - LENGTH (INTERVAL_PARENT (i)) |
| 725 | 725 | ||
| 726 | /* Find the interval containing POS, given some non-NULL INTERVAL in | 726 | /* Find the interval containing POS, given some interval I in |
| 727 | the same tree. Note that we update interval->position in each | 727 | the same tree. Note that we update interval->position in each |
| 728 | interval we traverse, assuming it is already correctly set for the | 728 | interval we traverse, assuming it is already correctly set for the |
| 729 | argument I. We don't assume that any other interval already has a | 729 | argument I. We don't assume that any other interval already has a |
| 730 | correctly set ->position. */ | 730 | correctly set ->position. */ |
| 731 | INTERVAL | 731 | INTERVAL |
| 732 | update_interval (register INTERVAL i, ptrdiff_t pos) | 732 | update_interval (INTERVAL i, ptrdiff_t pos) |
| 733 | { | 733 | { |
| 734 | if (!i) | 734 | if (!i) |
| 735 | return NULL; | 735 | return NULL; |
| @@ -739,7 +739,7 @@ update_interval (register INTERVAL i, ptrdiff_t pos) | |||
| 739 | if (pos < i->position) | 739 | if (pos < i->position) |
| 740 | { | 740 | { |
| 741 | /* Move left. */ | 741 | /* Move left. */ |
| 742 | if (pos >= i->position - TOTAL_LENGTH (i->left)) | 742 | if (pos >= i->position - LEFT_TOTAL_LENGTH (i)) |
| 743 | { | 743 | { |
| 744 | i->left->position = i->position - TOTAL_LENGTH (i->left) | 744 | i->left->position = i->position - TOTAL_LENGTH (i->left) |
| 745 | + LEFT_TOTAL_LENGTH (i->left); | 745 | + LEFT_TOTAL_LENGTH (i->left); |
| @@ -757,7 +757,7 @@ update_interval (register INTERVAL i, ptrdiff_t pos) | |||
| 757 | else if (pos >= INTERVAL_LAST_POS (i)) | 757 | else if (pos >= INTERVAL_LAST_POS (i)) |
| 758 | { | 758 | { |
| 759 | /* Move right. */ | 759 | /* Move right. */ |
| 760 | if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right)) | 760 | if (pos < INTERVAL_LAST_POS (i) + RIGHT_TOTAL_LENGTH (i)) |
| 761 | { | 761 | { |
| 762 | i->right->position = INTERVAL_LAST_POS (i) | 762 | i->right->position = INTERVAL_LAST_POS (i) |
| 763 | + LEFT_TOTAL_LENGTH (i->right); | 763 | + LEFT_TOTAL_LENGTH (i->right); |
diff --git a/src/intervals.h b/src/intervals.h index a93b10e9fff..9a7ba910a10 100644 --- a/src/intervals.h +++ b/src/intervals.h | |||
| @@ -96,24 +96,27 @@ struct interval | |||
| 96 | /* True if this interval has both left and right children. */ | 96 | /* True if this interval has both left and right children. */ |
| 97 | #define BOTH_KIDS_P(i) ((i)->left != NULL && (i)->right != NULL) | 97 | #define BOTH_KIDS_P(i) ((i)->left != NULL && (i)->right != NULL) |
| 98 | 98 | ||
| 99 | /* The total size of all text represented by this interval and all its | 99 | /* The total size of all text represented by the nonnull interval I |
| 100 | children in the tree. This is zero if the interval is null. */ | 100 | and all its children in the tree. */ |
| 101 | #define TOTAL_LENGTH(i) ((i) == NULL ? 0 : (i)->total_length) | 101 | #define TOTAL_LENGTH(i) ((i)->total_length) |
| 102 | |||
| 103 | /* Likewise, but also defined to be zero if I is null. */ | ||
| 104 | #define TOTAL_LENGTH0(i) ((i) ? TOTAL_LENGTH (i) : 0) | ||
| 102 | 105 | ||
| 103 | /* The size of text represented by this interval alone. */ | 106 | /* The size of text represented by this interval alone. */ |
| 104 | #define LENGTH(i) ((i)->total_length \ | 107 | #define LENGTH(i) (TOTAL_LENGTH (i) \ |
| 105 | - TOTAL_LENGTH ((i)->right) \ | 108 | - RIGHT_TOTAL_LENGTH (i) \ |
| 106 | - TOTAL_LENGTH ((i)->left)) | 109 | - LEFT_TOTAL_LENGTH (i)) |
| 107 | 110 | ||
| 108 | /* The position of the character just past the end of I. Note that | 111 | /* The position of the character just past the end of I. Note that |
| 109 | the position cache i->position must be valid for this to work. */ | 112 | the position cache i->position must be valid for this to work. */ |
| 110 | #define INTERVAL_LAST_POS(i) ((i)->position + LENGTH (i)) | 113 | #define INTERVAL_LAST_POS(i) ((i)->position + LENGTH (i)) |
| 111 | 114 | ||
| 112 | /* The total size of the left subtree of this interval. */ | 115 | /* The total size of the left subtree of this interval. */ |
| 113 | #define LEFT_TOTAL_LENGTH(i) ((i)->left ? (i)->left->total_length : 0) | 116 | #define LEFT_TOTAL_LENGTH(i) TOTAL_LENGTH0 ((i)->left) |
| 114 | 117 | ||
| 115 | /* The total size of the right subtree of this interval. */ | 118 | /* The total size of the right subtree of this interval. */ |
| 116 | #define RIGHT_TOTAL_LENGTH(i) ((i)->right ? (i)->right->total_length : 0) | 119 | #define RIGHT_TOTAL_LENGTH(i) TOTAL_LENGTH0 ((i)->right) |
| 117 | 120 | ||
| 118 | /* These macros are for dealing with the interval properties. */ | 121 | /* These macros are for dealing with the interval properties. */ |
| 119 | 122 | ||
| @@ -234,7 +237,7 @@ set_interval_plist (INTERVAL i, Lisp_Object plist) | |||
| 234 | 237 | ||
| 235 | /* Declared in alloc.c. */ | 238 | /* Declared in alloc.c. */ |
| 236 | 239 | ||
| 237 | extern INTERVAL make_interval (void); | 240 | extern INTERVAL make_interval (void) ATTRIBUTE_RETURNS_NONNULL; |
| 238 | 241 | ||
| 239 | /* Declared in intervals.c. */ | 242 | /* Declared in intervals.c. */ |
| 240 | 243 | ||
| @@ -246,7 +249,8 @@ extern void traverse_intervals (INTERVAL, ptrdiff_t, | |||
| 246 | Lisp_Object); | 249 | Lisp_Object); |
| 247 | extern void traverse_intervals_noorder (INTERVAL, | 250 | extern void traverse_intervals_noorder (INTERVAL, |
| 248 | void (*) (INTERVAL, void *), void *); | 251 | void (*) (INTERVAL, void *), void *); |
| 249 | extern INTERVAL split_interval_right (INTERVAL, ptrdiff_t); | 252 | extern INTERVAL split_interval_right (INTERVAL, ptrdiff_t) |
| 253 | ATTRIBUTE_RETURNS_NONNULL; | ||
| 250 | extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t); | 254 | extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t); |
| 251 | extern INTERVAL find_interval (INTERVAL, ptrdiff_t); | 255 | extern INTERVAL find_interval (INTERVAL, ptrdiff_t); |
| 252 | extern INTERVAL next_interval (INTERVAL); | 256 | extern INTERVAL next_interval (INTERVAL); |
diff --git a/src/pdumper.c b/src/pdumper.c index 4d81203f46f..e52163cdae2 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -3604,14 +3604,12 @@ dump_unwind_cleanup (void *data) | |||
| 3604 | Vprocess_environment = ctx->old_process_environment; | 3604 | Vprocess_environment = ctx->old_process_environment; |
| 3605 | } | 3605 | } |
| 3606 | 3606 | ||
| 3607 | /* Return DUMP_OFFSET, making sure it is within the heap. */ | 3607 | /* Check that DUMP_OFFSET is within the heap. */ |
| 3608 | static dump_off | 3608 | static void |
| 3609 | dump_check_dump_off (struct dump_context *ctx, dump_off dump_offset) | 3609 | dump_check_dump_off (struct dump_context *ctx, dump_off dump_offset) |
| 3610 | { | 3610 | { |
| 3611 | eassert (dump_offset > 0); | 3611 | eassert (dump_offset > 0); |
| 3612 | if (ctx) | 3612 | eassert (!ctx || dump_offset < ctx->end_heap); |
| 3613 | eassert (dump_offset < ctx->end_heap); | ||
| 3614 | return dump_offset; | ||
| 3615 | } | 3613 | } |
| 3616 | 3614 | ||
| 3617 | static void | 3615 | static void |
| @@ -3734,6 +3732,7 @@ decode_emacs_reloc (struct dump_context *ctx, Lisp_Object lreloc) | |||
| 3734 | } | 3732 | } |
| 3735 | else | 3733 | else |
| 3736 | { | 3734 | { |
| 3735 | eassume (ctx); /* Pacify GCC 9.2.1 -O3 -Wnull-dereference. */ | ||
| 3737 | eassert (!dump_object_emacs_ptr (target_value)); | 3736 | eassert (!dump_object_emacs_ptr (target_value)); |
| 3738 | reloc.u.dump_offset = dump_recall_object (ctx, target_value); | 3737 | reloc.u.dump_offset = dump_recall_object (ctx, target_value); |
| 3739 | if (reloc.u.dump_offset <= 0) | 3738 | if (reloc.u.dump_offset <= 0) |