lkml.org 
[lkml]   [2000]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch-2.4.0-test6-pre8] fork.c FIXME removed
Hi all,

Here's a small patch which gets rid of a FIXME comment in the
kernel/fork.c file. Instead of doing a memcpy, it copies each field
individually. I hope I got all of the fields which were supposed to be
in there.

Why do it this way? C allows structures to be packed with extra bytes so
simply calculating how much space all the elements *should* take, it's
better to either copy them individually or the whole structure at one
time (doing a sizeof(struct foo) for instance).

Comments?

--
|| Bill Wendling wendling@ganymede.isdn.uiuc.edu
diff -Naur linux-2.4.0-test6-pre8/kernel/fork.c linux-2.4.0-test6-pre8-new/kernel/fork.c
--- linux-2.4.0-test6-pre8/kernel/fork.c Tue Aug 8 03:29:16 2000
+++ linux-2.4.0-test6-pre8-new/kernel/fork.c Tue Aug 8 03:29:24 2000
@@ -126,10 +126,24 @@
static inline int dup_mmap(struct mm_struct * mm)
{
struct vm_area_struct * mpnt, *tmp, **pprev;
+ struct mm_struct *current_mm = current->mm;
int retval;

- /* Kill me slowly. UGLY! FIXME! */
- memcpy(&mm->start_code, &current->mm->start_code, 15*sizeof(unsigned long));
+ mm->start_code = current_mm->start_code;
+ mm->end_code = current_mm->end_code;
+ mm->start_data = current_mm->start_data;
+ mm->end_data = current_mm->end_data;
+ mm->start_brk = current_mm->start_brk;
+ mm->brk = current_mm->brk;
+ mm->start_stack = current_mm->start_stack;
+ mm->arg_start = current_mm->arg_start;
+ mm->arg_end = current_mm->arg_end;
+ mm->env_start = current_mm->env_start;
+ mm->env_end = current_mm->env_end;
+ mm->res = current_mm->res;
+ mm->total_vm = current_mm->total_vm;
+ mm->locked_vm = current_mm->locked_vm;
+ mm->def_flags = current_mm->def_flags;

flush_cache_mm(current->mm);
pprev = &mm->mmap;
\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.026 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site