diff options
| author | Paul Eggert | 2019-07-22 16:26:27 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-22 16:36:50 -0700 |
| commit | c63e7f1bf6151d4bb5fde01890c69cdd515e2df3 (patch) | |
| tree | db9958355d3b0a85c9a621ba4f0f07eca391dc2d /lisp/gnus | |
| parent | b904a238a5ab759a4d0d8c9ee5c48199febd8f62 (diff) | |
| download | emacs-c63e7f1bf6151d4bb5fde01890c69cdd515e2df3.tar.gz emacs-c63e7f1bf6151d4bb5fde01890c69cdd515e2df3.zip | |
Remove no-longer-needed integer overflow code
* lisp/calculator.el (calculator-number-to-string):
Use truncate, not calculator-truncate, since integer
overflow cannot occur here.
* lisp/calendar/cal-persia.el (calendar-persian-year-from-absolute):
* lisp/gnus/gnus-agent.el (gnus-agent-read-article-number):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number):
* lisp/scroll-bar.el (scroll-bar-scale):
* lisp/simple.el (beginning-of-buffer, end-of-buffer):
Simplify, now that integer overflow cannot occur.
Diffstat (limited to 'lisp/gnus')
| -rw-r--r-- | lisp/gnus/gnus-agent.el | 15 | ||||
| -rw-r--r-- | lisp/gnus/nnmaildir.el | 6 |
2 files changed, 2 insertions, 19 deletions
diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el index a09b4368893..40d0d246056 100644 --- a/lisp/gnus/gnus-agent.el +++ b/lisp/gnus/gnus-agent.el | |||
| @@ -1909,21 +1909,8 @@ article numbers will be returned." | |||
| 1909 | (defsubst gnus-agent-read-article-number () | 1909 | (defsubst gnus-agent-read-article-number () |
| 1910 | "Reads the article number at point. Returns nil when a valid article number can not be read." | 1910 | "Reads the article number at point. Returns nil when a valid article number can not be read." |
| 1911 | 1911 | ||
| 1912 | ;; It is unfortunate but the read function quietly overflows | ||
| 1913 | ;; integer. As a result, I have to use string operations to test | ||
| 1914 | ;; for overflow BEFORE calling read. | ||
| 1915 | (when (looking-at "[0-9]+\t") | 1912 | (when (looking-at "[0-9]+\t") |
| 1916 | (let ((len (- (match-end 0) (match-beginning 0)))) | 1913 | (read (current-buffer)))) |
| 1917 | (cond ((< len 9) | ||
| 1918 | (read (current-buffer))) | ||
| 1919 | ((= len 9) | ||
| 1920 | ;; Many 9 digit base-10 numbers can be represented in a 27-bit int | ||
| 1921 | ;; Back convert from int to string to ensure that this is one of them. | ||
| 1922 | (let* ((str1 (buffer-substring (match-beginning 0) (1- (match-end 0)))) | ||
| 1923 | (num (read (current-buffer))) | ||
| 1924 | (str2 (int-to-string num))) | ||
| 1925 | (when (equal str1 str2) | ||
| 1926 | num))))))) | ||
| 1927 | 1914 | ||
| 1928 | (defsubst gnus-agent-copy-nov-line (article) | 1915 | (defsubst gnus-agent-copy-nov-line (article) |
| 1929 | "Copy the indicated ARTICLE from the overview buffer to the nntp server buffer." | 1916 | "Copy the indicated ARTICLE from the overview buffer to the nntp server buffer." |
diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el index 3becee35112..246f52c8d2b 100644 --- a/lisp/gnus/nnmaildir.el +++ b/lisp/gnus/nnmaildir.el | |||
| @@ -322,8 +322,6 @@ This variable is set by `nnmaildir-request-article'.") | |||
| 322 | (setq ino-opened (file-attribute-inode-number attr) | 322 | (setq ino-opened (file-attribute-inode-number attr) |
| 323 | nlink (file-attribute-link-number attr) | 323 | nlink (file-attribute-link-number attr) |
| 324 | number-linked (+ number-opened nlink)) | 324 | number-linked (+ number-opened nlink)) |
| 325 | (if (or (< nlink 1) (< number-linked nlink)) | ||
| 326 | (signal 'error '("Arithmetic overflow"))) | ||
| 327 | (setq attr (file-attributes | 325 | (setq attr (file-attributes |
| 328 | (concat dir (number-to-string number-linked)))) | 326 | (concat dir (number-to-string number-linked)))) |
| 329 | (or attr (throw 'return (1- number-linked))) | 327 | (or attr (throw 'return (1- number-linked))) |
| @@ -395,9 +393,7 @@ This variable is set by `nnmaildir-request-article'.") | |||
| 395 | (let* ((attr (file-attributes path-open)) | 393 | (let* ((attr (file-attributes path-open)) |
| 396 | (nlink (file-attribute-link-number attr))) | 394 | (nlink (file-attribute-link-number attr))) |
| 397 | (setq ino-open (file-attribute-inode-number attr) | 395 | (setq ino-open (file-attribute-inode-number attr) |
| 398 | number-link (+ number-open nlink)) | 396 | number-link (+ number-open nlink))) |
| 399 | (if (or (< nlink 1) (< number-link nlink)) | ||
| 400 | (signal 'error '("Arithmetic overflow")))) | ||
| 401 | (if (= number-link previous-number-link) | 397 | (if (= number-link previous-number-link) |
| 402 | ;; We've already tried this number, in the previous loop iteration, | 398 | ;; We've already tried this number, in the previous loop iteration, |
| 403 | ;; and failed. | 399 | ;; and failed. |