summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-01-22 22:28:09 +0200
committerToomas Soome <tsoome@me.com>2019-07-01 21:33:31 +0300
commitf4593de73bc951089c91679a1104a589e85475d4 (patch)
tree3d615c37aded4059dc068905939ea3da03e369ee
parentc7832f2df55c7f8d07e31fd48692e0cb47da34a2 (diff)
downloadillumos-joyent-f4593de73bc951089c91679a1104a589e85475d4.tar.gz
11170 print: NULL pointer errors
Reviewed by: Gergő Doma <domag02@gmail.com> Reviewed by: Norm Jacobs <naj@snapcon.com> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/lib/print/libipp-listener/common/common.c77
-rw-r--r--usr/src/lib/print/libpapi-common/common/attribute.c10
-rw-r--r--usr/src/lib/print/libpapi-lpd/common/lpd-job.c20
-rw-r--r--usr/src/lib/print/libpapi-lpd/common/lpd-misc.c8
-rw-r--r--usr/src/lib/print/libprint/common/list.c29
-rw-r--r--usr/src/lib/print/libprint/common/ns_bsd_addr.c90
-rw-r--r--usr/src/lib/print/libprint/common/ns_cmn_printer.c10
-rw-r--r--usr/src/lib/print/libprint/common/nss_convert.c54
-rw-r--r--usr/src/lib/print/libprint/common/nss_write.c12
9 files changed, 146 insertions, 164 deletions
diff --git a/usr/src/lib/print/libipp-listener/common/common.c b/usr/src/lib/print/libipp-listener/common/common.c
index 22ec0dc07d..02370cfeaf 100644
--- a/usr/src/lib/print/libipp-listener/common/common.c
+++ b/usr/src/lib/print/libipp-listener/common/common.c
@@ -25,8 +25,6 @@
*
*/
-/* $Id: common.c 155 2006-04-26 02:34:54Z ktou $ */
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -83,10 +81,10 @@ get_printer_id(papi_attribute_t **attributes, char **printer, int *id)
result = papiAttributeListGetString(attributes, NULL, "job-uri", &job);
if (result != PAPI_OK) {
result = papiAttributeListGetString(attributes, NULL,
- "printer-uri", printer);
+ "printer-uri", printer);
if (result == PAPI_OK)
papiAttributeListGetInteger(attributes, NULL,
- "job-id", id);
+ "job-id", id);
} else {
*printer = job;
if ((job = strrchr(*printer, '/')) != NULL) {
@@ -105,10 +103,10 @@ get_string_list(papi_attribute_t **attributes, char *name, char ***values)
char *value = NULL;
for (result = papiAttributeListGetString(attributes, &iterator,
- name, &value);
+ name, &value);
result == PAPI_OK;
result = papiAttributeListGetString(attributes, &iterator,
- NULL, &value))
+ NULL, &value))
list_append(values, value);
}
@@ -117,17 +115,17 @@ add_default_attributes(papi_attribute_t ***attributes)
{
(void) papiAttributeListAddString(attributes, PAPI_ATTR_APPEND,
- "ipp-versions-supported", "1.0");
+ "ipp-versions-supported", "1.0");
(void) papiAttributeListAddString(attributes, PAPI_ATTR_APPEND,
- "ipp-versions-supported", "1.1");
+ "ipp-versions-supported", "1.1");
(void) papiAttributeListAddBoolean(attributes, PAPI_ATTR_EXCL,
- "multiple-document-jobs-supported", 0);
+ "multiple-document-jobs-supported", 0);
/*
* Should be able to ask the web server if it supports SSL or TLS, but
* for now, we pick only "none"
*/
(void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
- "uri-security-supported", "none");
+ "uri-security-supported", "none");
/*
* For now, we only "none". As we support more authentication methods,
@@ -137,21 +135,21 @@ add_default_attributes(papi_attribute_t ***attributes)
* See RFC2911 page 127 for more information.
*/
(void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
- "uri-authentication-supported", "requesting-user-name");
+ "uri-authentication-supported", "requesting-user-name");
(void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
- "uri-security-supported", "none");
+ "uri-security-supported", "none");
/* printer-uri-supported is added in the service based attributes */
(void) papiAttributeListAddInteger(attributes, PAPI_ATTR_EXCL,
- "multiple-operation-time-out", 60);
+ "multiple-operation-time-out", 60);
/* I18N related */
(void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
- "charset-configured", "utf-8");
+ "charset-configured", "utf-8");
(void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
- "charset-supported", "utf-8");
+ "charset-supported", "utf-8");
(void) papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE,
- "natural-language-configured", "en-us");
+ "natural-language-configured", "en-us");
}
static void
@@ -159,7 +157,7 @@ massage_printer_attributes_group(papi_attribute_t **group, char *printer_uri)
{
if (papiAttributeListFind(group, "printer-uri-supported") != NULL)
papiAttributeListAddString(&group, PAPI_ATTR_REPLACE,
- "printer-uri-supported", printer_uri);
+ "printer-uri-supported", printer_uri);
}
static void
@@ -167,7 +165,7 @@ massage_job_attributes_group(papi_attribute_t **group, char *printer_uri)
{
if (papiAttributeListFind(group, "job-printer-uri") != NULL)
papiAttributeListAddString(&group, PAPI_ATTR_REPLACE,
- "job-printer-uri", printer_uri);
+ "job-printer-uri", printer_uri);
if (papiAttributeListFind(group, "job-printer-uri") != NULL) {
char buf[BUFSIZ];
@@ -176,7 +174,7 @@ massage_job_attributes_group(papi_attribute_t **group, char *printer_uri)
papiAttributeListGetInteger(group, NULL, "job-id", &id);
snprintf(buf, sizeof (buf), "%s/%d", printer_uri, id);
papiAttributeListAddString(&group, PAPI_ATTR_REPLACE,
- "job-uri", buf);
+ "job-uri", buf);
}
}
@@ -205,18 +203,16 @@ massage_response(papi_attribute_t **request, papi_attribute_t **response)
snprintf(buf, sizeof (buf), "http://%s:%d%s", host, port, path);
for (status = papiAttributeListGetCollection(response, &iter,
- "printer-attributes-group", &group);
- status == PAPI_OK;
- status = papiAttributeListGetCollection(NULL, &iter,
- NULL, &group))
+ "printer-attributes-group", &group);
+ status == PAPI_OK;
+ status = papiAttributeListGetCollection(NULL, &iter, NULL, &group))
massage_printer_attributes_group(group, buf);
iter = NULL;
for (status = papiAttributeListGetCollection(response, &iter,
- "job-attributes-group", &group);
- status == PAPI_OK;
- status = papiAttributeListGetCollection(NULL, &iter,
- NULL, &group))
+ "job-attributes-group", &group);
+ status == PAPI_OK;
+ status = papiAttributeListGetCollection(NULL, &iter, NULL, &group))
massage_job_attributes_group(group, buf);
}
@@ -230,7 +226,7 @@ add_supported_locales(papi_attribute_t ***attributes)
FILE *fp;
papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE,
- "generated-natural-language-supported", "en-us");
+ "generated-natural-language-supported", "en-us");
if ((fp = fopen("/usr/lib/locale/lcttab", "r")) != NULL) {
char buf[1024];
@@ -243,26 +239,29 @@ add_supported_locales(papi_attribute_t ***attributes)
if (name == NULL)
continue;
- for (i = 0; ((passed == 1) && (name[i] != NULL)); i++)
+ for (i = 0; ((passed == 1) && (name[i] != '\0')); i++) {
if (isalpha(name[i]) != 0)
name[i] = tolower(name[i]);
else if ((name[i] == '_') || (name[i] == '-'))
name[i] = '-';
else
passed = 0;
+ }
if ((passed == 1) &&
((file = strtok(NULL, " \t\n")) != NULL)) {
char path[1024];
snprintf(path, sizeof (path),
- "/usr/lib/locale/%s", file);
+ "/usr/lib/locale/%s", file);
+
+ if (access(path, F_OK) != 0)
+ continue;
- if (access(path, F_OK) == 0)
- papiAttributeListAddString(attributes,
- PAPI_ATTR_APPEND,
- "generated-natural-language-supported",
- name);
+ papiAttributeListAddString(attributes,
+ PAPI_ATTR_APPEND,
+ "generated-natural-language-supported",
+ name);
}
}
(void) fclose(fp);
@@ -271,7 +270,7 @@ add_supported_locales(papi_attribute_t ***attributes)
void
papi_to_ipp_printer_group(papi_attribute_t ***response,
- papi_attribute_t **request, int flags, papi_printer_t p)
+ papi_attribute_t **request, int flags, papi_printer_t p)
{
papi_attribute_t **ipp_group = NULL;
@@ -284,19 +283,19 @@ papi_to_ipp_printer_group(papi_attribute_t ***response,
ipp_operations_supported(&ipp_group, request);
(void) papiAttributeListAddCollection(response, flags,
- "printer-attributes-group", ipp_group);
+ "printer-attributes-group", ipp_group);
papiAttributeListFree(ipp_group);
}
void
papi_to_ipp_job_group(papi_attribute_t ***response,
- papi_attribute_t **request, int flags, papi_job_t j)
+ papi_attribute_t **request, int flags, papi_job_t j)
{
papi_attribute_t **ipp_group = NULL;
copy_attributes(&ipp_group, papiJobGetAttributeList(j));
(void) papiAttributeListAddCollection(response, flags,
- "job-attributes-group", ipp_group);
+ "job-attributes-group", ipp_group);
papiAttributeListFree(ipp_group);
}
diff --git a/usr/src/lib/print/libpapi-common/common/attribute.c b/usr/src/lib/print/libpapi-common/common/attribute.c
index 8e90d4e9e0..50493f153a 100644
--- a/usr/src/lib/print/libpapi-common/common/attribute.c
+++ b/usr/src/lib/print/libpapi-common/common/attribute.c
@@ -160,8 +160,9 @@ papiAttributeValueDup(papi_attribute_value_type_t type,
if (v->string == NULL) {
free(result);
result = NULL;
- } else
+ } else {
result->string = strdup(v->string);
+ }
break;
case PAPI_INTEGER:
result->integer = v->integer;
@@ -451,8 +452,9 @@ papiAttributeListGetValue(papi_attribute_t **list, void **iter,
return (PAPI_NOT_POSSIBLE);
tmp = attr->values;
- } else
+ } else {
tmp = *iter;
+ }
if (tmp == NULL)
return (PAPI_NOT_FOUND);
@@ -648,7 +650,7 @@ _process_value(char *string, char ***parts)
{ PAPI_RANGE, 3, "^([[:digit:]]*)-([[:digit:]]*)$", 0 },
{ PAPI_RESOLUTION, 4, "^([[:digit:]]+)x([[:digit:]]+)dp(i|c)$",
0 },
- NULL
+ 0
};
regmatch_t matches[4];
@@ -867,7 +869,7 @@ papiAttributeListFromString(papi_attribute_t ***attrs, int flags, char *string)
papi_status_t result = PAPI_OK;
if ((attrs != NULL) && (string != NULL) &&
- ((flags & ~(PAPI_ATTR_APPEND+PAPI_ATTR_REPLACE+PAPI_ATTR_EXCL))
+ ((flags & ~(PAPI_ATTR_APPEND + PAPI_ATTR_REPLACE + PAPI_ATTR_EXCL))
== 0)) {
result = _parse_attribute_list(attrs, flags, string);
} else {
diff --git a/usr/src/lib/print/libpapi-lpd/common/lpd-job.c b/usr/src/lib/print/libpapi-lpd/common/lpd-job.c
index c958a51e06..e3e93f485d 100644
--- a/usr/src/lib/print/libpapi-lpd/common/lpd-job.c
+++ b/usr/src/lib/print/libpapi-lpd/common/lpd-job.c
@@ -98,8 +98,9 @@ add_lpd_control_line(char **metadata, char code, char *value)
strlcpy(tmp, *metadata, size);
free(*metadata);
*metadata = (char *)tmp;
- } else
+ } else {
return (PAPI_TEMPORARY_ERROR);
+ }
}
snprintf(line, sizeof (line), "%c%s\n", code, value);
@@ -151,7 +152,7 @@ add_int_control_line(char **metadata, char code, int value, int flag)
static papi_status_t
lpd_add_rfc1179_attributes(service_t *svc, papi_attribute_t **attributes,
- char **metadata, papi_attribute_t ***used)
+ char **metadata, papi_attribute_t ***used)
{
papi_status_t status = PAPI_OK;
char *s;
@@ -347,7 +348,7 @@ unused_attributes(papi_attribute_t **list, papi_attribute_t **used)
*/
static papi_status_t
lpd_add_svr4_attributes(service_t *svc, papi_attribute_t **attributes,
- char **metadata, papi_attribute_t ***used)
+ char **metadata, papi_attribute_t ***used)
{
papi_attribute_t *tmp[2];
char *s;
@@ -384,7 +385,7 @@ lpd_add_svr4_attributes(service_t *svc, papi_attribute_t **attributes,
/* Pages */
s = NULL;
- memset(tmp, NULL, sizeof (tmp));
+ memset(tmp, 0, sizeof (tmp));
tmp[0] = papiAttributeListFind(attributes, "page-ranges");
if (tmp[0] != NULL) {
char buf[BUFSIZ];
@@ -438,7 +439,7 @@ lpd_add_svr4_attributes(service_t *svc, papi_attribute_t **attributes,
papi_status_t
lpd_add_hpux_attributes(service_t *svc, papi_attribute_t **attributes,
- char **metadata, papi_attribute_t ***used)
+ char **metadata, papi_attribute_t ***used)
{
char *s = NULL;
@@ -453,7 +454,7 @@ lpd_add_hpux_attributes(service_t *svc, papi_attribute_t **attributes,
papi_status_t
lpd_job_add_attributes(service_t *svc, papi_attribute_t **attributes,
- char **metadata, papi_attribute_t ***used)
+ char **metadata, papi_attribute_t ***used)
{
if ((svc == NULL) || (metadata == NULL))
return (PAPI_BAD_REQUEST);
@@ -480,7 +481,7 @@ lpd_job_add_attributes(service_t *svc, papi_attribute_t **attributes,
papi_status_t
lpd_job_add_files(service_t *svc, papi_attribute_t **attributes,
- char **files, char **metadata, papi_attribute_t ***used)
+ char **files, char **metadata, papi_attribute_t ***used)
{
char *format = "text/plain";
char rfc_fmt = 'l';
@@ -563,7 +564,7 @@ lpd_job_add_files(service_t *svc, papi_attribute_t **attributes,
papi_status_t
lpd_submit_job(service_t *svc, char *metadata, papi_attribute_t ***attributes,
- int *ofd)
+ int *ofd)
{
papi_status_t status = PAPI_INTERNAL_ERROR;
int fd;
@@ -603,8 +604,9 @@ lpd_submit_job(service_t *svc, char *metadata, papi_attribute_t ***attributes,
status = PAPI_TIMEOUT;
break;
}
- } else
+ } else {
status = PAPI_OK;
+ }
if (ofd != NULL)
*ofd = fd;
diff --git a/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c b/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c
index 1dc9589d25..274ed50aa0 100644
--- a/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c
+++ b/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c
@@ -83,7 +83,7 @@ recvfd(int sockfd)
#if defined(sun) && defined(unix) && defined(I_RECVFD)
struct strrecvfd recv_fd;
- memset(&recv_fd, NULL, sizeof (recv_fd));
+ memset(&recv_fd, 0, sizeof (recv_fd));
if (ioctl(sockfd, I_RECVFD, &recv_fd) == 0)
fd = recv_fd.fd;
#else
@@ -136,7 +136,8 @@ lpd_open(service_t *svc, char type, char **args, int timeout)
#define SUID_LPD_PORT "/usr/lib/print/lpd-port"
#endif
- av[0] = SUID_LPD_PORT; ac = 1;
+ av[0] = SUID_LPD_PORT;
+ ac = 1;
/* server */
av[ac++] = "-H";
@@ -189,7 +190,8 @@ lpd_open(service_t *svc, char type, char **args, int timeout)
default: { /* parent */
int err, status = 0;
- while ((waitpid(pid, &status, 0) < 0) && (errno == EINTR));
+ while ((waitpid(pid, &status, 0) < 0) && (errno == EINTR))
+ ;
errno = WEXITSTATUS(status);
if (errno == 0)
diff --git a/usr/src/lib/print/libprint/common/list.c b/usr/src/lib/print/libprint/common/list.c
index 56060f44ec..fe7202baf5 100644
--- a/usr/src/lib/print/libprint/common/list.c
+++ b/usr/src/lib/print/libprint/common/list.c
@@ -59,14 +59,15 @@ list_append(void **list, void *item)
if (list != NULL)
list[0] = item;
} else {
- int count;
+ int count;
- for (count = 0; list[count] != NULL; count++);
+ for (count = 0; list[count] != NULL; count++)
+ ;
if ((count + 1) % _list_increment == 0) { /* increase size */
- void **new_list = NULL;
+ void **new_list = NULL;
int new_size = (((count + 1) / _list_increment) + 1) *
- _list_increment;
+ _list_increment;
new_list = (void **)calloc(new_size, sizeof (void *));
if (new_list == NULL)
@@ -123,28 +124,25 @@ list_locate(void **list, int (*compair)(void *, void *), void *element)
void **
list_concatenate(void **list1, void **list2)
{
- void **list = NULL;
- int size1 = 0,
- size2 = 0,
- new_size = 0;
+ void **list = NULL;
+ int size1 = 0, size2 = 0, new_size = 0;
#ifdef DEBUG
syslog(LOG_DEBUG, "list_concatenate(0x%x, 0x%x)", list1, list2);
#endif
if ((list1 == NULL) || (list2 == NULL))
return ((list1 != NULL) ? list1 : list2);
- for (size1 = 0; list1[size1] != NULL; size1++);
- for (size2 = 0; list2[size2] != NULL; size2++);
+ for (size1 = 0; list1[size1] != NULL; size1++)
+ ;
+ for (size2 = 0; list2[size2] != NULL; size2++)
+ ;
/* list1 + list2 padded to a multiple of _list_increment */
new_size = ((size1 + size2)/_list_increment + 2) * _list_increment;
- if ((list = (void **)calloc((new_size), sizeof (void *)))
- != NULL) {
+ if ((list = (void **)calloc((new_size), sizeof (void *))) != NULL) {
int count = 0;
- (void) memset(list, NULL, (new_size * sizeof (void *)));
-
for (size1 = 0; list1[size1] != NULL; size1++)
list[count++] = list1[size1];
for (size2 = 0; list2[size2] != NULL; size2++)
@@ -168,8 +166,7 @@ list_concatenate(void **list1, void **list2)
int
list_iterate(void **list, int (*vfunc)(void *, va_list), ...)
{
- int current = 0,
- rc = 0;
+ int current = 0, rc = 0;
#ifdef DEBUG
syslog(LOG_DEBUG, "list_iterate(0x%x, 0x%x)", list, vfunc);
diff --git a/usr/src/lib/print/libprint/common/ns_bsd_addr.c b/usr/src/lib/print/libprint/common/ns_bsd_addr.c
index ba142bb8a1..92a68f1964 100644
--- a/usr/src/lib/print/libprint/common/ns_bsd_addr.c
+++ b/usr/src/lib/print/libprint/common/ns_bsd_addr.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*LINTLIBRARY*/
#include <stdio.h>
@@ -93,7 +91,7 @@ bsd_addr_to_string(const ns_bsd_addr_t *addr)
if (addr->extension != NULL) {
(void) strlcat(buf, ",", sizeof (buf));
if (strlcat(buf, addr->extension, sizeof (buf))
- >= sizeof (buf)) {
+ >= sizeof (buf)) {
syslog(LOG_ERR, "bsd_addr_to_string: buffer overflow");
return (NULL);
}
@@ -163,7 +161,7 @@ internal_list_to_string(const ns_printer_t **list)
(void) strlcat(buf, ",", sizeof (buf));
if (strlcat(buf, (*list)->name, sizeof (buf)) >= sizeof (buf)) {
syslog(LOG_ERR,
- "internal_list_to_string:buffer overflow");
+ "internal_list_to_string:buffer overflow");
return (NULL);
}
}
@@ -181,7 +179,7 @@ value_to_string(const char *key, void *value)
if (strcmp(key, NS_KEY_BSDADDR) == 0) {
string = bsd_addr_to_string(value);
} else if ((strcmp(key, NS_KEY_ALL) == 0) ||
- (strcmp(key, NS_KEY_GROUP) == 0)) {
+ (strcmp(key, NS_KEY_GROUP) == 0)) {
string = list_to_string(value);
} else if (strcmp(key, NS_KEY_LIST) == 0) {
string = internal_list_to_string(value);
@@ -199,11 +197,11 @@ string_to_value(const char *key, char *string)
{
void *value = NULL;
- if ((key != NULL) && (string != NULL) && (string[0] != NULL)) {
+ if ((key != NULL) && (string != NULL) && (string[0] != '\0')) {
if (strcmp(key, NS_KEY_BSDADDR) == 0) {
value = (void *)string_to_bsd_addr(string);
} else if ((strcmp(key, NS_KEY_ALL) == 0) ||
- (strcmp(key, NS_KEY_GROUP) == 0)) {
+ (strcmp(key, NS_KEY_GROUP) == 0)) {
value = (void *)strsplit(string, ",");
} else {
value = (void *)string;
@@ -232,9 +230,9 @@ split_name(char *name, const char *delimiter, char **p1, char **p2, char **p3)
for (tmp = (char *)strtok_r(name, delimiter, &junk); tmp != NULL;
tmp = (char *)strtok_r(NULL, delimiter, &junk))
- if ((p1 != NULL) && (*p1 == NULL))
+ if ((p1 != NULL) && (*p1 == NULL)) {
*p1 = tmp;
- else if ((p2 != NULL) && (*p2 == NULL)) {
+ } else if ((p2 != NULL) && (*p2 == NULL)) {
*p2 = tmp;
if (p3 == NULL)
break;
@@ -275,18 +273,18 @@ posix_name(const char *name)
memset(buf, 0, sizeof (buf));
if ((server != NULL) && (queue != NULL))
snprintf(buf, sizeof (buf), "%s,%s%s%s", server,
- queue, (extension != NULL ? "," : ""),
- (extension != NULL ? extension : ""));
+ queue, (extension != NULL ? "," : ""),
+ (extension != NULL ? extension : ""));
/* build the structure here */
- if (buf[0] != NULL) {
+ if (buf[0] != '\0') {
ns_kvp_t **list, *kvp;
kvp = ns_kvp_create(NS_KEY_BSDADDR, buf);
list = (ns_kvp_t **)list_append(NULL, kvp);
if (list != NULL)
printer = ns_printer_create(strdup(name), NULL,
- "posix", list);
+ "posix", list);
}
}
@@ -331,33 +329,28 @@ ns_bsd_addr_cmp(ns_bsd_addr_t *a1, ns_bsd_addr_t *a2)
* real printer names and alias names while doing the compare.
*
* INPUTS: ns_bsd_addr_t *a1 - a bsd addr
- * ns_bsd_addr_t *21 - another bsd addr
+ * ns_bsd_addr_t *a2 - another bsd addr
*/
static int
ns_bsd_addr_cmp_local(ns_bsd_addr_t *a1, ns_bsd_addr_t *a2)
-
{
int rc;
- if ((a1 == NULL) || (a2 == NULL))
- {
+ if ((a1 == NULL) || (a2 == NULL)) {
return (1);
}
- if ((rc = strcmp(a1->server, a2->server)) != 0)
- {
+ if ((rc = strcmp(a1->server, a2->server)) != 0) {
return (rc);
}
- if ((a1->printer == NULL) || (a2->printer == NULL))
- {
+ if ((a1->printer == NULL) || (a2->printer == NULL)) {
return (a1->printer != a2->printer);
}
rc = strcmp(a1->printer, a2->printer);
- if (rc == 0)
- {
+ if (rc == 0) {
/*
* The printer's real names are the same, but now check if
* their local names (alias) are the same.
@@ -425,14 +418,13 @@ ns_bsd_addr_get_name(char *name)
*/
ns_bsd_addr_t **
ns_bsd_addr_get_list(int unique)
-
{
ns_printer_t **printers;
ns_bsd_addr_t **list = NULL;
char **aliases = NULL;
for (printers = ns_printer_get_list(NULL);
- printers != NULL && *printers != NULL; printers++) {
+ printers != NULL && *printers != NULL; printers++) {
ns_bsd_addr_t *addr;
if (strcmp(NS_NAME_ALL, (*printers)->name) == 0)
@@ -447,49 +439,39 @@ ns_bsd_addr_get_list(int unique)
if (unique == UNIQUE)
list =
(ns_bsd_addr_t **)list_append_unique((void **)list,
- (void *)addr, (COMP_T)ns_bsd_addr_cmp);
- else
- if (unique == LOCAL_UNIQUE)
+ (void *)addr, (COMP_T)ns_bsd_addr_cmp);
+ else if (unique == LOCAL_UNIQUE)
list =
(ns_bsd_addr_t **)list_append_unique((void **)list,
- (void *)addr, (COMP_T)ns_bsd_addr_cmp_local);
+ (void *)addr, (COMP_T)ns_bsd_addr_cmp_local);
else
list = (ns_bsd_addr_t **)list_append((void **)list,
- (void *)addr);
+ (void *)addr);
for (aliases = (*printers)->aliases;
- (aliases != NULL) && (*aliases != NULL); aliases++)
- {
+ (aliases != NULL) && (*aliases != NULL); aliases++) {
/*
* Include any alias names that belong to the printer
*/
if ((addr =
- ns_get_value(NS_KEY_BSDADDR, *printers)) != NULL)
- {
- if (addr->printer == NULL)
- {
+ ns_get_value(NS_KEY_BSDADDR, *printers)) != NULL) {
+ if (addr->printer == NULL) {
addr->printer = strdup(*aliases);
}
addr->pname = strdup(*aliases);
}
- if (unique == UNIQUE)
- {
+ if (unique == UNIQUE) {
list = (ns_bsd_addr_t **)
- list_append_unique((void **)list,
- (void *)addr, (COMP_T)ns_bsd_addr_cmp);
- }
- else
- if (unique == LOCAL_UNIQUE)
- {
+ list_append_unique((void **)list,
+ (void *)addr, (COMP_T)ns_bsd_addr_cmp);
+ } else if (unique == LOCAL_UNIQUE) {
list = (ns_bsd_addr_t **)
- list_append_unique((void **)list,
- (void *)addr,
- (COMP_T)ns_bsd_addr_cmp_local);
- }
- else
- {
+ list_append_unique((void **)list,
+ (void *)addr,
+ (COMP_T)ns_bsd_addr_cmp_local);
+ } else {
list = (ns_bsd_addr_t **)
list_append((void **)list, (void *)addr);
}
@@ -526,14 +508,14 @@ ns_bsd_addr_get_all(int unique)
def = NS_NAME_DEFAULT;
list = (ns_bsd_addr_t **)list_append((void **)list,
- (void *)ns_bsd_addr_get_name(def));
+ (void *)ns_bsd_addr_get_name(def));
endprinterentry();
if ((printer = ns_printer_get_name(NS_NAME_ALL, NULL)) == NULL)
return (ns_bsd_addr_get_list(unique));
for (printers = (char **)ns_get_value(NS_KEY_ALL, printer);
- printers != NULL && *printers != NULL; printers++) {
+ printers != NULL && *printers != NULL; printers++) {
ns_bsd_addr_t *addr;
addr = ns_bsd_addr_get_name(*printers);
@@ -542,10 +524,10 @@ ns_bsd_addr_get_all(int unique)
if (unique == UNIQUE)
list =
(ns_bsd_addr_t **)list_append_unique((void **)list,
- (void *)addr, (COMP_T)ns_bsd_addr_cmp);
+ (void *)addr, (COMP_T)ns_bsd_addr_cmp);
else
list = (ns_bsd_addr_t **)list_append((void **)list,
- (void *)addr);
+ (void *)addr);
}
return (list);
diff --git a/usr/src/lib/print/libprint/common/ns_cmn_printer.c b/usr/src/lib/print/libprint/common/ns_cmn_printer.c
index d289245e11..42a1fa350c 100644
--- a/usr/src/lib/print/libprint/common/ns_cmn_printer.c
+++ b/usr/src/lib/print/libprint/common/ns_cmn_printer.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*LINTLIBRARY*/
#include <stdio.h>
@@ -62,7 +60,7 @@
*/
ns_printer_t *
ns_printer_create(char *name, char **aliases, char *source,
- ns_kvp_t **attributes)
+ ns_kvp_t **attributes)
{
ns_printer_t *printer;
@@ -104,7 +102,7 @@ ns_printer_match_name(ns_printer_t *printer, const char *name)
if ((strcmp(printer->name, name) == 0) ||
(list_locate((void **)printer->aliases,
- (COMP_T)ns_strcmp, (void *)name) != NULL))
+ (COMP_T)ns_strcmp, (void *)name) != NULL))
return (0);
return (-1);
@@ -147,9 +145,9 @@ ns_printer_name_list(const ns_printer_t *printer)
}
list_iterate((void **)printer->aliases,
- (VFUNC_T)_ns_append_printer_name, buf, sizeof (buf));
+ (VFUNC_T)_ns_append_printer_name, buf, sizeof (buf));
- buf[strlen(buf) - 1] = (char)NULL;
+ buf[strlen(buf) - 1] = '\0';
return (strdup(buf));
}
diff --git a/usr/src/lib/print/libprint/common/nss_convert.c b/usr/src/lib/print/libprint/common/nss_convert.c
index eaee6df5b2..21610b157e 100644
--- a/usr/src/lib/print/libprint/common/nss_convert.c
+++ b/usr/src/lib/print/libprint/common/nss_convert.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains routines necessary to convert a string buffer into
* a printer object.
@@ -53,18 +51,18 @@ strncat_escaped(char *d, char *s, int len, char *escape)
{
char *t = d;
- while ((*t != NULL) && (len > 0))
+ while ((*t != '\0') && (len > 0))
len--, t++;
if (escape == NULL)
escape = "\\";
- while ((*s != NULL) && (len > 0)) {
+ while ((*s != '\0') && (len > 0)) {
if (strchr(escape, *s) != NULL)
len--, *t++ = '\\';
len--, *t++ = *s++;
}
- *t = NULL;
+ *t = '\0';
return (d);
}
@@ -77,13 +75,13 @@ _cvt_printer_to_entry(ns_printer_t *printer, char *buf, int buflen)
int i, len;
int bufferok = 1;
- (void) memset(buf, NULL, buflen);
+ (void) memset(buf, 0, buflen);
if ((printer == NULL) || (printer->attributes == NULL))
return (NULL);
if (snprintf(buf, buflen, "%s", printer->name) >= buflen) {
- (void) memset(buf, NULL, buflen);
+ (void) memset(buf, 0, buflen);
syslog(LOG_ERR, "_cvt_printer_to_entry: buffer overflow");
return (NULL);
}
@@ -99,7 +97,7 @@ _cvt_printer_to_entry(ns_printer_t *printer, char *buf, int buflen)
}
if (strlcat(buf, ":", buflen) >= buflen) {
- (void) memset(buf, NULL, buflen);
+ (void) memset(buf, 0, buflen);
syslog(LOG_ERR, "_cvt_printer_to_entry: buffer overflow");
return (NULL);
}
@@ -121,13 +119,13 @@ _cvt_printer_to_entry(ns_printer_t *printer, char *buf, int buflen)
}
if (!bufferok) {
- (void) memset(buf, NULL, buflen);
+ (void) memset(buf, 0, buflen);
syslog(LOG_ERR, "_cvt_printer_to_entry: buffer overflow");
return (NULL);
}
if (strlen(buf) == len) { /* there were no attributes */
- (void) memset(buf, NULL, buflen);
+ (void) memset(buf, 0, buflen);
buf = NULL;
}
@@ -138,19 +136,15 @@ _cvt_printer_to_entry(ns_printer_t *printer, char *buf, int buflen)
ns_printer_t *
_cvt_nss_entry_to_printer(char *entry, char *ns)
{
- char *name = NULL,
- *key = NULL,
- **aliases = NULL,
- *cp,
- buf[BUFSIZ];
+ char *name = NULL, *key = NULL, **aliases = NULL, *cp, buf[BUFSIZ];
int in_namelist = 1, buf_pos = 0;
ns_printer_t *printer = NULL;
if (entry == NULL)
return (NULL);
- (void) memset(buf, NULL, sizeof (buf));
- for (cp = entry; *cp != NULL; cp++) {
+ (void) memset(buf, 0, sizeof (buf));
+ for (cp = entry; *cp != '\0'; cp++) {
switch (*cp) {
case ':': /* end of kvp */
if (in_namelist != 0) {
@@ -158,25 +152,27 @@ _cvt_nss_entry_to_printer(char *entry, char *ns)
name = strdup(buf);
else
aliases = (char **)list_append(
- (void **)aliases,
- (void *)strdup(buf));
+ (void **)aliases,
+ (void *)strdup(buf));
printer = (ns_printer_t *)ns_printer_create(
- name, aliases, ns, NULL);
+ name, aliases, ns, NULL);
in_namelist = 0;
- } else if (key != NULL)
+ } else if (key != NULL) {
(void) ns_set_value_from_string(key, buf,
printer);
- (void) memset(buf, NULL, sizeof (buf));
+ }
+ (void) memset(buf, 0, sizeof (buf));
buf_pos = 0;
key = NULL;
break;
case '=': /* kvp seperator */
if (key == NULL) {
key = strdup(buf);
- (void) memset(buf, NULL, sizeof (buf));
+ (void) memset(buf, 0, sizeof (buf));
buf_pos = 0;
- } else
+ } else {
buf[buf_pos++] = *cp;
+ }
break;
case '|': /* namelist seperator */
if (in_namelist != 0) {
@@ -184,12 +180,14 @@ _cvt_nss_entry_to_printer(char *entry, char *ns)
name = strdup(buf);
else
aliases = (char **)list_append(
- (void **)aliases,
- (void *)strdup(buf));
- (void) memset(buf, NULL, sizeof (buf));
+ (void **)aliases,
+ (void *)strdup(buf));
+ (void) memset(buf, 0, sizeof (buf));
buf_pos = 0;
- } else /* add it to the buffer */
+ } else {
+ /* add it to the buffer */
buf[buf_pos++] = *cp;
+ }
break;
case '\\': /* escape char */
buf[buf_pos++] = *(++cp);
diff --git a/usr/src/lib/print/libprint/common/nss_write.c b/usr/src/lib/print/libprint/common/nss_write.c
index c617f0d0a5..0eb6ef7e35 100644
--- a/usr/src/lib/print/libprint/common/nss_write.c
+++ b/usr/src/lib/print/libprint/common/nss_write.c
@@ -64,7 +64,7 @@ freadline(FILE *fp, char *buf, int buflen)
continue;
} else {
if ((*s == '#') || (*s == '\n')) {
- *s = NULL;
+ *s = '\0';
break;
}
@@ -108,7 +108,7 @@ _file_put_printer(const char *file, const ns_printer_t *printer)
/* LINTED */
while (1) { /* syncronize writes */
- fd = open(file, O_RDWR|O_CREAT|O_EXCL, 0644);
+ fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644);
if ((fd < 0) && (errno == EEXIST))
fd = open(file, O_RDWR);
if (fd < 0) {
@@ -165,8 +165,9 @@ _file_put_printer(const char *file, const ns_printer_t *printer)
== 0) {
entry = pentry;
pentry = NULL;
- } else
+ } else {
entry = buf;
+ }
(void) fprintf(ofp, "%s\n", entry);
}
@@ -228,8 +229,9 @@ remote_command(char *command, char *host)
return (-1);
(void) close(fd);
return (0);
- } else
+ } else {
return (-1);
+ }
}
@@ -273,7 +275,7 @@ nis_put_printer(const ns_printer_t *printer)
if (((tmp = strrchr(rfile, '.')) != NULL) &&
(strcmp(tmp, ".byname") == 0))
- *tmp = NULL; /* strip the .byname */
+ *tmp = '\0'; /* strip the .byname */
/* copy it local */
if (snprintf(cmd, sizeof (cmd), "rcp %s %s >/dev/null 2>&1",