libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / infoleak-pr112969.c
blobe78fe3659759f4cb0116e6ff1a51a3943fa27319
1 /* Reduced from -Wanalyzer-exposure-through-uninit-copy false positives
2 seen in Linux kernel in drivers/net/ethernet/intel/ice/ice_ptp.c */
4 /* { dg-do compile } */
5 /* { dg-options "-fanalyzer" } */
6 /* { dg-require-effective-target analyzer } */
8 extern unsigned long
9 copy_from_user(void* to, const void* from, unsigned long n);
11 extern unsigned long
12 copy_to_user(void* to, const void* from, unsigned long n);
14 struct ifreq
16 union
18 void* ifru_data;
19 } ifr_ifru;
22 struct hwtstamp_config
24 int flags;
25 int tx_type;
26 int rx_filter;
29 struct ice_ptp
31 long placeholder;
32 struct hwtstamp_config tstamp_config;
35 struct ice_pf
37 struct ice_ptp ptp;
39 int
40 ice_ptp_set_ts_config(struct ice_pf* pf, struct ifreq* ifr)
42 struct hwtstamp_config config;
43 int err;
44 if (copy_from_user(&config, ifr->ifr_ifru.ifru_data, sizeof(config)))
45 return -14;
46 pf->ptp.tstamp_config.tx_type = 0;
47 pf->ptp.tstamp_config.rx_filter = 0;
48 config = pf->ptp.tstamp_config;
49 if (copy_to_user(ifr->ifr_ifru.ifru_data, &config, sizeof(config))) /* { dg-bogus "-Wanalyzer-exposure-through-uninit-copy" "PR analyzer/112969" } */
50 return -14;
51 return 0;