NULL is a pointer, not string terminator
authorMarcin Cieslak <saper@saper.info>
Mon, 13 Aug 2012 10:08:03 +0000 (12:08 +0200)
committerJon Trulson <jon@radscan.com>
Tue, 14 Aug 2012 01:23:34 +0000 (19:23 -0600)
Replace some instances of NULL to '\0', when
referring to string terminator.

14 files changed:
cde/lib/csa/api.c
cde/lib/csa/attr.c
cde/lib/csa/calendar.c
cde/lib/csa/cmsdata.c
cde/lib/csa/convert4-5.c
cde/lib/csa/convert5-4.c
cde/lib/csa/entry.c
cde/lib/csa/iso8601.c
cde/lib/csa/laccess.c
cde/lib/csa/lutil.c
cde/lib/csa/match.c
cde/lib/csa/nametbl.c
cde/lib/csa/reparser.y
cde/lib/csa/rpccalls.c

index 5ca49af7e4820aadc3121d846919dd76840829a7..9c789a51cc28797419ae0cde49383f71953bc7c4 100644 (file)
@@ -997,7 +997,7 @@ csa_list_entry_sequence(
                rtype = &entry->e->attrs[CSA_ENTRY_ATTR_RECURRENCE_RULE_I];
                if (rtype->value == NULL ||
                    rtype->value->item.string_value == NULL ||
-                   *(rtype->value->item.string_value) == NULL) {
+                   *(rtype->value->item.string_value) == '\0' ) {
                        return (CSA_E_INVALID_PARAMETER);
                }
        }
index 2dc4d0265045a005d9da6df9b5cfe02d7c6a60fc..eaa168417e41925b4ef541ef3b4950795c61c6b5 100644 (file)
@@ -1907,8 +1907,8 @@ _CheckNameAtHost(char *owner, char *value)
                        return (CSA_E_FAILURE);
        }
 
-       if (optr = strchr(owner, '@')) *optr = NULL;
-       if (ptr = strchr(value, '@')) *ptr = NULL;
+       if (optr = strchr(owner, '@')) *optr = '\0';
+       if (ptr = strchr(value, '@')) *ptr = '\0';
        res = strcmp(value, owner);
        if (optr) *optr = '@';
        if (ptr) *ptr = '@';
@@ -1965,7 +1965,7 @@ _CheckCalendarName(char *owner, char *cname, cms_attribute_value *val)
        /* now make sure if cal name is a user name, it's
         * the same as that of the calling user
         */
-       if (ptr = strchr(val->item.string_value, '@')) *ptr = NULL;
+       if (ptr = strchr(val->item.string_value, '@')) *ptr = '\0';
        isuser = _DtCmIsUserName(val->item.string_value);
        if (ptr) *ptr = '@';
 
index 00798069720738b049027a2967e5e9a9c1ffe41c..ea1b75b5d62005cf6afdd537932e305f7ceccbc1 100644 (file)
@@ -90,7 +90,7 @@ _DtCm_new_Calendar(const char *calendar)
        if ((cal = (Calendar *)malloc(sizeof(Calendar))) == NULL)
                return(NULL);
 
