From 39087321811e81e26a1a47d6967df1088dcf0e95 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 19 May 2020 20:47:23 +0100 Subject: style(3p/nix): Final act in the brace-wrapping saga This last change set was generated by a full clang-tidy run (including compilation): clang-tidy -p ~/projects/nix-build/ \ -checks=-*,readability-braces-around-statements -fix src/*/*.cc Actually running clang-tidy requires some massaging to make it play nice with Nix + meson, I'll be adding a wrapper or something for that soon. --- third_party/nix/src/libexpr/attr-path.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'third_party/nix/src/libexpr/attr-path.cc') diff --git a/third_party/nix/src/libexpr/attr-path.cc b/third_party/nix/src/libexpr/attr-path.cc index edab0b6df97f..3d4e9c1e1096 100644 --- a/third_party/nix/src/libexpr/attr-path.cc +++ b/third_party/nix/src/libexpr/attr-path.cc @@ -16,16 +16,18 @@ static Strings parseAttrPath(const string& s) { } else if (*i == '"') { ++i; while (1) { - if (i == s.end()) + if (i == s.end()) { throw Error(format("missing closing quote in selection path '%1%'") % s); + } if (*i == '"') { break; } cur.push_back(*i++); } - } else + } else { cur.push_back(*i); + } ++i; } if (!cur.empty()) { @@ -62,33 +64,38 @@ Value* findAlongAttrPath(EvalState& state, const string& attrPath, according to what is specified in the attrPath. */ if (apType == apAttr) { - if (v->type != tAttrs) + if (v->type != tAttrs) { throw TypeError(format("the expression selected by the selection path " "'%1%' should be a set but is %2%") % attrPath % showType(*v)); + } - if (attr.empty()) + if (attr.empty()) { throw Error(format("empty attribute name in selection path '%1%'") % attrPath); + } Bindings::iterator a = v->attrs->find(state.symbols.create(attr)); - if (a == v->attrs->end()) + if (a == v->attrs->end()) { throw Error( format("attribute '%1%' in selection path '%2%' not found") % attr % attrPath); + } v = &*a->value; } else if (apType == apIndex) { - if (!v->isList()) + if (!v->isList()) { throw TypeError(format("the expression selected by the selection path " "'%1%' should be a list but is %2%") % attrPath % showType(*v)); + } - if (attrIndex >= v->listSize()) + if (attrIndex >= v->listSize()) { throw Error( format("list index %1% in selection path '%2%' is out of range") % attrIndex % attrPath); + } v = v->listElems()[attrIndex]; } -- cgit 1.4.1