From owner-freebsd-hackers Fri Jul 13 10:30: 7 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from sneakerz.org (sneakerz.org [216.33.66.254]) by hub.freebsd.org (Postfix) with ESMTP id DD01037B403 for ; Fri, 13 Jul 2001 10:30:01 -0700 (PDT) (envelope-from bright@sneakerz.org) Received: by sneakerz.org (Postfix, from userid 1092) id 7BF195D010; Fri, 13 Jul 2001 12:29:58 -0500 (CDT) Date: Fri, 13 Jul 2001 12:29:58 -0500 From: Alfred Perlstein To: "Eugene L. Vorokov" Cc: freebsd-hackers@freebsd.org Subject: Re: Some questions about kernel programming Message-ID: <20010713122958.S6664@sneakerz.org> References: <20010712212809.F6664@sneakerz.org> <200107131529.f6DFTZI00705@bugz.infotecs.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <200107131529.f6DFTZI00705@bugz.infotecs.ru>; from vel@bugz.infotecs.ru on Fri, Jul 13, 2001 at 07:29:35PM +0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Eugene L. Vorokov [010713 10:16] wrote: > > /* > > * return number of characters in a userland address string > > * or -1 if an illegal access occurs. > > */ > Then I don't get it. Won't this piece of code cycle forever fetching > first byte of the string again and again ? According to fetch(9) > fubyte() doesn't change uaddr, or am I missing something again ? > Am I allowed to do uaddr++ for userspace addresses in such a case ? Yes, I forgot something: > > int > > user_strlen(uaddr) > > char *uaddr; > > { > > int ret; > > > > ret = -1; > > do { > > ch = fubyte(uaddr); > > ret++; ----------> uaddr++; <------------- > > } while (ch != 0 && ch != -1); > > > > return (ch == -1 ? -1 : ret); > > } > doh :) -- -Alfred Perlstein [alfred@freebsd.org] Ok, who wrote this damn function called '??'? And why do my programs keep crashing in it? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message