Embed
Email

msg00025

Document Sample

Shared by: ajizai
Categories
Tags
Stats
views:
0
posted:
12/20/2011
language:
pages:
2
getbsize(3): Convert blocksizep to be unsigned long?



getbsize(3): Convert blocksizep to be unsigned

long?



Source: http://unix.derkeiler.com/Mailing−Lists/FreeBSD/arch/2006−06/msg00025.html







• From: Xin LI

• Date: Tue, 06 Jun 2006 09:35:29 +0800



Dear folks,



When I was twiddling df(1)'s code I found that getbsize(3) accepts

blocksizep as long *. Because that the manual page says:



"The memory referenced by blocksizep is filled in with block size, in

bytes."



I think it makes no sense for the number to be negative. Is it

reasonable to apply the attached patch?



Cheers,

−−

Xin LI http://www.delphij.net/

Index: include/stdlib.h

===================================================================

RCS file: /home/ncvs/src/include/stdlib.h,v

retrieving revision 1.62

diff −u −r1.62 stdlib.h

−−− include/stdlib.h 14 Mar 2006 16:57:30 −0000 1.62

+++ include/stdlib.h 6 Jun 2006 01:27:56 −0000

@@ −237,7 +237,7 @@

arc4random(void);

void arc4random_addrandom(unsigned char *dat, int datlen);

void arc4random_stir(void);

−char *getbsize(int *, long *);

+char *getbsize(int *, unsigned long *);

/* getcap(3) functions */

char *cgetcap(char *, const char *, int);

int cgetclose(void);

Index: lib/libc/gen/getbsize.c

===================================================================

RCS file: /home/ncvs/src/lib/libc/gen/getbsize.c,v

retrieving revision 1.7

diff −u −r1.7 getbsize.c

−−− lib/libc/gen/getbsize.c 30 Dec 2002 19:04:06 −0000 1.7

+++ lib/libc/gen/getbsize.c 6 Jun 2006 01:27:56 −0000

@@ −38,17 +38,16 @@



getbsize(3): Convert blocksizep to be unsigned long? 1

getbsize(3): Convert blocksizep to be unsigned long?

__FBSDID("$FreeBSD: src/lib/libc/gen/getbsize.c,v 1.7 2002/12/30 19:04:06 obrien Exp $");



#include

+#include

#include

#include

#include



char *

−getbsize(headerlenp, blocksizep)

− int *headerlenp;

− long *blocksizep;

+getbsize(int *headerlenp, unsigned long *blocksizep)

{

static char header[20];

− long n, max, mul, blocksize;

+ unsigned long n, max, mul, blocksize;

char *ep, *p;

const char *form;



@@ −58,8 +57,11 @@

#define MAXB GB /* No tera, peta, nor exa. */

form = "";

if ((p = getenv("BLOCKSIZE")) != NULL && *p != '\0') {

− if ((n = strtol(p, &ep, 10)) < 0)

+ n = strtoul(p, &ep, 10);

+ if (errno == ERANGE)

goto underflow;

+ else if (errno == EINVAL)

+ n = 0;

if (n == 0)

n = 1;

if (*ep && ep[1])



Attachment: signature.asc

Description: =?UTF−8?Q?=E8=BF=99=E6=98=AF=E4=BF=A1=E4=BB=B6=E7=9A=84=E6=95=B0?=

=?UTF−8?Q?=E5=AD=97=E7=AD=BE=E5=90=8D=E9=83=A8=E5=88=86?=









getbsize(3): Convert blocksizep to be unsigned long? 2



Related docs
Other docs by ajizai
Resume 1.docx _20K_ - Student of Fortune
Views: 0  |  Downloads: 0
msg00000
Views: 0  |  Downloads: 0
Pre-Tax Return Calculator 2010-2011
Views: 0  |  Downloads: 0
Excel file - The GEO-3 Data Compendium
Views: 0  |  Downloads: 0
Cooperators Tests - ARS
Views: 0  |  Downloads: 0
2010101473142104
Views: 0  |  Downloads: 0
AJHL - Shawn Stewart Sales
Views: 0  |  Downloads: 0
OBLATES_ BROTHER CADFAEL AND ROME
Views: 1  |  Downloads: 0
DuaneChipKeeler_CV-Resume
Views: 0  |  Downloads: 0
AIT-2009-291-SC
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!