<p>(plus one bonus commit, hope that's ok)</p>
<hr>
<p>rpmlock_acquire() failed to set errno, when it failed to acquire a<br>
write-lock on a lock which was opened as read-only. errno was printed in<br>
the error message, so the error message was arbitrary. Typically the<br>
previous errno happened to be the right one, but if STDIN was not a TTY,<br>
then it was not. (Due to an intervening call to isatty()).</p>
<p>A one-line <span aria-label="This pull request closes issue #355." class="issue-keyword tooltipped tooltipped-se">fix</span> to set errno appropriately would not fix <a href="https://github.com/rpm-software-management/rpm/issues/355" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="272907514" data-permission-text="Issue title is private" data-url="https://github.com/rpm-software-management/rpm/issues/355">#355</a>. Because the<br>
appropriate errno for performing write operations on a read-only handle<br>
is EBADF. This is too generic to tell the user what the real problem is<br>
(i.e. that rpm was run without the necessary privilege to write to the lock<br>
file).</p>
<p>This obstacle would disappear if we could avoid the automatic fallback<br>
from a read-write open() to a read-only open(). It turns out that<br>
rpmlock.h never exported a read-only lock feature, so this was never used.</p>
<p>Remove the code for automatic fallback to read-only and read-only locks.<br>
This makes <a href="https://github.com/rpm-software-management/rpm/issues/355" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="272907514" data-permission-text="Issue title is private" data-url="https://github.com/rpm-software-management/rpm/issues/355">#355</a> go away.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/rpm-software-management/rpm/pull/358'>https://github.com/rpm-software-management/rpm/pull/358</a></p>
<h4>Commit Summary</h4>
<ul>
<li>Fix error message for rpmlock (#355), by removing dead code</li>
<li>rpmlock_new(): use xcalloc()</li>
</ul>
<h4>File Changes</h4>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/rpm-software-management/rpm/pull/358/files#diff-0">lib/rpmlock.c</a>
(60)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/rpm-software-management/rpm/pull/358/files#diff-1">lib/rpmlock.h</a>
(6)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/rpm-software-management/rpm/pull/358.patch'>https://github.com/rpm-software-management/rpm/pull/358.patch</a></li>
<li><a href='https://github.com/rpm-software-management/rpm/pull/358.diff'>https://github.com/rpm-software-management/rpm/pull/358.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/rpm-software-management/rpm/pull/358">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ANb806YDDnQIFgHieXpufxd9gesHAsEbks5s2H9ZgaJpZM4QcJUG">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ANb808jD41Em4_H9yu4Gmo_L5hS6sqpnks5s2H9ZgaJpZM4QcJUG.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/rpm-software-management/rpm/pull/358"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/rpm-software-management/rpm","title":"rpm-software-management/rpm","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/rpm-software-management/rpm"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Fix error message for rpmlock (#355), by removing dead code (#358)"}],"action":{"name":"View Pull Request","url":"https://github.com/rpm-software-management/rpm/pull/358"}}}</script>