Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:Test
multipath-tools
multipath-tools-basename-return-value
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File multipath-tools-basename-return-value of Package multipath-tools
From 53c7a13bf5383814a7118607d3b1da41de51c4b1 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke <hare@suse.de> Date: Thu, 20 Nov 2008 08:40:59 +0100 Subject: [PATCH] Return number of characters written in basename() basename() can fail, so we should return the number of characters written to get some error indicator. Signed-off-by: Hannes Reinecke <hare@suse.de> --- libmultipath/configure.c | 12 +++++++++--- libmultipath/discovery.h | 1 - libmultipath/util.c | 13 +++++++++++-- libmultipath/util.h | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 8444ef2..494ea70 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -34,13 +34,14 @@ #include "dict.h" #include "alias.h" #include "prio.h" +#include "util.h" extern int setup_map (struct multipath * mpp) { struct pathgroup * pgp; int i; - + /* * don't bother if devmap size is unknown */ @@ -579,9 +580,14 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec) return NULL; if (dev_type == DEV_DEVNODE) { - basename(dev, buff); + if (basename(dev, buff) == 0) { + condlog(1, "basename failed for '%s' (%s)", + dev, buff); + return NULL; + } + pp = find_path_by_dev(pathvec, buff); - + if (!pp) { pp = alloc_path(); diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h index c7cf7e8..05b1cfe 100644 --- a/libmultipath/discovery.h +++ b/libmultipath/discovery.h @@ -27,7 +27,6 @@ int sysfs_get_dev (struct sysfs_device * dev, char * buff, size_t len); int path_discovery (vector pathvec, struct config * conf, int flag); -void basename (char *, char *); int do_tur (char *); int devt2devname (char *, char *); int pathinfo (struct path *, vector hwtable, int mask); diff --git a/libmultipath/util.c b/libmultipath/util.c index c7fe6b4..3afe7ea 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -38,10 +38,18 @@ strchop(char *str) str[++i] = '\0'; } -void +int basename (char * str1, char * str2) { - char *p = str1 + (strlen(str1) - 1); + char *p; + + if (!str1 || !strlen(str1)) + return 0; + + if (!str2) + return 0; + + p = str1 + (strlen(str1) - 1); while (*--p != '/' && p != str1) continue; @@ -50,6 +58,7 @@ basename (char * str1, char * str2) p++; strcpy(str2, p); + return strlen(p); } int diff --git a/libmultipath/util.h b/libmultipath/util.h index d0df8aa..14af696 100644 --- a/libmultipath/util.h +++ b/libmultipath/util.h @@ -3,7 +3,7 @@ int strcmp_chomp(char *, char *); void strchop(char *); -void basename (char * src, char * dst); +int basename (char * src, char * dst); int filepresent (char * run); int get_word (char * sentence, char ** word); size_t strlcpy(char *dst, const char *src, size_t size); -- 1.5.3.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor