Return-Path: william@bourbon.usc.edu Delivery-Date: Fri Sep 5 13:18:20 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m85KIKqM009330 for ; Fri, 5 Sep 2008 13:18:20 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m85KGdET002780 for ; Fri, 5 Sep 2008 13:16:39 -0700 Message-Id: <200809052016.m85KGdET002780@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: CS-551 warmup-1 Date: Fri, 05 Sep 2008 13:16:39 -0700 From: Bill Cheng Someone wrote: > So thats when we might get a seg fault or a bus error. Sure! If you have something like: unsigned char *buf=NULL; unsigned short msg_type=0xfe01; memcpy(buf, &msg_type, 2); You should get a seg fault because you cannot copy to memory locaiont 0. -- Bill Cheng // bill.cheng@usc.edu On Fri, Sep 5, 2008 at 5:58 AM, Bill Cheng wrote: > Someone wrote: > > > Does memcpy always work? I mean it does not have any return value, and > the > > man pages do not specify anything on this too. > > The man pages say that it returns the first argument to it. > So, I guess it "always works", except when you write into bad > memory and get a SIGSEGV or SIGBUS. > -- > Bill Cheng // bill.cheng@usc.edu > >