<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jonh Wendell</title>
	<atom:link href="http://www.bani.com.br/lang/en/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bani.com.br</link>
	<description>Learning is cool!</description>
	<lastBuildDate>Fri, 10 May 2013 17:57:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Joining Intel</title>
		<link>http://www.bani.com.br/lang/en/2013/05/joining-intel</link>
		<comments>http://www.bani.com.br/lang/en/2013/05/joining-intel#comments</comments>
		<pubDate>Fri, 10 May 2013 17:57:09 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=582</guid>
		<description><![CDATA[Today is my last day at Oi WiFi. It has been 1 year and a half since I moved from my small city (Maceió) to the biggest, craziest Brazilian city, São Paulo. I don&#8217;t regret! I&#8217;m lucky to have joined a great company (Vex at the time. Oi WiFi nowadays), with great people where I [...]]]></description>
				<content:encoded><![CDATA[<p>Today is my last day at Oi WiFi.</p>
<p>It has been 1 year and a half since I moved from my small city (Maceió) to the biggest, craziest Brazilian city, São Paulo. I don&#8217;t regret!</p>
<p>I&#8217;m lucky to have joined a great company (Vex at the time. Oi WiFi nowadays), with great people where I learnt a lot. I&#8217;m glad for the things I helped to improve, I&#8217;m sure we have better products than before and I&#8217;m proud to be part of that progress. I leave as legacy the spirit of the Free Software, where we can (and should) contribute back to projects we use and improve internally. Every improvement we made here we submitted back to projects like Openwrt, busybox, glib, etc.<br />
However things and priorities in the company have changed a bit in the last few months. Time to look for a new challenge in my career.</p>
<p>What a challenge!</p>
<p>At Intel I&#8217;ll join the OTC &#8211; Intel Open Source Technology Center, and will work on Open Source projects such as Tizen, EFL, Webkit and hopefully GTK+ <img src='http://www.bani.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
The team I&#8217;ll work with is formed by the former Profusion company, <a href="https://01.org/blogs/imad/2013/welcome-profusion">acquired by Intel</a> in the beginning of the year. Profusion was a company that I admired even before it was acquired by Intel <img src='http://www.bani.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;m very excited to join Intel. It&#8217;s a great opportunity in a great company and I don&#8217;t want to disappoint them!</p>
<p>I hope to publish here very soon the things I&#8217;m working on under the Intel umbrella. See you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2013/05/joining-intel/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Shell script that updates itself</title>
		<link>http://www.bani.com.br/lang/en/2013/04/shell-script-that-updates-itself</link>
		<comments>http://www.bani.com.br/lang/en/2013/04/shell-script-that-updates-itself#comments</comments>
		<pubDate>Tue, 09 Apr 2013 23:52:46 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=559</guid>
		<description><![CDATA[Recently I needed to write a shell script that updates itself, and, surprising, I found it an easy job to do. I will share the recipe here. In my use case, I&#8217;m developing a kind of software updater and, before updating the system packages, I need to check if there is a new version of [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I needed to write a shell script that updates itself, and, surprising, I found it an easy job to do. I will share the recipe here.</p>
<p>In my use case, I&#8217;m developing a kind of software updater and, before updating the system packages, I need to check if there is a new version of this software updater. If there is, then I update myself and run my new copy on-the-fly.</p>
<p>Enough talk, show me the code. I&#8217;ll paste here a simple shell script that talks by itself:</p>
<pre class="wp-code-highlight prettyprint linenums:1">#!/bin/sh

SCRIPT_NAME=&#34;$0&#34;
ARGS=&#34;$@&#34;
NEW_FILE=&#34;/tmp/blog.sh&#34;
VERSION=&#34;1.0&#34;

check_upgrade () {

  # check if there is a new version of this file
  # here, hypothetically we check if a file exists in the disk.
  # it could be an apt/yum check or whatever...
  [ -f &#34;$NEW_FILE&#34; ] &#38;&#38; {

    # install a new version of this file or package
    # again, in this example, this is done by just copying the new file
    echo &#34;Found a new version of me, updating myself...&#34;
    cp &#34;$NEW_FILE&#34; &#34;$SCRIPT_NAME&#34;
    rm -f &#34;$NEW_FILE&#34;

    # note that at this point this file was overwritten in the disk
    # now run this very own file, in its new version!
    echo &#34;Running the new version...&#34;
    $SCRIPT_NAME $ARGS

    # now exit this old instance
    exit 0
  }

  echo &#34;I&#039;m VERSION $VERSION, already the latest version.&#34;
}

main () {
  # main script stuff
  echo &#34;Hello World! I&#039;m the version $VERSION of the script&#34;
}

check_upgrade
main</pre>
<p>To try this script:<br />
1) save it somewhere<br />
2) save a copy of it at /tmp/blog.sh (as pointed at line 5)<br />
3) modify the variable &#8220;VERSION&#8221; (line 6) of that copy, to, say, &#8220;2.0&#8243;.<br />
4) run the original script (not the one at /tmp)</p>
<p>You will see that the script updated itself and ran the &#8220;new&#8221; 2.0 version.</p>
<p>Try running again the original script (step 4 above). See the difference? It doesn&#8217;t update itself anymore, because it is the &#8220;latest&#8221; version.</p>
<p>A small thing you might notice: at line 19, I deleted the &#8220;new file&#8221;. That&#8217;s merely for this educational example, that we check if there&#8217;s a new version of the script by just checking if a file exists in the disk. On real life (with apt/yum or any smarter process) this is not needed as our check for a new version (line 13) will naturally fail.</p>
<p>This was tested with bash, dash and busybox&#8217;s ash. Worked fine.</p>
<p>I hope it&#8217;s useful to someone. Comments are welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2013/04/shell-script-that-updates-itself/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>g_list_copy_deep and g_slist_copy_deep in GLib</title>
		<link>http://www.bani.com.br/lang/en/2012/06/g_list_copy_deep-and-g_slist_copy_deep-in-glib</link>
		<comments>http://www.bani.com.br/lang/en/2012/06/g_list_copy_deep-and-g_slist_copy_deep-in-glib#comments</comments>
		<pubDate>Thu, 21 Jun 2012 20:58:42 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=536</guid>
		<description><![CDATA[If you have in your code things like that: copy = g_slist_copy (list); g_slist_foreach (copy, g_object_ref, NULL); In GLib 2.34 (to be released soon) you can do: copy = g_slist_copy_deep (list, g_object_ref, NULL); Thus eliminating another loop in the list (one loop is done when copying the list). In other words, there&#8217;s now a function [...]]]></description>
				<content:encoded><![CDATA[<p>If you have in your code things like that:</p>
<pre class="wp-code-highlight prettyprint linenums:1">
copy = g_slist_copy (list);
g_slist_foreach (copy, g_object_ref, NULL);
</pre>
<p>In GLib 2.34 (to be released soon) you can do:</p>
<pre class="wp-code-highlight prettyprint linenums:1">
copy = g_slist_copy_deep (list, g_object_ref, NULL);
</pre>
<p>Thus eliminating another loop in the list (one loop is done when copying the list).</p>
<p>In other words, <a href="http://git.gnome.org/browse/glib/commit/?id=2fd6eb7e1cfc878d011ec0b7e58c5e696186516e">there&#8217;s now</a> a function to do a deep (full) copy of a GList and GSList. It accepts, besides the list to be cloned, a function as a second argument, and a user data as the third argument. That function will be called for each element in the list.</p>
<p>To free the new list, use g_list_free_full().</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2012/06/g_list_copy_deep-and-g_slist_copy_deep-in-glib/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programmatically managing iptables rules in C: IPTC</title>
		<link>http://www.bani.com.br/lang/en/2012/05/programmatically-managing-iptables-rules-in-c-iptc</link>
		<comments>http://www.bani.com.br/lang/en/2012/05/programmatically-managing-iptables-rules-in-c-iptc#comments</comments>
		<pubDate>Tue, 29 May 2012 15:10:14 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=523</guid>
		<description><![CDATA[Sometimes we need to manage iptables rules from inside our own programs. The recommended solution given by iptables developers is to spawn the iptables command with execl() or system(). It&#8217;s explicitly stated that there&#8217;s no stable/public API to do that: http://www.netfilter.org/documentation/FAQ/netfilter-faq-4.html#ss4.5 However, if you have control of your box, including kernel, iptables, and all related [...]]]></description>
				<content:encoded><![CDATA[<p>Sometimes we need to manage iptables rules from inside our own programs. The recommended solution given by iptables developers is to spawn the iptables command with <em>execl()</em> or <em>system()</em>. It&#8217;s explicitly stated that there&#8217;s no stable/public API to do that: <a href="http://www.netfilter.org/documentation/FAQ/netfilter-faq-4.html#ss4.5">http://www.netfilter.org/documentation/FAQ/netfilter-faq-4.html#ss4.5</a></p>
<p>However, if you have control of your box, including <em>kernel</em>, <em>iptables</em>, and all related packages, it&#8217;s safe to use <strong>IPTC</strong> to programmatically manage iptables rules.</p>
<p><strong>IPTC</strong> is an internal iptables library that actually inserts/removes the rules. It&#8217;s used by the <em>iptables</em> (<em>xtables-multi</em>, <em>iptables-save</em>, <em>iptables-restore</em>) binaries. Depending on how iptables was compiled, there might be a shared <em>libiptc.so</em> object and/or a static <em>libiptc.a</em> object.</p>
<p>You should check that in order to correctly build your application. In Debian/Ubuntu, which this post is based, it&#8217;s enough to install the <em>iptables-dev</em> package. It will install the shared libraries, the header files and the pkg-config facility.</p>
<p>So, let&#8217;s take a look at a complete function that adds a rule to iptables:</p>
<pre class="wp-code-highlight prettyprint linenums:1">
#include &#60;stdio.h&#62;
#include &#60;errno.h&#62;
#include &#60;string.h&#62;
#include &#60;libiptc/libiptc.h&#62;

static int
insert_rule (const char *table,
             const char *chain, 
             unsigned int src,
             int inverted_src,
             unsigned int dest,
             int inverted_dst,
             const char *target)
{
  struct
    {
      struct ipt_entry entry;
      struct xt_standard_target target;
    } entry;
  struct xtc_handle *h;
  int ret = 1;

  h = iptc_init (table);
  if (!h)
    {
      fprintf (stderr, &#34;Could not init IPTC library: %s\n&#34;, iptc_strerror (errno));
      goto out;
    }

  memset (&#38;entry, 0, sizeof (entry));

  /* target */
  entry.target.target.u.user.target_size = XT_ALIGN (sizeof (struct xt_standard_target));
  strncpy (entry.target.target.u.user.name, target, sizeof (entry.target.target.u.user.name));

  /* entry */
  entry.entry.target_offset = sizeof (struct ipt_entry);
  entry.entry.next_offset = entry.entry.target_offset + entry.target.target.u.user.target_size;
  
  if (src)
    {
      entry.entry.ip.src.s_addr  = src;
      entry.entry.ip.smsk.s_addr = 0xFFFFFFFF;
      if (inverted_src)
        entry.entry.ip.invflags &#124;= IPT_INV_SRCIP;
    }

  if (dest)
    {
      entry.entry.ip.dst.s_addr  = dest;
      entry.entry.ip.dmsk.s_addr = 0xFFFFFFFF;
      if (inverted_dst)
        entry.entry.ip.invflags &#124;= IPT_INV_DSTIP;
    }

  if (!iptc_append_entry (chain, (struct ipt_entry *) &#38;entry, h))
    {
      fprintf (stderr, &#34;Could not insert a rule in iptables (table %s): %s\n&#34;, table, iptc_strerror (errno));
      goto out;
    }

  if (!iptc_commit (h))
    {
      fprintf (stderr, &#34;Could not commit changes in iptables (table %s): %s\n&#34;, table, iptc_strerror (errno));
      goto out;
    }

  ret = 0;
out:
  if (h)
    iptc_free (h);

  return ret;
}

int main (int argc, char **argv)
{
  unsigned int a, b;

  inet_pton (AF_INET, &#34;1.2.3.4&#34;, &#38;a);
  inet_pton (AF_INET, &#34;4.3.2.1&#34;, &#38;b);

  insert_rule (&#34;filter&#34;,
               &#34;INPUT&#34;,
               a,
               0,
               b,
               1,
               &#34;DROP&#34;);
  return 0;
}
</pre>
<p><em><small>Note: The code above was compiled and tested against the 1.4.13 version of iptables.</small></em><br />
To compile: </p>
<blockquote><p>cc `pkg-config &#8211;cflags &#8211;libs libiptc` source-file.c -o test-iptc</p></blockquote>
<p>So, the code in <em>main()</em> above does the equivalent of:</p>
<blockquote><p>iptables -t filter -A INPUT -s 1.2.3.4/32 ! -d 4.3.2.1/32 -j DROP</p></blockquote>
<p>The main functions used were <strong>iptc_init</strong>, <strong>iptc_append_entry</strong> and <strong>iptc_commit</strong>. There are functions to remove a rule (<strong>iptc_delete_num_entry</strong>), to iterate over all the rules (<strong>iptc_first_rule</strong>, <strong>iptc_next_rule</strong>) and to clear all rules (<strong>iptc_flush_entries</strong>).</p>
<p>You can check the header file <em><strong>libiptc/libiptc.h</strong></em> to see all available functions and their descriptions. I can post some more examples here in the future if there&#8217;s demand to it.</p>
<p>Again, remember that there&#8217;s no API stability in IPTC, so, it can change in each new version of iptables.</p>
<p>Hope it&#8217;s useful to someone. Feel free to ask anything or to report any issues you have. See you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2012/05/programmatically-managing-iptables-rules-in-c-iptc/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux firewall: Mac filtering &#8211; iptables and arptables</title>
		<link>http://www.bani.com.br/lang/en/2012/05/linux-firewall-mac-filtering-iptables-and-arptablesfirewall-no-linux-filtro-por-mac-iptables-e-arptables</link>
		<comments>http://www.bani.com.br/lang/en/2012/05/linux-firewall-mac-filtering-iptables-and-arptablesfirewall-no-linux-filtro-por-mac-iptables-e-arptables#comments</comments>
		<pubDate>Fri, 25 May 2012 14:10:57 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=510</guid>
		<description><![CDATA[[english] It&#8217;s common: you don&#8217;t want just filter the access by IP address, but also by the MAC address. The solution can be quite simple: use the MAC module of iptables: iptables -A INPUT -s 1.2.3.4 -m mac ! &#8211;mac-source aa:bb:cc:dd:ee:ff -j DROP The command above says: Drop every packet with source ip address 1.2.3.4 [...]]]></description>
				<content:encoded><![CDATA[<p><em><span lang="en">[english]</span></em><br />
<span lang="en"><br />
It&#8217;s common: you don&#8217;t want just filter the access by IP address, but also by the MAC address. The solution can be quite simple: use the <strong>MAC</strong> module of <strong>iptables</strong>:<br />
</span></p>
<p><span lang="en"></p>
<blockquote><p>iptables -A INPUT -s 1.2.3.4 -m mac ! &#8211;mac-source aa:bb:cc:dd:ee:ff -j DROP</p></blockquote>
<p></span></p>
<p><span lang="en"><br />
The command above says: Drop every packet with source ip address 1.2.3.4 and its MAC address is <strong>NOT</strong> aa:bb:cc:dd:ee:ff. Thus you&#8217;re forcing the origin of the packet to be the desired one.<br />
</span></p>
<p><span lang="en"><br />
However there is a minor issue with that approach: iptables manages packets at the network (IP) layer, which is above the link (MAC) layer. What does that mean? Simple: Once the packet arrives at the network interface, it&#8217;s handled by the MAC layer and then it&#8217;s forwarded to the IP layer. That&#8217;s where iptables filter it. Again, what&#8217;s the problem? At this pointer, the ARP table of the kernel was touched, meaning that (using the example above), if a packet with source IP 1.2.3.4 and source MAC 00:00:00:00:00:01 arrives, it will change the ARP entry in the kernel table to point the IP 1.2.3.4 to that wrong MAC address. After that, the packet is forwarded to the above layer, which is then dropped by iptables from go on over the network. Even if the packet is dropped, which is what you want, your ARP table is messed up right now.<br />
</span></p>
<p><span lang="en"><br />
That&#8217;s where <strong>arptables</strong> command comes in. It works just like iptables, but it filters packets at MAC layer, preventing the kernel <strong>ARP table</strong> being touched by wrong packets. Its syntax is very similar to iptables (in fact, it&#8217;s a copy of iptables adapted to work in the lower level). The same command (iptables) above could be better implemented with arptables:<br />
</span></p>
<p><span lang="en"></p>
<blockquote><p>arptables -A IN -s 1.2.3.4 ! &#8211;source-hw aa:bb:cc:dd:ee:ff -j DROP</p></blockquote>
<p></span></p>
<p><span lang="en"><br />
You just need this rule, it&#8217;s not necessary to have the iptables rules anymore. arptables needs a kernel with support built in, which I guess most distros do, just like they do with iptables.<br />
</span></p>
<p><span lang="en"><br />
Take a look at the arptables man page, it has some examples. Its similarity with iptables facilitates our lives.<br />
</span></p>
<p><em><span lang="pt-br">[português]</span></em><br />
<span lang="pt-br"><br />
É uma situação comum: você não quer apenas filtrar o acesso por endereço IP, mas também pelo endereço MAC. A solução pode ser bastante simples: usar o módulo <strong>MAC</strong> do <strong>iptables</strong>:<br />
</span></p>
<p><span lang="pt-br"></p>
<blockquote><p>iptables -A INPUT -s 1.2.3.4 -m mac ! &#8211;mac-source aa:bb:cc:dd:ee:ff -j DROP</p></blockquote>
<p></span></p>
<p><span lang="pt-br"><br />
O comando acima diz: Descarte todos os pacotes com o endereço IP de origem 1.2.3.4 e cujo endereço MAC <strong>não</strong> é aa:bb:cc:dd:ee:ff. Assim, você está forçando a origem do pacote a ser a desejada.<br />
</span></p>
<p><span lang="pt-br"><br />
No entanto, há um pequeno problema com essa abordagem: o iptables gerencia pacotes na camada de rede (IP), que é acima da camada de enlace (MAC). O que significa isso? Simples: Quando o pacote chega na interface da rede, ele é tratado pela camada MAC e depois é encaminhado para a camada IP. É onde iptables o filtra. Novamente, qual é o problema? Neste ponto, a tabela ARP do kernel foi alterada, o que significa que (usando o exemplo acima), se um pacote com o IP origem 1.2.3.4 e MAC 00:00:00:00:00:01 chega, ele vai mudar a entrada na tabela ARP do kernel para apontar o IP 1.2.3.4 para o endereço MAC errado. Depois disso, o pacote é encaminhado para a camada superior, que é então descartado pelo iptables de continuar na rede. Mesmo o pacote sendo descartado, que é o que você deseja, sua tabela ARP está uma bagunça agora.<br />
</span></p>
<p><span lang="pt-br"><br />
É aí que o comando <strong>arptables</strong> entra. Ele funciona exatamente como o iptables, mas filtra os pacotes na camada MAC, evitando que a <strong>tabela ARP</strong> do kernel seja alterada por pacotes errados. Sua sintaxe é muito semelhante ao iptables (na verdade, é uma cópia do iptables adaptado para trabalhar num nível mais baixo). O mesmo comando (iptables) acima poderia ser melhor implementado com arptables:<br />
</span></p>
<p><span lang="pt-br"></p>
<blockquote><p>arptables -A IN -s 1.2.3.4 ! &#8211;source-hw aa:bb:cc:dd:ee:ff -j DROP</p></blockquote>
<p></span></p>
<p><span lang="pt-br"><br />
Você só precisa dessa regra, não é necessário ter as regras de iptables mais. o arptables precisa que o kernel tenha suporte, o que eu acho que a maioria das distribuições já fazem, assim como eles fazem com o iptables.<br />
</span></p>
<p><span lang="pt-br"><br />
Dê uma olhada no man do arptables, lá tem alguns exemplos. Sua semelhança com o iptables facilita nossas vidas.<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2012/05/linux-firewall-mac-filtering-iptables-and-arptablesfirewall-no-linux-filtro-por-mac-iptables-e-arptables/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>free() inconsistencies</title>
		<link>http://www.bani.com.br/lang/en/2012/01/free-inconsistenciesinconsistencias-no-free</link>
		<comments>http://www.bani.com.br/lang/en/2012/01/free-inconsistenciesinconsistencias-no-free#comments</comments>
		<pubDate>Thu, 19 Jan 2012 13:27:57 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=496</guid>
		<description><![CDATA[Hi, folks! Last week I was porting a program from uClibc to glibc. Everything went fine, until I found a crash to always happen in a certain part of it. The failure was in a call to the free() function. First thing that came in my head: Why the hell is it crashing now, while [...]]]></description>
				<content:encoded><![CDATA[<p><span lang="en"><br />
Hi, folks!</span></p>
<p><span lang="en"><br />
Last week I was porting a program from uClibc to glibc. Everything went fine, until I found a crash to always happen in a certain part of it. The failure was in a call to the free() function. First thing that came in my head: Why the hell is it crashing now, while it used to run fine on uClibc? I made a simple program that simulates the problem:<br />
</span></p>


<pre class="wp-code-highlight prettyprint linenums:1">#include &#38;lt;stdio.h&#38;gt;
#include &#38;lt;stdlib.h&#38;gt;

typedef struct {
  char *field1;
} s_test;

s_test test = {
  .field1 = NULL
};

int main (int argc, char **argv) {
  s_test *t;

  t = &#38;amp;test;
  free (t);
  t = &#38;amp;test;
  t-&#38;gt;field1 = &#34;bug&#34;;
  printf (&#34;%s\n&#34;, t-&#38;gt;field1);

  return 0;
}</pre>
<p><span lang="en"><br />
Look at line 16. I&#8217;m executing a free() in a pointer to a static variable, instead of a pointer in the heap (previously allocated with malloc() or similar). It&#8217;s expected a crash here, right? Maybe! Yes, if you&#8217;re using glibc. No if you&#8217;re using uClibc. The above code works like [not] expected. Weird! Everything we learned at the programming school is ruined now <img src='http://www.bani.com.br/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  !</span><br />
<span lang="en"><br />
So, we have a similar code here that have been worked for a long time, exactly because it was compiled and run on top of uClibc. I&#8217;ve seen this and other behavior differences between uClibc and glibc. The solution? Change the code to make it portable, not only to make it compile, but also so that it have the same behavior on every platform.</span></p>
<p><span lang="en"><br />
I thought it was a bug in uClibc, but I was told it doesn&#8217;t break the standards. In fact, standards say, in that case, the behavior is &#8220;undefined&#8221;. Ah, standards <img src='http://www.bani.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &#8230; So, in order to avoid surprises like that, here is what I learned: Always code in the right way, even if it comes with a harder job. Don&#8217;t say: &#8220;hey, it&#8217;s working, let&#8217;s deploy it!&#8221;.</span></p>
<p><span lang="en"><br />
See you!</span></p>




]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2012/01/free-inconsistenciesinconsistencias-no-free/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New challenges</title>
		<link>http://www.bani.com.br/lang/en/2011/11/new-challengesnovos-desafios</link>
		<comments>http://www.bani.com.br/lang/en/2011/11/new-challengesnovos-desafios#comments</comments>
		<pubDate>Thu, 17 Nov 2011 16:47:37 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=489</guid>
		<description><![CDATA[[english] Hi, folks! This is a small post, just to share the news with you: I moved to São Paulo (the biggest Brazilian city) to work with what I like the most: linux development! It&#8217;s indeed a big step in my career, I&#8217;m too excited about my new job: embedded linux developer! I hope to [...]]]></description>
				<content:encoded><![CDATA[<p><em><span lang="en">[english]</span></em></p>
<p><span lang="en"><br />
Hi, folks!</span></p>
<p><span lang="en"><br />
This is a small post, just to share the news with you: I moved to São Paulo (the biggest Brazilian city) to work with what I like the most: linux development! It&#8217;s indeed a big step in my career, I&#8217;m too excited about my new job: embedded linux developer!</span></p>
<p><span lang="en"><br />
I hope to learn a lot in this new job, and, at the right time, I want to contribute back to FLOSS community, since we use a lot of free software here.</span></p>
<p><span lang="en"><br />
See you!</span></p>
<p><em></em><br />
</p>




]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2011/11/new-challengesnovos-desafios/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Software livre, ajude a fazer</title>
		<link>http://www.bani.com.br/lang/en/2011/05/software-livre-ajude-a-fazer</link>
		<comments>http://www.bani.com.br/lang/en/2011/05/software-livre-ajude-a-fazer#comments</comments>
		<pubDate>Fri, 27 May 2011 21:26:57 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=477</guid>
		<description><![CDATA[Este post é direcionado a programadores. Repasse-o pra todos os programadores que você conhece. O software livre agradece! Oi gente, esse é um assunto que sempre menciono nos eventos que vou, e que me incomoda bastante. Por estes dias tava com vontade de fazer um post simples e prático sobre o assunto. Felizmente aconteceram 3 [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Este post é direcionado a programadores. Repasse-o pra todos os programadores que você conhece. O software livre agradece!</strong></p>
<p>Oi gente, esse é um assunto que sempre menciono nos eventos que vou, e que me incomoda bastante. Por estes dias tava com vontade de fazer um post simples e prático sobre o assunto. Felizmente aconteceram 3 coisas que me motivaram a escrevê-lo:</p>
<ol>
<li>Depois de ter aberto um bug no ano passado, ainda sem solução, resolvi escrever um pequeno patch que foi aceito, com modificações;</li>
<li>Li isso: <a href="http://www.dicas-l.com.br/arquivo/yad_yet_another_dialog.php">http://www.dicas-l.com.br/arquivo/yad_yet_another_dialog.php</a>;</li>
<li>Jomar escreveu um ótimo artigo exatamente sobre esse tema: <a href="http://www.trezentos.blog.br/?p=5907">http://www.trezentos.blog.br/?p=5907</a></li>
</ol>
<p>Por que as pessoas se referem ao software livre sempre na terceira pessoa: &#8220;Eles&#8221;? É comum a gente ouvir:</p>
<blockquote><p>- Quando o software X implementar a feature Y eu migro.<br />
- Software X? Ah, ele tem muitos bugs, prefiro esperar ficar redondo.<br />
- Não gostei da versão nova do software X. Vou ficar na atual ou testar uma alternativa.<br />
- O pessoal do projeto X é devagar demais.</p></blockquote>
<p>Gente, quando é que vai cair a ficha que o software é livre e que nós podemos mudá-lo? Vocês já pararam pra pensar que podem tornar o software X um software melhor? Não tô entrando aqui no mérito da liberdade de escolha, você é livre pra usar o software que quiser. O recado aqui é para <strong>programadores</strong>, que querem ao mesmo tempo ganhar experiência e contribuir para um mundo melhor.</p>
<p>Contribuir com código não é um bicho de 7 cabeças. Software é software em todo lugar do mundo, e software livre é a melhor forma de espalhar e receber conhecimento. Vejam aqui um exemplo muito simples, porém prático de como você pode fazer a coisa acontecer, ao invés de simplesmente esperar &#8220;eles&#8221; resolverem o bug (explicação do item 1 lá de cima):</p>
<ul>
<li>Ano: 2008. Senti a falta de um conversor de moedas no GNOME. Reportei meu desejo no bugzilla: <a href="https://bugzilla.gnome.org/show_bug.cgi?id=533690">https://bugzilla.gnome.org/show_bug.cgi?id=533690</a>. Pouco mais de 1 ano depois esse recurso foi implementado.</li>
<li>Ano: 2010. Usando o recurso acima, senti a falta de um botão pra trocar de moedas. Da mesma forma, reportei meu desejo: <a href="https://bugzilla.gnome.org/show_bug.cgi?id=633193">https://bugzilla.gnome.org/show_bug.cgi?id=633193</a>.</li>
<li>Ano: 2011. 7 meses depois, usando muito o recurso e sentindo realmente falta do tal botão, resolvi dar uma olhada no fonte e ver se seria fácil sua implementação. E foi. Submeti um patch, que no mesmo dia foi aceito, com algumas modificações feitas pelo mantenedor. Na próxima versão, a calculadora do GNOME virá com esse recurso.</li>
</ul>
<p>O que quero mostrar com isso? Que o software livre basicamente é movido por empresas e voluntários. Se uma empresa não tem interesse em determinado recurso (a ponto de alocar um funcionário para implementá-lo), o recurso tem que ser implementado por algum voluntário. Então, ao invés de ficar dizendo &#8220;Eles não ligam pra minha opinião, reportei o bug há mais de um ano e nada até agora&#8230;&#8221;, simplesmente tente resolver você mesmo! Algumas considerações:</p>
<ul>
<li>Mesmo que o seu patch não esteja correto, não tenha medo de enviá-lo. Dependendo do grau de complexidade, o desenvolvedor pode sugerir algumas modificações, explicar porque tá errado, onde tá errado e tal e pedir pra você corrigir e reenviar&#8230; ou ele pode simplesmente modificar e seu patch e aplicá-lo diretamente (foi o que aconteceu comigo acima).</li>
<li>Há sempre a possibilidade de entrar em contato direto com o desenvolvedor/mantenedor, via email, irc, jabber, etc. Assim, você pode tirar dúvidas, pedir um direcionamento, e coisas do tipo, antes de efetivamente enviar seu patch para avaliação.</li>
</ul>
<p>Quanto ao item 2 lá em cima, até mencionei minha &#8220;indignação&#8221; nos microblogs, e algumas pessoas me perguntaram o por quê. Deixa eu explicar: Minha indignação, neste caso, não é com a pessoa do Júlio. Não quero nem discutir isso. É que tô cansado de ver empresas e pessoas que ganham a vida com software livre, seja usando em seu trabalho, seja escrevendo livros, seja dando aulas, enfim, você captou a ideia, e que são aptas a escrever (ou pagar alguém que escreva) código livre mas não o fazem. Neste caso específico, o Júlio citou no post:</p>
<blockquote><p>&#8220;Sempre esperei que a qualquer momento o <em>gnome</em> lançaria uma nova versão deste software [...] Estava enganado, acompanhei o lançamento de diversas revisões do software mas elas simplesmente tratavam <em>bugs</em> e apresentação. Infelizmente nada de inovação. Porém um dia descobri o <em>YAD</em>.&#8221;</p></blockquote>
<p>Veja que o gnome está sendo tratado na terceira pessoa. &#8220;Eles&#8221;. Segue o mesmo raciocínio que usei acima. Tanto para o Júlio como para os criadores do YAD. Se o zenity não tava atendendo as expectativas, por que não ajuda-lo? Por que não implementar os recursos tão desejados?</p>
<p>Quanto ao item 3 lá de cima, não tenho muito o que falar. Leiam o texto do Jomar, é muito bom!</p>
<p>Enfim, esse &#8220;desabafo&#8221; é uma forma de mostrar pra vocês que o software livre é nosso! Vamos colaborar mais (com código). Afinal de contas, já recebemos tanto, de tantos desenvolvedores espalhados pelo mundo, o que custa doar um pouco do nosso tempo e conhecimento como uma forma de retribuição?</p>
<p>Então, esse lance de falar na terceira pessoa (&#8220;eles&#8221;, &#8220;o gnome&#8221;, &#8220;o pessoal do kde&#8221;, etc), deixa para os leigos, meros usuários de software. Na próxima vez que for criticar algum software livre, tome ele para si e pense em uma forma de ajudar, beleza? <img src='http://www.bani.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2011/05/software-livre-ajude-a-fazer/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Looking for new maintainers</title>
		<link>http://www.bani.com.br/lang/en/2010/12/looking-for-new-maintainers</link>
		<comments>http://www.bani.com.br/lang/en/2010/12/looking-for-new-maintainers#comments</comments>
		<pubDate>Sun, 12 Dec 2010 10:55:04 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=474</guid>
		<description><![CDATA[Hi, folks. Vino and Vinagre are an one-person projects. Since I hadn&#8217;t have been much time to improve them, I decided to look for new blood, new maintainers. Perhaps this will be a hard task, since nobody seems to care much about these two GNOME modules. Anyway, if you are interested, send me an email.]]></description>
				<content:encoded><![CDATA[<p>Hi, folks. Vino and Vinagre are an one-person projects. Since I hadn&#8217;t have been much time to improve them, I decided to look for new blood, new maintainers. Perhaps this will be a hard task, since nobody seems to care much about these two GNOME modules.</p>
<p>Anyway, if you are interested, send me an email.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2010/12/looking-for-new-maintainers/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>7º Brazilian GNOME Forum</title>
		<link>http://www.bani.com.br/lang/en/2010/10/7%c2%ba-brazilian-gnome-forum7%c2%ba-forum-gnome</link>
		<comments>http://www.bani.com.br/lang/en/2010/10/7%c2%ba-brazilian-gnome-forum7%c2%ba-forum-gnome#comments</comments>
		<pubDate>Wed, 20 Oct 2010 12:10:45 +0000</pubDate>
		<dc:creator>Jonh Wendell</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.bani.com.br/?p=457</guid>
		<description><![CDATA[Hello folks. It&#8217;s a pleasure to announce the 7th edition of the Brazilian GNOME Forum, that part of the year where we put together GNOMErs from all parts of Brazil to have fun! This year the Forum will take place in Natal, a greatest city in Northeast Brazil, as part of the main event, ENSL [...]]]></description>
				<content:encoded><![CDATA[







<p><span lang="en">Hello folks. It&#8217;s a pleasure to announce the 7th edition of the <strong>Brazilian GNOME Forum</strong>, that part of the year where we put together <em>GNOMErs</em> from all parts of Brazil to have fun!</span></p>
<p><span lang="en">This year the Forum will take place in Natal, a greatest city in Northeast Brazil, as part of the main event, <a href="http://ensl.org.br/2010/">ENSL &#8211; Northeast Free Software Conference</a>, on <strong>5 and 6th November</strong>.</span></p>
<p><span lang="en">This edition, besides the usual Brazilians, will have the  presence of <a href="http://live.gnome.org/FredericPeters"><strong>Frédéric Peters</strong></a>, a great hacker of the Release Team! Also, we will have the annual Brazilian meeting, where we, the Brazilian team discuss our activities, our community and our goals.</span></p>
<p><span lang="en">GNOME 3, the next version of GNOME will be widely discussed there. We will be discussing its news as well showing how to contribute in practice with its development.<br />
</span></p>
<p><a href="http://br.gnome.org/GNOMEBR/VForumFotos?id=1&#38;filename=DSC03043.JPG#igp1"><img class=" " title="We having fun at 5º Forum&#124;A gente se divertindo no 5º Fórum" src="http://br.gnome.org/pub/images/GNOMEBR/VForumFotos/1/DSC03043.JPG" alt="" width="384" height="288" /></a></p>


<p><span lang="en">Hopefully we are going to have a lot of <a href="http://www.youtube.com/watch?v=Q-TdQDwN1vU">fun</a> there! <img src='http://www.bani.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
</span></p>
<p><span lang="en">I would like to thank the <a href="http://ensl.org.br">ENSL</a> team and the <a href="http://foundation.gnome.org/">GNOME Foundation</a>. They made the forum possible. Have you <a href="http://www.gnome.org/friends/">donated to GNOME today?</a> <img src='http://www.bani.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bani.com.br/lang/en/2010/10/7%c2%ba-brazilian-gnome-forum7%c2%ba-forum-gnome/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