-       memset((void *)cal, NULL, sizeof(Calendar));
+       memset((void *)cal, 0, sizeof(Calendar));
 
        if ((cal->name = strdup(calendar)) == NULL) {
                free(cal);
@@ -305,7 +305,7 @@ _DtCm_list_old_cal_attr_names(
        for (i = 1, j = 0; i <= _DtCM_DEFINED_CAL_ATTR_SIZE; i++) {
                if (_CSA_cal_attr_info[i].fst_vers > 0 &&
                    _CSA_cal_attr_info[i].fst_vers <= cal->file_version) {
-                       if (i == CSA_CAL_ATTR_CALENDAR_OWNER_I && *buf == NULL)
+                       if (i == CSA_CAL_ATTR_CALENDAR_OWNER_I && *buf == '\0')
                                continue;
 
                        if ((names[j] =
@@ -527,7 +527,7 @@ _get_owner_from_old_cal(Calendar *cal, char *owner)
        if (_DtCmIsUserName(calname) == B_TRUE)
                strcpy(owner, calname);
        else
-               *owner = NULL;
+               *owner = '\0';
 
        free(calname);
        return (CSA_SUCCESS);
@@ -555,7 +555,7 @@ _get_calendar_owner(
        } else {
                if ((stat = _get_owner_from_old_cal(cal, buf)) != CSA_SUCCESS)
                        return (stat);
-               else if (*buf == NULL)
+               else if (*buf == '\0')
                        return (CSA_SUCCESS);
                else
                        owner = buf;
index 1ce04b14f2f5680db3eae0d1ac0c25f3ca27f73e..3893a5915e220772c29f26e8af974c00bd15715d 100644 (file)
@@ -164,7 +164,7 @@ _DtCmGrowAttrArray(uint *num_attrs, cms_attribute **attrs, cms_attribute *attr)
                return (CSA_E_INSUFFICIENT_MEMORY);
        else {
                *attrs = newptr;
-               memset((void *)&(*attrs)[*num_attrs+1], NULL,
+               memset((void *)&(*attrs)[*num_attrs+1], 0,
                        sizeof(cms_attribute) * (index - *num_attrs));
        }
 
index dfca086dbf5887e4906417faee2e29ec558b31a8..344c4a2ae0edb7fce0c84befe25c5ef3e39a342d 100644 (file)
@@ -378,7 +378,7 @@ _DtCmAttr4ToReminderValue(
        _csa_duration_to_iso8601(atoi(remval->value), timestr);
        rval.lead_time = timestr;
 
-       if (remval->clientdata && *remval->clientdata != NULL) {
+       if (remval->clientdata && *remval->clientdata != '\0') {
                rval.reminder_data.size = strlen(remval->clientdata);
                rval.reminder_data.data = (unsigned char *)remval->clientdata;
        } else {
index 7ec6c5c8f10fa352d9fda40521e2361653232875..fb439d5470967eb132ecf59455d38a05c20052f4 100644 (file)
@@ -92,11 +92,11 @@ _DtCm_cmsattrs_to_apptdata(uint size, cms_attribute *attrs, Appt_4 *appt)
        {
                strncpy(buf, (char *)aptr->value->item.opaque_data_value->data,
                        aptr->value->item.opaque_data_value->size);
-               buf[aptr->value->item.opaque_data_value->size] = NULL;
+               buf[aptr->value->item.opaque_data_value->size] = '\0';
 
                ptr = strchr(buf, ':');
                if (ptr != NULL)
-                       *ptr = NULL;
+                       *ptr = '\0';
 
                appt->appt_id.key = atol(buf);
 
@@ -819,7 +819,7 @@ _DtCm_add_reminder(char *rem, CSA_reminder * val, Appt_4 *appt)
                }
                memcpy(newattr->clientdata, val->reminder_data.data,
                        val->reminder_data.size);
-               newattr->clientdata[val->reminder_data.size] = NULL;
+               newattr->clientdata[val->reminder_data.size] = '\0';
 
        } else if ((newattr->clientdata = calloc(1,1)) == NULL) {
                _DtCm_free_attr4(newattr);
index 5e87cc5e0a68a6a6ab138d164a29786f7d712feb..f4febf51336a0a999615d622da2ee69b9abf532e 100644 (file)
@@ -578,7 +578,7 @@ _DtCm_free_entry_content(uint dummy, _DtCm_libentry *entry)
 {
        _DtCm_remove_from_entry_list(entry->cal, (caddr_t)entry, (caddr_t)entry);
        if (entry->e) _DtCm_free_cms_entry(entry->e);
-       memset((void *)entry, NULL, sizeof(_DtCm_libentry));
+       memset((void *)entry, 0, sizeof(_DtCm_libentry));
 }
 
 /*
@@ -611,7 +611,7 @@ _DtCm_free_libentries(_DtCm_libentry *entry)
                nptr = entry->next;
 
                if (entry->e) _DtCm_free_cms_entry(entry->e);
-               memset((void *)entry, NULL, sizeof(_DtCm_libentry));
+               memset((void *)entry, 0, sizeof(_DtCm_libentry));
 
                free(entry);
 
index ef7a55cce2edc1d6263b6447c8e71460a8b21248..559919230041d9653710bbd0e6296bc9bd4dbe06 100644 (file)
@@ -318,7 +318,7 @@ _csa_iso8601_to_duration(char *buf, time_t *sec)
    numptr = ptr;
    while (*ptr >= '0' && *ptr <= '9') ptr++;
 
-   if (numptr == ptr || !(*ptr && *ptr++ == 'S' && *ptr == NULL))
+   if (numptr == ptr || !(*ptr && *ptr++ == 'S' && *ptr == '\0'))
        return (-1);
    else {
        num = atoi(numptr);
index 631f38d96341cf299c74b51f37be25ed0ec911be..0da60b3042c86304aa5093df55f75667ec4e6f9d 100644 (file)
@@ -215,10 +215,10 @@ match_forward(char *str1, char *str2)
                get_component(&str2, com2, '.');
 
                if (*com1) {
-                       if (*com2 == NULL)
+                       if (*com2 == '\0')
                                return (B_TRUE);
                } else {
-                       if (*com2 == NULL)
+                       if (*com2 == '\0')
                                return (B_TRUE);
                        else
                                return (B_FALSE);
@@ -229,18 +229,18 @@ match_forward(char *str1, char *str2)
 
                /* take care of case: a.b a. */
                if (strcmp(str2, ".") == 0
-                   && (strcmp(str1, ".") != 0 || *str1 != NULL))
+                   && (strcmp(str1, ".") != 0 || *str1 != '\0'))
                        return (B_FALSE);
 
                /* skip "." */
                if (*str1 == '.') {
-                       if (*str2 == NULL)
+                       if (*str2 == '\0')
                                return (B_TRUE);
                        else {
                                str1++;
                                str2++;
                        }
-               } else if (strcmp(str2, ".") == 0 || *str2 == NULL)
+               } else if (strcmp(str2, ".") == 0 || *str2 == '\0')
                        return (B_TRUE);
                else
                        return (B_FALSE);
@@ -278,10 +278,10 @@ match_backward(char *str1, char *str2)
                get_last_component(str2, &ptr2, com2, '.');
 
                if (*com1) {
-                       if (*com2 == NULL)
+                       if (*com2 == '\0')
                                return (B_TRUE);
                } else {
-                       if (*com2 == NULL)
+                       if (*com2 == '\0')
                                return (B_TRUE);
                        else
                                return (B_FALSE);
index 1191c8617c8d119c782d8828feebd542f25854b6..9a3ff7a48588c11a1ab1e0224ca061ec5ff46107 100644 (file)
@@ -69,7 +69,7 @@ _DtCmGetPrefix(char *str, char sep)
         if (ptr == buf)
                 return(NULL);
         else {
-                *ptr = NULL;
+                *ptr = '\0';
                 return(strdup(buf));
         }
 }
index 1b1dc77a1a4788c0a097713d0d524ace5d318930..805a908592fcf4b2d381db08ca1c0b67eac0d8b0 100644 (file)
@@ -1134,15 +1134,15 @@ contain_substr(char *str1, char *str2)
 {
        int     i, len;
 
-       if (str2 == NULL || *str2 == NULL)
+       if (str2 == NULL || *str2 == '\0')
                return (B_TRUE);
 
-       if (str1 == NULL || *str1 == NULL) {
+       if (str1 == NULL || *str1 == '\0') {
                return (B_FALSE);
        } else {
                len = strlen(str2);
 
-               for (i = 0; str1[i] != NULL; i++) {
+               for (i = 0; str1[i] != '\0'; i++) {
                        if (strncasecmp(&str1[i], str2, len) == 0)
                                return (B_TRUE);
                }
index b06f4ef0d47fac8ec76817bf41605675f2ed161c..2fd22f00d69fe6ce5e5d486faad642d2f83f6e85 100644 (file)
@@ -120,7 +120,7 @@ _DtCm_add_name_to_table(_DtCmNameTable *tbl, int index, char *newname)
                        return (CSA_E_INSUFFICIENT_MEMORY);
                } else {
                        tbl->names = newptr;
-                       memset((void *)&tbl->names[tbl->size+1], NULL,
+                       memset((void *)&tbl->names[tbl->size+1], 0,
                                sizeof(char *)*(index - tbl->size));
                }
        }
index 9044765e488375a3ee761cc8c08edc68a363cda9..4c2a19a2d906bc55ed1f6687f1f11ab31adddf51 100644 (file)
@@ -435,12 +435,12 @@ occurrence        : FIRSTWEEK endMarker
 
 endDate        : /* empty */
                    {
-                       $$ = NULL;
+                       $$ = '\0';
                    }
        | DATE
                    {
                        if (_csa_iso8601_to_tick($1, &$$) == -1)
-                               $$ = NULL;
+                               $$ = '\0';
                    }
                ;
 
index 30ac82e814c417213fdf9e27a209cc548a8bb95b..a4a7cd52f5a050888fd2eb9a56fa6c73429e542d 100644 (file)
@@ -226,7 +226,7 @@ _DtCm_rpc_create_calendar(
                /* check to make sure user is not creating a calendar
                 * using another user's name
                 */
-               if (ptr = strchr(cal->name, '@')) *ptr = NULL;
+               if (ptr = strchr(cal->name, '@')) *ptr = '\0';
                if (_DtCmIsUserName(cal->name) == B_TRUE) {
 
                        if ((owner = _DtCmGetUserName()) == NULL)
@@ -1412,7 +1412,7 @@ _GetV4UserAccess(Calendar *cal, cms_access_entry *alist)
        boolean_t isowner = B_FALSE;
 
        /* first check if user is owner */
-       if (ptr = strchr(cal->name, '@')) *ptr = NULL;
+       if (ptr = strchr(cal->name, '@')) *ptr = '\0';
 
        if (_DtCmIsUserName(cal->name) == B_TRUE) {
                if (strcmp(user, cal->name) == 0) {