Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143853645
D31663.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D31663.id.diff
View Options
Index: stand/libsa/dev.c
===================================================================
--- stand/libsa/dev.c
+++ stand/libsa/dev.c
@@ -40,22 +40,19 @@
#include "stand.h"
int
-nodev()
+nodev(void)
{
return (ENXIO);
}
void
-nullsys()
+nullsys(void)
{
}
/* ARGSUSED */
int
-noioctl(f, cmd, data)
- struct open_file *f;
- u_long cmd;
- void *data;
+noioctl(struct open_file *f __unused, u_long cmd __unused, void *data __unused)
{
return (EINVAL);
}
Index: stand/libsa/ext2fs.c
===================================================================
--- stand/libsa/ext2fs.c
+++ stand/libsa/ext2fs.c
@@ -796,10 +796,11 @@
struct file *fp = (struct file *)f->f_fsdata;
int level;
- f->f_fsdata = (void *)0;
- if (fp == (struct file *)0)
+ if (fp == NULL)
return (0);
+ f->f_fsdata = NULL;
+
for (level = 0; level < EXT2_NIADDR; level++) {
if (fp->f_blk[level])
free(fp->f_blk[level]);
@@ -891,16 +892,17 @@
/*
* assume that a directory entry will not be split across blocks
*/
-again:
- if (fp->f_seekp >= fp->f_di.di_size)
- return (ENOENT);
- error = buf_read_file(f, &buf, &buf_size);
- if (error)
- return (error);
- ed = (struct ext2dirent *)buf;
- fp->f_seekp += ed->d_reclen;
- if (ed->d_ino == (ino_t)0)
- goto again;
+
+ do {
+ if (fp->f_seekp >= fp->f_di.di_size)
+ return (ENOENT);
+ error = buf_read_file(f, &buf, &buf_size);
+ if (error)
+ return (error);
+ ed = (struct ext2dirent *)buf;
+ fp->f_seekp += ed->d_reclen;
+ } while (ed->d_ino == (ino_t)0);
+
d->d_type = EXTFTODT(ed->d_type);
strncpy(d->d_name, ed->d_name, ed->d_namlen);
d->d_name[ed->d_namlen] = '\0';
Index: stand/libsa/in_cksum.c
===================================================================
--- stand/libsa/in_cksum.c
+++ stand/libsa/in_cksum.c
@@ -50,12 +50,10 @@
* In particular, it should not be this one.
*/
int
-in_cksum(p, len)
- void *p;
- int len;
+in_cksum(void *p, int len)
{
int sum = 0, oddbyte = 0, v = 0;
- u_char *cp = p;
+ u_char *cp = (u_char *)p;
/* we assume < 2^16 bytes being summed */
while (len > 0) {
@@ -63,7 +61,7 @@
sum += v + *cp++;
len--;
}
- if (((long)cp & 1) == 0) {
+ if (((intptr_t)cp & 1) == 0) {
while ((len -= 2) >= 0) {
sum += *(u_short *)cp;
cp += 2;
@@ -90,5 +88,5 @@
sum += v;
sum = (sum >> 16) + (sum & 0xffff); /* add in accumulated carries */
sum += sum >> 16; /* add potential last carry */
- return (0xffff & ~sum);
+ return (~sum & 0xffff);
}
Index: stand/libsa/inet_ntoa.c
===================================================================
--- stand/libsa/inet_ntoa.c
+++ stand/libsa/inet_ntoa.c
@@ -45,8 +45,7 @@
* to base 256 d.d.d.d representation.
*/
char *
-inet_ntoa(in)
- struct in_addr in;
+inet_ntoa(struct in_addr in)
{
static const char fmt[] = "%u.%u.%u.%u";
static char ret[sizeof "255.255.255.255"];
Index: stand/libsa/stand.h
===================================================================
--- stand/libsa/stand.h
+++ stand/libsa/stand.h
@@ -352,7 +352,7 @@
extern ev_unsethook_t env_nounset; /* refuse unset operation */
/* stdlib.h routines */
-extern int abs(int a);
+extern int abs(int a) __pure2;
extern void abort(void) __dead2;
extern long strtol(const char * __restrict, char ** __restrict, int);
extern long long strtoll(const char * __restrict, char ** __restrict, int);
Index: stand/libsa/stat.c
===================================================================
--- stand/libsa/stat.c
+++ stand/libsa/stat.c
@@ -37,9 +37,7 @@
#include "stand.h"
int
-stat(str, sb)
- const char *str;
- struct stat *sb;
+stat(const char *str, struct stat *sb)
{
int fd, rv;
Index: stand/libsa/strcasecmp.c
===================================================================
--- stand/libsa/strcasecmp.c
+++ stand/libsa/strcasecmp.c
@@ -39,34 +39,39 @@
#endif /* LIBC_SCCS and not lint */
int
-strcasecmp(s1, s2)
- const char *s1, *s2;
+strcasecmp(const char *s1, const char *s2)
{
- const u_char
- *us1 = (const u_char *)s1,
- *us2 = (const u_char *)s2;
+ const u_char *us1 = (const u_char *)s1,
+ *us2 = (const u_char *)s2;
- while (tolower(*us1) == tolower(*us2++))
- if (*us1++ == '\0')
+ u_char u1, u2;
+
+ while ((u1 = tolower(*us1)) == (u2 = tolower(*us2))) {
+ if (u1 == '\0') {
return (0);
- return (tolower(*us1) - tolower(*--us2));
+ }
+ us1++, us2++;
+ }
+ return (u1 - u2);
}
int
-strncasecmp(s1, s2, n)
- const char *s1, *s2;
- size_t n;
+strncasecmp(const char *s1, const char *s2, size_t n)
{
if (n != 0) {
- const u_char
- *us1 = (const u_char *)s1,
- *us2 = (const u_char *)s2;
+ const u_char *us1 = (const u_char *)s1,
+ *us2 = (const u_char *)s2;
+
+ u_char u1, u2;
do {
- if (tolower(*us1) != tolower(*us2++))
- return (tolower(*us1) - tolower(*--us2));
- if (*us1++ == '\0')
+ if ((u1 = tolower(*us1)) != (u2 = tolower(*us2))) {
+ return (u1 - u2);
+ }
+ if (u1 == '\0') {
break;
+ }
+ us1++, us2++;
} while (--n != 0);
}
return (0);
Index: stand/libsa/strdup.c
===================================================================
--- stand/libsa/strdup.c
+++ stand/libsa/strdup.c
@@ -39,17 +39,15 @@
#include <string.h>
char *
-strdup(str)
- const char *str;
+strdup(const char *str)
{
- size_t len;
char *copy = NULL;
+ size_t len;
if (str != NULL) {
- len = strlen(str) + 1;
- if ((copy = malloc(len)) == NULL)
- return (NULL);
- memcpy(copy, str, len);
+ len = strlen(str) + 1;
+ if ((copy = (char *)malloc(len)) != NULL)
+ memcpy(copy, str, len);
}
return (copy);
}
Index: stand/libsa/ufs.c
===================================================================
--- stand/libsa/ufs.c
+++ stand/libsa/ufs.c
@@ -150,9 +150,7 @@
* Read a new inode into a file structure.
*/
static int
-read_inode(inumber, f)
- ino_t inumber;
- struct open_file *f;
+read_inode(ino_t inumber, struct open_file *f)
{
struct file *fp = (struct file *)f->f_fsdata;
struct fs *fs = fp->f_fs;
@@ -207,10 +205,7 @@
* contains that block.
*/
static int
-block_map(f, file_block, disk_block_p)
- struct open_file *f;
- ufs2_daddr_t file_block;
- ufs2_daddr_t *disk_block_p; /* out */
+block_map(struct open_file *f, ufs2_daddr_t file_block, ufs2_daddr_t *disk_block_p) /* out */
{
struct file *fp = (struct file *)f->f_fsdata;
struct fs *fs = fp->f_fs;
@@ -312,10 +307,7 @@
* Write a portion of a file from an internal buffer.
*/
static int
-buf_write_file(f, buf_p, size_p)
- struct open_file *f;
- const char *buf_p;
- size_t *size_p; /* out */
+buf_write_file(struct open_file *f, const char *buf_p, size_t *size_p) /* out */
{
struct file *fp = (struct file *)f->f_fsdata;
struct fs *fs = fp->f_fs;
@@ -390,10 +382,7 @@
* the location in the buffer and the amount in the buffer.
*/
static int
-buf_read_file(f, buf_p, size_p)
- struct open_file *f;
- char **buf_p; /* out */
- size_t *size_p; /* out */
+buf_read_file(struct open_file *f, char **buf_p, size_t *size_p) /* out */
{
struct file *fp = (struct file *)f->f_fsdata;
struct fs *fs = fp->f_fs;
@@ -408,7 +397,7 @@
block_size = sblksize(fs, DIP(fp, di_size), file_block);
if (file_block != fp->f_buf_blkno) {
- if (fp->f_buf == (char *)0)
+ if (fp->f_buf == NULL)
fp->f_buf = malloc(fs->fs_bsize);
rc = block_map(f, file_block, &disk_block);
@@ -452,10 +441,7 @@
* i_number.
*/
static int
-search_directory(name, f, inumber_p)
- char *name;
- struct open_file *f;
- ino_t *inumber_p; /* out */
+search_directory(char *name, struct open_file *f, ino_t *inumber_p) /* out */
{
struct file *fp = (struct file *)f->f_fsdata;
struct direct *dp;
@@ -502,9 +488,7 @@
* Open a file.
*/
static int
-ufs_open(upath, f)
- const char *upath;
- struct open_file *f;
+ufs_open(const char *upath, struct open_file *f)
{
char *cp, *ncp;
int c;
@@ -711,8 +695,7 @@
}
static int
-ufs_close(f)
- struct open_file *f;
+ufs_close(struct open_file *f)
{
struct file *fp = (struct file *)f->f_fsdata;
int level;
@@ -741,11 +724,7 @@
* Cross block boundaries when necessary.
*/
static int
-ufs_read(f, start, size, resid)
- struct open_file *f;
- void *start;
- size_t size;
- size_t *resid; /* out */
+ufs_read(struct open_file *f, void *start, size_t size, size_t *resid) /* out */
{
struct file *fp = (struct file *)f->f_fsdata;
size_t csize;
@@ -815,10 +794,7 @@
}
static off_t
-ufs_seek(f, offset, where)
- struct open_file *f;
- off_t offset;
- int where;
+ufs_seek(struct open_file *f, off_t offset, int where)
{
struct file *fp = (struct file *)f->f_fsdata;
@@ -840,9 +816,7 @@
}
static int
-ufs_stat(f, sb)
- struct open_file *f;
- struct stat *sb;
+ufs_stat(struct open_file *f, struct stat *sb)
{
struct file *fp = (struct file *)f->f_fsdata;
@@ -880,16 +854,17 @@
/*
* assume that a directory entry will not be split across blocks
*/
-again:
- if (fp->f_seekp >= DIP(fp, di_size))
- return (ENOENT);
- error = buf_read_file(f, &buf, &buf_size);
- if (error)
- return (error);
- dp = (struct direct *)buf;
- fp->f_seekp += dp->d_reclen;
- if (dp->d_ino == (ino_t)0)
- goto again;
+
+ do {
+ if (fp->f_seekp >= DIP(fp, di_size))
+ return (ENOENT);
+ error = buf_read_file(f, &buf, &buf_size);
+ if (error)
+ return (error);
+ dp = (struct direct *)buf;
+ fp->f_seekp += dp->d_reclen;
+ } while (dp->d_ino == (ino_t)0);
+
d->d_type = dp->d_type;
strcpy(d->d_name, dp->d_name);
return (0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 2, 1:25 AM (11 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28369733
Default Alt Text
D31663.id.diff (9 KB)
Attached To
Mode
D31663: [libsa][NFC] ANSI libsa functions
Attached
Detach File
Event Timeline
Log In to Comment