Changeset 561db3f in mainline


Ignore:
Timestamp:
2009-03-02T22:46:52Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2f57690
Parents:
20f1597
Message:

Didn't need strrcpy() afterall. Also remove strcpy() since strncpy() is better.

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/string.h

    r20f1597 r561db3f  
    4242extern int strncmp(const char *src, const char *dst, size_t len);
    4343extern void strncpy(char *dest, const char *src, size_t len);
    44 extern char *strcpy(char *dest, const char *src);
    4544
    4645extern char *strchr(const char *s, int i);
    47 extern char *strrchr(const char *s, int i);
    4846
    4947#endif
  • kernel/generic/src/lib/string.c

    r20f1597 r561db3f  
    142142}
    143143
    144 /** Copy string.
    145  *
    146  * Copy string from src address to dst address.  The copying is done
    147  * char-by-char until the null character. The source and destination memory
    148  * areas cannot overlap.
    149  *
    150  * @param src           Source string to copy from.
    151  * @param dst           Destination string to copy to.
    152  *
    153  * @return              Address of the destination string.
    154  */
    155 char *strcpy(char *dest, const char *src)
    156 {
    157         char *orig = dest;
    158        
    159         while ((*dest++ = *src++) != '\0');
    160 
    161         return orig;
    162 }
    163 
    164144/** Find first occurence of character in string.
    165145 *
     
    179159}
    180160
    181 /** Find last occurence of character in string.
    182  *
    183  * @param s     String to search.
    184  * @param i     Character to look for.
    185  *
    186  * @return      Pointer to character in @a s or NULL if not found.
    187  */
    188 extern char *strrchr(const char *s, int i)
    189 {
    190         const char *start;
    191 
    192         start = s;
    193         if (*s == '\0') return NULL;
    194 
    195         while (*s != '\0') ++s;
    196 
    197         while (s != start) {
    198                 --s;
    199                 if (*s == i) return (char *) s;
    200         }
    201 
    202         return NULL;
    203 }
    204 
    205161/** @}
    206162 */
  • kernel/generic/src/proc/task.c

    r20f1597 r561db3f  
    275275
    276276        namebuf[name_len] = '\0';
    277         strcpy(TASK->name, namebuf);
     277        strncpy(TASK->name, namebuf, TASK_NAME_BUFLEN);
    278278
    279279        return EOK;
Note: See TracChangeset for help on using the changeset viewer.