summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-06-19 12:18:51 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-06-19 12:18:51 +0000
commit6040a68c1ef27209fe7cd5dfd799ddfa5f11a701 (patch)
tree5ac8fef7a57586e8ebcbfe6013e47a96f9f26ce2
parent4227bcffd4e1abf8a3987dbe0f649d7cc7ea4940 (diff)
parentae7ff7d6ac239648a2579a0de5a0a1be3d4e10e6 (diff)
downloadillumos-joyent-6040a68c1ef27209fe7cd5dfd799ddfa5f11a701.tar.gz
[illumos-gate merge]
commit ae7ff7d6ac239648a2579a0de5a0a1be3d4e10e6 11118 libhotplug: NULL pointer errors commit dd6458550ab2996163712b25c080615392bf94d2 11117 libzfs_core: NULL pointer errors commit 281eb3a97ad0e298603325ba7c56d0222aaa5ac3 11114 libsecdb: NULL pointer errors commit d5fa36a7366530f78b3c5d1cd4c4a40085383b9f 11110 crle: NULL pointer errors commit e2294b844b9f4bfc375e88fd1260d9a39ffc82e1 11103 link_audit: NULL pointer errors commit 430c2cddc92582fc7155aaf65c78f0919d7081c1 6474 getupeercred causes spurious event port wakeups on FIFOs commit 5f5c35baa7f18214d2cd9ec105270892288f8497 11100 liblddbg: NULL pointer errors commit 344db6f401efe76f7e1d4f4c1a644ae593910219 11092 libnsl: NULL pointer errors commit e86c3f00315e5838c0ec0b14f34b94c292085956 11091 libc: NULL pointer errors commit ad24f9fb30ac1431734347d46a592d22cbfcf3b6 11081 liblddbg: comparison between pointer and integer commit 0362cabb4921eb6283a19fb680876f50907fda08 11115 libdisasm: NULL pointer errors commit 9a34674dce796d46567833216389d6d430925bb2 11182 loader: Distinguish between "no partition" and "choose best partition" with a constant. commit a8412dc108558a7a3635b7ab4f3b1b743bdff9e8 11074 loader: mod_loadkld() error: we previously assumed 'last_file' could be null commit 535ff4fc926c4df67c4665a72c71724810962d4f 11047 zmod: make sure we use zmemcpy and friends commit e207f0de2012ff5024160daa7e6e3cf11d04f2dc 11111 lex: NULL pointer errors
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/lib/libstand/zfs/zfs.c2
-rw-r--r--usr/src/boot/sys/boot/common/disk.c92
-rw-r--r--usr/src/boot/sys/boot/common/disk.h31
-rw-r--r--usr/src/boot/sys/boot/common/module.c36
-rw-r--r--usr/src/boot/sys/boot/efi/libefi/efipart.c4
-rw-r--r--usr/src/boot/sys/boot/efi/loader/main.c6
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/biosdisk.c8
-rw-r--r--usr/src/boot/sys/boot/uboot/common/main.c43
-rw-r--r--usr/src/boot/sys/boot/uboot/lib/disk.c4
-rw-r--r--usr/src/boot/sys/boot/usb/storage/umass_loader.c4
-rw-r--r--usr/src/boot/sys/boot/userboot/userboot/main.c8
-rw-r--r--usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c4
-rw-r--r--usr/src/cmd/sgs/crle/common/print.c4
-rw-r--r--usr/src/cmd/sgs/lex/common/ldefs.h8
-rw-r--r--usr/src/cmd/sgs/lex/common/sub1.c40
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/debug.c4
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/statistics.c2
-rw-r--r--usr/src/cmd/sgs/link_audit/common/bindings.c2
-rw-r--r--usr/src/cmd/sgs/link_audit/common/hash.c2
-rw-r--r--usr/src/contrib/zlib/zconf.h4
-rw-r--r--usr/src/contrib/zlib/zutil.c2
-rw-r--r--usr/src/lib/libc/i386/crt/_rtld.c2
-rw-r--r--usr/src/lib/libc/port/gen/_xftw.c4
-rw-r--r--usr/src/lib/libc/port/gen/catopen.c8
-rw-r--r--usr/src/lib/libc/port/gen/crypt.c4
-rw-r--r--usr/src/lib/libc/port/gen/event_port.c10
-rw-r--r--usr/src/lib/libc/port/gen/fmtmsg.c6
-rw-r--r--usr/src/lib/libc/port/gen/getopt.c4
-rw-r--r--usr/src/lib/libc/port/gen/getutx.c2
-rw-r--r--usr/src/lib/libc/port/gen/mkstemp.c2
-rw-r--r--usr/src/lib/libc/port/gen/plock.c8
-rw-r--r--usr/src/lib/libc/port/gen/ttyname.c2
-rw-r--r--usr/src/lib/libc/port/inet/inet_network.c2
-rw-r--r--usr/src/lib/libc/port/locale/strptime.c2
-rw-r--r--usr/src/lib/libc/port/print/doprnt.c2
-rw-r--r--usr/src/lib/libc/port/rt/mqueue.c8
-rw-r--r--usr/src/lib/libc/port/threads/tdb_agent.c4
-rw-r--r--usr/src/lib/libc/port/threads/thr.c12
-rw-r--r--usr/src/lib/libc/sparc/crt/_rtld.c2
-rw-r--r--usr/src/lib/libdisasm/common/dis_sparc.c2
-rw-r--r--usr/src/lib/libhotplug/common/libhotplug.c6
-rw-r--r--usr/src/lib/libnsl/dial/interface.c6
-rw-r--r--usr/src/lib/libnsl/netselect/netselect.c2
-rw-r--r--usr/src/lib/libnsl/nss/getexecattr.c2
-rw-r--r--usr/src/lib/libnsl/nss/parse.c4
-rw-r--r--usr/src/lib/libnsl/rpc/clnt_generic.c6
-rw-r--r--usr/src/lib/libnsl/rpc/clnt_simple.c4
-rw-r--r--usr/src/lib/libnsl/rpc/netname.c2
-rw-r--r--usr/src/lib/libnsl/rpc/rpc_generic.c6
-rw-r--r--usr/src/lib/libnsl/rpc/rpcb_clnt.c4
-rw-r--r--usr/src/lib/libsecdb/common/chkauthattr.c4
-rw-r--r--usr/src/lib/libsecdb/common/secdb.c4
-rw-r--r--usr/src/lib/libzfs_core/common/libzfs_core.c20
-rw-r--r--usr/src/uts/common/fs/fifofs/fifovnops.c40
55 files changed, 283 insertions, 225 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index 5febd80a06..ff8cecbbf6 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2019.05.17.1
+BOOT_VERSION = $(LOADER_VERSION)-2019.05.29.1
diff --git a/usr/src/boot/lib/libstand/zfs/zfs.c b/usr/src/boot/lib/libstand/zfs/zfs.c
index 471fd6b32f..77ec5dbbad 100644
--- a/usr/src/boot/lib/libstand/zfs/zfs.c
+++ b/usr/src/boot/lib/libstand/zfs/zfs.c
@@ -543,7 +543,7 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid)
int slice = dev->d_slice;
free(dev);
- if (partition != -1 && slice != -1) {
+ if (partition != D_PARTNONE && slice != D_SLICENONE) {
ret = zfs_probe(pa.fd, pool_guid);
if (ret == 0)
return (0);
diff --git a/usr/src/boot/sys/boot/common/disk.c b/usr/src/boot/sys/boot/common/disk.c
index f77e4a3a93..08912cc4e1 100644
--- a/usr/src/boot/sys/boot/common/disk.c
+++ b/usr/src/boot/sys/boot/common/disk.c
@@ -140,7 +140,7 @@ ptable_print(void *arg, const char *pname, const struct ptable_entry *part)
dev.dd.d_dev = pa->dev->dd.d_dev;
dev.dd.d_unit = pa->dev->dd.d_unit;
dev.d_slice = part->index;
- dev.d_partition = -1;
+ dev.d_partition = D_PARTNONE;
if (disk_open(&dev, partsize, sectsize) == 0) {
table = ptable_open(&dev, partsize, sectsize, ptblread);
if (table != NULL) {
@@ -227,6 +227,7 @@ disk_ioctl(struct disk_devdesc *dev, unsigned long cmd, void *data)
int
disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
{
+ struct disk_devdesc partdev;
struct open_disk *od;
struct ptable *table;
struct ptable_entry part;
@@ -237,14 +238,6 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
return (ENXIO);
}
rc = 0;
- /*
- * While we are reading disk metadata, make sure we do it relative
- * to the start of the disk
- */
- dev->d_offset = 0;
- table = NULL;
- slice = dev->d_slice;
- partition = dev->d_partition;
od = (struct open_disk *)malloc(sizeof (struct open_disk));
if (od == NULL) {
DPRINTF("no memory");
@@ -254,11 +247,25 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
od->entrysize = 0;
od->mediasize = mediasize;
od->sectorsize = sectorsize;
+ /*
+ * While we are reading disk metadata, make sure we do it relative
+ * to the start of the disk
+ */
+ memcpy(&partdev, dev, sizeof(partdev));
+ partdev.d_offset = 0;
+ partdev.d_slice = D_SLICENONE;
+ partdev.d_partition = D_PARTNONE;
+
+ dev->d_offset = 0;
+ table = NULL;
+ slice = dev->d_slice;
+ partition = dev->d_partition;
+
DPRINTF("%s unit %d, slice %d, partition %d => %p", disk_fmtdev(dev),
dev->dd.d_unit, dev->d_slice, dev->d_partition, od);
/* Determine disk layout. */
- od->table = ptable_open(dev, mediasize / sectorsize, sectorsize,
+ od->table = ptable_open(&partdev, mediasize / sectorsize, sectorsize,
ptblread);
if (od->table == NULL) {
DPRINTF("Can't read partition table");
@@ -272,7 +279,8 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
}
od->mediasize = mediasize;
- if (ptable_gettype(od->table) == PTABLE_BSD &&
+ if ((ptable_gettype(od->table) == PTABLE_BSD ||
+ ptable_gettype(od->table) == PTABLE_VTOC) &&
partition >= 0) {
/* It doesn't matter what value has d_slice */
rc = ptable_getpart(od->table, &part, partition);
@@ -295,24 +303,38 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
od->entrysize = part.end - part.start + 1;
slice = part.index;
if (ptable_gettype(od->table) == PTABLE_GPT) {
- partition = 255;
+ partition = D_PARTISGPT;
goto out; /* Nothing more to do */
- } else if (partition == 255) {
+ } else if (partition == D_PARTISGPT) {
/*
* When we try to open GPT partition, but partition
- * table isn't GPT, reset d_partition value to -1
- * and try to autodetect appropriate value.
+ * table isn't GPT, reset partition value to
+ * D_PARTWILD and try to autodetect appropriate value.
*/
- partition = -1;
+ partition = D_PARTWILD;
}
+
/*
- * If d_partition < 0 and we are looking at a BSD/VTOC slice,
- * then try to read label, otherwise return the
- * whole MBR slice.
+ * If partition is D_PARTNONE, then disk_open() was called
+ * to open raw MBR slice.
*/
- if (partition == -1 &&
- (part.type != PART_FREEBSD || part.type != PART_SOLARIS2))
+ if (partition == D_PARTNONE)
goto out;
+
+ /*
+ * If partition is D_PARTWILD and we are looking at a
+ * BSD/VTOC slice, then try to read label, otherwise return
+ * the whole MBR slice.
+ */
+ if (partition == D_PARTWILD) {
+ switch (part.type) {
+ case PART_FREEBSD:
+ case PART_SOLARIS2:
+ break;
+ default:
+ goto out;
+ }
+ }
/* Try to read label */
table = ptable_open(dev, part.end - part.start + 1,
od->sectorsize, ptblread);
@@ -322,12 +344,12 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
goto out;
}
/*
- * If slice contains BSD/VTOC label and d_partition < 0, then
+ * If slice contains BSD/VTOC label and partition < 0, then
* assume the 'a' partition. Otherwise just return the
* whole MBR slice, because it can contain ZFS.
*/
if (partition < 0) {
- if (ptable_gettype(table) != PTABLE_BSD ||
+ if (ptable_gettype(table) != PTABLE_BSD &&
ptable_gettype(table) != PTABLE_VTOC)
goto out;
partition = 0;
@@ -376,9 +398,9 @@ disk_fmtdev(struct disk_devdesc *dev)
char *cp;
cp = buf + sprintf(buf, "%s%d", dev->dd.d_dev->dv_name, dev->dd.d_unit);
- if (dev->d_slice >= 0) {
+ if (dev->d_slice > D_SLICENONE) {
#ifdef LOADER_GPT_SUPPORT
- if (dev->d_partition == 255) {
+ if (dev->d_partition == D_PARTISGPT) {
sprintf(cp, "p%d:", dev->d_slice);
return (buf);
} else
@@ -387,7 +409,7 @@ disk_fmtdev(struct disk_devdesc *dev)
cp += sprintf(cp, "s%d", dev->d_slice);
#endif
}
- if (dev->d_partition >= 0)
+ if (dev->d_partition > D_PARTNONE)
cp += sprintf(cp, "%c", dev->d_partition + 'a');
strcat(cp, ":");
return (buf);
@@ -401,7 +423,21 @@ disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path)
char *cp;
np = devspec;
- unit = slice = partition = -1;
+ unit = -1;
+ /*
+ * If there is path/file info after the device info, then any missing
+ * slice or partition info should be considered a request to search for
+ * an appropriate partition. Otherwise we want to open the raw device
+ * itself and not try to fill in missing info by searching.
+ */
+ if ((cp = strchr(np, ':')) != NULL && cp[1] != '\0') {
+ slice = D_SLICEWILD;
+ partition = D_PARTWILD;
+ } else {
+ slice = D_SLICENONE;
+ partition = D_PARTNONE;
+ }
+
if (*np != '\0' && *np != ':') {
unit = strtol(np, &cp, 10);
if (cp == np)
@@ -415,7 +451,7 @@ disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path)
/* we don't support nested partitions on GPT */
if (*cp != '\0' && *cp != ':')
return (EINVAL);
- partition = 255;
+ partition = D_PARTISGPT;
} else
#endif
#ifdef LOADER_MBR_SUPPORT
diff --git a/usr/src/boot/sys/boot/common/disk.h b/usr/src/boot/sys/boot/common/disk.h
index cfdfbf4a95..81d002314f 100644
--- a/usr/src/boot/sys/boot/common/disk.h
+++ b/usr/src/boot/sys/boot/common/disk.h
@@ -30,37 +30,40 @@
*
* Whole disk access:
*
- * d_slice = -1
- * d_partition = -1
+ * d_slice = D_SLICENONE
+ * d_partition = <doesn't matter>
*
* Whole MBR slice:
*
* d_slice = MBR slice number (typically 1..4)
- * d_partition = -1
+ * d_partition = D_PARTNONE
*
* VTOC disklabel partition within an MBR slice:
*
* d_slice = MBR slice number (typically 1..4)
- * d_partition = disklabel partition (typically 0..19)
+ * d_partition = disklabel partition (typically 0..19 or D_PARTWILD)
*
* BSD disklabel partition within an MBR slice:
*
* d_slice = MBR slice number (typically 1..4)
- * d_partition = disklabel partition (typically 0..19)
+ * d_partition = disklabel partition (typically 0..19 or D_PARTWILD)
*
* BSD disklabel partition on the true dedicated disk:
*
- * d_slice = -1
- * d_partition = disklabel partition (typically 0..19)
+ * d_slice = D_SLICENONE
+ * d_partition = disklabel partition (typically 0..19 or D_PARTWILD)
*
* GPT partition:
*
* d_slice = GPT partition number (typically 1..N)
- * d_partition = 255
+ * d_partition = D_PARTISGPT
*
- * For both MBR and GPT, to automatically find the 'best' slice or partition,
- * set d_slice to zero. This uses the partition type to decide which partition
- * to use according to the following list of preferences:
+ * For MBR, setting d_partition to D_PARTWILD will automatically use the first
+ * partition within the slice.
+ *
+ * For both MBR and GPT, to automatically find the 'best' slice and partition,
+ * set d_slice to D_SLICEWILD. This uses the partition type to decide which
+ * partition to use according to the following list of preferences:
*
* Solaris2 (active)
* Solaris2 (inactive)
@@ -84,6 +87,12 @@
#ifndef _DISK_H
#define _DISK_H
+#define D_SLICENONE -1
+#define D_SLICEWILD 0
+#define D_PARTNONE -1
+#define D_PARTWILD -2
+#define D_PARTISGPT 255
+
struct disk_devdesc {
struct devdesc dd; /* Must be first. */
int d_slice;
diff --git a/usr/src/boot/sys/boot/common/module.c b/usr/src/boot/sys/boot/common/module.c
index ab16b6b8a4..ca4090fc24 100644
--- a/usr/src/boot/sys/boot/common/module.c
+++ b/usr/src/boot/sys/boot/common/module.c
@@ -68,6 +68,7 @@ static struct kernel_module *file_findmodule(struct preloaded_file *, char *,
static int file_havepath(const char *);
static char *mod_searchmodule(char *, struct mod_depend *);
static void file_insert_tail(struct preloaded_file *);
+static void file_remove(struct preloaded_file *);
struct file_metadata *metadata_next(struct file_metadata *, int);
static void moduledir_readhints(struct moduledir *);
static void moduledir_rebuild(void);
@@ -763,9 +764,10 @@ mod_load(char *modname, struct mod_depend *verinfo, int argc, char *argv[])
int
mod_loadkld(const char *kldname, int argc, char *argv[])
{
- struct preloaded_file *fp, *last_file;
+ struct preloaded_file *fp;
int err;
char *filename;
+ vm_offset_t loadaddr_saved;
/*
* Get fully qualified KLD name
@@ -786,22 +788,19 @@ mod_loadkld(const char *kldname, int argc, char *argv[])
free(filename);
return (0);
}
- for (last_file = preloaded_files;
- last_file != NULL && last_file->f_next != NULL;
- last_file = last_file->f_next)
- ;
do {
err = file_load(filename, loadaddr, &fp);
if (err)
break;
fp->f_args = unargv(argc, argv);
+ loadaddr_saved = loadaddr;
loadaddr = fp->f_addr + fp->f_size;
file_insert_tail(fp); /* Add to the list of loaded files */
if (file_load_dependencies(fp) != 0) {
err = ENOENT;
- last_file->f_next = NULL;
- loadaddr = last_file->f_addr + last_file->f_size;
+ file_remove(fp);
+ loadaddr = loadaddr_saved;
fp = NULL;
break;
}
@@ -1205,6 +1204,29 @@ file_insert_tail(struct preloaded_file *fp)
}
}
+/*
+ * Remove module from the chain
+ */
+static void
+file_remove(struct preloaded_file *fp)
+{
+ struct preloaded_file *cm;
+
+ if (preloaded_files == NULL)
+ return;
+
+ if (preloaded_files == fp) {
+ preloaded_files = fp->f_next;
+ return;
+ }
+ for (cm = preloaded_files; cm->f_next != NULL; cm = cm->f_next) {
+ if (cm->f_next == fp) {
+ cm->f_next = fp->f_next;
+ return;
+ }
+ }
+}
+
static char *
moduledir_fullpath(struct moduledir *mdp, const char *fname)
{
diff --git a/usr/src/boot/sys/boot/efi/libefi/efipart.c b/usr/src/boot/sys/boot/efi/libefi/efipart.c
index 7a277d3c07..1af5f9dcf4 100644
--- a/usr/src/boot/sys/boot/efi/libefi/efipart.c
+++ b/usr/src/boot/sys/boot/efi/libefi/efipart.c
@@ -794,8 +794,8 @@ efipart_print_common(struct devsw *dev, pdinfo_list_t *pdlist, int verbose)
pd->pd_blkio = blkio;
pd_dev.dd.d_dev = dev;
pd_dev.dd.d_unit = pd->pd_unit;
- pd_dev.d_slice = -1;
- pd_dev.d_partition = -1;
+ pd_dev.d_slice = D_SLICENONE;
+ pd_dev.d_partition = D_PARTNONE;
ret = disk_open(&pd_dev, blkio->Media->BlockSize *
(blkio->Media->LastBlock + 1),
blkio->Media->BlockSize);
diff --git a/usr/src/boot/sys/boot/efi/loader/main.c b/usr/src/boot/sys/boot/efi/loader/main.c
index 2cb24357af..0c01a85fe3 100644
--- a/usr/src/boot/sys/boot/efi/loader/main.c
+++ b/usr/src/boot/sys/boot/efi/loader/main.c
@@ -269,12 +269,12 @@ set_currdev_pdinfo(pdinfo_t *dp)
currdev.dd.d_dev = dp->pd_devsw;
if (dp->pd_parent == NULL) {
currdev.dd.d_unit = dp->pd_unit;
- currdev.d_slice = -1;
- currdev.d_partition = -1;
+ currdev.d_slice = D_SLICENONE;
+ currdev.d_partition = D_PARTNONE;
} else {
currdev.dd.d_unit = dp->pd_parent->pd_unit;
currdev.d_slice = dp->pd_unit;
- currdev.d_partition = 255; /* Assumes GPT */
+ currdev.d_partition = D_PARTISGPT; /* Assumes GPT */
}
set_currdev_devdesc((struct devdesc *)&currdev);
} else {
diff --git a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
index 0b8e90c4d7..e1259509ad 100644
--- a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
+++ b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
@@ -686,8 +686,8 @@ bd_print_common(struct devsw *dev, bdinfo_list_t *bdi, int verbose)
devd.dd.d_dev = dev;
devd.dd.d_unit = i;
- devd.d_slice = -1;
- devd.d_partition = -1;
+ devd.d_slice = D_SLICENONE;
+ devd.d_partition = D_PARTNONE;
if (disk_open(&devd,
bd->bd_sectorsize * bd->bd_sectors,
bd->bd_sectorsize) == 0) {
@@ -740,8 +740,8 @@ bd_disk_get_sectors(struct disk_devdesc *dev)
disk.dd.d_dev = dev->dd.d_dev;
disk.dd.d_unit = dev->dd.d_unit;
- disk.d_slice = -1;
- disk.d_partition = -1;
+ disk.d_slice = D_SLICENONE;
+ disk.d_partition = D_PARTNONE;
disk.d_offset = 0;
size = bd->bd_sectors * bd->bd_sectorsize;
diff --git a/usr/src/boot/sys/boot/uboot/common/main.c b/usr/src/boot/sys/boot/uboot/common/main.c
index 704a5a8708..841f2b560d 100644
--- a/usr/src/boot/sys/boot/uboot/common/main.c
+++ b/usr/src/boot/sys/boot/uboot/common/main.c
@@ -197,10 +197,10 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
const char *p;
char *endp;
- *type = -1;
+ *type = DEV_TYP_NONE;
*unit = -1;
- *slice = 0;
- *partition = -1;
+ *slice = D_SLICEWILD;
+ *partition = D_PARTWILD;
devstr = ub_env_get("loaderdev");
if (devstr == NULL) {
@@ -222,7 +222,7 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
/* Malformed unit number. */
if (!isdigit(*p)) {
- *type = -1;
+ *type = DEV_TYP_NONE;
return;
}
@@ -237,7 +237,7 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
/* Device string is malformed beyond unit number. */
if (*p != ':') {
- *type = -1;
+ *type = DEV_TYP_NONE;
*unit = -1;
return;
}
@@ -250,7 +250,7 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
/* Only DEV_TYP_STOR devices can have a slice specification. */
if (!(*type & DEV_TYP_STOR)) {
- *type = -1;
+ *type = DEV_TYP_NONE;
*unit = -1;
return;
}
@@ -259,9 +259,9 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
/* Malformed slice number. */
if (p == endp) {
- *type = -1;
+ *type = DEV_TYP_NONE;
*unit = -1;
- *slice = 0;
+ *slice = D_SLICEWILD;
return;
}
@@ -273,9 +273,9 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
/* Device string is malformed beyond slice number. */
if (*p != '.') {
- *type = -1;
+ *type = DEV_TYP_NONE;
*unit = -1;
- *slice = 0;
+ *slice = D_SLICEWILD;
return;
}
@@ -293,10 +293,10 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
return;
/* Junk beyond partition number. */
- *type = -1;
+ *type = DEV_TYP_NONE;
*unit = -1;
- *slice = 0;
- *partition = -1;
+ *slice = D_SLICEWILD;
+ *partition = D_PARTWILD;
}
static void
@@ -305,15 +305,22 @@ print_disk_probe_info()
char slice[32];
char partition[32];
- if (currdev.d_disk.slice > 0)
- sprintf(slice, "%d", currdev.d_disk.slice);
+ if (currdev.d_disk.slice == D_SLICENONE)
+ strlcpy(slice, "<none>", sizeof(slice));
+ else if (currdev.d_disk.d_slice == D_SLICEWILD)
+ strlcpy(slice, "<auto>", sizeof(slice));
else
- strcpy(slice, "<auto>");
+ snprintf(slice, sizeof(slice), "%d", currdev.d_disk.d_slice);
- if (currdev.d_disk.partition >= 0)
+ if (currdev.d_disk.partition == D_PARTNONE)
+ strlcpy(partition, "<none>", sizeof(partition));
+ else if (currdev.d_disk.d_partition == D_PARTWILD)
+ strlcpy(partition, "<auto>", sizeof(partition));
+ else
sprintf(partition, "%d", currdev.d_disk.partition);
else
- strcpy(partition, "<auto>");
+ snprintf(partition, sizeof(partition), "%d",
+ currdev.d_disk.d_partition);
printf(" Checking unit=%d slice=%s partition=%s...",
currdev.dd.d_unit, slice, partition);
diff --git a/usr/src/boot/sys/boot/uboot/lib/disk.c b/usr/src/boot/sys/boot/uboot/lib/disk.c
index c2c625ee9a..088101aab6 100644
--- a/usr/src/boot/sys/boot/uboot/lib/disk.c
+++ b/usr/src/boot/sys/boot/uboot/lib/disk.c
@@ -253,8 +253,8 @@ stor_print(int verbose)
for (i = 0; i < stor_info_no; i++) {
dev.dd.d_dev = &uboot_storage;
dev.dd.d_unit = i;
- dev.d_slice = -1;
- dev.d_partition = -1;
+ dev.d_slice = D_SLICENONE;
+ dev.d_partition = D_PARTNONE;
sprintf(line, "\tdisk%d (%s)\n", i,
ub_stor_type(SI(&dev).type));
pager_output(line);
diff --git a/usr/src/boot/sys/boot/usb/storage/umass_loader.c b/usr/src/boot/sys/boot/usb/storage/umass_loader.c
index 963e00b61b..cb9d632ebe 100644
--- a/usr/src/boot/sys/boot/usb/storage/umass_loader.c
+++ b/usr/src/boot/sys/boot/usb/storage/umass_loader.c
@@ -184,8 +184,8 @@ umass_disk_print(int verbose)
pager_output(" umass0 UMASS device\n");
dev.d_dev = &umass_disk;
dev.d_unit = 0;
- dev.d_slice = -1;
- dev.d_partition = -1;
+ dev.d_slice = D_SLICENONE;
+ dev.d_partition = D_PARTNONE;
if (umass_disk_open_sub(&dev) == 0) {
disk_print(&dev, " umass0", verbose);
diff --git a/usr/src/boot/sys/boot/userboot/userboot/main.c b/usr/src/boot/sys/boot/userboot/userboot/main.c
index cb8d87ec59..7fa4331e36 100644
--- a/usr/src/boot/sys/boot/userboot/userboot/main.c
+++ b/usr/src/boot/sys/boot/userboot/userboot/main.c
@@ -159,15 +159,15 @@ extract_currdev(void)
} else if (userboot_disk_maxunit > 0) {
dev.dd.d_dev = &userboot_disk;
dev.dd.d_unit = 0;
- dev.d_slice = 0;
- dev.d_partition = 0;
+ dev.d_slice = D_SLICEWILD;
+ dev.d_partition = D_SLICEWILD;
/*
* If we cannot auto-detect the partition type then
* access the disk as a raw device.
*/
if (dev.dd.d_dev->dv_open(NULL, &dev)) {
- dev.d_slice = -1;
- dev.d_partition = -1;
+ dev.d_slice = D_SLICENONE;
+ dev.d_partition = D_SLICENONE;
}
} else {
dev.dd.d_dev = &host_dev;
diff --git a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c
index 5e87ef1e25..2742bc11f4 100644
--- a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c
+++ b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c
@@ -128,8 +128,8 @@ userdisk_print(int verbose)
pager_output(line);
dev.dd.d_dev = &userboot_disk;
dev.dd.d_unit = i;
- dev.d_slice = -1;
- dev.d_partition = -1;
+ dev.d_slice = D_SLICENONE;
+ dev.d_partition = D_SLICENONE;
if (disk_open(&dev, ud_info[i].mediasize,
ud_info[i].sectorsize) == 0) {
sprintf(line, " disk%d", i);
diff --git a/usr/src/cmd/sgs/crle/common/print.c b/usr/src/cmd/sgs/crle/common/print.c
index 2692018dfc..fe3e0ada96 100644
--- a/usr/src/cmd/sgs/crle/common/print.c
+++ b/usr/src/cmd/sgs/crle/common/print.c
@@ -214,7 +214,7 @@ getflags(Half flags)
static INSCFG_RET
scanconfig(Crle_desc * crle, Addr addr, int c_class)
{
- Conv_inv_buf_t inv_buf1, inv_buf2, inv_buf3, inv_buf4;
+ Conv_inv_buf_t inv_buf1, inv_buf2, inv_buf3, inv_buf4;
Conv_dl_flag_buf_t dl_flag_buf;
Rtc_id *id;
Rtc_head *head;
@@ -976,7 +976,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class)
const char *str;
Word _ndx;
- if (*hash == NULL)
+ if (*hash == 0)
continue;
obj = objtbl + *hash;
diff --git a/usr/src/cmd/sgs/lex/common/ldefs.h b/usr/src/cmd/sgs/lex/common/ldefs.h
index b94134fcfa..18758ea191 100644
--- a/usr/src/cmd/sgs/lex/common/ldefs.h
+++ b/usr/src/cmd/sgs/lex/common/ldefs.h
@@ -29,8 +29,6 @@
#ifndef _LDEFS_H
#define _LDEFS_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <stdlib.h>
@@ -129,7 +127,7 @@
* example, a lex character class "[_0-9a-zA-Z]"
* would be translated to the intermidiate
* form:
- * RCCL
+ * RCCL
* |
* |
* v
@@ -250,8 +248,8 @@ void phead2(void);
void ptail(void);
void statistics(void);
void error_tail(void) __NORETURN;
-void error();
-void warning();
+void error(char *, ...);
+void warning(char *, ...);
void lgate(void);
void scopy(CHR *s, CHR *t);
void cclinter(int sw);
diff --git a/usr/src/cmd/sgs/lex/common/sub1.c b/usr/src/cmd/sgs/lex/common/sub1.c
index 69eb0b545c..f1d3fa601b 100644
--- a/usr/src/cmd/sgs/lex/common/sub1.c
+++ b/usr/src/cmd/sgs/lex/common/sub1.c
@@ -26,8 +26,8 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
+#include <stdio.h>
+#include <stdarg.h>
#include "ldefs.h"
#include <limits.h>
@@ -88,23 +88,23 @@ digit(int c)
return (c >= '0' && c <= '9');
}
-/* VARARGS1 */
void
-error(s, p, d)
-char *s;
-int p, d;
+error(char *s, ...)
{
+ va_list ap;
+
/* if(!eof) */
- if (!yyline)
+ if (!yyline) {
(void) fprintf(errorf, "Command line: ");
- else {
+ } else {
(void) fprintf(errorf,
- !no_input ? "" : "\"%s\":", sargv[optind]);
+ !no_input ? "" : "\"%s\":", sargv[optind]);
(void) fprintf(errorf, "line %d: ", yyline);
}
(void) fprintf(errorf, "Error: ");
- /*LINTED: E_SEC_PRINTF_VAR_FMT*/
- (void) fprintf(errorf, s, p, d);
+ va_start(ap, s);
+ (void) vfprintf(errorf, s, ap);
+ va_end(ap);
(void) putc('\n', errorf);
if (fatal)
error_tail();
@@ -126,24 +126,24 @@ error_tail(void)
/* NOTREACHED */
}
-/* VARARGS1 */
void
-warning(s, p, d)
-char *s;
-int p, d;
+warning(char *s, ...)
{
+ va_list ap;
+
if (!eof)
if (!yyline)
(void) fprintf(errorf, "Command line: ");
else {
(void) fprintf(errorf,
- !no_input?"":"\"%s\":", sargv[optind]);
+ !no_input ? "" : "\"%s\":", sargv[optind]);
(void) fprintf(errorf,
- "line %d: ", yyline);
+ "line %d: ", yyline);
}
(void) fprintf(errorf, "Warning: ");
- /*LINTED: E_SEC_PRINTF_VAR_FMT*/
- (void) fprintf(errorf, s, p, d);
+ va_start(ap, s);
+ (void) vfprintf(errorf, s, ap);
+ va_end(ap);
(void) putc('\n', errorf);
(void) fflush(errorf);
if (fout)
@@ -490,7 +490,7 @@ cpycom(CHR *p)
* FIX BUG #1058428, not parsing comments correctly
* that span more than one line
*/
- if (*t != NULL)
+ if (*t != 0)
(void) putc(*t++, fout);
}
(void) putc('\n', fout);
diff --git a/usr/src/cmd/sgs/liblddbg/common/debug.c b/usr/src/cmd/sgs/liblddbg/common/debug.c
index bc7428596e..07ca899083 100644
--- a/usr/src/cmd/sgs/liblddbg/common/debug.c
+++ b/usr/src/cmd/sgs/liblddbg/common/debug.c
@@ -92,7 +92,7 @@ static DBG_options _Dbg_options_ld[] = { /* ld only options */
static DBG_options _Dbg_options_rtld[] = { /* ld.so.1 only options */
{MSG_ORIG(MSG_TOK_AUDIT), DBG_C_AUDITING, 0},
{MSG_ORIG(MSG_TOK_BINDINGS), DBG_C_BINDINGS, 0},
- {MSG_ORIG(MSG_TOK_DL), DBG_C_DL, 0},
+ {MSG_ORIG(MSG_TOK_DL), DBG_C_DL, 0},
{MSG_ORIG(MSG_TOK_INIT), DBG_C_INIT, 0},
{NULL, 0, 0},
};
@@ -327,7 +327,7 @@ process_lmid(char *name, Dbg_desc *dbp)
{MSG_ORIG(MSG_TOK_LMID_ALL), 0, DBG_E_LMID_ALL},
{MSG_ORIG(MSG_TOK_LMID_BASE), 0, DBG_E_LMID_BASE},
{MSG_ORIG(MSG_TOK_LMID_LDSO), 0, DBG_E_LMID_LDSO},
- {NULL, NULL},
+ {NULL, 0, 0},
};
Dbg_desc tmp_db;
diff --git a/usr/src/cmd/sgs/liblddbg/common/statistics.c b/usr/src/cmd/sgs/liblddbg/common/statistics.c
index 3346a7b708..c327da4324 100644
--- a/usr/src/cmd/sgs/liblddbg/common/statistics.c
+++ b/usr/src/cmd/sgs/liblddbg/common/statistics.c
@@ -184,7 +184,7 @@ Dbg_statistics_ar(Ofl_desc *ofl)
arsym = adp->ad_start;
aux = adp->ad_aux;
- while ((arsym != NULL) && (arsym->as_off != NULL)) {
+ while ((arsym != NULL) && (arsym->as_off != 0)) {
/*
* Assume that symbols from the same member file are
* adjacent within the archive symbol table.
diff --git a/usr/src/cmd/sgs/link_audit/common/bindings.c b/usr/src/cmd/sgs/link_audit/common/bindings.c
index 28e3f0d316..f1a8e9c215 100644
--- a/usr/src/cmd/sgs/link_audit/common/bindings.c
+++ b/usr/src/cmd/sgs/link_audit/common/bindings.c
@@ -416,7 +416,7 @@ la_i86_pltenter(Elf32_Sym *symp, uint_t symndx, uintptr_t *refcooke,
(void) close(fd);
}
- if (bhp->bh_bkts[bktno].bb_head == NULL) {
+ if (bhp->bh_bkts[bktno].bb_head == 0) {
binding_entry * bep;
unsigned int be_off;
unsigned int sym_off;
diff --git a/usr/src/cmd/sgs/link_audit/common/hash.c b/usr/src/cmd/sgs/link_audit/common/hash.c
index da9641a7e4..fa03dab222 100644
--- a/usr/src/cmd/sgs/link_audit/common/hash.c
+++ b/usr/src/cmd/sgs/link_audit/common/hash.c
@@ -252,7 +252,7 @@ hash_string(const char *s, long modulo)
unsigned int result = 0;
int i = 1;
- while (*s != NULL) {
+ while (*s != '\0') {
result += (*s++ << i++);
}
diff --git a/usr/src/contrib/zlib/zconf.h b/usr/src/contrib/zlib/zconf.h
index c91476cd96..fcbe253d2c 100644
--- a/usr/src/contrib/zlib/zconf.h
+++ b/usr/src/contrib/zlib/zconf.h
@@ -22,8 +22,10 @@
* We define our own memory allocation and deallocation routines that use kmem.
*/
#define MY_ZCALLOC
-#endif
+#define NO_MEMCPY
+#else
#define HAVE_MEMCPY
+#endif
#define ZLIB_CONST
#define Z_PREFIX
diff --git a/usr/src/contrib/zlib/zutil.c b/usr/src/contrib/zlib/zutil.c
index 0cf1998874..b7fdbbb851 100644
--- a/usr/src/contrib/zlib/zutil.c
+++ b/usr/src/contrib/zlib/zutil.c
@@ -141,7 +141,7 @@ const char * ZEXPORT zError(int err)
int errno = 0;
#endif
-#ifndef HAVE_MEMCPY
+#if !defined(HAVE_MEMCPY) && !defined(_KERNEL)
void ZLIB_INTERNAL zmemcpy(dest, source, len)
Bytef* dest;
diff --git a/usr/src/lib/libc/i386/crt/_rtld.c b/usr/src/lib/libc/i386/crt/_rtld.c
index 92c9e53c55..459481ff57 100644
--- a/usr/src/lib/libc/i386/crt/_rtld.c
+++ b/usr/src/lib/libc/i386/crt/_rtld.c
@@ -99,7 +99,7 @@ __rtld(Elf32_Boot *ebp, const char *strings[], int (*funcs[])())
* Discover things about our environment: auxiliary vector (if
* any), arguments, program name, and the like.
*/
- while (ebp->eb_tag != NULL) {
+ while (ebp->eb_tag != 0) {
switch (ebp->eb_tag) {
case EB_ARGV:
program_name = *((char **)ebp->eb_un.eb_ptr);
diff --git a/usr/src/lib/libc/port/gen/_xftw.c b/usr/src/lib/libc/port/gen/_xftw.c
index c30d19fac0..681b6f20ca 100644
--- a/usr/src/lib/libc/port/gen/_xftw.c
+++ b/usr/src/lib/libc/port/gen/_xftw.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* _xftw - file tree walk the uses expanded stat structure
*
@@ -348,7 +346,7 @@ nocdstat(const char *path, struct stat *statp, struct Var *vp, int sym)
(void) close(fd);
(void) free(dirp);
errno = ENAMETOOLONG;
- return (NULL);
+ return (0);
}
(void) close(fd);
fd = cfd;
diff --git a/usr/src/lib/libc/port/gen/catopen.c b/usr/src/lib/libc/port/gen/catopen.c
index 8a0ca43a3c..ece463fc2a 100644
--- a/usr/src/lib/libc/port/gen/catopen.c
+++ b/usr/src/lib/libc/port/gen/catopen.c
@@ -126,10 +126,10 @@ process_nls_path(char *name, int oflag)
while (s && *s) {
if (*s == '_') {
s1 = s;
- *s1++ = NULL;
+ *s1++ = '\0';
} else if (*s == '.') {
s2 = s;
- *s2++ = NULL;
+ *s2++ = '\0';
}
s++;
}
@@ -206,7 +206,7 @@ process_nls_path(char *name, int oflag)
s = name;
while (*s && t < pathname + PATH_MAX)
*t++ = *s++;
- *t = NULL;
+ *t = '\0';
return (file_open(pathname, SAFE_F));
}
@@ -269,7 +269,7 @@ replace_nls_option(char *s, char *name, char *pathname, char *locale,
}
++s;
}
- *t = NULL;
+ *t = '\0';
return (s);
}
diff --git a/usr/src/lib/libc/port/gen/crypt.c b/usr/src/lib/libc/port/gen/crypt.c
index 3d3e369bab..5edc9a1deb 100644
--- a/usr/src/lib/libc/port/gen/crypt.c
+++ b/usr/src/lib/libc/port/gen/crypt.c
@@ -697,9 +697,7 @@ free_crypt_alg(struct crypt_alg_s *alg)
if (alg->a_libhandle != NULL) {
(void) dlclose(alg->a_libhandle);
}
- if (alg->a_nparams != NULL) {
- free(alg->a_params);
- }
+ free(alg->a_params);
free(alg);
}
diff --git a/usr/src/lib/libc/port/gen/event_port.c b/usr/src/lib/libc/port/gen/event_port.c
index ee8317f21e..df8f5c7a64 100644
--- a/usr/src/lib/libc/port/gen/event_port.c
+++ b/usr/src/lib/libc/port/gen/event_port.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -73,7 +71,7 @@ port_get(int port, port_event_t *pe, struct timespec *to)
r.r_vals = _portfs(PORT_GET, port, (uintptr_t)pe, to->tv_sec,
to->tv_nsec, (uintptr_t)to);
else
- r.r_vals = _portfs(PORT_GET, port, (uintptr_t)pe, 0, 0, NULL);
+ r.r_vals = _portfs(PORT_GET, port, (uintptr_t)pe, 0, 0, 0);
return (r.r_val1);
}
@@ -112,8 +110,7 @@ int
port_send(int port, int events, void *user)
{
rval_t r;
- r.r_vals = _portfs(PORT_SEND, port, events, (uintptr_t)user, NULL,
- NULL);
+ r.r_vals = _portfs(PORT_SEND, port, events, (uintptr_t)user, 0, 0);
return (r.r_val1);
}
@@ -178,7 +175,6 @@ int
port_alert(int port, int flags, int events, void *user)
{
rval_t r;
- r.r_vals = _portfs(PORT_ALERT, port, flags, events, (uintptr_t)user,
- NULL);
+ r.r_vals = _portfs(PORT_ALERT, port, flags, events, (uintptr_t)user, 0);
return (r.r_val1);
}
diff --git a/usr/src/lib/libc/port/gen/fmtmsg.c b/usr/src/lib/libc/port/gen/fmtmsg.c
index 08ada435ce..063fe325f8 100644
--- a/usr/src/lib/libc/port/gen/fmtmsg.c
+++ b/usr/src/lib/libc/port/gen/fmtmsg.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* fmtmsg.c
*
@@ -992,7 +990,7 @@ writemsg(char *buf, size_t size,
/* Write the TEXT, if requested */
if (dotext) {
p = (char *)text;
- for (c = *p++; c != NULL && buf < ebuf; c = *p++) {
+ for (c = *p++; c != '\0' && buf < ebuf; c = *p++) {
*buf++ = c;
if (c == '\n') {
for (i = 0; i < textindent && buf < ebuf; i++)
@@ -1017,7 +1015,7 @@ writemsg(char *buf, size_t size,
/* Write the "action" string */
p = (char *)action;
- for (c = *p++; c != NULL && buf < ebuf; c = *p++) {
+ for (c = *p++; c != '\0' && buf < ebuf; c = *p++) {
*buf++ = c;
if (c == '\n') {
for (i = 0; i < actindent && buf < ebuf; i++)
diff --git a/usr/src/lib/libc/port/gen/getopt.c b/usr/src/lib/libc/port/gen/getopt.c
index 5e3e3e23eb..cb6839f2ff 100644
--- a/usr/src/lib/libc/port/gen/getopt.c
+++ b/usr/src/lib/libc/port/gen/getopt.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* See getopt(3C) and SUS/XPG getopt() for function definition and
* requirements.
@@ -199,7 +197,7 @@ getopt(int argc, char *const *argv, const char *optstring)
if (optind >= argc || argv[optind][0] != '-' ||
argv[optind] == NULL || argv[optind][1] == '\0')
return (EOF);
- else if (strcmp(argv[optind], "--") == NULL) {
+ else if (strcmp(argv[optind], "--") == 0) {
optind++;
return (EOF);
}
diff --git a/usr/src/lib/libc/port/gen/getutx.c b/usr/src/lib/libc/port/gen/getutx.c
index 145ffc4a2a..da0c86fbbb 100644
--- a/usr/src/lib/libc/port/gen/getutx.c
+++ b/usr/src/lib/libc/port/gen/getutx.c
@@ -658,7 +658,7 @@ pututxline(const struct utmpx *entry)
*/
if (getutxid(&tmpxbuf) == NULL) {
lock++;
- if (lockf(fd, F_LOCK, 0) < NULL)
+ if (lockf(fd, F_LOCK, 0) < 0)
return (NULL);
(void) fseek(fp, 0, SEEK_END);
} else
diff --git a/usr/src/lib/libc/port/gen/mkstemp.c b/usr/src/lib/libc/port/gen/mkstemp.c
index d9de436d13..cb2b9be347 100644
--- a/usr/src/lib/libc/port/gen/mkstemp.c
+++ b/usr/src/lib/libc/port/gen/mkstemp.c
@@ -67,7 +67,7 @@ libc_mkstemps(char *as, int slen, int flags)
int len;
char *tstr, *str, *mkret;
- if (as == NULL || *as == NULL)
+ if (as == NULL || *as == '\0')
return (-1);
len = (int)strlen(as);
diff --git a/usr/src/lib/libc/port/gen/plock.c b/usr/src/lib/libc/port/gen/plock.c
index 1fb0367f1f..a3b313301d 100644
--- a/usr/src/lib/libc/port/gen/plock.c
+++ b/usr/src/lib/libc/port/gen/plock.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* plock - lock "segments" in physical memory.
*
@@ -117,7 +115,7 @@ plock(int op) /* desired operation */
* memcntl backs them out automatically.
*/
e = memcntl(NULL, 0, MC_LOCKAS, (caddr_t)MCL_CURRENT,
- PROC_TEXT|PRIVATE, (int)NULL);
+ PROC_TEXT|PRIVATE, 0);
if (!e)
lock_state |= TXTLOCK;
lmutex_unlock(&plock_lock);
@@ -144,7 +142,7 @@ plock(int op) /* desired operation */
* memcntl undoes the locks internally.
*/
e = memcntl(NULL, 0, MC_LOCKAS, (caddr_t)MCL_CURRENT,
- PROC_DATA|PRIVATE, (int)NULL);
+ PROC_DATA|PRIVATE, 0);
if (e) {
lmutex_unlock(&plock_lock);
return (-1);
@@ -160,7 +158,7 @@ plock(int op) /* desired operation */
if (e) {
e = errno;
(void) memcntl(NULL, 0, MC_UNLOCKAS,
- (caddr_t)MCL_CURRENT, PROC_DATA|PRIVATE, (int)NULL);
+ (caddr_t)MCL_CURRENT, PROC_DATA|PRIVATE, 0);
errno = e;
lmutex_unlock(&plock_lock);
return (-1);
diff --git a/usr/src/lib/libc/port/gen/ttyname.c b/usr/src/lib/libc/port/gen/ttyname.c
index d5c321a824..042a738db3 100644
--- a/usr/src/lib/libc/port/gen/ttyname.c
+++ b/usr/src/lib/libc/port/gen/ttyname.c
@@ -285,7 +285,7 @@ _ttyname_common(struct stat64 *fsp, char *buffer, uint_t match_mask)
* Is /dev/pts then just do a quick check. We don't have
* to stat the entire /dev/pts dir.
*/
- if (strcmp(PTS, srch_dirs[dirno].name) == NULL) {
+ if (strcmp(PTS, srch_dirs[dirno].name) == 0) {
if ((pt = ispts(fsp, match_mask)) != NULL) {
is_pts = 1;
found = 1;
diff --git a/usr/src/lib/libc/port/inet/inet_network.c b/usr/src/lib/libc/port/inet/inet_network.c
index 8205a4795a..952804b43c 100644
--- a/usr/src/lib/libc/port/inet/inet_network.c
+++ b/usr/src/lib/libc/port/inet/inet_network.c
@@ -68,7 +68,7 @@ again:
else
base = 8;
}
- while ((c = *cp) != NULL) {
+ while ((c = *cp) != '\0') {
if (isdigit(c)) {
if ((c - '0') >= base)
break;
diff --git a/usr/src/lib/libc/port/locale/strptime.c b/usr/src/lib/libc/port/locale/strptime.c
index f5be4eba8c..eba76189ad 100644
--- a/usr/src/lib/libc/port/locale/strptime.c
+++ b/usr/src/lib/libc/port/locale/strptime.c
@@ -426,7 +426,7 @@ label:
case 'Y':
case 'y':
- if (*buf == NULL || isspace(*buf))
+ if (*buf == '\0' || isspace(*buf))
break;
if (!isdigit(*buf))
diff --git a/usr/src/lib/libc/port/print/doprnt.c b/usr/src/lib/libc/port/print/doprnt.c
index e8cfaad6de..8a6dfd5e90 100644
--- a/usr/src/lib/libc/port/print/doprnt.c
+++ b/usr/src/lib/libc/port/print/doprnt.c
@@ -1904,7 +1904,7 @@ wide_S:
* wbuff, allocate larger buffer
*/
if ((nwc =
- mbstowcs(NULL, bp, NULL)) ==
+ mbstowcs(NULL, bp, 0)) ==
(size_t)-1) {
sec_display =
strlen(bp);
diff --git a/usr/src/lib/libc/port/rt/mqueue.c b/usr/src/lib/libc/port/rt/mqueue.c
index 59ff825210..b2cbd48264 100644
--- a/usr/src/lib/libc/port/rt/mqueue.c
+++ b/usr/src/lib/libc/port/rt/mqueue.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "mtlib.h"
#define _KMEMUSER
@@ -260,7 +258,7 @@ mq_getmsg(mqhdr_t *mqhp, char *msgp, uint_t *msg_prio)
MQ_ASSERT_PTR(mqhp, currentp);
curbuf = MQ_PTR(mqhp, currentp);
- if ((*headpp = curbuf->msg_next) == NULL) {
+ if ((*headpp = curbuf->msg_next) == 0) {
/*
* We just nuked the last message in this priority's queue.
* Twiddle this priority's bit, and then find the next bit
@@ -275,7 +273,7 @@ mq_getmsg(mqhdr_t *mqhp, char *msgp, uint_t *msg_prio)
break;
mqhp->mq_curmaxprio = prio;
- *tailpp = NULL;
+ *tailpp = 0;
}
/*
@@ -312,7 +310,7 @@ mq_putmsg(mqhdr_t *mqhp, const char *msgp, ssize_t len, uint_t prio)
* Remove a message from the free list, and copy in the new contents.
*/
mqhp->mq_freep = curbuf->msg_next;
- curbuf->msg_next = NULL;
+ curbuf->msg_next = 0;
(void) memcpy((char *)&curbuf[1], msgp, len);
curbuf->msg_len = len;
diff --git a/usr/src/lib/libc/port/threads/tdb_agent.c b/usr/src/lib/libc/port/threads/tdb_agent.c
index 919f0473f4..84de640b63 100644
--- a/usr/src/lib/libc/port/threads/tdb_agent.c
+++ b/usr/src/lib/libc/port/threads/tdb_agent.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains most of the functionality
* required to support the threads portion of libc_db.
@@ -368,7 +366,7 @@ tdb_sync_obj_deregister(void *addr)
* (Once the hash table is allocated, it is never deallocated.)
*/
if (tdbp->tdb_sync_addr_hash == NULL ||
- tdbp->tdb_sync_addr_hash[hash = tdb_addr_hash(addr)] == NULL)
+ tdbp->tdb_sync_addr_hash[hash = tdb_addr_hash(addr)] == 0)
return;
lmutex_lock(&udp->tdb_hash_lock);
diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c
index 10302bae90..8026ffad9c 100644
--- a/usr/src/lib/libc/port/threads/thr.c
+++ b/usr/src/lib/libc/port/threads/thr.c
@@ -88,12 +88,12 @@ extern const Lc_interface rtld_funcs[];
*/
#pragma weak _uberdata = __uberdata
uberdata_t __uberdata = {
- { DEFAULTMUTEX, NULL, 0 }, /* link_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* ld_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* fork_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* atfork_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* callout_lock */
- { DEFAULTMUTEX, NULL, 0 }, /* tdb_hash_lock */
+ { DEFAULTMUTEX, 0, 0 }, /* link_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* ld_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* fork_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* atfork_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* callout_lock */
+ { DEFAULTMUTEX, 0, 0 }, /* tdb_hash_lock */
{ 0, }, /* tdb_hash_lock_stats */
{ { 0 }, }, /* siguaction[NSIG] */
{{ DEFAULTMUTEX, NULL, 0 }, /* bucket[NBUCKETS] */
diff --git a/usr/src/lib/libc/sparc/crt/_rtld.c b/usr/src/lib/libc/sparc/crt/_rtld.c
index a9e9c6d98a..84caa8460e 100644
--- a/usr/src/lib/libc/sparc/crt/_rtld.c
+++ b/usr/src/lib/libc/sparc/crt/_rtld.c
@@ -98,7 +98,7 @@ __rtld(Elf32_Boot *ebp, const char *strings[], int (*funcs[])())
* Discover things about our environment: auxiliary vector (if
* any), arguments, program name, and the like.
*/
- while (ebp->eb_tag != NULL) {
+ while (ebp->eb_tag != 0) {
switch (ebp->eb_tag) {
case EB_ARGV:
program_name = *((char **)ebp->eb_un.eb_ptr);
diff --git a/usr/src/lib/libdisasm/common/dis_sparc.c b/usr/src/lib/libdisasm/common/dis_sparc.c
index 224fe9042d..fc5e585a4f 100644
--- a/usr/src/lib/libdisasm/common/dis_sparc.c
+++ b/usr/src/lib/libdisasm/common/dis_sparc.c
@@ -129,7 +129,7 @@ dis_sparc_handle_attach(dis_handle_t *dhp)
if ((dhx = dis_zalloc(sizeof (dis_handle_sparc_t))) == NULL) {
(void) dis_seterrno(E_DIS_NOMEM);
- return (NULL);
+ return (0);
}
dhx->dhx_debug = DIS_DEBUG_COMPAT;
dhp->dh_arch_private = dhx;
diff --git a/usr/src/lib/libhotplug/common/libhotplug.c b/usr/src/lib/libhotplug/common/libhotplug.c
index 91609f457a..d343bebb2c 100644
--- a/usr/src/lib/libhotplug/common/libhotplug.c
+++ b/usr/src/lib/libhotplug/common/libhotplug.c
@@ -345,14 +345,14 @@ hp_last_change(hp_node_t node)
if (node == NULL) {
i_hp_dprintf("hp_last_change: invalid arguments.\n");
errno = EINVAL;
- return (NULL);
+ return (0);
}
if ((node->hp_type != HP_NODE_CONNECTOR) &&
(node->hp_type != HP_NODE_PORT)) {
i_hp_dprintf("hp_last_change: operation not supported.\n");
errno = ENOTSUP;
- return (NULL);
+ return (0);
}
return (node->hp_last_change);
@@ -794,7 +794,7 @@ hp_unpack(char *packed_buf, size_t packed_len, hp_node_t *retp)
if (nvlist_next_nvpair(nvl, NULL) == NULL) {
nvlist_free(nvl);
errno = EINVAL;
- return (NULL);
+ return (0);
}
for (nvp = NULL; nvp = nvlist_next_nvpair(nvl, nvp); ) {
diff --git a/usr/src/lib/libnsl/dial/interface.c b/usr/src/lib/libnsl/dial/interface.c
index 09f0a8d55a..2dbd10375e 100644
--- a/usr/src/lib/libnsl/dial/interface.c
+++ b/usr/src/lib/libnsl/dial/interface.c
@@ -186,18 +186,18 @@ twrite(int fd, char *buf, unsigned nbytes)
}
if (info.tsdu <= 0 || nbytes <= info.tsdu)
- return ((ssize_t)t_snd(fd, buf, nbytes, NULL));
+ return ((ssize_t)t_snd(fd, buf, nbytes, 0));
/* if get here, then there is a limit on transmit size */
/* (info.tsdu > 0) and buf exceeds it */
i = ret = 0;
while (nbytes >= info.tsdu) {
- if ((ret = t_snd(fd, &buf[i], info.tsdu, NULL)) != info.tsdu)
+ if ((ret = t_snd(fd, &buf[i], info.tsdu, 0)) != info.tsdu)
return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
i += info.tsdu;
nbytes -= info.tsdu;
}
if (nbytes != 0) {
- if ((ret = t_snd(fd, &buf[i], nbytes, NULL)) != nbytes)
+ if ((ret = t_snd(fd, &buf[i], nbytes, 0)) != nbytes)
return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
i += nbytes;
}
diff --git a/usr/src/lib/libnsl/netselect/netselect.c b/usr/src/lib/libnsl/netselect/netselect.c
index 7790894c9e..461840b695 100644
--- a/usr/src/lib/libnsl/netselect/netselect.c
+++ b/usr/src/lib/libnsl/netselect/netselect.c
@@ -476,7 +476,7 @@ setnetpath(void)
/* Skip all leading ':'s */
while (*tp && *tp == ':')
tp++;
- if (*tp == NULL)
+ if (*tp == '\0')
break; /* last one */
netid = tp;
while (*tp && *tp != ':')
diff --git a/usr/src/lib/libnsl/nss/getexecattr.c b/usr/src/lib/libnsl/nss/getexecattr.c
index 8df3b6a076..7c04fe2ec1 100644
--- a/usr/src/lib/libnsl/nss/getexecattr.c
+++ b/usr/src/lib/libnsl/nss/getexecattr.c
@@ -298,7 +298,7 @@ _doexeclist(nss_XbyY_args_t *argp)
else
status = 0;
}
- (void) memset(argp->buf.buffer, NULL, argp->buf.buflen);
+ (void) memset(argp->buf.buffer, 0, argp->buf.buflen);
return (status);
diff --git a/usr/src/lib/libnsl/nss/parse.c b/usr/src/lib/libnsl/nss/parse.c
index 80c22a3e40..56d382daaa 100644
--- a/usr/src/lib/libnsl/nss/parse.c
+++ b/usr/src/lib/libnsl/nss/parse.c
@@ -25,8 +25,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "mt.h"
#include <stdio.h>
#include <stdlib.h>
@@ -135,7 +133,7 @@ _unescape(char *s, char *esc)
else
tmp[j++] = s[i];
}
- tmp[j] = NULL;
+ tmp[j] = '\0';
return (tmp);
}
diff --git a/usr/src/lib/libnsl/rpc/clnt_generic.c b/usr/src/lib/libnsl/rpc/clnt_generic.c
index f89c1d5f75..34deeb1f2c 100644
--- a/usr/src/lib/libnsl/rpc/clnt_generic.c
+++ b/usr/src/lib/libnsl/rpc/clnt_generic.c
@@ -32,8 +32,6 @@
* California.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "mt.h"
#include "rpc_mt.h"
#include <stdio.h>
@@ -425,11 +423,11 @@ clnt_create_service_timed(const char *host, const char *service,
netdir_free((void *)raddrs, ND_ADDRLIST);
if (port) {
- if (strcmp(nconf->nc_protofmly, NC_INET) == NULL)
+ if (strcmp(nconf->nc_protofmly, NC_INET) == 0)
/* LINTED pointer alignment */
((struct sockaddr_in *)
tbind->addr.buf)->sin_port = htons(port);
- else if (strcmp(nconf->nc_protofmly, NC_INET6) == NULL)
+ else if (strcmp(nconf->nc_protofmly, NC_INET6) == 0)
/* LINTED pointer alignment */
((struct sockaddr_in6 *)
tbind->addr.buf)->sin6_port = htons(port);
diff --git a/usr/src/lib/libnsl/rpc/clnt_simple.c b/usr/src/lib/libnsl/rpc/clnt_simple.c
index b33e1bb85b..78e88fce29 100644
--- a/usr/src/lib/libnsl/rpc/clnt_simple.c
+++ b/usr/src/lib/libnsl/rpc/clnt_simple.c
@@ -32,8 +32,6 @@
* California.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Simplified front end to client rpc.
*/
@@ -115,7 +113,7 @@ rpc_call(const char *host, const rpcprog_t prognum, const rpcvers_t versnum,
return (rpc_createerr.cf_stat);
}
- if ((nettype == NULL) || (nettype[0] == NULL))
+ if ((nettype == NULL) || (nettype[0] == '\0'))
nettype = "netpath";
if (!(rcp->valid &&
rcp->pid == getpid() &&
diff --git a/usr/src/lib/libnsl/rpc/netname.c b/usr/src/lib/libnsl/rpc/netname.c
index 1ac9a58e3d..0e5b19d2a0 100644
--- a/usr/src/lib/libnsl/rpc/netname.c
+++ b/usr/src/lib/libnsl/rpc/netname.c
@@ -306,7 +306,7 @@ host2netname(char netname[MAXNETNAMELEN + 1], const char *host,
}
(void) strcpy(domainname, p);
} else {
- domainname[0] = NULL;
+ domainname[0] = '\0';
if (getdomainname(domainname, MAXHOSTNAMELEN) < 0)
return (0);
}
diff --git a/usr/src/lib/libnsl/rpc/rpc_generic.c b/usr/src/lib/libnsl/rpc/rpc_generic.c
index 65fb2d08a9..34bb85c97c 100644
--- a/usr/src/lib/libnsl/rpc/rpc_generic.c
+++ b/usr/src/lib/libnsl/rpc/rpc_generic.c
@@ -32,8 +32,6 @@
* California.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Miscl routines for RPC.
*/
@@ -168,7 +166,7 @@ getnettype(const char *nettype)
{
int i;
- if ((nettype == NULL) || (nettype[0] == NULL))
+ if ((nettype == NULL) || (nettype[0] == '\0'))
return (_RPC_NETPATH); /* Default */
for (i = 0; _rpctypelist[i].name; i++)
@@ -250,7 +248,7 @@ __rpc_getconfip(char *nettype)
netid = netid_tcp;
else
return (NULL);
- if ((netid == NULL) || (netid[0] == NULL))
+ if ((netid == NULL) || (netid[0] == '\0'))
return (NULL);
return (getnetconfigent(netid));
}
diff --git a/usr/src/lib/libnsl/rpc/rpcb_clnt.c b/usr/src/lib/libnsl/rpc/rpcb_clnt.c
index 0fb7a8f32e..1b5a56910d 100644
--- a/usr/src/lib/libnsl/rpc/rpcb_clnt.c
+++ b/usr/src/lib/libnsl/rpc/rpcb_clnt.c
@@ -544,7 +544,7 @@ got_entry(rpcb_entry_list_ptr relp, struct netconfig *nconf)
if ((strcmp(nconf->nc_proto, rmap->r_nc_proto) == 0) &&
(strcmp(nconf->nc_protofmly, rmap->r_nc_protofmly) == 0) &&
(nconf->nc_semantics == rmap->r_nc_semantics) &&
- (rmap->r_maddr != NULL) && (rmap->r_maddr[0] != NULL)) {
+ (rmap->r_maddr != NULL) && (rmap->r_maddr[0] != 0)) {
na = uaddr2taddr(nconf, rmap->r_maddr);
break;
}
@@ -1226,7 +1226,7 @@ rpcb_gettime(const char *host, time_t *timep)
int vers;
enum clnt_stat st;
- if ((host == NULL) || (host[0] == NULL)) {
+ if ((host == NULL) || (host[0] == '\0')) {
(void) time(timep);
return (TRUE);
}
diff --git a/usr/src/lib/libsecdb/common/chkauthattr.c b/usr/src/lib/libsecdb/common/chkauthattr.c
index e76db0af24..b3c830374a 100644
--- a/usr/src/lib/libsecdb/common/chkauthattr.c
+++ b/usr/src/lib/libsecdb/common/chkauthattr.c
@@ -99,7 +99,7 @@ _enum_common_p(const char *cprofiles,
if (cprofiles == NULL)
return (0);
- if (*pcnt > 0 && strcmp(profs[*pcnt - 1], PROFILE_STOP) == NULL)
+ if (*pcnt > 0 && strcmp(profs[*pcnt - 1], PROFILE_STOP) == 0)
return (0);
COPYTOSTACK(profiles, cprofiles)
@@ -333,7 +333,7 @@ _auth_match_noun(const char *pattern, const char *auth,
if (strncmp(pattern, auth, pattern_len - 1) == 0) {
grant = strrchr(auth, '.');
if (grant != NULL) {
- if (strncmp(grant + 1, "grant", 5) != NULL)
+ if (strncmp(grant + 1, "grant", 5) != 0)
return (1);
}
}
diff --git a/usr/src/lib/libsecdb/common/secdb.c b/usr/src/lib/libsecdb/common/secdb.c
index e012d95ce0..7378ce11f4 100644
--- a/usr/src/lib/libsecdb/common/secdb.c
+++ b/usr/src/lib/libsecdb/common/secdb.c
@@ -257,7 +257,7 @@ _kva_dup(kva_t *old_kva)
int size;
kv_t *old_data;
kv_t *new_data;
- kva_t *nkva = NULL;
+ kva_t *nkva = NULL;
if (old_kva == NULL) {
return (NULL);
@@ -339,7 +339,7 @@ _argv_to_csl(char **strings)
(void) strcat(newstr, strings[i]);
(void) strcat(newstr, ",");
}
- newstr[len-1] = NULL;
+ newstr[len-1] = '\0';
return (newstr);
} else
return (NULL);
diff --git a/usr/src/lib/libzfs_core/common/libzfs_core.c b/usr/src/lib/libzfs_core/common/libzfs_core.c
index 79e9901bd7..61259846a8 100644
--- a/usr/src/lib/libzfs_core/common/libzfs_core.c
+++ b/usr/src/lib/libzfs_core/common/libzfs_core.c
@@ -154,7 +154,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
}
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
malloc(zc.zc_nvlist_dst_size);
- if (zc.zc_nvlist_dst == NULL) {
+ if (zc.zc_nvlist_dst == 0) {
error = ENOMEM;
goto out;
}
@@ -174,7 +174,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
zc.zc_nvlist_dst_size *= 2;
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
malloc(zc.zc_nvlist_dst_size);
- if (zc.zc_nvlist_dst == NULL) {
+ if (zc.zc_nvlist_dst == 0) {
error = ENOMEM;
goto out;
}
@@ -1003,16 +1003,16 @@ lzc_channel_program(const char *pool, const char *program, uint64_t instrlimit,
* checkpoint at most, at any given time.
*
* ZFS_ERR_DISCARDING_CHECKPOINT
- * ZFS is in the middle of discarding a checkpoint for this pool.
- * The pool can be checkpointed again once the discard is done.
+ * ZFS is in the middle of discarding a checkpoint for this pool.
+ * The pool can be checkpointed again once the discard is done.
*
* ZFS_DEVRM_IN_PROGRESS
- * A vdev is currently being removed. The pool cannot be
- * checkpointed until the device removal is done.
+ * A vdev is currently being removed. The pool cannot be
+ * checkpointed until the device removal is done.
*
* ZFS_VDEV_TOO_BIG
- * One or more top-level vdevs exceed the maximum vdev size
- * supported for this feature.
+ * One or more top-level vdevs exceed the maximum vdev size
+ * supported for this feature.
*/
int
lzc_pool_checkpoint(const char *pool)
@@ -1038,10 +1038,10 @@ lzc_pool_checkpoint(const char *pool)
* This method may also return:
*
* ZFS_ERR_NO_CHECKPOINT
- * The pool does not have a checkpoint.
+ * The pool does not have a checkpoint.
*
* ZFS_ERR_DISCARDING_CHECKPOINT
- * ZFS is already in the middle of discarding the checkpoint.
+ * ZFS is already in the middle of discarding the checkpoint.
*/
int
lzc_pool_checkpoint_discard(const char *pool)
diff --git a/usr/src/uts/common/fs/fifofs/fifovnops.c b/usr/src/uts/common/fs/fifofs/fifovnops.c
index c288a2eb61..ceec9bd012 100644
--- a/usr/src/uts/common/fs/fifofs/fifovnops.c
+++ b/usr/src/uts/common/fs/fifofs/fifovnops.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All rights reserved. */
+/* All rights reserved. */
/*
@@ -561,11 +561,11 @@ fifo_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *crp,
/*
* If this a pipe and this is the first end to close,
* then we have a bit of cleanup work to do.
- * Mark both ends of pipe as closed.
- * Wake up anybody blocked at the other end and for named pipes,
+ * Mark both ends of pipe as closed.
+ * Wake up anybody blocked at the other end and for named pipes,
* Close down this end of the stream
* Allow other opens/closes to continue
- * force an unmount of other end.
+ * force an unmount of other end.
* Otherwise if this is last close,
* flush messages,
* close down the stream
@@ -1136,6 +1136,21 @@ fifo_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr,
fifo_strioctl(vp, cmd, arg, mode, cr, rvalp));
}
+static inline int
+fifo_ioctl_getpeercred(fifonode_t *fnp, intptr_t arg, int mode)
+{
+ k_peercred_t *kp = (k_peercred_t *)arg;
+
+ if (mode == FKIOCTL && fnp->fn_pcredp != NULL) {
+ crhold(fnp->fn_pcredp);
+ kp->pc_cr = fnp->fn_pcredp;
+ kp->pc_cpid = fnp->fn_cpid;
+ return (0);
+ } else {
+ return (ENOTSUP);
+ }
+}
+
static int
fifo_fastioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr,
int *rvalp)
@@ -1356,6 +1371,10 @@ fifo_fastioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr,
*rvalp = 0;
break;
+ case _I_GETPEERCRED:
+ error = fifo_ioctl_getpeercred(fnp, arg, mode);
+ break;
+
/*
* invalid calls for stream head or fifos
*/
@@ -1403,17 +1422,8 @@ fifo_strioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr,
int error;
fifolock_t *fn_lock;
- if (cmd == _I_GETPEERCRED) {
- if (mode == FKIOCTL && fnp->fn_pcredp != NULL) {
- k_peercred_t *kp = (k_peercred_t *)arg;
- crhold(fnp->fn_pcredp);
- kp->pc_cr = fnp->fn_pcredp;
- kp->pc_cpid = fnp->fn_cpid;
- return (0);
- } else {
- return (ENOTSUP);
- }
- }
+ if (cmd == _I_GETPEERCRED)
+ return (fifo_ioctl_getpeercred(fnp, arg, mode));
error = strioctl(vp, cmd, arg, mode, U_TO_K, cr, rvalp);