<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>amarao</title>
  <link>https://amarao.dreamwidth.org/</link>
  <description>amarao - Dreamwidth Studios</description>
  <lastBuildDate>Tue, 18 Oct 2022 13:31:56 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>amarao</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/14605094/3740325</url>
    <title>amarao</title>
    <link>https://amarao.dreamwidth.org/</link>
    <width>100</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>https://amarao.dreamwidth.org/49410.html</guid>
  <pubDate>Tue, 18 Oct 2022 13:31:56 GMT</pubDate>
  <title>За что я люблю Rust</title>
  <link>https://amarao.dreamwidth.org/49410.html</link>
  <description>Это корректный код из mdadm. Многослойно-хтонический ужас С. Не программистов, которые это писали, самого языка.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;color: #d4d4d4;background-color: #1e1e1e;font-family: &amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace, &amp;#39;Droid Sans Fallback&amp;#39;;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; sysfs_fd_get_two(&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; fd, &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; *v1, &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; *v2)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/* two numbers in this sysfs file, either&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;         *  NNN (NNN)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;         * or&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;         *  NNN / NNN&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;         */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; buf[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; n;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; *ep, *ep2;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;                  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        lseek(fd, &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        n = read(fd, buf, &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;(buf));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; (n &amp;lt;= &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; || n == &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;(buf))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        buf[n] = &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        *v1 = strtoull(buf, &amp;amp;ep, &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; (ep == buf || (*ep != &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &amp;amp;&amp;amp; *ep != &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos;\n&apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &amp;amp;&amp;amp; *ep != &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; (*ep == &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; || *ep == &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos;/&apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; || *ep == &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos;(&apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;                ep++;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        *v2 = strtoull(ep, &amp;amp;ep2, &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;);    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; (ep2 == ep || (*ep2 != &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &amp;amp;&amp;amp; *ep2 != &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos;\n&apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &amp;amp;&amp;amp; *ep2 != &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &amp;amp;&amp;amp; *ep2 != &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&apos;)&apos;&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;)) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;                *v2 = *v1;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=amarao&amp;ditemid=49410&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://amarao.dreamwidth.org/49410.html</comments>
  <category>c</category>
  <lj:security>public</lj:security>
  <lj:reply-count>5</lj:reply-count>
</item>
</channel>
</rss>
