[4288] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[barnowl/barnowl] owl.c: declare getopt_long return variable as int

daemon@ATHENA.MIT.EDU (Daniel JB Clark)
Sun Nov 1 12:31:01 2026

Date: Sun, 01 Nov 2026 09:30:55 -0800
From: Daniel JB Clark <notifications@github.com>
Reply-To: barnowl/barnowl <reply+ABCERSPSTLBVTG5G2UJ6FF3LMDAU7EVBNHHQAAAAAFXJASIC@reply.github.com>
To: barnowl/barnowl <barnowl@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>


----==_mimepart_6ae7774f42bfa_e212a81408314
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

### Summary
In `owl_parse_options` (`owl.c`), `c` was declared as `char c;` to hold the return value of `getopt_long(...)`.

On architectures where `char` is unsigned by default (such as ARM/aarch64, PowerPC, and s390x), `(c = getopt_long(...)) != -1` is never false because `getopt_long`'s `-1` return value is converted to `(unsigned char)-1` (`255`), which does not equal `-1`. This causes BarnOwl on arm64 systems to immediately enter the `default:` branch of the option switch, print usage, and exit 1 upon launch.

Declaring `int c;` correctly matches `getopt_long`'s return type and preserves the `-1` sentinel across all architectures without requiring `-fsigned-char`.

### Verification
- Tested with standard POSIX `getopt_long` parsing behavior on aarch64 Linux.
- Prior duplicate search conducted on `barnowl/barnowl` PRs and issues for `getopt`, `arm64`, `signed char`, and `unsigned char` (no existing open or closed matches found).
- Adversary review: no findings (type widening to standard `int` matches `getopt_long` prototype).
You can view, comment on, or merge this pull request online at:

  https://github.com/barnowl/barnowl/pull/191

-- Commit Summary --

  * owl.c: declare getopt_long return variable as int for unsigned char architectures

-- File Changes --

    M owl.c (2)

-- Patch Links --

https://github.com/barnowl/barnowl/pull/191.patch
https://github.com/barnowl/barnowl/pull/191.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/barnowl/barnowl/pull/191
You are receiving this because you are subscribed to this thread.

Message ID: <barnowl/barnowl/pull/191@github.com>

----==_mimepart_6ae7774f42bfa_e212a81408314
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<h3 dir=3D"auto">Summary</h3>
<p dir=3D"auto">In <code class=3D"notranslate">owl_parse_options</code> (=
<code class=3D"notranslate">owl.c</code>), <code class=3D"notranslate">c<=
/code> was declared as <code class=3D"notranslate">char c;</code> to hold=
 the return value of <code class=3D"notranslate">getopt_long(...)</code>.=
</p>
<p dir=3D"auto">On architectures where <code class=3D"notranslate">char</=
code> is unsigned by default (such as ARM/aarch64, PowerPC, and s390x), <=
code class=3D"notranslate">(c =3D getopt_long(...)) !=3D -1</code> is nev=
er false because <code class=3D"notranslate">getopt_long</code>'s <code c=
lass=3D"notranslate">-1</code> return value is converted to <code class=3D=
"notranslate">(unsigned char)-1</code> (<code class=3D"notranslate">255</=
code>), which does not equal <code class=3D"notranslate">-1</code>. This =
causes BarnOwl on arm64 systems to immediately enter the <code class=3D"n=
otranslate">default:</code> branch of the option switch, print usage, and=
 exit 1 upon launch.</p>
<p dir=3D"auto">Declaring <code class=3D"notranslate">int c;</code> corre=
ctly matches <code class=3D"notranslate">getopt_long</code>'s return type=
 and preserves the <code class=3D"notranslate">-1</code> sentinel across =
all architectures without requiring <code class=3D"notranslate">-fsigned-=
char</code>.</p>
<h3 dir=3D"auto">Verification</h3>
<ul dir=3D"auto">
<li>Tested with standard POSIX <code class=3D"notranslate">getopt_long</c=
ode> parsing behavior on aarch64 Linux.</li>
<li>Prior duplicate search conducted on <code class=3D"notranslate">barno=
wl/barnowl</code> PRs and issues for <code class=3D"notranslate">getopt</=
code>, <code class=3D"notranslate">arm64</code>, <code class=3D"notransla=
te">signed char</code>, and <code class=3D"notranslate">unsigned char</co=
de> (no existing open or closed matches found).</li>
<li>Adversary review: no findings (type widening to standard <code class=3D=
"notranslate">int</code> matches <code class=3D"notranslate">getopt_long<=
/code> prototype).</li>
</ul>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>&nbsp;&nbsp;<a href=3D'https://github.com/barnowl/barnowl/pull/191'>ht=
tps://github.com/barnowl/barnowl/pull/191</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href=3D"https://github.com/barnowl/barnowl/pull/191/commits/ae58=
d34d0451c261bfde962ca66875b049ed008f" class=3D"commit-link">ae58d34</a>  =
owl.c: declare getopt_long return variable as int for unsigned char archi=
tectures</li>
</ul>

<h4 style=3D"display: inline-block">File Changes </h4> <p style=3D"displa=
y: inline-block">(<a href=3D"https://github.com/barnowl/barnowl/pull/191/=
files">1&nbsp;file</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href=3D"https://github.com/barnowl/barnowl/pull/191/files#diff-7aa=
159174e27b0be5736ce16ff757bade110f533505958a6e3b55a4edb732697">owl.c</a>
    (2)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href=3D'https://github.com/barnowl/barnowl/pull/191.patch'>https=
://github.com/barnowl/barnowl/pull/191.patch</a></li>
  <li><a href=3D'https://github.com/barnowl/barnowl/pull/191.diff'>https:=
//github.com/barnowl/barnowl/pull/191.diff</a></li>
</ul>

<p style=3D"font-size:small;-webkit-text-size-adjust:none;color:#666;">&m=
dash;<br />Reply to this email directly, <a href=3D"https://github.com/ba=
rnowl/barnowl/pull/191?email_source=3Dnotifications&amp;email_token=3DABC=
ERSJ53W5OAN3HQCOCIL35W5QL7A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2W=
K43UF42TCMBZHAYDGNJQG2THEZLBONXW5KTTOVRHGY3SNFRGKZFFMV3GK3TUVRTG633UMVZF6=
Y3MNFRWW">view it on GitHub</a>, or <a href=3D"https://github.com/notific=
ations/unsubscribe-auth/ABCERSLFE3DDEDUJFARJUI35W5QL7AVCNFSNUABCKJSXA33TN=
F2G64TZHM3TINZTGA4TWSLTON2WKOZWGE2DSOJRGY4TGMFBOYBA">unsubscribe</a>.<br =
/>Triage notifications, keep track of coding agent tasks and review pull =
requests on the go with GitHub Mobile for <a href=3D"https://github.com/n=
otifications/mobile/ios/ABCERSJF2X44UGUNKXF4VPT5W5QL7A5CNFSNUABEM5UWIORPF=
5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF42TCMBZHAYDGNJQG2THEZLBONXW5KTTOVRHGY3SNF=
RGKZFFMV3GK3TUVJTG633UMVZF62LPOM">iOS</a> and <a href=3D"https://github.c=
om/notifications/mobile/android/ABCERSLR7O33RLQ3NM2O3UL5W5QL7A5CNFSNUABEM=
5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF42TCMBZHAYDGNJQG2THEZLBONXW5KTTOV=
RHGY3SNFRGKZFFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE">Android</a>. Download it =
today!
<br />You are receiving this because you are subscribed to this thread.<i=
mg src=3D"https://github.com/notifications/beacon/ABCERSKX6MMUBVJNAUYWY4D=
5W5QL7BFCNFSM6AAAAADD6YH6S6WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3J=
MTHQAAAAAFXJASICUZZGKYLTN5XKU43VMJZWG4TJMJSWI.gif" height=3D"1" width=3D"=
1" alt=3D"" /><span style=3D"color: transparent; font-size: 0; display: n=
one; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: =
0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span>&lt;barn=
owl/barnowl/pull/191</span><span>@</span><span>github</span><span>.</span=
><span>com&gt;</span></span></p>
<script type=3D"application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/barnowl/barnowl/pull/191?email_source=3Dnot=
ifications\u0026email_token=3DABCERSOSF3PEQD5MCT667335W5QL7A5CNFSNUABEM5U=
WIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF42TCMBZHAYDGNJQG2THEZLBONXW5KTTOVRH=
GY3SNFRGKZFFMV3GK3TUVNTW2YLJNRPWG3DJMNVQ",
"url": "https://github.com/barnowl/barnowl/pull/191?email_source=3Dnotifi=
cations\u0026email_token=3DABCERSOSF3PEQD5MCT667335W5QL7A5CNFSNUABEM5UWIO=
RPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF42TCMBZHAYDGNJQG2THEZLBONXW5KTTOVRHGY3=
SNFRGKZFFMV3GK3TUVNTW2YLJNRPWG3DJMNVQ",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>

----==_mimepart_6ae7774f42bfa_e212a81408314--

home help back first fref pref prev next nref lref last post