Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/smbfs some KNF, add a KASSERT() for smbfs_findnextLM1...
details: https://anonhg.NetBSD.org/src/rev/e2b5acd13976
branches: trunk
changeset: 543284:e2b5acd13976
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Fri Feb 21 20:15:01 2003 +0000
description:
some KNF, add a KASSERT() for smbfs_findnextLM1() case
replace some 'never should happen' printfs with KASSERTs
diffstat:
sys/fs/smbfs/smbfs_smb.c | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)
diffs (93 lines):
diff -r a7e2e8cd72ee -r e2b5acd13976 sys/fs/smbfs/smbfs_smb.c
--- a/sys/fs/smbfs/smbfs_smb.c Fri Feb 21 20:13:21 2003 +0000
+++ b/sys/fs/smbfs/smbfs_smb.c Fri Feb 21 20:15:01 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smbfs_smb.c,v 1.5 2003/02/19 13:51:24 jdolecek Exp $ */
+/* $NetBSD: smbfs_smb.c,v 1.6 2003/02/21 20:15:01 jdolecek Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@@ -883,12 +883,13 @@
md_get_uint16le(mbp, &time);
md_get_uint16le(mbp, &date);
md_get_uint32le(mbp, &size);
+ KASSERT(ctx->f_name == ctx->f_fname);
cp = ctx->f_name;
md_get_mem(mbp, cp, sizeof(ctx->f_fname), MB_MSYSTEM);
- cp[sizeof(ctx->f_fname) - 1] = 0;
+ cp[sizeof(ctx->f_fname) - 1] = '\0';
cp += strlen(cp) - 1;
- while (*cp == ' ' && cp >= ctx->f_name)
- *cp-- = 0;
+ while(*cp == ' ' && cp > ctx->f_name)
+ *cp-- = '\0';
ctx->f_attr.fa_attr = battr;
smb_dos2unixtime(date, time, 0, rqp->sr_vc->vc_sopt.sv_tz,
&ctx->f_attr.fa_mtime);
@@ -1004,14 +1005,10 @@
return ENOENT;
ctx->f_rnameofs = tw;
mdp = &t2p->t2_rdata;
- if (mdp->md_top == NULL) {
- printf("bug: ecnt = %d, but data is NULL (please report)\n", ctx->f_ecnt);
- return ENOENT;
- }
- if (mdp->md_top->m_len == 0) {
- printf("bug: ecnt = %d, but m_len = 0 and m_next = %p (please report)\n", ctx->f_ecnt,mbp->mb_top->m_next);
- return ENOENT;
- }
+
+ KASSERT(mdp->md_top != NULL);
+ KASSERT(mdp->md_top->m_len != 0);
+
ctx->f_eofs = 0;
return 0;
}
@@ -1076,7 +1073,7 @@
mbp = &t2p->t2_rdata;
svtz = SSTOVC(ctx->f_ssp)->vc_sopt.sv_tz;
switch (ctx->f_infolevel) {
- case SMB_INFO_STANDARD:
+ case SMB_INFO_STANDARD:
next = 0;
fxsz = 0;
md_get_uint16le(mbp, &date);
@@ -1097,7 +1094,7 @@
fxsz = 23;
recsz = next = 24 + nmlen; /* docs misses zero byte at end */
break;
- case SMB_FIND_FILE_DIRECTORY_INFO:
+ case SMB_FIND_FILE_DIRECTORY_INFO:
md_get_uint32le(mbp, &next);
md_get_uint32(mbp, NULL); /* file index */
md_get_int64(mbp, NULL); /* creation time */
@@ -1116,7 +1113,7 @@
fxsz = 64;
recsz = next ? next : fxsz + size;
break;
- default:
+ default:
SMBERROR("unexpected info level %d\n", ctx->f_infolevel);
return EINVAL;
}
@@ -1181,10 +1178,7 @@
struct smbfs_fctx *ctx;
int error;
- ctx = malloc(sizeof(*ctx), M_SMBFSDATA, M_WAITOK);
- if (ctx == NULL)
- return ENOMEM;
- bzero(ctx, sizeof(*ctx));
+ ctx = malloc(sizeof(*ctx), M_SMBFSDATA, M_WAITOK|M_ZERO);
ctx->f_ssp = dnp->n_mount->sm_share;
ctx->f_dnp = dnp;
ctx->f_flags = SMBFS_RDD_FINDFIRST;
@@ -1219,6 +1213,8 @@
error = smbfs_findnextLM2(ctx, limit);
if (error)
return error;
+
+ /* Skip '.' and '..' */
if ((ctx->f_nmlen == 1 && ctx->f_name[0] == '.') ||
(ctx->f_nmlen == 2 && ctx->f_name[0] == '.' &&
ctx->f_name[1] == '.'))
Home |
Main Index |
Thread Index |
Old Index