@@ -305,28 +305,36 @@ void parse_cmdline(INTN argc, CHAR16 **argv)
305305{
306306 INTN i ;
307307
308- for (i = 0 ; i < argc ; i ++ ) {
309- if (!StrnCmp (opt_enable_xue , argv [i ], StrLen (opt_enable_xue ))) {
308+ if (argc <= 1 ) {
309+ return ;
310+ }
311+
312+ for (i = 1 ; i < argc ; i ++ ) {
313+ if (!StrnCmp (opt_enable_xue , argv [i ], StrLen (opt_enable_xue ) + 1 )) {
310314 BFINFO ("Enabling Xue USB Debugger\n" );
311315 g_enable_xue = 1 ;
316+ continue ;
312317 }
313318
314- if (!StrnCmp (opt_enable_winpv , argv [i ], StrLen (opt_enable_winpv ))) {
319+ if (!StrnCmp (opt_enable_winpv , argv [i ], StrLen (opt_enable_winpv ) + 1 )) {
315320 BFINFO ("Enabling Windows PV\n" );
316321 g_enable_winpv = 1 ;
322+ continue ;
317323 }
318324
319- if (!StrnCmp (opt_disable_winpv , argv [i ], StrLen (opt_disable_winpv ))) {
325+ if (!StrnCmp (opt_disable_winpv , argv [i ], StrLen (opt_disable_winpv ) + 1 )) {
320326 BFINFO ("Disabling Windows PV\n" );
321327 g_enable_winpv = 0 ;
328+ continue ;
322329 }
323330
324- if (!StrnCmp (opt_disable_xen_pfd , argv [i ], StrLen (opt_disable_xen_pfd ))) {
331+ if (!StrnCmp (opt_disable_xen_pfd , argv [i ], StrLen (opt_disable_xen_pfd ) + 1 )) {
325332 BFINFO ("Disabling Xen Platform PCI device\n" );
326333 g_disable_xen_pfd = 1 ;
334+ continue ;
327335 }
328336
329- if (!StrnCmp (opt_pci_pt_class , argv [i ], StrLen (opt_pci_pt_class ))) {
337+ if (!StrnCmp (opt_pci_pt_class , argv [i ], StrLen (opt_pci_pt_class ) + 1 )) {
330338 if (i >= argc - 1 ) {
331339 BFALERT ("Missing class value\n" );
332340 BFALERT (" usage: --pci-pt-class n\n" );
@@ -347,9 +355,12 @@ void parse_cmdline(INTN argc, CHAR16 **argv)
347355 pci_pt_class_count ++ ;
348356
349357 BFINFO ("Enabling passthrough for PCI class %ld\n" , pci_class );
358+
359+ i ++ ;
360+ continue ;
350361 }
351362
352- if (!StrnCmp (opt_no_pci_pt , argv [i ], StrLen (opt_no_pci_pt ))) {
363+ if (!StrnCmp (opt_no_pci_pt , argv [i ], StrLen (opt_no_pci_pt ) + 1 )) {
353364 if (i >= argc - 1 ) {
354365 continue ;
355366 }
@@ -366,6 +377,9 @@ void parse_cmdline(INTN argc, CHAR16 **argv)
366377 (bdf & 0x00FF0000 ) >> 16 ,
367378 (bdf & 0x0000F800 ) >> 11 ,
368379 (bdf & 0x00000700 ) >> 8 );
380+
381+ i ++ ;
382+ continue ;
369383 }
370384
371385 if (!StrnCmp (opt_pci_pt , argv [i ], StrLen (opt_pci_pt ) + 1 )) {
@@ -385,7 +399,13 @@ void parse_cmdline(INTN argc, CHAR16 **argv)
385399 (bdf & 0x00FF0000 ) >> 16 ,
386400 (bdf & 0x0000F800 ) >> 11 ,
387401 (bdf & 0x00000700 ) >> 8 );
402+
403+ i ++ ;
404+ continue ;
388405 }
406+
407+ BFALERT ("Ignoring unknown argument: " );
408+ Print (L"%s\n" , argv [i ]);
389409 }
390410}
391411
0 commit comments