diff options
| author | Paul Eggert | 2012-09-11 15:59:50 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-09-11 15:59:50 -0700 |
| commit | ae1d87e24edc6a5fa4bc291e1b2ea20d7853127c (patch) | |
| tree | 200f48e41018df77fb2f63e55e0d22c829968ebe | |
| parent | 5779a1dc62593be8294edaecfecca4359be9ab4e (diff) | |
| download | emacs-ae1d87e24edc6a5fa4bc291e1b2ea20d7853127c.tar.gz emacs-ae1d87e24edc6a5fa4bc291e1b2ea20d7853127c.zip | |
Prefer assignment to memcpy when either will do.
* lib-src/pop.c (socket_connection) [HAVE_GETADDRINFO]:
* src/bidi.c (bidi_push_it, bidi_pop_it):
* src/fns.c (copy_hash_table):
* src/image.c (define_image_type):
* src/keyboard.c (kbd_buffer_store_event_hold):
* src/process.c (Fprocess_send_eof):
* src/xfaces.c (x_create_gc) [HAVE_NS]:
* src/xgselect.c (xg_select):
Use assignment, not memcpy, as either will do here, and assignment is
more likely to catch type errors.
| -rw-r--r-- | lib-src/ChangeLog | 5 | ||||
| -rw-r--r-- | lib-src/pop.c | 2 | ||||
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/bidi.c | 4 | ||||
| -rw-r--r-- | src/fns.c | 2 | ||||
| -rw-r--r-- | src/image.c | 2 | ||||
| -rw-r--r-- | src/keyboard.c | 2 | ||||
| -rw-r--r-- | src/process.c | 5 | ||||
| -rw-r--r-- | src/xfaces.c | 2 | ||||
| -rw-r--r-- | src/xgselect.c | 4 |
10 files changed, 25 insertions, 12 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 35190fd2a8f..f5846657707 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-09-11 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * pop.c (socket_connection) [HAVE_GETADDRINFO]: | ||
| 4 | Prefer assignment to memcpy when either will do. | ||
| 5 | |||
| 1 | 2012-08-31 Andreas Schwab <schwab@linux-m68k.org> | 6 | 2012-08-31 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 7 | ||
| 3 | * etags.c (consider_token): Always zero-terminate token buffer. | 8 | * etags.c (consider_token): Always zero-terminate token buffer. |
diff --git a/lib-src/pop.c b/lib-src/pop.c index 74054e0e1b1..bfbcb8c9466 100644 --- a/lib-src/pop.c +++ b/lib-src/pop.c | |||
| @@ -1083,7 +1083,7 @@ socket_connection (char *host, int flags) | |||
| 1083 | if (it->ai_addrlen == sizeof (addr)) | 1083 | if (it->ai_addrlen == sizeof (addr)) |
| 1084 | { | 1084 | { |
| 1085 | struct sockaddr_in *in_a = (struct sockaddr_in *) it->ai_addr; | 1085 | struct sockaddr_in *in_a = (struct sockaddr_in *) it->ai_addr; |
| 1086 | memcpy (&addr.sin_addr, &in_a->sin_addr, sizeof (addr.sin_addr)); | 1086 | addr.sin_addr = in_a->sin_addr; |
| 1087 | if (! connect (sock, (struct sockaddr *) &addr, sizeof (addr))) | 1087 | if (! connect (sock, (struct sockaddr *) &addr, sizeof (addr))) |
| 1088 | break; | 1088 | break; |
| 1089 | } | 1089 | } |
diff --git a/src/ChangeLog b/src/ChangeLog index 2b0686cc49e..74a12b94b08 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2012-09-11 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-09-11 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * bidi.c (bidi_push_it, bidi_pop_it): | ||
| 4 | * fns.c (copy_hash_table): | ||
| 5 | * image.c (define_image_type): | ||
| 6 | * keyboard.c (kbd_buffer_store_event_hold): | ||
| 7 | * process.c (Fprocess_send_eof): | ||
| 8 | * xfaces.c (x_create_gc) [HAVE_NS]: | ||
| 9 | * xgselect.c (xg_select): | ||
| 10 | Prefer assignment to memcpy when either will do. | ||
| 11 | |||
| 3 | * alloc.c (discard_killed_buffers): Tune and simplify a bit. | 12 | * alloc.c (discard_killed_buffers): Tune and simplify a bit. |
| 4 | Use pointer-to-a-pointer to simplify and avoid a NILP check each | 13 | Use pointer-to-a-pointer to simplify and avoid a NILP check each |
| 5 | time an item is removed. No need to mark this function 'inline'; | 14 | time an item is removed. No need to mark this function 'inline'; |
diff --git a/src/bidi.c b/src/bidi.c index 73fec3533a4..4186a46e19e 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -612,7 +612,7 @@ bidi_push_it (struct bidi_it *bidi_it) | |||
| 612 | /* Save the current iterator state in its entirety after the last | 612 | /* Save the current iterator state in its entirety after the last |
| 613 | used cache slot. */ | 613 | used cache slot. */ |
| 614 | bidi_cache_ensure_space (bidi_cache_idx); | 614 | bidi_cache_ensure_space (bidi_cache_idx); |
| 615 | memcpy (&bidi_cache[bidi_cache_idx++], bidi_it, sizeof (struct bidi_it)); | 615 | bidi_cache[bidi_cache_idx++] = *bidi_it; |
| 616 | 616 | ||
| 617 | /* Push the current cache start onto the stack. */ | 617 | /* Push the current cache start onto the stack. */ |
| 618 | eassert (bidi_cache_sp < IT_STACK_SIZE); | 618 | eassert (bidi_cache_sp < IT_STACK_SIZE); |
| @@ -636,7 +636,7 @@ bidi_pop_it (struct bidi_it *bidi_it) | |||
| 636 | bidi_cache_idx = bidi_cache_start - 1; | 636 | bidi_cache_idx = bidi_cache_start - 1; |
| 637 | 637 | ||
| 638 | /* Restore the bidi iterator state saved in the cache. */ | 638 | /* Restore the bidi iterator state saved in the cache. */ |
| 639 | memcpy (bidi_it, &bidi_cache[bidi_cache_idx], sizeof (struct bidi_it)); | 639 | *bidi_it = bidi_cache[bidi_cache_idx]; |
| 640 | 640 | ||
| 641 | /* Pop the previous cache start from the stack. */ | 641 | /* Pop the previous cache start from the stack. */ |
| 642 | if (bidi_cache_sp <= 0) | 642 | if (bidi_cache_sp <= 0) |
| @@ -3680,7 +3680,7 @@ copy_hash_table (struct Lisp_Hash_Table *h1) | |||
| 3680 | 3680 | ||
| 3681 | h2 = allocate_hash_table (); | 3681 | h2 = allocate_hash_table (); |
| 3682 | next = h2->header.next.vector; | 3682 | next = h2->header.next.vector; |
| 3683 | memcpy (h2, h1, sizeof *h2); | 3683 | *h2 = *h1; |
| 3684 | h2->header.next.vector = next; | 3684 | h2->header.next.vector = next; |
| 3685 | h2->key_and_value = Fcopy_sequence (h1->key_and_value); | 3685 | h2->key_and_value = Fcopy_sequence (h1->key_and_value); |
| 3686 | h2->hash = Fcopy_sequence (h1->hash); | 3686 | h2->hash = Fcopy_sequence (h1->hash); |
diff --git a/src/image.c b/src/image.c index 4ec6105d72d..52598a41ab9 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -593,7 +593,7 @@ define_image_type (struct image_type *type, int loaded) | |||
| 593 | /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. | 593 | /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. |
| 594 | The initialized data segment is read-only. */ | 594 | The initialized data segment is read-only. */ |
| 595 | struct image_type *p = xmalloc (sizeof *p); | 595 | struct image_type *p = xmalloc (sizeof *p); |
| 596 | memcpy (p, type, sizeof *p); | 596 | *p = *type; |
| 597 | p->next = image_types; | 597 | p->next = image_types; |
| 598 | image_types = p; | 598 | image_types = p; |
| 599 | success = Qt; | 599 | success = Qt; |
diff --git a/src/keyboard.c b/src/keyboard.c index d26cf35e108..42c67f68ede 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -3602,7 +3602,7 @@ kbd_buffer_store_event_hold (register struct input_event *event, | |||
| 3602 | 3602 | ||
| 3603 | if (hold_quit) | 3603 | if (hold_quit) |
| 3604 | { | 3604 | { |
| 3605 | memcpy (hold_quit, event, sizeof (*event)); | 3605 | *hold_quit = *event; |
| 3606 | return; | 3606 | return; |
| 3607 | } | 3607 | } |
| 3608 | 3608 | ||
diff --git a/src/process.c b/src/process.c index 0ae68567d6b..f80b5e80c76 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -6367,9 +6367,8 @@ process has been transmitted to the serial port. */) | |||
| 6367 | if (!proc_encode_coding_system[new_outfd]) | 6367 | if (!proc_encode_coding_system[new_outfd]) |
| 6368 | proc_encode_coding_system[new_outfd] | 6368 | proc_encode_coding_system[new_outfd] |
| 6369 | = xmalloc (sizeof (struct coding_system)); | 6369 | = xmalloc (sizeof (struct coding_system)); |
| 6370 | memcpy (proc_encode_coding_system[new_outfd], | 6370 | *proc_encode_coding_system[new_outfd] |
| 6371 | proc_encode_coding_system[old_outfd], | 6371 | = *proc_encode_coding_system[old_outfd]; |
| 6372 | sizeof (struct coding_system)); | ||
| 6373 | memset (proc_encode_coding_system[old_outfd], 0, | 6372 | memset (proc_encode_coding_system[old_outfd], 0, |
| 6374 | sizeof (struct coding_system)); | 6373 | sizeof (struct coding_system)); |
| 6375 | 6374 | ||
diff --git a/src/xfaces.c b/src/xfaces.c index aee5158036f..c113c1a37b7 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -661,7 +661,7 @@ x_create_gc (struct frame *f, | |||
| 661 | XGCValues *xgcv) | 661 | XGCValues *xgcv) |
| 662 | { | 662 | { |
| 663 | GC gc = xmalloc (sizeof *gc); | 663 | GC gc = xmalloc (sizeof *gc); |
| 664 | memcpy (gc, xgcv, sizeof (XGCValues)); | 664 | *gc = *xgcv; |
| 665 | return gc; | 665 | return gc; |
| 666 | } | 666 | } |
| 667 | 667 | ||
diff --git a/src/xgselect.c b/src/xgselect.c index 0c00d815820..5f4c7edfb79 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -49,9 +49,9 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | |||
| 49 | && g_main_context_pending (context = g_main_context_default ()))) | 49 | && g_main_context_pending (context = g_main_context_default ()))) |
| 50 | return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask); | 50 | return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask); |
| 51 | 51 | ||
| 52 | if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds)); | 52 | if (rfds) all_rfds = *rfds; |
| 53 | else FD_ZERO (&all_rfds); | 53 | else FD_ZERO (&all_rfds); |
| 54 | if (wfds) memcpy (&all_wfds, wfds, sizeof (all_rfds)); | 54 | if (wfds) all_wfds = *wfds; |
| 55 | else FD_ZERO (&all_wfds); | 55 | else FD_ZERO (&all_wfds); |
| 56 | 56 | ||
| 57 | n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec, | 57 | n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec, |