@@ -122,59 +122,51 @@ main(int argc, char **argv)
122122 { "staging" , no_argument , NULL , 2 },
123123 { NULL , 0 , NULL , 0 }
124124 };
125- struct xbps_handle xh ;
125+ struct xbps_handle xh = { 0 } ;
126126 struct xferstat xfer ;
127- const char * rootdir , * cachedir , * confdir ;
128- int i , c , flags , rv , fflag = 0 ;
127+ int i , c , rv , fflag = 0 ;
129128 bool syncf , yes , force , drun , update ;
130129 int maxcols , eexist = 0 ;
131130
132- rootdir = cachedir = confdir = NULL ;
133- flags = rv = 0 ;
134131 syncf = yes = force = drun = update = false;
135132
136- memset (& xh , 0 , sizeof (xh ));
137-
138133 while ((c = getopt_long (argc , argv , shortopts , longopts , NULL )) != -1 ) {
139134 switch (c ) {
140135 case 1 :
141- flags |= XBPS_FLAG_INSTALL_REPRO ;
136+ xh . flags |= XBPS_FLAG_INSTALL_REPRO ;
142137 break ;
143138 case 2 :
144- flags |= XBPS_FLAG_USE_STAGE ;
139+ xh . flags |= XBPS_FLAG_USE_STAGE ;
145140 break ;
146141 case 'A' :
147- flags |= XBPS_FLAG_INSTALL_AUTO ;
142+ xh . flags |= XBPS_FLAG_INSTALL_AUTO ;
148143 break ;
149144 case 'C' :
150- confdir = optarg ;
151- break ;
152- case 'c' :
153- cachedir = optarg ;
145+ xbps_strlcpy (xh .cachedir , optarg , sizeof (xh .cachedir ));
154146 break ;
155147 case 'd' :
156- flags |= XBPS_FLAG_DEBUG ;
148+ xh . flags |= XBPS_FLAG_DEBUG ;
157149 break ;
158150 case 'D' :
159- flags |= XBPS_FLAG_DOWNLOAD_ONLY ;
151+ xh . flags |= XBPS_FLAG_DOWNLOAD_ONLY ;
160152 break ;
161153 case 'f' :
162154 fflag ++ ;
163155 if (fflag > 1 )
164- flags |= XBPS_FLAG_FORCE_UNPACK ;
156+ xh . flags |= XBPS_FLAG_FORCE_UNPACK ;
165157 force = true;
166158 break ;
167159 case 'h' :
168160 usage (false);
169161 /* NOTREACHED */
170162 case 'I' :
171- flags |= XBPS_FLAG_IGNORE_FILE_CONFLICTS ;
163+ xh . flags |= XBPS_FLAG_IGNORE_FILE_CONFLICTS ;
172164 break ;
173165 case 'i' :
174- flags |= XBPS_FLAG_IGNORE_CONF_REPOS ;
166+ xh . flags |= XBPS_FLAG_IGNORE_CONF_REPOS ;
175167 break ;
176168 case 'M' :
177- flags |= XBPS_FLAG_REPOS_MEMSYNC ;
169+ xh . flags |= XBPS_FLAG_REPOS_MEMSYNC ;
178170 break ;
179171 case 'n' :
180172 drun = true;
@@ -183,19 +175,19 @@ main(int argc, char **argv)
183175 xbps_repo_store (& xh , optarg );
184176 break ;
185177 case 'r' :
186- rootdir = optarg ;
178+ xbps_strlcpy ( xh . rootdir , optarg , sizeof ( xh . rootdir )) ;
187179 break ;
188180 case 'S' :
189181 syncf = true;
190182 break ;
191183 case 'U' :
192- flags |= XBPS_FLAG_UNPACK_ONLY ;
184+ xh . flags |= XBPS_FLAG_UNPACK_ONLY ;
193185 break ;
194186 case 'u' :
195187 update = true;
196188 break ;
197189 case 'v' :
198- flags |= XBPS_FLAG_VERBOSE ;
190+ xh . flags |= XBPS_FLAG_VERBOSE ;
199191 break ;
200192 case 'V' :
201193 printf ("%s\n" , XBPS_RELVER );
@@ -218,14 +210,7 @@ main(int argc, char **argv)
218210 xh .state_cb = state_cb ;
219211 xh .fetch_cb = fetch_file_progress_cb ;
220212 xh .fetch_cb_data = & xfer ;
221- if (rootdir )
222- xbps_strlcpy (xh .rootdir , rootdir , sizeof (xh .rootdir ));
223- if (cachedir )
224- xbps_strlcpy (xh .cachedir , cachedir , sizeof (xh .cachedir ));
225- if (confdir )
226- xbps_strlcpy (xh .confdir , confdir , sizeof (xh .confdir ));
227- xh .flags = flags ;
228- if (flags & XBPS_FLAG_VERBOSE )
213+ if (xh .flags & XBPS_FLAG_VERBOSE )
229214 xh .unpack_cb = unpack_progress_cb ;
230215
231216 if ((rv = xbps_init (& xh )) != 0 ) {
0 commit comments