From f507a63e755faeda0e139556dbaab882aded819f Mon Sep 17 00:00:00 2001
From: Elliott Hughes <enh@google.com>
Date: Thu, 5 Sep 2024 13:57:03 -0400
Subject: [PATCH] diff.c: fix warnings.

Also make xlstat() pull its weight a bit better.
---
 toys/pending/diff.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/toys/pending/diff.c b/toys/pending/diff.c
index 362365df..ef45e16b 100644
--- a/toys/pending/diff.c
+++ b/toys/pending/diff.c
@@ -591,7 +591,6 @@ static void show_label(char *prefix, char *filename, struct stat *sb)
 static void do_symlink_diff(char **files)
 {
   size_t i;
-  int s = sizeof(toybuf)/2;
 
   TT.is_symlink = 1;
   TT.differ = 0;
@@ -688,8 +687,6 @@ static void do_diff(char **files)
 
     struct diff *t, *ptr1 = d, *ptr2 = d;
     while (i) {
-      long a,b;
-
       // trim context to file len.
       if (TT.new_line_format || TT.U>TT.file[0].len) TT.U = TT.file[0].len;
       if (ptr1->b < ptr1->a && ptr1->d < ptr1->c) {
@@ -697,9 +694,7 @@ static void do_diff(char **files)
         continue;
       }
       //Handle the context stuff
-      a =  ptr1->a;
-      b = minof(TT.file[0].len, ptr1->b);
-      if (i == x + 1) ptr1->suff = maxof(1, a-TT.U);
+      if (i == x + 1) ptr1->suff = maxof(1, ptr1->a-TT.U);
       else if (ptr1[-1].prev >= ptr1->a-TT.U) ptr1->suff = ptr1[-1].prev+1;
       else ptr1->suff =  ptr1->a-TT.U;
 calc_ct:
@@ -864,8 +859,7 @@ void diff_main(void)
 
   for (j = 0; j < 2; j++) {
     if (IS_STDIN(files[j])) fstat(0, &TT.st[j]);
-    else if (FLAG(no_dereference)) xlstat(files[j], &TT.st[j]);
-    else xstat(files[j], &TT.st[j]);
+    else (FLAG(no_dereference) ? xlstat : xstat)(files[j], &TT.st[j]);
   }
 
   if (S_ISDIR(TT.st[0].st_mode) != S_ISDIR(TT.st[1].st_mode))
-- 
2.46.0.598.g6f2099f65c-goog

