Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 000676.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml" />
11
12    <title>Status for Andrew DeFaria: UCMWB su bug</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/000675.html" title="UCMWB/Document Visibility" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/000677.html" title="ucmwb 1.2.3 release/Perl'isms" />
17
18    <!--
19 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
20          xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
21          xmlns:dc="http://purl.org/dc/elements/1.1/">
22 <rdf:Description
23     rdf:about="http://defaria.com/blogs/Status/archives/000676.html"
24     trackback:ping="http://defaria.com/mt/mt-tb.cgi/63"
25     dc:title="UCMWB su bug"
26     dc:identifier="http://defaria.com/blogs/Status/archives/000676.html"
27     dc:subject="General Dynamics"
28     dc:description=" Fixed an issue with ucmwb running after su&apos;ed to another user Addressed some issues about PC running CC in the RAN network..."
29     dc:creator=""
30     dc:date="2007-09-13T11:28:07-06:00" />
31 </rdf:RDF>
32 -->
33
34
35    
36
37    <script type="text/javascript" src="http://defaria.com/blogs/Status/mt-site.js"></script>
38 </head>
39 <body class="layout-one-column" onload="individualArchivesOnLoad(commenter_name)">
40    <div id="container">
41       <div id="container-inner" class="pkg">
42
43          <div id="banner">
44             <div id="banner-inner" class="pkg">
45                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
46                <h2 id="banner-description">Searchable status reports and work log</h2>
47             </div>
48          </div>
49
50          <div id="pagebody">
51             <div id="pagebody-inner" class="pkg">
52                <div id="alpha">
53                   <div id="alpha-inner" class="pkg">
54
55                      <p class="content-nav">
56                         <a href="http://defaria.com/blogs/Status/archives/000675.html">&laquo; UCMWB/Document Visibility</a> |
57                         <a href="http://defaria.com/blogs/Status/">Main</a>
58                         | <a href="http://defaria.com/blogs/Status/archives/000677.html">ucmwb 1.2.3 release/Perl'isms &raquo;</a>
59                      </p>
60
61                      <a id="a000676"></a>
62                      <div class="entry" id="entry-676">
63                         <h3 class="entry-header">UCMWB su bug</h3>
64                         <div class="entry-content">
65                            <div class="entry-body">
66                               <ul>
67   <li>Fixed an issue with ucmwb running after su'ed to another user</li>
68
69   <li>Addressed some issues about PC running CC in the RAN network</li>
70 </ul>
71                            </div>
72                            <div id="more" class="entry-more">
73                               <h3>Stupid coding</h3>
74
75 <p>It never ceases to amaze me what some programmers do that when I look at it seem to be just foolish things. Here's today's example:</p>
76
77 <p>In ucmwb a bug was discovered when a user first su's to some other user then runs ucmwb (in this case the user is su'ing to ccadm). The while the main window dutifully displays the list of WORs for the su'ed user, the view browser does not. Instead it displays the list of views for the original user. Turns out that there was specific code for Solaris to call cuserid instead of getenv("USER"). So Linux was working but Solaris failed. Why the difference?</p>
78
79 <p>But along with that I noticed the following code:</p>
80
81 <div class=code><pre>
82     QSting homePath = QDir::homePath();
83
84     if (homePath.isEmpty()) {
85       qDebug() << "homePath is empty!";
86       // Note the following is a Unix'ism and non portable!
87       homePath = QString("/home/") + appUsername;
88     }
89
90     qDebug() << "homePath = " << homePath;
91     QString settingsFilename = QDir::homePath() + QString("/.ucmwbrc");
92     QString settingsDirname  = QDir::homePath() + QString("/.ucmwb.d");
93     QString filterFilename   = settingsDirname + QString("/filters");
94 </pre></div>
95
96 <p>OK so first ask yourself what do you see wrong here.....?</p>
97
98 <p>Pencils down!</p>
99
100 <p>Here's my questions:</p>
101
102 <ol>
103   <li>Why go through the effort of getting the user's homePath, check to see if it's empty and then compose one with "/home" + appUsername only then to totally ignore all that work and get it again for settingsFilename?</li>
104
105   <li>Why then do this operation of obtaining homePath yet again to set settingsDirname?</li>
106
107   <li>If homePath were determined to be empty, aren't you ignoring what you set it to?</li>
108 </ol>
109
110 <p>Naturally I fixed this to be:</p>
111
112 <div class=code><pre>
113     QSting homePath = QDir::homePath();
114
115     if (homePath.isEmpty()) {
116       // Note the following is a Unix'ism and non portable!
117       homePath = QString("/home/") + appUsername;
118     }
119
120     QString settingsFilename = homePath + QString("/.ucmwbrc");
121     QString settingsDirname  = homePath + QString("/.ucmwb.d");
122     QString filterFilename   = settingsDirname + QString("/filters");
123 </pre></div>
124                            </div>
125                         </div>
126                         <p class="entry-footer">
127                            <span class="post-footers">Posted by  on September 13, 2007 11:28 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000676.html">Permalink</a>
128                         </p>
129                      </div>
130
131                      
132                      <div class="trackbacks">
133                         <h3 id="trackback" class="trackbacks-header">TrackBack</h3>
134                         <div id="trackbacks-info">
135                            <p>TrackBack URL for this entry:<br />http://defaria.com/mt/mt-tb.cgi/63</p>
136                         </div>
137                         <div class="trackbacks-content">
138                            
139                         </div>
140                      </div>
141                      
142
143                      
144                   </div>
145                </div>
146             </div>
147          </div>
148       </div>
149    </div>
150 </body>
151 </html>