Issue #8914: fix various warnings from the Clang static analyzer v254.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 7448354..9290d00 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2439,7 +2439,7 @@
 static PyObject *
 bytearray_rstrip(PyByteArrayObject *self, PyObject *args)
 {
-    Py_ssize_t left, right, mysize, argsize;
+    Py_ssize_t right, mysize, argsize;
     void *myptr, *argptr;
     PyObject *arg = Py_None;
     Py_buffer varg;
@@ -2457,11 +2457,10 @@
     }
     myptr = self->ob_bytes;
     mysize = Py_SIZE(self);
-    left = 0;
     right = rstrip_helper(myptr, mysize, argptr, argsize);
     if (arg != Py_None)
         PyBuffer_Release(&varg);
-    return PyByteArray_FromStringAndSize(self->ob_bytes + left, right - left);
+    return PyByteArray_FromStringAndSize(self->ob_bytes, right);
 }
 
 PyDoc_STRVAR(decode_doc,
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index d20f196..cffa5de 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -297,8 +297,8 @@
         *p++ = c;
         if (c == '\n') break;
     }
-    if ( c == EOF && skipnextlf )
-        newlinetypes |= NEWLINE_CR;
+    /* if ( c == EOF && skipnextlf )
+        newlinetypes |= NEWLINE_CR; */
     FUNLOCKFILE(stream);
     *p = '\0';
     if ( skipnextlf ) {
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 09c0e96..6d1745e 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -197,7 +197,6 @@
             Py_DECREF(s_buffer);
             return NULL;
         }
-        last = s + len;
     }
     else if (PyObject_AsCharBuffer(v, &s, &len)) {
         PyErr_SetString(PyExc_TypeError,
@@ -2246,7 +2245,7 @@
 
         /* Eighth byte */
         *p = flo & 0xFF;
-        p += incr;
+        /* p += incr; */
 
         /* Done */
         return 0;
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 3916262..483847c 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -1775,7 +1775,6 @@
      * will be living in full pools -- would be a shame to miss them.
      */
     for (i = 0; i < maxarenas; ++i) {
-        uint poolsinarena;
         uint j;
         uptr base = arenas[i].address;
 
@@ -1784,7 +1783,6 @@
             continue;
         narenas += 1;
 
-        poolsinarena = arenas[i].ntotalpools;
         numfreepools += arenas[i].nfreepools;
 
         /* round up to pool alignment */
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 72b79c9..bfb7ec7 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -86,7 +86,7 @@
         {
             return PyErr_NoMemory();
         }
-        nbytes += sizeof(PyTupleObject) - sizeof(PyObject *);
+        /* nbytes += sizeof(PyTupleObject) - sizeof(PyObject *); */
 
         op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
         if (op == NULL)
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 7a1aa77..500dfc9 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -902,7 +902,7 @@
 
     /* Find the nearest base with a different tp_dealloc */
     base = type;
-    while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
+    while ((/*basedealloc =*/ base->tp_dealloc) == subtype_dealloc) {
         base = base->tp_base;
         assert(base);
     }
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 57baebd..e7bbd80 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -5418,7 +5418,6 @@
         if (!result)
             return NULL;
         for (i = 0; i < 256; i++) {
-            key = value = NULL;
             key = PyLong_FromLong(decode[i]);
             value = PyLong_FromLong(i);
             if (!key || !value)
@@ -6935,7 +6934,7 @@
         }
     } else {
 
-        Py_ssize_t n, i, j, e;
+        Py_ssize_t n, i, j;
         Py_ssize_t product, new_size, delta;
         Py_UNICODE *p;
 
@@ -6967,7 +6966,6 @@
             return NULL;
         i = 0;
         p = u->str;
-        e = self->length - str1->length;
         if (str1->length > 0) {
             while (n-- > 0) {
                 /* look for next match */
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 13323cf..dfaa1b9 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -168,13 +168,20 @@
                 PyErr_Clear();
         else if (PyUnicode_Check(nameobj))
                 name = _PyUnicode_AsString(nameobj);
-        PyOS_snprintf(buffer, sizeof(buffer),
-                      name ? "<weakref at %p; to '%.50s' at %p (%s)>"
-                           : "<weakref at %p; to '%.50s' at %p>",
-                      self,
-                      Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
-                      PyWeakref_GET_OBJECT(self),
-                      name);
+        if (name)
+            PyOS_snprintf(buffer, sizeof(buffer),
+                          "<weakref at %p; to '%.50s' at %p (%s)>",
+                          self,
+                          Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
+                          PyWeakref_GET_OBJECT(self),
+                          name);
+        else
+            PyOS_snprintf(buffer, sizeof(buffer),
+                          "<weakref at %p; to '%.50s' at %p>",
+                          self,
+                          Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
+                          PyWeakref_GET_OBJECT(self));
+
         Py_XDECREF(nameobj);
     }
     return PyUnicode_FromString(buffer);