* [PATCH] var: move hashvar() calls into findvar()
@ 2022-05-10 8:16 Ron Yorston
2024-04-05 10:46 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Ron Yorston @ 2022-05-10 8:16 UTC (permalink / raw
To: dash
The first argument to findvar() is always obtained by a call to
hashvar(), the return value of which is otherwise unused.
Signed-off-by: Ron Yorston <rmy@frippery.org>
---
src/var.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/var.c b/src/var.c
index ef9c2bd..e301fe5 100644
--- a/src/var.c
+++ b/src/var.c
@@ -107,7 +107,7 @@ STATIC struct var *vartab[VTABSIZE];
STATIC struct var **hashvar(const char *);
STATIC int vpcmp(const void *, const void *);
-STATIC struct var **findvar(struct var **, const char *);
+STATIC struct var **findvar(const char *);
/*
* Initialize the varable symbol tables and import the environment
@@ -247,9 +247,8 @@ struct var *setvareq(char *s, int flags)
{
struct var *vp, **vpp;
- vpp = hashvar(s);
flags |= (VEXPORT & (((unsigned) (1 - aflag)) - 1));
- vpp = findvar(vpp, s);
+ vpp = findvar(s);
vp = *vpp;
if (vp) {
if (vp->flags & VREADONLY) {
@@ -311,7 +310,7 @@ lookupvar(const char *name)
{
struct var *v;
- if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) {
+ if ((v = *findvar(name)) && !(v->flags & VUNSET)) {
#ifdef WITH_LINENO
if (v == &vlineno && v->text == linenovar) {
fmtstr(linenovar+7, sizeof(linenovar)-7, "%d", lineno);
@@ -418,7 +417,7 @@ exportcmd(int argc, char **argv)
if ((p = strchr(name, '=')) != NULL) {
p++;
} else {
- if ((vp = *findvar(hashvar(name), name))) {
+ if ((vp = *findvar(name))) {
vp->flags |= flag;
continue;
}
@@ -462,7 +461,6 @@ localcmd(int argc, char **argv)
void mklocal(char *name, int flags)
{
struct localvar *lvp;
- struct var **vpp;
struct var *vp;
INTOFF;
@@ -475,8 +473,7 @@ void mklocal(char *name, int flags)
} else {
char *eq;
- vpp = hashvar(name);
- vp = *findvar(vpp, name);
+ vp = *findvar(name);
eq = strchr(name, '=');
if (vp == NULL) {
if (eq)
@@ -663,9 +660,11 @@ vpcmp(const void *a, const void *b)
}
STATIC struct var **
-findvar(struct var **vpp, const char *name)
+findvar(const char *name)
{
- for (; *vpp; vpp = &(*vpp)->next) {
+ struct var **vpp;
+
+ for (vpp = hashvar(name); *vpp; vpp = &(*vpp)->next) {
if (varequal((*vpp)->text, name)) {
break;
}
--
2.35.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] var: move hashvar() calls into findvar()
2022-05-10 8:16 [PATCH] var: move hashvar() calls into findvar() Ron Yorston
@ 2024-04-05 10:46 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2024-04-05 10:46 UTC (permalink / raw
To: Ron Yorston; +Cc: dash
On Tue, May 10, 2022 at 09:16:55AM +0100, Ron Yorston wrote:
> The first argument to findvar() is always obtained by a call to
> hashvar(), the return value of which is otherwise unused.
>
> Signed-off-by: Ron Yorston <rmy@frippery.org>
> ---
> src/var.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
Nice work!
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-05 10:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10 8:16 [PATCH] var: move hashvar() calls into findvar() Ron Yorston
2024-04-05 10:46 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).