summaryrefslogtreecommitdiff
path: root/lib/libcam/camlib.c
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2017-03-28 22:32:11 +0000
committerEnji Cooper <ngie@FreeBSD.org>2017-03-28 22:32:11 +0000
commitc9bac21cc90e04946bad6fe06e45a97ffd90cac0 (patch)
tree46679db4dc1cfaf057a406e1b1f62af2db089cc5 /lib/libcam/camlib.c
parent50e04f492dafb7f0e36371d35e4d3135947f67e9 (diff)
downloadsrc-test2-c9bac21cc90e04946bad6fe06e45a97ffd90cac0.tar.gz
src-test2-c9bac21cc90e04946bad6fe06e45a97ffd90cac0.zip
Notes
Diffstat (limited to 'lib/libcam/camlib.c')
-rw-r--r--lib/libcam/camlib.c66
1 files changed, 30 insertions, 36 deletions
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c
index 09371aaed025..b87f5d221895 100644
--- a/lib/libcam/camlib.c
+++ b/lib/libcam/camlib.c
@@ -114,7 +114,6 @@ cam_freeccb(union ccb *ccb)
int
cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
{
- char *func_name = "cam_get_device";
char *tmpstr, *tmpstr2;
char *newpath;
int unit_offset;
@@ -122,7 +121,7 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
if (path == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: device pathname was NULL", func_name);
+ "%s: device pathname was NULL", __func__);
return(-1);
}
@@ -145,7 +144,7 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
if (*tmpstr == '\0') {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: no text after slash", func_name);
+ "%s: no text after slash", __func__);
free(newpath);
return(-1);
}
@@ -174,7 +173,7 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
if (strlen(tmpstr) < 2) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: must have both device name and unit number",
- func_name);
+ __func__);
free(newpath);
return(-1);
}
@@ -186,7 +185,7 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
if (isdigit(*tmpstr)) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: device name cannot begin with a number",
- func_name);
+ __func__);
free(newpath);
return(-1);
}
@@ -198,7 +197,7 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
*/
if (!isdigit(tmpstr[strlen(tmpstr) - 1])) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: unable to find device unit number", func_name);
+ "%s: unable to find device unit number", __func__);
free(newpath);
return(-1);
}
@@ -270,13 +269,12 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
{
union ccb ccb;
struct periph_match_pattern *match_pat;
- char *func_name = "cam_open_btl";
int fd, bufsize;
if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: couldn't open %s\n%s: %s", func_name, XPT_DEVICE,
- func_name, strerror(errno));
+ "%s: couldn't open %s\n%s: %s", __func__, XPT_DEVICE,
+ __func__, strerror(errno));
return(NULL);
}
@@ -292,7 +290,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
ccb.cdm.matches = (struct dev_match_result *)malloc(bufsize);
if (ccb.cdm.matches == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: couldn't malloc match buffer", func_name);
+ "%s: couldn't malloc match buffer", __func__);
close(fd);
return(NULL);
}
@@ -305,7 +303,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
sizeof(struct dev_match_pattern));
if (ccb.cdm.patterns == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: couldn't malloc pattern buffer", func_name);
+ "%s: couldn't malloc pattern buffer", __func__);
free(ccb.cdm.matches);
ccb.cdm.matches = NULL;
close(fd);
@@ -329,7 +327,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: CAMIOCOMMAND ioctl failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ "%s: %s", __func__, __func__, strerror(errno));
goto btl_bailout;
}
@@ -341,7 +339,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
&& (ccb.cdm.status != CAM_DEV_MATCH_MORE))) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: CAM error %#x, CDM error %d "
- "returned from XPT_DEV_MATCH ccb", func_name,
+ "returned from XPT_DEV_MATCH ccb", __func__,
ccb.ccb_h.status, ccb.cdm.status);
goto btl_bailout;
}
@@ -350,14 +348,14 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: CDM reported more than one"
" passthrough device at %d:%d:%jx!!\n",
- func_name, path_id, target_id, (uintmax_t)target_lun);
+ __func__, path_id, target_id, (uintmax_t)target_lun);
goto btl_bailout;
}
if (ccb.cdm.num_matches == 0) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: no passthrough device found at"
- " %d:%d:%jx", func_name, path_id, target_id,
+ " %d:%d:%jx", __func__, path_id, target_id,
(uintmax_t)target_lun);
goto btl_bailout;
}
@@ -383,7 +381,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
default:
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: asked for a peripheral match, but"
- " got a bus or device match", func_name);
+ " got a bus or device match", __func__);
goto btl_bailout;
break; /* NOTREACHED */
}
@@ -417,7 +415,6 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
int fd;
union ccb ccb;
char dev_path[256];
- char *func_name = "cam_lookup_pass";
/*
* The flags argument above only applies to the actual passthrough
@@ -426,8 +423,8 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
*/
if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: couldn't open %s\n%s: %s", func_name, XPT_DEVICE,
- func_name, strerror(errno));
+ "%s: couldn't open %s\n%s: %s", __func__, XPT_DEVICE,
+ __func__, strerror(errno));
return(NULL);
}
@@ -456,11 +453,11 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
snprintf(tmpstr, sizeof(tmpstr),
"\n%s: either the pass driver isn't in "
"your kernel\n%s: or %s%d doesn't exist",
- func_name, func_name, dev_name, unit);
+ __func__, __func__, dev_name, unit);
}
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: CAMGETPASSTHRU ioctl failed\n"
- "%s: %s%s", func_name, func_name, strerror(errno),
+ "%s: %s%s", __func__, __func__, strerror(errno),
(errno == ENOENT) ? tmpstr : "");
close(fd);
@@ -478,7 +475,7 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
if (ccb.cgdl.status == CAM_GDEVLIST_ERROR) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: device %s%d does not exist!",
- func_name, dev_name, unit);
+ __func__, dev_name, unit);
return(NULL);
}
@@ -498,7 +495,6 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
const char *given_path, const char *given_dev_name,
int given_unit_number)
{
- char *func_name = "cam_real_open_device";
union ccb ccb;
int fd = -1, malloced_device = 0;
@@ -510,7 +506,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
sizeof(struct cam_device))) == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: device structure malloc"
- " failed\n%s: %s", func_name, func_name,
+ " failed\n%s: %s", __func__, __func__,
strerror(errno));
return(NULL);
}
@@ -541,7 +537,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
if ((fd = open(path, flags)) < 0) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: couldn't open passthrough device %s\n"
- "%s: %s", func_name, path, func_name,
+ "%s: %s", __func__, path, __func__,
strerror(errno));
goto crod_bailout;
}
@@ -569,7 +565,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
*/
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: CAMGETPASSTHRU ioctl failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ "%s: %s", __func__, __func__, strerror(errno));
goto crod_bailout;
}
@@ -581,7 +577,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
*/
if (ccb.cgdl.status == CAM_GDEVLIST_ERROR) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: passthrough device does not exist!", func_name);
+ "%s: passthrough device does not exist!", __func__);
goto crod_bailout;
}
@@ -596,7 +592,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: Path Inquiry CCB failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ "%s: %s", __func__, __func__, strerror(errno));
goto crod_bailout;
}
strlcpy(device->sim_name, ccb.cpi.dev_name, sizeof(device->sim_name));
@@ -611,7 +607,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: Get Device Type CCB failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ "%s: %s", __func__, __func__, strerror(errno));
goto crod_bailout;
}
device->pd_type = SID_TYPE(&ccb.cgd.inq_data);
@@ -635,7 +631,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: Get Transfer Settings CCB failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ "%s: %s", __func__, __func__, strerror(errno));
goto crod_bailout;
}
if (ccb.cts.transport == XPORT_SPI) {
@@ -712,19 +708,18 @@ cam_path_string(struct cam_device *dev, char *str, int len)
struct cam_device *
cam_device_dup(struct cam_device *device)
{
- char *func_name = "cam_device_dup";
struct cam_device *newdev;
if (device == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: device is NULL", func_name);
+ "%s: device is NULL", __func__);
return (NULL);
}
newdev = malloc(sizeof(struct cam_device));
if (newdev == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: couldn't malloc CAM device structure", func_name);
+ "%s: couldn't malloc CAM device structure", __func__);
return (NULL);
}
@@ -739,17 +734,16 @@ cam_device_dup(struct cam_device *device)
void
cam_device_copy(struct cam_device *src, struct cam_device *dst)
{
- char *func_name = "cam_device_copy";
if (src == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: source device struct was NULL", func_name);
+ "%s: source device struct was NULL", __func__);
return;
}
if (dst == NULL) {
snprintf(cam_errbuf, sizeof(cam_errbuf),
- "%s: destination device struct was NULL", func_name);
+ "%s: destination device struct was NULL", __func__);
return;
}