From jin@iss-p2.lbl.gov Thu Jul 29 14:33:09 1999
Return-Path: <jin@iss-p2.lbl.gov>
Received: from iss-p2.lbl.gov (iss-p2.lbl.gov [128.3.196.71])
	by hub.freebsd.org (Postfix) with ESMTP id 782C3156AF
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 29 Jul 1999 14:32:50 -0700 (PDT)
	(envelope-from jin@iss-p2.lbl.gov)
Received: (from jin@localhost)
	by iss-p2.lbl.gov (8.9.3/8.9.3) id OAA38936;
	Thu, 29 Jul 1999 14:30:52 -0700 (PDT)
	(envelope-from jin)
Message-Id: <199907292130.OAA38936@iss-p2.lbl.gov>
Date: Thu, 29 Jul 1999 14:30:52 -0700 (PDT)
From: Jin Guojun (FTG staff) <jin@iss-p2.lbl.gov>
Reply-To: jin@iss-p2.lbl.gov
To: FreeBSD-gnats-submit@freebsd.org
Subject: incorrect off_t value range / causing lseek failure?
X-Send-Pr-Version: 3.2

>Number:         12876
>Category:       i386
>Synopsis:       incorrect off_t value range / causing lseek failure?
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 29 14:40:00 PDT 1999
>Closed-Date:    Sun Aug 22 13:22:41 PDT 1999
>Last-Modified:  Sun Aug 22 13:44:18 PDT 1999
>Originator:     Jin Guojun (FTG staff)
>Release:        FreeBSD 3.2-19990708-STABLE i386
>Organization:
>Environment:

	(1, 2) in All released versions of FreeBSD.
	(3) in FreeBSD 2.2.x.

>Description:

op2.lbl.gov: make x
cc -O x.c  -o x -lm
x.c: In function `main':
x.c:8: warning: left shift count >= width of type
*** Error code 1

Two problems:

(1) off_t is an 8 byte type, so it should be able to handle more than 32-bit
data. I test this because the lseek() cannot seek beyond the 2GB range.
I am not sure if off_t causes this proble, or lseek() is not implemented
to do so; the vfs_syscall.c:lseek() seems no problem, but depends on off_t.

(2) lseek fails to seek beyond 2GB range; but fseek works OK.

(3) There is no correct format for I/O off_t data in 2.2.x releases.

>How-To-Repeat:

	
/* x.c	*/
#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>

main ( int c, char **v )
{
off_t	lret = 5 + (1<<33), bottom = 12345;	/* line 8	*/
char	foo[64];

	if (c <= 1)	{
		printf("%s #\n", v[0]);
		exit(1);
	}
	bottom = strtouq(v[1], &foo, 10);
	printf("lret = %lld, bt = %lld : extra %ld\n", lret, bottom);
	printf("lret = %ld, bt = %ld : extra %ld\n", lret, bottom);
}

>Fix:
	
	Not clear if this is a GNU CC problem or kernel type-definition issue.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Sun Aug 22 13:22:41 PDT 1999 
State-Changed-Why:  
You can't write 

off_t   lret = 5 + (1<<33); 

You must write 

off_t   lret = 5 + ((off_t)1<<33); 

If you change your sample program appropriately, it appears to work as 
expected.  My interpretation of this is that the reason lseek() did 
not work for you is due to the incorrect lack of a necessary cast 
somewhere. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: hoek 
Responsible-Changed-When: Sun Aug 22 13:22:41 PDT 1999 
Responsible-Changed-Why:  
Misfiled PR. 
>Unformatted:
