Subject: 28.1; Wrong format specifiers in tramp-adb-get-device

From: Hayden Shenk <[email-masked]>
Date: Wed, 25 May 2022 22:12:35 -0400

Description:
When attempting to open a file on Android devices via tramp using adb
over tcp/ip tramp-adb-get-device throws the following error:

error: "Format specifier doesn’t match argument typex"

Reproducing the bug:
To reproduce the bug set up an android device to connect to over
TCP/IP with adb.  Instructions to do so can be found here:

https://developer.android.com/studio/command-line/adb

In this example, we'll assume the device is listening for adb
connections on 192.168.1.7:7449

Then the bug can be triggered by executing the following bit of elisp:

(find-file "/adb:192.168.1.7#7449:/data/local/tmp")

Patch:
Here is a proposed patch, which fixes the issue on my host:

modified   lisp/net/tramp-adb.el
@@ -1112,9 +1112,9 @@ E.g. a host name \"192.168.1.1#5555\" returns \"
192.168.1.1:5555\"
        tramp-prefix-port-format ":"
        (cond ((member host devices) host)
      ;; This is the case when the host is connected to the default port.
-     ((member (format "%s%s%d" host tramp-prefix-port-format port)
+     ((member (format "%s%s%s" host tramp-prefix-port-format port)
       devices)
-      (format "%s:%d" host port))
+      (format "%s:%s" host port))
      ;; An empty host name shall be mapped as well, when there
      ;; is exactly one entry in `devices'.
      ((and (zerop (length host)) (= (length devices) 1))

In GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version
1.16.0, Xaw scroll bars)
 of 2022-05-24 built on papa-XPS-15-9500
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.4 LTS

Configured using:
 'configure --with-x-toolkit=lucid --with-mailutils --with-modules
 --enable-gcc-warnings --with-json --with-native-compilation --with-jpeg
 --with-png --with-rsvg --with-tiff --with-wide-int --with-imagemagick'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ IMAGEMAGICK
JPEG JSON LIBSELINUX MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID
ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search seq byte-opt
gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils time-date subr-x cl-loaddefs
cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 70504 11007)
 (symbols 48 7157 0)
 (strings 32 21358 1675)
 (string-bytes 1 686899)
 (vectors 16 14101)
 (vector-slots 8 297090 16970)
 (floats 8 25 38)
 (intervals 56 260 0)
 (buffers 992 11))