aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-11-01 11:08:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-11-01 11:08:12 +0200
commit736c9f08b68b2735d85fe7eefdf2118de8b8c34e (patch)
tree644a6f1a9ae2da93d7c4ef132ab53748ffea962c /libbuild2/rule.cxx
parent7bcb45cba78795dccdb2684f6f290daeb8bab488 (diff)
Fix incorrect fsdir_rule::perform_update_direct() calls
Also make fsdir_rule::perform_{update,clean}_direct() harder to misuse.
Diffstat (limited to 'libbuild2/rule.cxx')
-rw-r--r--libbuild2/rule.cxx30
1 files changed, 16 insertions, 14 deletions
diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx
index a3e3268..79ccb86 100644
--- a/libbuild2/rule.cxx
+++ b/libbuild2/rule.cxx
@@ -352,16 +352,17 @@ namespace build2
}
void fsdir_rule::
- perform_update_direct (action a, const target& t)
+ perform_update_direct (action a, const fsdir& t)
{
// First create the parent directory. If present, it is always first.
//
- const target* p (t.prerequisite_targets[a].empty ()
- ? nullptr
- : t.prerequisite_targets[a][0]);
-
- if (p != nullptr && p->is_a<fsdir> ())
- perform_update_direct (a, *p);
+ if (const target* p = (t.prerequisite_targets[a].empty ()
+ ? nullptr
+ : t.prerequisite_targets[a][0]))
+ {
+ if (const fsdir* fp = p->is_a<fsdir> ())
+ perform_update_direct (a, *fp);
+ }
// The same code as in perform_update() above.
//
@@ -394,7 +395,7 @@ namespace build2
}
void fsdir_rule::
- perform_clean_direct (action a, const target& t)
+ perform_clean_direct (action a, const fsdir& t)
{
// The same code as in perform_clean() above.
//
@@ -402,12 +403,13 @@ namespace build2
// Then clean the parent directory. If present, it is always first.
//
- const target* p (t.prerequisite_targets[a].empty ()
- ? nullptr
- : t.prerequisite_targets[a][0]);
-
- if (p != nullptr && p->is_a<fsdir> ())
- perform_clean_direct (a, *p);
+ if (const target* p = (t.prerequisite_targets[a].empty ()
+ ? nullptr
+ : t.prerequisite_targets[a][0]))
+ {
+ if (const fsdir* fp = p->is_a<fsdir> ())
+ perform_clean_direct (a, *fp);
+ }
}
const fsdir_rule fsdir_rule::instance;