static void pakfire_path_free_segments(struct pakfire_path* path) {
for (unsigned int i = 0; i < path->num_segments; i++)
free(path->segments[i]);
-
free(path->segments);
// Reset the data structure
// Copy path into buffer
r = pakfire_string_set(buffer, s);
- if (r)
+ if (r < 0)
return r;
const char* segment = strtok_r(buffer, "/", &p);
// Append all segments
while (segment) {
r = pakfire_path_append_segment(path, segment);
- if (r)
+ if (r < 0)
break;
segment = strtok_r(NULL, "/", &p);
// Import the path
r = pakfire_path_import_segments(p, s);
- if (r)
+ if (r < 0)
goto ERROR;
// Success
*path = p;
+
return 0;
ERROR:
static int pakfire_path_do_normalize(struct pakfire_path* path) {
int r;
+ // Make the analyzer happy
+ if (!path)
+ return -EINVAL;
+
for (unsigned int i = 0; i < path->num_segments; i++) {
// Simply remove single dots
if (strcmp(path->segments[i], ".") == 0) {
// Parse the path
r = pakfire_path_parse(&path, s);
- if (r)
+ if (r < 0)
+ goto ERROR;
+
+ // Make the static analyzer happy
+ if (!path)
goto ERROR;
// Drop everything but the last segment
if (r)
goto ERROR;
+ // Make the static analyzer happy
+ if (!path)
+ goto ERROR;
+
// Drop the last segment
r = pakfire_path_remove_segment(path, path->num_segments - 1);
if (r)
if (r)
goto ERROR;
+ // Make the static analyzer happy
+ if (!root || !path)
+ goto ERROR;
+
// Both paths must be absolute
if (!root->is_absolute || !path->is_absolute) {
r = -EINVAL;