Change-Id: I9be22c09557f426f271310fac4b1cdd5000e0161
return l >= 0;
}
+static const char *normalsubpath(const char *subpath)
+{
+ while(*subpath == '/')
+ subpath++;
+ return validsubpath(subpath) ? subpath : NULL;
+}
+
struct wgt *wgt_create()
{
struct wgt *wgt = malloc(sizeof * wgt);
{
assert(wgt);
assert(wgt_is_connected(wgt));
- if (!validsubpath(filename)) {
+
+ filename = normalsubpath(filename);
+ if (!filename) {
errno = EINVAL;
return -1;
}
{
assert(wgt);
assert(wgt_is_connected(wgt));
- if (!validsubpath(filename)) {
+ filename = normalsubpath(filename);
+ if (!filename) {
errno = EINVAL;
return -1;
}
{
int i;
- if (!validsubpath(filename)) {
+ filename = normalsubpath(filename);
+ if (!filename) {
errno = EINVAL;
return NULL;
}