diff options
| author | Paul Eggert | 2014-04-05 12:30:36 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-04-05 12:30:36 -0700 |
| commit | faa521749378dbfd97f49a0e5c48f6da2ce1ddba (patch) | |
| tree | d470dbfa3328aaeffe5cba065103e237238a13be /src | |
| parent | 1b058e42524353c9ff133ea330876ed2d39b6515 (diff) | |
| download | emacs-faa521749378dbfd97f49a0e5c48f6da2ce1ddba.tar.gz emacs-faa521749378dbfd97f49a0e5c48f6da2ce1ddba.zip | |
Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'.
* alloc.c (memory_full):
* charset.c (syms_of_charset):
* doc.c (Fsnarf_documentation):
* emacs.c (main):
* font.c (BUILD_STYLE_TABLE):
* keyboard.c (make_lispy_event):
* profiler.c (setup_cpu_timer):
* xgselect.c (xg_select):
* xterm.c (record_event, STORE_KEYSYM_FOR_DEBUG):
Use ARRAYELTS.
* font.c (FONT_PROPERTY_TABLE_SIZE): Remove.
Replace the only use with ARRAYELTS (font_property_table).
* xfaces.c (DIM): Remove. All uses replaced by ARRAYELTS.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 17 | ||||
| -rw-r--r-- | src/alloc.c | 45 | ||||
| -rw-r--r-- | src/charset.c | 2 | ||||
| -rw-r--r-- | src/coding.c | 4 | ||||
| -rw-r--r-- | src/coding.h | 2 | ||||
| -rw-r--r-- | src/doc.c | 2 | ||||
| -rw-r--r-- | src/emacs.c | 4 | ||||
| -rw-r--r-- | src/font.c | 9 | ||||
| -rw-r--r-- | src/gnutls.c | 12 | ||||
| -rw-r--r-- | src/keyboard.c | 11 | ||||
| -rw-r--r-- | src/keymap.c | 2 | ||||
| -rw-r--r-- | src/keymap.h | 2 | ||||
| -rw-r--r-- | src/lisp.h | 4 | ||||
| -rw-r--r-- | src/process.c | 6 | ||||
| -rw-r--r-- | src/profiler.c | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 2 | ||||
| -rw-r--r-- | src/unexcoff.c | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 2 | ||||
| -rw-r--r-- | src/xfaces.c | 14 | ||||
| -rw-r--r-- | src/xgselect.c | 2 | ||||
| -rw-r--r-- | src/xsmfns.c | 2 | ||||
| -rw-r--r-- | src/xterm.c | 4 | ||||
| -rw-r--r-- | src/xterm.h | 2 |
23 files changed, 82 insertions, 72 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7152890f45d..a474c261187 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2014-04-05 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'. | ||
| 4 | * alloc.c (memory_full): | ||
| 5 | * charset.c (syms_of_charset): | ||
| 6 | * doc.c (Fsnarf_documentation): | ||
| 7 | * emacs.c (main): | ||
| 8 | * font.c (BUILD_STYLE_TABLE): | ||
| 9 | * keyboard.c (make_lispy_event): | ||
| 10 | * profiler.c (setup_cpu_timer): | ||
| 11 | * xgselect.c (xg_select): | ||
| 12 | * xterm.c (record_event, STORE_KEYSYM_FOR_DEBUG): | ||
| 13 | Use ARRAYELTS. | ||
| 14 | * font.c (FONT_PROPERTY_TABLE_SIZE): Remove. | ||
| 15 | Replace the only use with ARRAYELTS (font_property_table). | ||
| 16 | * xfaces.c (DIM): Remove. All uses replaced by ARRAYELTS. | ||
| 17 | |||
| 1 | 2014-04-03 Daniel Colascione <dancol@dancol.org> | 18 | 2014-04-03 Daniel Colascione <dancol@dancol.org> |
| 2 | 19 | ||
| 3 | * xterm.c (x_term_init): | 20 | * xterm.c (x_term_init): |
diff --git a/src/alloc.c b/src/alloc.c index 9740afe2ab8..2919c21dfe5 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -208,19 +208,19 @@ const char *pending_malloc_warning; | |||
| 208 | 208 | ||
| 209 | #ifdef SUSPICIOUS_OBJECT_CHECKING | 209 | #ifdef SUSPICIOUS_OBJECT_CHECKING |
| 210 | struct suspicious_free_record { | 210 | struct suspicious_free_record { |
| 211 | void* suspicious_object; | 211 | void *suspicious_object; |
| 212 | #ifdef HAVE_EXECINFO_H | 212 | #ifdef HAVE_EXECINFO_H |
| 213 | void* backtrace[128]; | 213 | void *backtrace[128]; |
| 214 | #endif | 214 | #endif |
| 215 | }; | 215 | }; |
| 216 | static void* suspicious_objects[32]; | 216 | static void *suspicious_objects[32]; |
| 217 | static int suspicious_object_index; | 217 | static int suspicious_object_index; |
| 218 | struct suspicious_free_record suspicious_free_history[64]; | 218 | struct suspicious_free_record suspicious_free_history[64]; |
| 219 | static int suspicious_free_history_index; | 219 | static int suspicious_free_history_index; |
| 220 | /* Find the first currently-monitored suspicious pointer in range | 220 | /* Find the first currently-monitored suspicious pointer in range |
| 221 | [begin,end) or NULL if no such pointer exists. */ | 221 | [begin,end) or NULL if no such pointer exists. */ |
| 222 | static void* find_suspicious_object_in_range (void* begin, void* end); | 222 | static void *find_suspicious_object_in_range (void *begin, void *end); |
| 223 | static void detect_suspicious_free (void* ptr); | 223 | static void detect_suspicious_free (void *ptr); |
| 224 | #else | 224 | #else |
| 225 | #define find_suspicious_object_in_range(begin, end) NULL | 225 | #define find_suspicious_object_in_range(begin, end) NULL |
| 226 | #define detect_suspicious_free(ptr) (void) | 226 | #define detect_suspicious_free(ptr) (void) |
| @@ -3116,7 +3116,7 @@ allocate_vectorlike (ptrdiff_t len) | |||
| 3116 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); | 3116 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
| 3117 | #endif | 3117 | #endif |
| 3118 | 3118 | ||
| 3119 | if (find_suspicious_object_in_range (p, (char*)p + nbytes)) | 3119 | if (find_suspicious_object_in_range (p, (char *) p + nbytes)) |
| 3120 | emacs_abort (); | 3120 | emacs_abort (); |
| 3121 | 3121 | ||
| 3122 | consing_since_gc += nbytes; | 3122 | consing_since_gc += nbytes; |
| @@ -3765,7 +3765,7 @@ memory_full (size_t nbytes) | |||
| 3765 | memory_full_cons_threshold = sizeof (struct cons_block); | 3765 | memory_full_cons_threshold = sizeof (struct cons_block); |
| 3766 | 3766 | ||
| 3767 | /* The first time we get here, free the spare memory. */ | 3767 | /* The first time we get here, free the spare memory. */ |
| 3768 | for (i = 0; i < sizeof (spare_memory) / sizeof (char *); i++) | 3768 | for (i = 0; i < ARRAYELTS (spare_memory); i++) |
| 3769 | if (spare_memory[i]) | 3769 | if (spare_memory[i]) |
| 3770 | { | 3770 | { |
| 3771 | if (i == 0) | 3771 | if (i == 0) |
| @@ -3818,7 +3818,6 @@ refill_memory_reserve (void) | |||
| 3818 | Vmemory_full = Qnil; | 3818 | Vmemory_full = Qnil; |
| 3819 | #endif | 3819 | #endif |
| 3820 | } | 3820 | } |
| 3821 | |||
| 3822 | 3821 | ||
| 3823 | /************************************************************************ | 3822 | /************************************************************************ |
| 3824 | C Stack Marking | 3823 | C Stack Marking |
| @@ -6829,23 +6828,24 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) | |||
| 6829 | #ifdef SUSPICIOUS_OBJECT_CHECKING | 6828 | #ifdef SUSPICIOUS_OBJECT_CHECKING |
| 6830 | 6829 | ||
| 6831 | static void* | 6830 | static void* |
| 6832 | find_suspicious_object_in_range (void* begin, void* end) | 6831 | find_suspicious_object_in_range (void *begin, void *end) |
| 6833 | { | 6832 | { |
| 6834 | char* begin_a = begin; | 6833 | char *begin_a = begin; |
| 6835 | char* end_a = end; | 6834 | char *end_a = end; |
| 6836 | int i; | 6835 | int i; |
| 6837 | 6836 | ||
| 6838 | for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) { | 6837 | for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) |
| 6839 | char* suspicious_object = suspicious_objects[i]; | 6838 | { |
| 6840 | if (begin_a <= suspicious_object && suspicious_object < end_a) | 6839 | char *suspicious_object = suspicious_objects[i]; |
| 6841 | return suspicious_object; | 6840 | if (begin_a <= suspicious_object && suspicious_object < end_a) |
| 6842 | } | 6841 | return suspicious_object; |
| 6842 | } | ||
| 6843 | 6843 | ||
| 6844 | return NULL; | 6844 | return NULL; |
| 6845 | } | 6845 | } |
| 6846 | 6846 | ||
| 6847 | static void | 6847 | static void |
| 6848 | detect_suspicious_free (void* ptr) | 6848 | detect_suspicious_free (void *ptr) |
| 6849 | { | 6849 | { |
| 6850 | int i; | 6850 | int i; |
| 6851 | struct suspicious_free_record* rec; | 6851 | struct suspicious_free_record* rec; |
| @@ -6882,11 +6882,12 @@ garbage collection bugs. Otherwise, do nothing and return OBJ. */) | |||
| 6882 | { | 6882 | { |
| 6883 | #ifdef SUSPICIOUS_OBJECT_CHECKING | 6883 | #ifdef SUSPICIOUS_OBJECT_CHECKING |
| 6884 | /* Right now, we care only about vectors. */ | 6884 | /* Right now, we care only about vectors. */ |
| 6885 | if (VECTORLIKEP (obj)) { | 6885 | if (VECTORLIKEP (obj)) |
| 6886 | suspicious_objects[suspicious_object_index++] = XVECTOR (obj); | 6886 | { |
| 6887 | if (suspicious_object_index == ARRAYELTS (suspicious_objects)) | 6887 | suspicious_objects[suspicious_object_index++] = XVECTOR (obj); |
| 6888 | suspicious_object_index = 0; | 6888 | if (suspicious_object_index == ARRAYELTS (suspicious_objects)) |
| 6889 | } | 6889 | suspicious_object_index = 0; |
| 6890 | } | ||
| 6890 | #endif | 6891 | #endif |
| 6891 | return obj; | 6892 | return obj; |
| 6892 | } | 6893 | } |
diff --git a/src/charset.c b/src/charset.c index 3566b156736..baa692232c7 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -2386,7 +2386,7 @@ syms_of_charset (void) | |||
| 2386 | } | 2386 | } |
| 2387 | 2387 | ||
| 2388 | charset_table = charset_table_init; | 2388 | charset_table = charset_table_init; |
| 2389 | charset_table_size = sizeof charset_table_init / sizeof *charset_table_init; | 2389 | charset_table_size = ARRAYELTS (charset_table_init); |
| 2390 | charset_table_used = 0; | 2390 | charset_table_used = 0; |
| 2391 | 2391 | ||
| 2392 | defsubr (&Scharsetp); | 2392 | defsubr (&Scharsetp); |
diff --git a/src/coding.c b/src/coding.c index 654e39c0e3d..fbe14f1695f 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -8443,11 +8443,11 @@ from_unicode (Lisp_Object str) | |||
| 8443 | } | 8443 | } |
| 8444 | 8444 | ||
| 8445 | Lisp_Object | 8445 | Lisp_Object |
| 8446 | from_unicode_buffer (const wchar_t* wstr) | 8446 | from_unicode_buffer (const wchar_t *wstr) |
| 8447 | { | 8447 | { |
| 8448 | return from_unicode ( | 8448 | return from_unicode ( |
| 8449 | make_unibyte_string ( | 8449 | make_unibyte_string ( |
| 8450 | (char*) wstr, | 8450 | (char *) wstr, |
| 8451 | /* we get one of the two final 0 bytes for free. */ | 8451 | /* we get one of the two final 0 bytes for free. */ |
| 8452 | 1 + sizeof (wchar_t) * wcslen (wstr))); | 8452 | 1 + sizeof (wchar_t) * wcslen (wstr))); |
| 8453 | } | 8453 | } |
diff --git a/src/coding.h b/src/coding.h index 4e8b1056e43..f3efcca031d 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -743,7 +743,7 @@ extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf); | |||
| 743 | extern Lisp_Object from_unicode (Lisp_Object str); | 743 | extern Lisp_Object from_unicode (Lisp_Object str); |
| 744 | 744 | ||
| 745 | /* Convert WSTR to an Emacs string. */ | 745 | /* Convert WSTR to an Emacs string. */ |
| 746 | extern Lisp_Object from_unicode_buffer (const wchar_t* wstr); | 746 | extern Lisp_Object from_unicode_buffer (const wchar_t *wstr); |
| 747 | 747 | ||
| 748 | #endif /* WINDOWSNT || CYGWIN */ | 748 | #endif /* WINDOWSNT || CYGWIN */ |
| 749 | 749 | ||
| @@ -595,7 +595,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 595 | { | 595 | { |
| 596 | #include "buildobj.h" | 596 | #include "buildobj.h" |
| 597 | }; | 597 | }; |
| 598 | int i = sizeof buildobj / sizeof *buildobj; | 598 | int i = ARRAYELTS (buildobj); |
| 599 | while (0 <= --i) | 599 | while (0 <= --i) |
| 600 | Vbuild_files = Fcons (build_string (buildobj[i]), Vbuild_files); | 600 | Vbuild_files = Fcons (build_string (buildobj[i]), Vbuild_files); |
| 601 | Vbuild_files = Fpurecopy (Vbuild_files); | 601 | Vbuild_files = Fpurecopy (Vbuild_files); |
diff --git a/src/emacs.c b/src/emacs.c index 75498dce50e..deebb2280c7 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -136,7 +136,7 @@ static void *malloc_state_ptr; | |||
| 136 | /* From glibc, a routine that returns a copy of the malloc internal state. */ | 136 | /* From glibc, a routine that returns a copy of the malloc internal state. */ |
| 137 | extern void *malloc_get_state (void); | 137 | extern void *malloc_get_state (void); |
| 138 | /* From glibc, a routine that overwrites the malloc internal state. */ | 138 | /* From glibc, a routine that overwrites the malloc internal state. */ |
| 139 | extern int malloc_set_state (void*); | 139 | extern int malloc_set_state (void *); |
| 140 | /* True if the MALLOC_CHECK_ environment variable was set while | 140 | /* True if the MALLOC_CHECK_ environment variable was set while |
| 141 | dumping. Used to work around a bug in glibc's malloc. */ | 141 | dumping. Used to work around a bug in glibc's malloc. */ |
| 142 | static bool malloc_using_checking; | 142 | static bool malloc_using_checking; |
| @@ -1008,7 +1008,7 @@ main (int argc, char **argv) | |||
| 1008 | { | 1008 | { |
| 1009 | int i; | 1009 | int i; |
| 1010 | printf ("Usage: %s [OPTION-OR-FILENAME]...\n", argv[0]); | 1010 | printf ("Usage: %s [OPTION-OR-FILENAME]...\n", argv[0]); |
| 1011 | for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++) | 1011 | for (i = 0; i < ARRAYELTS (usage_message); i++) |
| 1012 | fputs (usage_message[i], stdout); | 1012 | fputs (usage_message[i], stdout); |
| 1013 | exit (0); | 1013 | exit (0); |
| 1014 | } | 1014 | } |
diff --git a/src/font.c b/src/font.c index e99141bfe5c..5faf477fa90 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -662,10 +662,6 @@ static const struct | |||
| 662 | { &QCotf, font_prop_validate_otf } | 662 | { &QCotf, font_prop_validate_otf } |
| 663 | }; | 663 | }; |
| 664 | 664 | ||
| 665 | /* Size (number of elements) of the above table. */ | ||
| 666 | #define FONT_PROPERTY_TABLE_SIZE \ | ||
| 667 | ((sizeof font_property_table) / (sizeof *font_property_table)) | ||
| 668 | |||
| 669 | /* Return an index number of font property KEY or -1 if KEY is not an | 665 | /* Return an index number of font property KEY or -1 if KEY is not an |
| 670 | already known property. */ | 666 | already known property. */ |
| 671 | 667 | ||
| @@ -674,7 +670,7 @@ get_font_prop_index (Lisp_Object key) | |||
| 674 | { | 670 | { |
| 675 | int i; | 671 | int i; |
| 676 | 672 | ||
| 677 | for (i = 0; i < FONT_PROPERTY_TABLE_SIZE; i++) | 673 | for (i = 0; i < ARRAYELTS (font_property_table); i++) |
| 678 | if (EQ (key, *font_property_table[i].key)) | 674 | if (EQ (key, *font_property_table[i].key)) |
| 679 | return i; | 675 | return i; |
| 680 | return -1; | 676 | return -1; |
| @@ -4935,8 +4931,7 @@ If the named font is not yet loaded, return nil. */) | |||
| 4935 | #endif | 4931 | #endif |
| 4936 | 4932 | ||
| 4937 | 4933 | ||
| 4938 | #define BUILD_STYLE_TABLE(TBL) \ | 4934 | #define BUILD_STYLE_TABLE(TBL) build_style_table (TBL, ARRAYELTS (TBL)) |
| 4939 | build_style_table ((TBL), sizeof TBL / sizeof (struct table_entry)) | ||
| 4940 | 4935 | ||
| 4941 | static Lisp_Object | 4936 | static Lisp_Object |
| 4942 | build_style_table (const struct table_entry *entry, int nelement) | 4937 | build_style_table (const struct table_entry *entry, int nelement) |
diff --git a/src/gnutls.c b/src/gnutls.c index 03c29d03014..d9b417b46ed 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -56,7 +56,7 @@ static Lisp_Object QCgnutls_bootprop_verify_error; | |||
| 56 | static Lisp_Object QCgnutls_bootprop_callbacks_verify; | 56 | static Lisp_Object QCgnutls_bootprop_callbacks_verify; |
| 57 | 57 | ||
| 58 | static void gnutls_log_function (int, const char *); | 58 | static void gnutls_log_function (int, const char *); |
| 59 | static void gnutls_log_function2 (int, const char*, const char*); | 59 | static void gnutls_log_function2 (int, const char *, const char *); |
| 60 | #ifdef HAVE_GNUTLS3 | 60 | #ifdef HAVE_GNUTLS3 |
| 61 | static void gnutls_audit_log_function (gnutls_session_t, const char *); | 61 | static void gnutls_audit_log_function (gnutls_session_t, const char *); |
| 62 | #endif | 62 | #endif |
| @@ -267,7 +267,7 @@ init_gnutls_functions (void) | |||
| 267 | #ifdef HAVE_GNUTLS3 | 267 | #ifdef HAVE_GNUTLS3 |
| 268 | /* Function to log a simple audit message. */ | 268 | /* Function to log a simple audit message. */ |
| 269 | static void | 269 | static void |
| 270 | gnutls_audit_log_function (gnutls_session_t session, const char* string) | 270 | gnutls_audit_log_function (gnutls_session_t session, const char *string) |
| 271 | { | 271 | { |
| 272 | if (global_gnutls_log_level >= 1) | 272 | if (global_gnutls_log_level >= 1) |
| 273 | { | 273 | { |
| @@ -278,21 +278,21 @@ gnutls_audit_log_function (gnutls_session_t session, const char* string) | |||
| 278 | 278 | ||
| 279 | /* Function to log a simple message. */ | 279 | /* Function to log a simple message. */ |
| 280 | static void | 280 | static void |
| 281 | gnutls_log_function (int level, const char* string) | 281 | gnutls_log_function (int level, const char *string) |
| 282 | { | 282 | { |
| 283 | message ("gnutls.c: [%d] %s", level, string); | 283 | message ("gnutls.c: [%d] %s", level, string); |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | /* Function to log a message and a string. */ | 286 | /* Function to log a message and a string. */ |
| 287 | static void | 287 | static void |
| 288 | gnutls_log_function2 (int level, const char* string, const char* extra) | 288 | gnutls_log_function2 (int level, const char *string, const char *extra) |
| 289 | { | 289 | { |
| 290 | message ("gnutls.c: [%d] %s %s", level, string, extra); | 290 | message ("gnutls.c: [%d] %s %s", level, string, extra); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | /* Function to log a message and an integer. */ | 293 | /* Function to log a message and an integer. */ |
| 294 | static void | 294 | static void |
| 295 | gnutls_log_function2i (int level, const char* string, int extra) | 295 | gnutls_log_function2i (int level, const char *string, int extra) |
| 296 | { | 296 | { |
| 297 | message ("gnutls.c: [%d] %s %d", level, string, extra); | 297 | message ("gnutls.c: [%d] %s %d", level, string, extra); |
| 298 | } | 298 | } |
| @@ -794,7 +794,7 @@ one trustfile (usually a CA bundle). */) | |||
| 794 | Lisp_Object global_init; | 794 | Lisp_Object global_init; |
| 795 | char const *priority_string_ptr = "NORMAL"; /* default priority string. */ | 795 | char const *priority_string_ptr = "NORMAL"; /* default priority string. */ |
| 796 | unsigned int peer_verification; | 796 | unsigned int peer_verification; |
| 797 | char* c_hostname; | 797 | char *c_hostname; |
| 798 | 798 | ||
| 799 | /* Placeholders for the property list elements. */ | 799 | /* Placeholders for the property list elements. */ |
| 800 | Lisp_Object priority_string; | 800 | Lisp_Object priority_string; |
diff --git a/src/keyboard.c b/src/keyboard.c index 6de537085fe..277d4f1047c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -5478,7 +5478,7 @@ make_lispy_event (struct input_event *event) | |||
| 5478 | case NON_ASCII_KEYSTROKE_EVENT: | 5478 | case NON_ASCII_KEYSTROKE_EVENT: |
| 5479 | button_down_time = 0; | 5479 | button_down_time = 0; |
| 5480 | 5480 | ||
| 5481 | for (i = 0; i < sizeof (lispy_accent_codes) / sizeof (int); i++) | 5481 | for (i = 0; i < ARRAYELTS (lispy_accent_codes); i++) |
| 5482 | if (event->code == lispy_accent_codes[i]) | 5482 | if (event->code == lispy_accent_codes[i]) |
| 5483 | return modify_event_symbol (i, | 5483 | return modify_event_symbol (i, |
| 5484 | event->modifiers, | 5484 | event->modifiers, |
| @@ -5511,7 +5511,7 @@ make_lispy_event (struct input_event *event) | |||
| 5511 | if (event->code & (1 << 28) | 5511 | if (event->code & (1 << 28) |
| 5512 | || event->code - FUNCTION_KEY_OFFSET < 0 | 5512 | || event->code - FUNCTION_KEY_OFFSET < 0 |
| 5513 | || (event->code - FUNCTION_KEY_OFFSET | 5513 | || (event->code - FUNCTION_KEY_OFFSET |
| 5514 | >= sizeof lispy_function_keys / sizeof *lispy_function_keys) | 5514 | >= ARRAYELTS (lispy_function_keys)) |
| 5515 | || !lispy_function_keys[event->code - FUNCTION_KEY_OFFSET]) | 5515 | || !lispy_function_keys[event->code - FUNCTION_KEY_OFFSET]) |
| 5516 | { | 5516 | { |
| 5517 | /* We need to use an alist rather than a vector as the cache | 5517 | /* We need to use an alist rather than a vector as the cache |
| @@ -7282,7 +7282,7 @@ store_user_signal_events (void) | |||
| 7282 | } | 7282 | } |
| 7283 | 7283 | ||
| 7284 | 7284 | ||
| 7285 | static void menu_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*); | 7285 | static void menu_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void *); |
| 7286 | static Lisp_Object menu_bar_one_keymap_changed_items; | 7286 | static Lisp_Object menu_bar_one_keymap_changed_items; |
| 7287 | 7287 | ||
| 7288 | /* These variables hold the vector under construction within | 7288 | /* These variables hold the vector under construction within |
| @@ -7292,7 +7292,7 @@ static Lisp_Object menu_bar_items_vector; | |||
| 7292 | static int menu_bar_items_index; | 7292 | static int menu_bar_items_index; |
| 7293 | 7293 | ||
| 7294 | 7294 | ||
| 7295 | static const char* separator_names[] = { | 7295 | static const char *separator_names[] = { |
| 7296 | "space", | 7296 | "space", |
| 7297 | "no-line", | 7297 | "no-line", |
| 7298 | "single-line", | 7298 | "single-line", |
| @@ -7900,7 +7900,8 @@ static Lisp_Object QCrtl; | |||
| 7900 | /* Function prototypes. */ | 7900 | /* Function prototypes. */ |
| 7901 | 7901 | ||
| 7902 | static void init_tool_bar_items (Lisp_Object); | 7902 | static void init_tool_bar_items (Lisp_Object); |
| 7903 | static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*); | 7903 | static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, |
| 7904 | void *); | ||
| 7904 | static bool parse_tool_bar_item (Lisp_Object, Lisp_Object); | 7905 | static bool parse_tool_bar_item (Lisp_Object, Lisp_Object); |
| 7905 | static void append_tool_bar_item (void); | 7906 | static void append_tool_bar_item (void); |
| 7906 | 7907 | ||
diff --git a/src/keymap.c b/src/keymap.c index c1416f8a780..663c4661be3 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1894,7 +1894,7 @@ struct accessible_keymaps_data { | |||
| 1894 | 1894 | ||
| 1895 | static void | 1895 | static void |
| 1896 | accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *data) | 1896 | accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *data) |
| 1897 | /* Use void* data to be compatible with map_keymap_function_t. */ | 1897 | /* Use void * data to be compatible with map_keymap_function_t. */ |
| 1898 | { | 1898 | { |
| 1899 | struct accessible_keymaps_data *d = data; /* Cast! */ | 1899 | struct accessible_keymaps_data *d = data; /* Cast! */ |
| 1900 | Lisp_Object maps = d->maps; | 1900 | Lisp_Object maps = d->maps; |
diff --git a/src/keymap.h b/src/keymap.h index 4a408c6a2a0..b01886dfa61 100644 --- a/src/keymap.h +++ b/src/keymap.h | |||
| @@ -46,7 +46,7 @@ extern void syms_of_keymap (void); | |||
| 46 | extern void keys_of_keymap (void); | 46 | extern void keys_of_keymap (void); |
| 47 | 47 | ||
| 48 | typedef void (*map_keymap_function_t) | 48 | typedef void (*map_keymap_function_t) |
| 49 | (Lisp_Object key, Lisp_Object val, Lisp_Object args, void* data); | 49 | (Lisp_Object key, Lisp_Object val, Lisp_Object args, void *data); |
| 50 | extern void map_keymap (Lisp_Object, map_keymap_function_t, Lisp_Object, | 50 | extern void map_keymap (Lisp_Object, map_keymap_function_t, Lisp_Object, |
| 51 | void *, bool); | 51 | void *, bool); |
| 52 | extern void map_keymap_canonical (Lisp_Object map, | 52 | extern void map_keymap_canonical (Lisp_Object map, |
diff --git a/src/lisp.h b/src/lisp.h index a697e39a204..03c0d99fb27 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -58,8 +58,8 @@ INLINE_HEADER_BEGIN | |||
| 58 | #define max(a, b) ((a) > (b) ? (a) : (b)) | 58 | #define max(a, b) ((a) > (b) ? (a) : (b)) |
| 59 | #define min(a, b) ((a) < (b) ? (a) : (b)) | 59 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
| 60 | 60 | ||
| 61 | /* Find number of elements in array */ | 61 | /* Number of elements in an array. */ |
| 62 | #define ARRAYELTS(arr) (sizeof (arr) / sizeof ((arr)[0])) | 62 | #define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0]) |
| 63 | 63 | ||
| 64 | /* EMACS_INT - signed integer wide enough to hold an Emacs value | 64 | /* EMACS_INT - signed integer wide enough to hold an Emacs value |
| 65 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if | 65 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if |
diff --git a/src/process.c b/src/process.c index fe365a136de..5a5ce0ce674 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -2022,11 +2022,11 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len) | |||
| 2022 | terminator, however. */ | 2022 | terminator, however. */ |
| 2023 | if (name_length > 0 && sockun->sun_path[0] != '\0') | 2023 | if (name_length > 0 && sockun->sun_path[0] != '\0') |
| 2024 | { | 2024 | { |
| 2025 | const char* terminator = | 2025 | const char *terminator |
| 2026 | memchr (sockun->sun_path, '\0', name_length); | 2026 | = memchr (sockun->sun_path, '\0', name_length); |
| 2027 | 2027 | ||
| 2028 | if (terminator) | 2028 | if (terminator) |
| 2029 | name_length = terminator - (const char*) sockun->sun_path; | 2029 | name_length = terminator - (const char *) sockun->sun_path; |
| 2030 | } | 2030 | } |
| 2031 | 2031 | ||
| 2032 | return make_unibyte_string (sockun->sun_path, name_length); | 2032 | return make_unibyte_string (sockun->sun_path, name_length); |
diff --git a/src/profiler.c b/src/profiler.c index 8b092dcc818..ff97fe88b7b 100644 --- a/src/profiler.c +++ b/src/profiler.c | |||
| @@ -294,7 +294,7 @@ setup_cpu_timer (Lisp_Object sampling_interval) | |||
| 294 | sigev.sigev_signo = SIGPROF; | 294 | sigev.sigev_signo = SIGPROF; |
| 295 | sigev.sigev_notify = SIGEV_SIGNAL; | 295 | sigev.sigev_notify = SIGEV_SIGNAL; |
| 296 | 296 | ||
| 297 | for (i = 0; i < sizeof system_clock / sizeof *system_clock; i++) | 297 | for (i = 0; i < ARRAYELTS (system_clock); i++) |
| 298 | if (timer_create (system_clock[i], &sigev, &profiler_timer) == 0) | 298 | if (timer_create (system_clock[i], &sigev, &profiler_timer) == 0) |
| 299 | { | 299 | { |
| 300 | profiler_timer_ok = 1; | 300 | profiler_timer_ok = 1; |
diff --git a/src/sysdep.c b/src/sysdep.c index 964dc419d25..7a888834bcc 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -128,7 +128,7 @@ static const int baud_convert[] = | |||
| 128 | /* Return the current working directory. Returns NULL on errors. | 128 | /* Return the current working directory. Returns NULL on errors. |
| 129 | Any other returned value must be freed with free. This is used | 129 | Any other returned value must be freed with free. This is used |
| 130 | only when get_current_dir_name is not defined on the system. */ | 130 | only when get_current_dir_name is not defined on the system. */ |
| 131 | char* | 131 | char * |
| 132 | get_current_dir_name (void) | 132 | get_current_dir_name (void) |
| 133 | { | 133 | { |
| 134 | char *buf; | 134 | char *buf; |
diff --git a/src/unexcoff.c b/src/unexcoff.c index 5710ac04570..cb0b6f2f0b5 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c | |||
| @@ -120,7 +120,7 @@ static int pagemask; | |||
| 120 | into an int which is the number of a byte. | 120 | into an int which is the number of a byte. |
| 121 | This is a no-op on ordinary machines, but not on all. */ | 121 | This is a no-op on ordinary machines, but not on all. */ |
| 122 | 122 | ||
| 123 | #define ADDR_CORRECT(x) ((char *)(x) - (char*)0) | 123 | #define ADDR_CORRECT(x) ((char *) (x) - (char *) 0) |
| 124 | 124 | ||
| 125 | #include "lisp.h" | 125 | #include "lisp.h" |
| 126 | 126 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index 53bd46328f2..3431a7bad29 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -22639,7 +22639,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 22639 | return decode_mode_spec_buf; | 22639 | return decode_mode_spec_buf; |
| 22640 | no_value: | 22640 | no_value: |
| 22641 | { | 22641 | { |
| 22642 | char* p = decode_mode_spec_buf; | 22642 | char *p = decode_mode_spec_buf; |
| 22643 | int pad = width - 2; | 22643 | int pad = width - 2; |
| 22644 | while (pad-- > 0) | 22644 | while (pad-- > 0) |
| 22645 | *p++ = ' '; | 22645 | *p++ = ' '; |
diff --git a/src/xfaces.c b/src/xfaces.c index 7a630704fc9..4e599d0bd05 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -273,10 +273,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 273 | 273 | ||
| 274 | #define IGNORE_DEFFACE_P(ATTR) EQ ((ATTR), QCignore_defface) | 274 | #define IGNORE_DEFFACE_P(ATTR) EQ ((ATTR), QCignore_defface) |
| 275 | 275 | ||
| 276 | /* Value is the number of elements of VECTOR. */ | ||
| 277 | |||
| 278 | #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR)) | ||
| 279 | |||
| 280 | /* Size of hash table of realized faces in face caches (should be a | 276 | /* Size of hash table of realized faces in face caches (should be a |
| 281 | prime number). */ | 277 | prime number). */ |
| 282 | 278 | ||
| @@ -5093,14 +5089,14 @@ Value is ORDER. */) | |||
| 5093 | { | 5089 | { |
| 5094 | Lisp_Object list; | 5090 | Lisp_Object list; |
| 5095 | int i; | 5091 | int i; |
| 5096 | int indices[DIM (font_sort_order)]; | 5092 | int indices[ARRAYELTS (font_sort_order)]; |
| 5097 | 5093 | ||
| 5098 | CHECK_LIST (order); | 5094 | CHECK_LIST (order); |
| 5099 | memset (indices, 0, sizeof indices); | 5095 | memset (indices, 0, sizeof indices); |
| 5100 | i = 0; | 5096 | i = 0; |
| 5101 | 5097 | ||
| 5102 | for (list = order; | 5098 | for (list = order; |
| 5103 | CONSP (list) && i < DIM (indices); | 5099 | CONSP (list) && i < ARRAYELTS (indices); |
| 5104 | list = XCDR (list), ++i) | 5100 | list = XCDR (list), ++i) |
| 5105 | { | 5101 | { |
| 5106 | Lisp_Object attr = XCAR (list); | 5102 | Lisp_Object attr = XCAR (list); |
| @@ -5122,9 +5118,9 @@ Value is ORDER. */) | |||
| 5122 | indices[i] = xlfd; | 5118 | indices[i] = xlfd; |
| 5123 | } | 5119 | } |
| 5124 | 5120 | ||
| 5125 | if (!NILP (list) || i != DIM (indices)) | 5121 | if (!NILP (list) || i != ARRAYELTS (indices)) |
| 5126 | signal_error ("Invalid font sort order", order); | 5122 | signal_error ("Invalid font sort order", order); |
| 5127 | for (i = 0; i < DIM (font_sort_order); ++i) | 5123 | for (i = 0; i < ARRAYELTS (font_sort_order); ++i) |
| 5128 | if (indices[i] == 0) | 5124 | if (indices[i] == 0) |
| 5129 | signal_error ("Invalid font sort order", order); | 5125 | signal_error ("Invalid font sort order", order); |
| 5130 | 5126 | ||
| @@ -6348,7 +6344,7 @@ DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, doc: /* */) | |||
| 6348 | int i; | 6344 | int i; |
| 6349 | 6345 | ||
| 6350 | fprintf (stderr, "font selection order: "); | 6346 | fprintf (stderr, "font selection order: "); |
| 6351 | for (i = 0; i < DIM (font_sort_order); ++i) | 6347 | for (i = 0; i < ARRAYELTS (font_sort_order); ++i) |
| 6352 | fprintf (stderr, "%d ", font_sort_order[i]); | 6348 | fprintf (stderr, "%d ", font_sort_order[i]); |
| 6353 | fprintf (stderr, "\n"); | 6349 | fprintf (stderr, "\n"); |
| 6354 | 6350 | ||
diff --git a/src/xgselect.c b/src/xgselect.c index 1d3f916c9f8..5f71ff84014 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -41,7 +41,7 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds, | |||
| 41 | int have_wfds = wfds != NULL; | 41 | int have_wfds = wfds != NULL; |
| 42 | GPollFD gfds_buf[128]; | 42 | GPollFD gfds_buf[128]; |
| 43 | GPollFD *gfds = gfds_buf; | 43 | GPollFD *gfds = gfds_buf; |
| 44 | int gfds_size = sizeof gfds_buf / sizeof *gfds_buf; | 44 | int gfds_size = ARRAYELTS (gfds_buf); |
| 45 | int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1; | 45 | int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1; |
| 46 | int i, nfds, tmo_in_millisec; | 46 | int i, nfds, tmo_in_millisec; |
| 47 | bool need_to_dispatch; | 47 | bool need_to_dispatch; |
diff --git a/src/xsmfns.c b/src/xsmfns.c index 9a31f518f30..81b012690f9 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -395,7 +395,7 @@ x_session_initialize (struct x_display_info *dpyinfo) | |||
| 395 | { | 395 | { |
| 396 | #define SM_ERRORSTRING_LEN 512 | 396 | #define SM_ERRORSTRING_LEN 512 |
| 397 | char errorstring[SM_ERRORSTRING_LEN]; | 397 | char errorstring[SM_ERRORSTRING_LEN]; |
| 398 | char* previous_id = NULL; | 398 | char *previous_id = NULL; |
| 399 | SmcCallbacks callbacks; | 399 | SmcCallbacks callbacks; |
| 400 | ptrdiff_t name_len = 0; | 400 | ptrdiff_t name_len = 0; |
| 401 | 401 | ||
diff --git a/src/xterm.c b/src/xterm.c index a04f2fef055..dd71a8a1986 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -308,7 +308,7 @@ int event_record_index; | |||
| 308 | void | 308 | void |
| 309 | record_event (char *locus, int type) | 309 | record_event (char *locus, int type) |
| 310 | { | 310 | { |
| 311 | if (event_record_index == sizeof (event_record) / sizeof (struct record)) | 311 | if (event_record_index == ARRAYELTS (event_record)) |
| 312 | event_record_index = 0; | 312 | event_record_index = 0; |
| 313 | 313 | ||
| 314 | event_record[event_record_index].locus = locus; | 314 | event_record[event_record_index].locus = locus; |
| @@ -5624,7 +5624,7 @@ static int temp_index; | |||
| 5624 | static short temp_buffer[100]; | 5624 | static short temp_buffer[100]; |
| 5625 | 5625 | ||
| 5626 | #define STORE_KEYSYM_FOR_DEBUG(keysym) \ | 5626 | #define STORE_KEYSYM_FOR_DEBUG(keysym) \ |
| 5627 | if (temp_index == sizeof temp_buffer / sizeof (short)) \ | 5627 | if (temp_index == ARRAYELTS (temp_buffer)) \ |
| 5628 | temp_index = 0; \ | 5628 | temp_index = 0; \ |
| 5629 | temp_buffer[temp_index++] = (keysym) | 5629 | temp_buffer[temp_index++] = (keysym) |
| 5630 | 5630 | ||
diff --git a/src/xterm.h b/src/xterm.h index 50df88cb592..90d2e131717 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -996,7 +996,7 @@ extern Lisp_Object x_get_focus_frame (struct frame *); | |||
| 996 | 996 | ||
| 997 | #ifdef USE_GTK | 997 | #ifdef USE_GTK |
| 998 | extern int xg_set_icon (struct frame *, Lisp_Object); | 998 | extern int xg_set_icon (struct frame *, Lisp_Object); |
| 999 | extern int xg_set_icon_from_xpm_data (struct frame *, const char**); | 999 | extern int xg_set_icon_from_xpm_data (struct frame *, const char **); |
| 1000 | #endif /* USE_GTK */ | 1000 | #endif /* USE_GTK */ |
| 1001 | 1001 | ||
| 1002 | extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); | 1002 | extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); |