opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

0005-Don-t-omit-second-operand-to-operator.patch (4600B)


      1 From 586b8d1808d18149a872f0ee1dc8903b9f9e8750 Mon Sep 17 00:00:00 2001
      2 From: Michael Forney <mforney@mforney.org>
      3 Date: Sun, 7 Jul 2019 21:53:16 -0700
      4 Subject: [PATCH] Don't omit second operand to '?' operator
      5 
      6 ---
      7  src/kd_ioctl.c | 2 +-
      8  src/open.c     | 5 +++--
      9  src/prctl.c    | 8 ++++----
     10  src/strace.c   | 8 ++++----
     11  src/strauss.c  | 4 +++-
     12  src/util.c     | 2 +-
     13  6 files changed, 16 insertions(+), 13 deletions(-)
     14 
     15 diff --git a/src/kd_ioctl.c b/src/kd_ioctl.c
     16 index ada23d536..fddbd38fb 100644
     17 --- a/src/kd_ioctl.c
     18 +++ b/src/kd_ioctl.c
     19 @@ -457,7 +457,7 @@ kd_kbd_str_entry(struct tcb *const tcp, const kernel_ulong_t arg,
     20  
     21  	if (print_quoted_string((char *) val.kb_string,
     22  				MIN(max_strlen,
     23 -				   (unsigned int) ret ?: sizeof(val.kb_string)),
     24 +				   ret ? (unsigned int) ret : sizeof(val.kb_string)),
     25  				QUOTE_OMIT_TRAILING_0))
     26  		tprint_more_data_follows();
     27  
     28 diff --git a/src/open.c b/src/open.c
     29 index 6356c5831..df59ea999 100644
     30 --- a/src/open.c
     31 +++ b/src/open.c
     32 @@ -88,8 +88,9 @@ sprint_open_modes64(uint64_t flags)
     33  	}
     34  	*p = '\0';
     35  
     36 -	return sprintflags_ex(outstr, open_mode_flags, flags, sep,
     37 -			      XLAT_STYLE_ABBREV) ?: outstr;
     38 +	str = sprintflags_ex(outstr, open_mode_flags, flags, sep,
     39 +			     XLAT_STYLE_ABBREV);
     40 +	return str ? str : outstr;
     41  }
     42  
     43  const char *
     44 diff --git a/src/prctl.c b/src/prctl.c
     45 index f6b4dd741..951133a83 100644
     46 --- a/src/prctl.c
     47 +++ b/src/prctl.c
     48 @@ -92,10 +92,10 @@ sprint_sve_val(kernel_ulong_t arg, bool aux)
     49  	if (!aux && flags && xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
     50  	{
     51  		xsprintf(out, "%#" PRI_klx " /* %s%s%#" PRI_klx " */",
     52 -			 arg, flags_str ?: "", flags_str ? "|" : "", vl);
     53 +			 arg, flags_str ? flags_str : "", flags_str ? "|" : "", vl);
     54  	} else {
     55  		xsprintf(out, "%s%s%#" PRI_klx,
     56 -			 flags_str ?: "", flags_str ? "|" : "", vl);
     57 +			 flags_str ? flags_str : "", flags_str ? "|" : "", vl);
     58  	}
     59  
     60  	return out;
     61 @@ -128,10 +128,10 @@ sprint_sme_val(kernel_ulong_t arg, bool aux)
     62  	if (!aux && flags && xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
     63  	{
     64  		xsprintf(out, "%#" PRI_klx " /* %s%s%#" PRI_klx " */",
     65 -			 arg, flags_str ?: "", flags_str ? "|" : "", vl);
     66 +			 arg, flags_str ? flags_str : "", flags_str ? "|" : "", vl);
     67  	} else {
     68  		xsprintf(out, "%s%s%#" PRI_klx,
     69 -			 flags_str ?: "", flags_str ? "|" : "", vl);
     70 +			 flags_str ? flags_str : "", flags_str ? "|" : "", vl);
     71  	}
     72  
     73  	return out;
     74 diff --git a/src/strace.c b/src/strace.c
     75 index 9c87e34ed..13904f6e1 100644
     76 --- a/src/strace.c
     77 +++ b/src/strace.c
     78 @@ -2609,7 +2609,7 @@ init(int argc, char *argv[])
     79  			break;
     80  		case GETOPT_TS:
     81  			tflag_long_set = true;
     82 -			if (parse_ts_arg(optarg ?: tflag_str))
     83 +			if (parse_ts_arg(optarg ? optarg : tflag_str))
     84  				error_opt_arg(c, lopt, optarg);
     85  			break;
     86  		case 'T':
     87 @@ -2683,7 +2683,7 @@ init(int argc, char *argv[])
     88  				error_opt_arg(c, lopt, optarg);
     89  			break;
     90  		case GETOPT_TIPS:
     91 -			if (parse_tips_arg(optarg ?: ""))
     92 +			if (parse_tips_arg(optarg ? optarg : ""))
     93  				error_opt_arg(c, lopt, optarg);
     94  			break;
     95  		case GETOPT_ARGV0:
     96 @@ -2729,10 +2729,10 @@ init(int argc, char *argv[])
     97  			qualify_kvm(optarg);
     98  			break;
     99  		case GETOPT_QUAL_QUIET:
    100 -			qualify_quiet(optarg ?: qflag_qual);
    101 +			qualify_quiet(optarg ? optarg : qflag_qual);
    102  			break;
    103  		case GETOPT_QUAL_DECODE_FD:
    104 -			qualify_decode_fd(optarg ?: yflag_qual);
    105 +			qualify_decode_fd(optarg ? optarg : yflag_qual);
    106  			break;
    107  		case GETOPT_QUAL_DECODE_PID:
    108  			qualify_decode_pid(optarg);
    109 diff --git a/src/strauss.c b/src/strauss.c
    110 index bec85021b..5d49f950a 100644
    111 --- a/src/strauss.c
    112 +++ b/src/strauss.c
    113 @@ -367,6 +367,7 @@ print_totd(void)
    114  	struct timeval tv;
    115  	size_t id;
    116  	size_t i;
    117 +	const char *tip;
    118  
    119  	if (printed || show_tips == TIPS_NONE)
    120  		return;
    121 @@ -386,9 +387,10 @@ print_totd(void)
    122  	for (i = 0; (i < MAX_TIP_LINES) && (tips_tricks_tweaks[id][i] ||
    123  					    (i < (ARRAY_SIZE(tip_right) - 1)));
    124  	     i++) {
    125 +		tip = tips_tricks_tweaks[id][i];
    126  		fprintf(stderr, "%s%-*s%s%s\n",
    127  			tip_left[MIN(i + 1, ARRAY_SIZE(tip_left) - 1)],
    128 -			w, tips_tricks_tweaks[id][i] ?: "",
    129 +			w, tip ? tip : "",
    130  			tip_right[MIN(i + 1, ARRAY_SIZE(tip_right) - 1)],
    131  			strauss[MIN(3 + i, strauss_lines - 1)]);
    132  	}
    133 diff --git a/src/util.c b/src/util.c
    134 index efd390577..5e87559dc 100644
    135 --- a/src/util.c
    136 +++ b/src/util.c
    137 @@ -640,7 +640,7 @@ printsocket(struct tcb *tcp, int fd, const char *path)
    138  		return false;
    139  
    140  	const char *details = get_sockaddr_by_inode(tcp, fd, inode);
    141 -	print_string_in_angle_brackets(details ?: path);
    142 +	print_string_in_angle_brackets(details ? details : path);
    143  
    144  	return true;
    145  }
    146 -- 
    147 2.44.0
    148