Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_descrip.c
Show First 20 Lines • Show All 3,502 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct kinfo_file *kif; | struct kinfo_file *kif; | ||||
kif = &efbuf->kif; | kif = &efbuf->kif; | ||||
if (efbuf->remainder != -1) { | if (efbuf->remainder != -1) { | ||||
if (efbuf->remainder < kif->kf_structsize) { | if (efbuf->remainder < kif->kf_structsize) { | ||||
/* Terminate export. */ | /* Terminate export. */ | ||||
efbuf->remainder = 0; | efbuf->remainder = 0; | ||||
return (0); | return (ENOMEM); | ||||
} | } | ||||
efbuf->remainder -= kif->kf_structsize; | efbuf->remainder -= kif->kf_structsize; | ||||
} | } | ||||
return (sbuf_bcat(efbuf->sb, kif, kif->kf_structsize) == 0 ? 0 : ENOMEM); | return (sbuf_bcat(efbuf->sb, kif, kif->kf_structsize) == 0 ? 0 : | ||||
sbuf_error(sb)); | |||||
cem: Is the ordering of sbuf_bcat() -> sbuf_error() well-defined as used here? Or should this be an… | |||||
markjAuthorUnsubmitted Not Done Inline ActionsThe "?" operator is a sequence point, i.e., the first expression must be evaluated before the ones following "?". markj: The "?" operator is a sequence point, i.e., the first expression must be evaluated before the… | |||||
cemUnsubmitted Done Inline ActionsI think I'd still prefer if/else for clarity. It doesn't fit in a single line anymore anyways. cem: I think I'd still prefer if/else for clarity. It doesn't fit in a single line anymore anyways. | |||||
markjAuthorUnsubmitted Not Done Inline ActionsOk. It didn't fit before either (> 80 cols). markj: Ok. It didn't fit before either (> 80 cols). | |||||
cemUnsubmitted Not Done Inline ActionsHeh, oops :-) cem: Heh, oops :-) | |||||
} | } | ||||
static int | static int | ||||
export_file_to_sb(struct file *fp, int fd, cap_rights_t *rightsp, | export_file_to_sb(struct file *fp, int fd, cap_rights_t *rightsp, | ||||
struct export_fd_buf *efbuf) | struct export_fd_buf *efbuf) | ||||
{ | { | ||||
int error; | int error; | ||||
if (efbuf->remainder == 0) | if (efbuf->remainder == 0) | ||||
return (0); | return (ENOMEM); | ||||
export_file_to_kinfo(fp, fd, rightsp, &efbuf->kif, efbuf->fdp, | export_file_to_kinfo(fp, fd, rightsp, &efbuf->kif, efbuf->fdp, | ||||
efbuf->flags); | efbuf->flags); | ||||
FILEDESC_SUNLOCK(efbuf->fdp); | FILEDESC_SUNLOCK(efbuf->fdp); | ||||
error = export_kinfo_to_sb(efbuf); | error = export_kinfo_to_sb(efbuf); | ||||
FILEDESC_SLOCK(efbuf->fdp); | FILEDESC_SLOCK(efbuf->fdp); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
export_vnode_to_sb(struct vnode *vp, int fd, int fflags, | export_vnode_to_sb(struct vnode *vp, int fd, int fflags, | ||||
struct export_fd_buf *efbuf) | struct export_fd_buf *efbuf) | ||||
{ | { | ||||
int error; | int error; | ||||
if (efbuf->remainder == 0) | if (efbuf->remainder == 0) | ||||
return (0); | return (ENOMEM); | ||||
if (efbuf->fdp != NULL) | if (efbuf->fdp != NULL) | ||||
FILEDESC_SUNLOCK(efbuf->fdp); | FILEDESC_SUNLOCK(efbuf->fdp); | ||||
export_vnode_to_kinfo(vp, fd, fflags, &efbuf->kif, efbuf->flags); | export_vnode_to_kinfo(vp, fd, fflags, &efbuf->kif, efbuf->flags); | ||||
error = export_kinfo_to_sb(efbuf); | error = export_kinfo_to_sb(efbuf); | ||||
if (efbuf->fdp != NULL) | if (efbuf->fdp != NULL) | ||||
FILEDESC_SLOCK(efbuf->fdp); | FILEDESC_SLOCK(efbuf->fdp); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 700 Lines • Show Last 20 Lines |
Is the ordering of sbuf_bcat() -> sbuf_error() well-defined as used here? Or should this be an if()/else?