problem
stringlengths
26
131k
labels
class label
2 classes
static uint64_t qemu_rdma_make_wrid(uint64_t wr_id, uint64_t index, uint64_t chunk) { uint64_t result = wr_id & RDMA_WRID_TYPE_MASK; result |= (index << RDMA_WRID_BLOCK_SHIFT); result |= (chunk << RDMA_WRID_CHUNK_SHIFT); return result; }
1threat
How to split the strings in angular js : <p>I wanted to split a string and get the string in two parts.</p> <p>for example:</p> <pre><code>www.medicoshere.com/register.html?23457cedlske234cd </code></pre> <p>i wish to split the string in the above url and store the string that is after the ? to a variable. How can i do that.</p>
0debug
static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, MachineState *machine) { const char *cpu_model = machine->cpu_model; unsigned int i; void *iommu, *espdma, *ledma, *nvram; qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS], espdma_irq, ledma_irq; qemu_irq esp_reset, dma_enable; qemu_irq fdc_tc; qemu_irq *cpu_halt; unsigned long kernel_size; DriveInfo *fd[MAX_FD]; FWCfgState *fw_cfg; unsigned int num_vsimms; if (!cpu_model) cpu_model = hwdef->default_cpu_model; for(i = 0; i < smp_cpus; i++) { cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]); } for (i = smp_cpus; i < MAX_CPUS; i++) cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS); ram_init(0, machine->ram_size, hwdef->max_mem); if (!hwdef->ecc_base) { empty_slot_init(machine->ram_size, hwdef->max_mem - machine->ram_size); } prom_init(hwdef->slavio_base, bios_name); slavio_intctl = slavio_intctl_init(hwdef->intctl_base, hwdef->intctl_base + 0x10000ULL, cpu_irqs); for (i = 0; i < 32; i++) { slavio_irq[i] = qdev_get_gpio_in(slavio_intctl, i); } for (i = 0; i < MAX_CPUS; i++) { slavio_cpu_irq[i] = qdev_get_gpio_in(slavio_intctl, 32 + i); } if (hwdef->idreg_base) { idreg_init(hwdef->idreg_base); } if (hwdef->afx_base) { afx_init(hwdef->afx_base); } iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version, slavio_irq[30]); if (hwdef->iommu_pad_base) { empty_slot_init(hwdef->iommu_pad_base,hwdef->iommu_pad_len); } espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[18], iommu, &espdma_irq, 0); ledma = sparc32_dma_init(hwdef->dma_base + 16ULL, slavio_irq[16], iommu, &ledma_irq, 1); if (graphic_depth != 8 && graphic_depth != 24) { error_report("Unsupported depth: %d", graphic_depth); exit (1); } num_vsimms = 0; if (num_vsimms == 0) { if (vga_interface_type == VGA_CG3) { if (graphic_depth != 8) { error_report("Unsupported depth: %d", graphic_depth); exit(1); } if (!(graphic_width == 1024 && graphic_height == 768) && !(graphic_width == 1152 && graphic_height == 900)) { error_report("Unsupported resolution: %d x %d", graphic_width, graphic_height); exit(1); } cg3_init(hwdef->tcx_base, slavio_irq[11], 0x00100000, graphic_width, graphic_height, graphic_depth); } else { if (graphic_depth != 8 && graphic_depth != 24) { error_report("Unsupported depth: %d", graphic_depth); exit(1); } if (!(graphic_width == 1024 && graphic_height == 768)) { error_report("Unsupported resolution: %d x %d", graphic_width, graphic_height); exit(1); } tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000, graphic_width, graphic_height, graphic_depth); } } for (i = num_vsimms; i < MAX_VSIMMS; i++) { if (hwdef->vsimm[i].reg_base) { empty_slot_init(hwdef->vsimm[i].reg_base, 0x2000); } } if (hwdef->sx_base) { empty_slot_init(hwdef->sx_base, 0x2000); } lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq); nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 1968, 8); slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus); slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14], display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1); escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15], serial_hds[0], serial_hds[1], ESCC_CLOCK, 1); cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1); if (hwdef->apc_base) { apc_init(hwdef->apc_base, cpu_halt[0]); } if (hwdef->fd_base) { memset(fd, 0, sizeof(fd)); fd[0] = drive_get(IF_FLOPPY, 0, 0); sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd, &fdc_tc); } else { fdc_tc = *qemu_allocate_irqs(dummy_fdc_tc, NULL, 1); } slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base, slavio_irq[30], fdc_tc); if (drive_get_max_bus(IF_SCSI) > 0) { fprintf(stderr, "qemu: too many SCSI bus\n"); exit(1); } esp_init(hwdef->esp_base, 2, espdma_memory_read, espdma_memory_write, espdma, espdma_irq, &esp_reset, &dma_enable); qdev_connect_gpio_out(espdma, 0, esp_reset); qdev_connect_gpio_out(espdma, 1, dma_enable); if (hwdef->cs_base) { sysbus_create_simple("SUNW,CS4231", hwdef->cs_base, slavio_irq[5]); } if (hwdef->dbri_base) { empty_slot_init(hwdef->dbri_base+0x1000, 0x30); empty_slot_init(hwdef->dbri_base+0x10000, 0x100); } if (hwdef->bpp_base) { empty_slot_init(hwdef->bpp_base, 0x20); } kernel_size = sun4m_load_kernel(machine->kernel_filename, machine->initrd_filename, machine->ram_size); nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, machine->kernel_cmdline, machine->boot_order, machine->ram_size, kernel_size, graphic_width, graphic_height, graphic_depth, hwdef->nvram_machine_id, "Sun4m"); if (hwdef->ecc_base) ecc_init(hwdef->ecc_base, slavio_irq[28], hwdef->ecc_version); fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (machine->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, machine->kernel_cmdline); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(machine->kernel_cmdline) + 1); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
1threat
static target_ulong h_read(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUPPCState *env = &cpu->env; target_ulong flags = args[0]; target_ulong ptex = args[1]; uint8_t *hpte; int i, ridx, n_entries = 1; if (!valid_ptex(cpu, ptex)) { return H_PARAMETER; } if (flags & H_READ_4) { ptex &= ~(3ULL); n_entries = 4; } hpte = env->external_htab + (ptex * HASH_PTE_SIZE_64); for (i = 0, ridx = 0; i < n_entries; i++) { args[ridx++] = ldq_p(hpte); args[ridx++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2)); hpte += HASH_PTE_SIZE_64; } return H_SUCCESS; }
1threat
Android stops finding BLE devices: onClientRegistered() - status=133 clientIf=0 : <p>I am developing an app in which I can both find and configure BLE devices. I am using standard Android BLE API, but recently I've encountered some strange problems. </p> <p>When I turn on my app the BLE scan works OK. I am scanning using:</p> <pre><code>mBluetoothAdapter.startLeScan(mLeScanCallback); // for Kitkat and below </code></pre> <p>and</p> <pre><code>mBluetoothAdapter.getBluetoothLeScanner().startScan(mScanCallback); // for Lollipop and above </code></pre> <p>In the Logcat I am getting following messages (I guess this is important for this issue):</p> <pre><code>D/BluetoothAdapter: onClientRegistered() - status=0 clientIf=5 </code></pre> <p>In my app I can also read certain characteristics from my BLE devices (eg. battery state). I connect to a device to read this characteristic in a separate fragment using:</p> <pre><code>mBluetoothManager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = mBluetoothManager.getAdapter(); mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(mMacAddress); mBluetoothGatt = mBluetoothDevice.connectGatt(mContext, false, mGattCallback); </code></pre> <p>The characteristics are read correctly. In the <code>onCharacteristicRead</code> callback I also disconnect and close Gatt:</p> <pre><code>mBluetoothGatt.disconnect(); mBluetoothGatt.close(); </code></pre> <p>Each time I open a fragment to read a characteristic (no matter whether it is the same device or not) <code>clientIf</code> value increases. I can see in the LogCat:</p> <pre><code>D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=7 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=9 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=10 </code></pre> <p>Everything works fine until the <code>clientIf</code> value equals 10. BLE scan stops finding any devices, I can't connect to any of my devices to read any characteristics etc. And the LogCat infinitely displays these messages:</p> <pre><code>D/BluetoothGatt: unregisterApp() - mClientIf=0 D/BluetoothGatt: onClientRegistered() - status=133 clientIf=0 </code></pre> <p>The only way to fix it is to kill the app and relaunch it or restart Bluetooth by turning it off and on manually. I've encountered this issue only on certain devices such as Xperia Z1 (Android KitKat) and Galaxy S4 (Android Lollipop). I couldn't reproduce this issue on Xperia Z3 Compact running Android Marshmallow...</p> <p>Is there anything I can do about it? I've already tried multiple "solutions" such as - calling all BLE methods from the UI thread and closing/disconnecting GATT, but nothing helps. How can I fix it?</p>
0debug
How to debug typescript code, which is bundled using webpack in vscode/vs2015 : <p>Here is my workflow.</p> <p>I have moduled typescript code. Imports like the following: <code>import { Logger } from './../data/logger';</code></p> <p>Then I bundle it using webpack (precisely - webpack-stream) with ts-loader. I run webpack using gulp.</p> <p>So I have the following workflow: gulp --> webpack (ts-loader) --> bundled *.js with source-maps. I also use the <a href="https://www.browsersync.io/">browsersync</a> to run simple server and auto update the page.</p> <p>I can debug this code from the browser, but I can't from vscode (using <a href="https://code.visualstudio.com/blogs/2016/02/23/introducing-chrome-debugger-for-vs-code">Chrome Debugging for VS Code</a>, or even from vs2015.</p> <p>What could cause the problem ?</p>
0debug
static int fdctrl_init_common(FDCtrl *fdctrl) { int i, j; static int command_tables_inited = 0; if (!command_tables_inited) { command_tables_inited = 1; for (i = ARRAY_SIZE(handlers) - 1; i >= 0; i--) { for (j = 0; j < sizeof(command_to_handler); j++) { if ((j & handlers[i].mask) == handlers[i].value) { command_to_handler[j] = i; } } } } FLOPPY_DPRINTF("init controller\n"); fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN); fdctrl->fifo_size = 512; fdctrl->result_timer = qemu_new_timer(vm_clock, fdctrl_result_timer, fdctrl); fdctrl->version = 0x90; fdctrl->config = FD_CONFIG_EIS | FD_CONFIG_EFIFO; fdctrl->num_floppies = MAX_FD; if (fdctrl->dma_chann != -1) DMA_register_channel(fdctrl->dma_chann, &fdctrl_transfer_handler, fdctrl); fdctrl_connect_drives(fdctrl); return 0; }
1threat
static int ppce500_load_device_tree(CPUPPCState *env, QEMUMachineInitArgs *args, PPCE500Params *params, hwaddr addr, hwaddr initrd_base, hwaddr initrd_size) { int ret = -1; uint64_t mem_reg_property[] = { 0, cpu_to_be64(args->ram_size) }; int fdt_size; void *fdt; uint8_t hypercall[16]; uint32_t clock_freq = 400000000; uint32_t tb_freq = 400000000; int i; char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus"; char soc[128]; char mpic[128]; uint32_t mpic_ph; uint32_t msi_ph; char gutil[128]; char pci[128]; char msi[128]; uint32_t *pci_map = NULL; int len; uint32_t pci_ranges[14] = { 0x2000000, 0x0, 0xc0000000, 0x0, 0xc0000000, 0x0, 0x20000000, 0x1000000, 0x0, 0x0, 0x0, 0xe1000000, 0x0, 0x10000, }; QemuOpts *machine_opts = qemu_get_machine_opts(); const char *dtb_file = qemu_opt_get(machine_opts, "dtb"); const char *toplevel_compat = qemu_opt_get(machine_opts, "dt_compatible"); if (dtb_file) { char *filename; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_file); if (!filename) { goto out; } fdt = load_device_tree(filename, &fdt_size); if (!fdt) { goto out; } goto done; } fdt = create_device_tree(&fdt_size); if (fdt == NULL) { goto out; } qemu_devtree_setprop_cell(fdt, "/", "#address-cells", 2); qemu_devtree_setprop_cell(fdt, "/", "#size-cells", 2); qemu_devtree_add_subnode(fdt, "/memory"); qemu_devtree_setprop_string(fdt, "/memory", "device_type", "memory"); qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, sizeof(mem_reg_property)); qemu_devtree_add_subnode(fdt, "/chosen"); if (initrd_size) { ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", initrd_base); if (ret < 0) { fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); } ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", (initrd_base + initrd_size)); if (ret < 0) { fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); } } ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", args->kernel_cmdline); if (ret < 0) fprintf(stderr, "couldn't set /chosen/bootargs\n"); if (kvm_enabled()) { clock_freq = kvmppc_get_clockfreq(); tb_freq = kvmppc_get_tbfreq(); qemu_devtree_add_subnode(fdt, "/hypervisor"); qemu_devtree_setprop_string(fdt, "/hypervisor", "compatible", "linux,kvm"); kvmppc_get_hypercall(env, hypercall, sizeof(hypercall)); qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions", hypercall, sizeof(hypercall)); if (kvmppc_get_hasidle(env)) { qemu_devtree_setprop(fdt, "/hypervisor", "has-idle", NULL, 0); } } qemu_devtree_add_subnode(fdt, "/cpus"); qemu_devtree_setprop_cell(fdt, "/cpus", "#address-cells", 1); qemu_devtree_setprop_cell(fdt, "/cpus", "#size-cells", 0); for (i = smp_cpus - 1; i >= 0; i--) { CPUState *cpu; char cpu_name[128]; uint64_t cpu_release_addr = MPC8544_SPIN_BASE + (i * 0x20); cpu = qemu_get_cpu(i); if (cpu == NULL) { continue; } env = cpu->env_ptr; snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", cpu->cpu_index); qemu_devtree_add_subnode(fdt, cpu_name); qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq); qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq); qemu_devtree_setprop_string(fdt, cpu_name, "device_type", "cpu"); qemu_devtree_setprop_cell(fdt, cpu_name, "reg", cpu->cpu_index); qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-line-size", env->dcache_line_size); qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-line-size", env->icache_line_size); qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-size", 0x8000); qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-size", 0x8000); qemu_devtree_setprop_cell(fdt, cpu_name, "bus-frequency", 0); if (cpu->cpu_index) { qemu_devtree_setprop_string(fdt, cpu_name, "status", "disabled"); qemu_devtree_setprop_string(fdt, cpu_name, "enable-method", "spin-table"); qemu_devtree_setprop_u64(fdt, cpu_name, "cpu-release-addr", cpu_release_addr); } else { qemu_devtree_setprop_string(fdt, cpu_name, "status", "okay"); } } qemu_devtree_add_subnode(fdt, "/aliases"); snprintf(soc, sizeof(soc), "/soc@%llx", MPC8544_CCSRBAR_BASE); qemu_devtree_add_subnode(fdt, soc); qemu_devtree_setprop_string(fdt, soc, "device_type", "soc"); qemu_devtree_setprop(fdt, soc, "compatible", compatible_sb, sizeof(compatible_sb)); qemu_devtree_setprop_cell(fdt, soc, "#address-cells", 1); qemu_devtree_setprop_cell(fdt, soc, "#size-cells", 1); qemu_devtree_setprop_cells(fdt, soc, "ranges", 0x0, MPC8544_CCSRBAR_BASE >> 32, MPC8544_CCSRBAR_BASE, MPC8544_CCSRBAR_SIZE); qemu_devtree_setprop_cell(fdt, soc, "bus-frequency", 0); snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET); qemu_devtree_add_subnode(fdt, mpic); qemu_devtree_setprop_string(fdt, mpic, "device_type", "open-pic"); qemu_devtree_setprop_string(fdt, mpic, "compatible", "fsl,mpic"); qemu_devtree_setprop_cells(fdt, mpic, "reg", MPC8544_MPIC_REGS_OFFSET, 0x40000); qemu_devtree_setprop_cell(fdt, mpic, "#address-cells", 0); qemu_devtree_setprop_cell(fdt, mpic, "#interrupt-cells", 2); mpic_ph = qemu_devtree_alloc_phandle(fdt); qemu_devtree_setprop_cell(fdt, mpic, "phandle", mpic_ph); qemu_devtree_setprop_cell(fdt, mpic, "linux,phandle", mpic_ph); qemu_devtree_setprop(fdt, mpic, "interrupt-controller", NULL, 0); dt_serial_create(fdt, MPC8544_SERIAL1_REGS_OFFSET, soc, mpic, "serial1", 1, false); dt_serial_create(fdt, MPC8544_SERIAL0_REGS_OFFSET, soc, mpic, "serial0", 0, true); snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc, MPC8544_UTIL_OFFSET); qemu_devtree_add_subnode(fdt, gutil); qemu_devtree_setprop_string(fdt, gutil, "compatible", "fsl,mpc8544-guts"); qemu_devtree_setprop_cells(fdt, gutil, "reg", MPC8544_UTIL_OFFSET, 0x1000); qemu_devtree_setprop(fdt, gutil, "fsl,has-rstcr", NULL, 0); snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET); qemu_devtree_add_subnode(fdt, msi); qemu_devtree_setprop_string(fdt, msi, "compatible", "fsl,mpic-msi"); qemu_devtree_setprop_cells(fdt, msi, "reg", MPC8544_MSI_REGS_OFFSET, 0x200); msi_ph = qemu_devtree_alloc_phandle(fdt); qemu_devtree_setprop_cells(fdt, msi, "msi-available-ranges", 0x0, 0x100); qemu_devtree_setprop_phandle(fdt, msi, "interrupt-parent", mpic); qemu_devtree_setprop_cells(fdt, msi, "interrupts", 0xe0, 0x0, 0xe1, 0x0, 0xe2, 0x0, 0xe3, 0x0, 0xe4, 0x0, 0xe5, 0x0, 0xe6, 0x0, 0xe7, 0x0); qemu_devtree_setprop_cell(fdt, msi, "phandle", msi_ph); qemu_devtree_setprop_cell(fdt, msi, "linux,phandle", msi_ph); snprintf(pci, sizeof(pci), "/pci@%llx", MPC8544_PCI_REGS_BASE); qemu_devtree_add_subnode(fdt, pci); qemu_devtree_setprop_cell(fdt, pci, "cell-index", 0); qemu_devtree_setprop_string(fdt, pci, "compatible", "fsl,mpc8540-pci"); qemu_devtree_setprop_string(fdt, pci, "device_type", "pci"); qemu_devtree_setprop_cells(fdt, pci, "interrupt-map-mask", 0xf800, 0x0, 0x0, 0x7); pci_map = pci_map_create(fdt, qemu_devtree_get_phandle(fdt, mpic), params->pci_first_slot, params->pci_nr_slots, &len); qemu_devtree_setprop(fdt, pci, "interrupt-map", pci_map, len); qemu_devtree_setprop_phandle(fdt, pci, "interrupt-parent", mpic); qemu_devtree_setprop_cells(fdt, pci, "interrupts", 24, 2); qemu_devtree_setprop_cells(fdt, pci, "bus-range", 0, 255); for (i = 0; i < 14; i++) { pci_ranges[i] = cpu_to_be32(pci_ranges[i]); } qemu_devtree_setprop_cell(fdt, pci, "fsl,msi", msi_ph); qemu_devtree_setprop(fdt, pci, "ranges", pci_ranges, sizeof(pci_ranges)); qemu_devtree_setprop_cells(fdt, pci, "reg", MPC8544_PCI_REGS_BASE >> 32, MPC8544_PCI_REGS_BASE, 0, 0x1000); qemu_devtree_setprop_cell(fdt, pci, "clock-frequency", 66666666); qemu_devtree_setprop_cell(fdt, pci, "#interrupt-cells", 1); qemu_devtree_setprop_cell(fdt, pci, "#size-cells", 2); qemu_devtree_setprop_cell(fdt, pci, "#address-cells", 3); qemu_devtree_setprop_string(fdt, "/aliases", "pci0", pci); params->fixup_devtree(params, fdt); if (toplevel_compat) { qemu_devtree_setprop(fdt, "/", "compatible", toplevel_compat, strlen(toplevel_compat) + 1); } done: qemu_devtree_dumpdtb(fdt, fdt_size); ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); if (ret < 0) { goto out; } g_free(fdt); ret = fdt_size; out: g_free(pci_map); return ret; }
1threat
ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, ram_addr_t size, void *host) { RAMBlock *new_block, *block; size = TARGET_PAGE_ALIGN(size); new_block = qemu_mallocz(sizeof(*new_block)); if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { char *id = dev->parent_bus->info->get_dev_path(dev); if (id) { snprintf(new_block->idstr, sizeof(new_block->idstr), "%s/", id); qemu_free(id); } } pstrcat(new_block->idstr, sizeof(new_block->idstr), name); QLIST_FOREACH(block, &ram_list.blocks, next) { if (!strcmp(block->idstr, new_block->idstr)) { fprintf(stderr, "RAMBlock \"%s\" already registered, abort!\n", new_block->idstr); abort(); } } new_block->offset = find_ram_offset(size); if (host) { new_block->host = host; new_block->flags |= RAM_PREALLOC_MASK; } else { if (mem_path) { #if defined (__linux__) && !defined(TARGET_S390X) new_block->host = file_ram_alloc(new_block, size, mem_path); if (!new_block->host) { new_block->host = qemu_vmalloc(size); qemu_madvise(new_block->host, size, QEMU_MADV_MERGEABLE); } #else fprintf(stderr, "-mem-path option unsupported\n"); exit(1); #endif } else { #if defined(TARGET_S390X) && defined(CONFIG_KVM) new_block->host = mmap((void*)0x1000000, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); #else if (xen_mapcache_enabled()) { xen_ram_alloc(new_block->offset, size); } else { new_block->host = qemu_vmalloc(size); } #endif qemu_madvise(new_block->host, size, QEMU_MADV_MERGEABLE); } } new_block->length = size; QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next); ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty, last_ram_offset() >> TARGET_PAGE_BITS); memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS), 0xff, size >> TARGET_PAGE_BITS); if (kvm_enabled()) kvm_setup_guest_memory(new_block->host, size); return new_block->offset; }
1threat
How can I use nested formulas in arrayfomula functions in google sheets? : I am new to posting in this community but have found solutions here many times. I need google sheets to compute sums for each row using the arrayformula() function. I know I can manualy enter somthing like; =ARRAYFORMULA(A:A + B:B + C:C) but I need the use of the functions to do it. I've tried many things including; =ARRAYFORMULA(sum(A:A,C:C)) Here is a sample file that I could use help with. https://docs.google.com/spreadsheets/d/15ehNnTjAbuIUo_KNz363zLXjqlk-0InIspZAQm9yhB8/edit#gid=0 Thank you.
0debug
static void pci_info_device(PCIBus *bus, PCIDevice *d) { Monitor *mon = cur_mon; int i, class; PCIIORegion *r; const pci_class_desc *desc; monitor_printf(mon, " Bus %2d, device %3d, function %d:\n", pci_bus_num(d->bus), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); class = pci_get_word(d->config + PCI_CLASS_DEVICE); monitor_printf(mon, " "); desc = pci_class_descriptions; while (desc->desc && class != desc->class) desc++; if (desc->desc) { monitor_printf(mon, "%s", desc->desc); } else { monitor_printf(mon, "Class %04x", class); } monitor_printf(mon, ": PCI device %04x:%04x\n", pci_get_word(d->config + PCI_VENDOR_ID), pci_get_word(d->config + PCI_DEVICE_ID)); if (d->config[PCI_INTERRUPT_PIN] != 0) { monitor_printf(mon, " IRQ %d.\n", d->config[PCI_INTERRUPT_LINE]); } if (class == 0x0604) { uint64_t base; uint64_t limit; monitor_printf(mon, " BUS %d.\n", d->config[0x19]); monitor_printf(mon, " secondary bus %d.\n", d->config[PCI_SECONDARY_BUS]); monitor_printf(mon, " subordinate bus %d.\n", d->config[PCI_SUBORDINATE_BUS]); base = pci_bridge_get_base(d, PCI_BASE_ADDRESS_SPACE_IO); limit = pci_bridge_get_limit(d, PCI_BASE_ADDRESS_SPACE_IO); monitor_printf(mon, " IO range [0x%04"PRIx64", 0x%04"PRIx64"]\n", base, limit); base = pci_bridge_get_base(d, PCI_BASE_ADDRESS_SPACE_MEMORY); limit= pci_config_get_memory_base(d, PCI_BASE_ADDRESS_SPACE_MEMORY); monitor_printf(mon, " memory range [0x%08"PRIx64", 0x%08"PRIx64"]\n", base, limit); base = pci_bridge_get_base(d, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_PREFETCH); limit = pci_bridge_get_limit(d, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_PREFETCH); monitor_printf(mon, " prefetchable memory range " "[0x%08"PRIx64", 0x%08"PRIx64"]\n", base, limit); } for(i = 0;i < PCI_NUM_REGIONS; i++) { r = &d->io_regions[i]; if (r->size != 0) { monitor_printf(mon, " BAR%d: ", i); if (r->type & PCI_BASE_ADDRESS_SPACE_IO) { monitor_printf(mon, "I/O at 0x%04"FMT_PCIBUS " [0x%04"FMT_PCIBUS"].\n", r->addr, r->addr + r->size - 1); } else { const char *type = r->type & PCI_BASE_ADDRESS_MEM_TYPE_64 ? "64 bit" : "32 bit"; const char *prefetch = r->type & PCI_BASE_ADDRESS_MEM_PREFETCH ? " prefetchable" : ""; monitor_printf(mon, "%s%s memory at 0x%08"FMT_PCIBUS " [0x%08"FMT_PCIBUS"].\n", type, prefetch, r->addr, r->addr + r->size - 1); } } } monitor_printf(mon, " id \"%s\"\n", d->qdev.id ? d->qdev.id : ""); if (class == 0x0604 && d->config[0x19] != 0) { pci_for_each_device(bus, d->config[0x19], pci_info_device); } }
1threat
int main(int argc, char **argv, char **envp) int i; int snapshot, linux_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; const char *boot_order = NULL; const char *boot_once = NULL; DisplayState *ds; int cyls, heads, secs, translation; QemuOpts *opts, *machine_opts; QemuOpts *hda_opts = NULL, *icount_opts = NULL, *accel_opts = NULL; QemuOptsList *olist; int optind; const char *optarg; const char *loadvm = NULL; MachineClass *machine_class; const char *cpu_model; const char *vga_model = NULL; const char *qtest_chrdev = NULL; const char *qtest_log = NULL; const char *pid_file = NULL; const char *incoming = NULL; bool defconfig = true; bool userconfig = true; bool nographic = false; DisplayType display_type = DT_DEFAULT; int display_remote = 0; const char *log_mask = NULL; const char *log_file = NULL; char *trace_file = NULL; ram_addr_t maxram_size; uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; Error *main_loop_err = NULL; Error *err = NULL; bool list_data_dirs = false; typedef struct BlockdevOptions_queue { BlockdevOptions *bdo; Location loc; QSIMPLEQ_ENTRY(BlockdevOptions_queue) entry; } BlockdevOptions_queue; QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); qemu_init_cpu_loop(); qemu_mutex_lock_iothread(); atexit(qemu_run_exit_notifiers); error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); module_call_init(MODULE_INIT_QOM); monitor_init_qmp_commands(); qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); qemu_add_drive_opts(&qemu_common_drive_opts); qemu_add_drive_opts(&qemu_drive_opts); qemu_add_drive_opts(&bdrv_runtime_opts); qemu_add_opts(&qemu_chardev_opts); qemu_add_opts(&qemu_device_opts); qemu_add_opts(&qemu_netdev_opts); qemu_add_opts(&qemu_net_opts); qemu_add_opts(&qemu_rtc_opts); qemu_add_opts(&qemu_global_opts); qemu_add_opts(&qemu_mon_opts); qemu_add_opts(&qemu_trace_opts); qemu_add_opts(&qemu_option_rom_opts); qemu_add_opts(&qemu_machine_opts); qemu_add_opts(&qemu_accel_opts); qemu_add_opts(&qemu_mem_opts); qemu_add_opts(&qemu_smp_opts); qemu_add_opts(&qemu_boot_opts); qemu_add_opts(&qemu_sandbox_opts); qemu_add_opts(&qemu_add_fd_opts); qemu_add_opts(&qemu_object_opts); qemu_add_opts(&qemu_tpmdev_opts); qemu_add_opts(&qemu_realtime_opts); qemu_add_opts(&qemu_msg_opts); qemu_add_opts(&qemu_name_opts); qemu_add_opts(&qemu_numa_opts); qemu_add_opts(&qemu_icount_opts); qemu_add_opts(&qemu_semihosting_config_opts); qemu_add_opts(&qemu_fw_cfg_opts); module_call_init(MODULE_INIT_OPTS); runstate_init(); if (qcrypto_init(&err) < 0) { error_reportf_err(err, "cannot initialize crypto: "); rtc_clock = QEMU_CLOCK_HOST; QLIST_INIT (&vm_change_state_head); os_setup_early_signal_handling(); cpu_model = NULL; snapshot = 0; cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; nb_nics = 0; bdrv_init_with_whitelist(); autostart = 1; optind = 1; while (optind < argc) { if (argv[optind][0] != '-') { optind++; } else { const QEMUOption *popt; popt = lookup_opt(argc, argv, &optarg, &optind); switch (popt->index) { case QEMU_OPTION_nodefconfig: defconfig = false; case QEMU_OPTION_nouserconfig: userconfig = false; if (defconfig && userconfig) { if (qemu_read_default_config_file() < 0) { optind = 1; for(;;) { if (optind >= argc) if (argv[optind][0] != '-') { hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS); } else { const QEMUOption *popt; popt = lookup_opt(argc, argv, &optarg, &optind); if (!(popt->arch_mask & arch_type)) { error_report("Option not supported for this target"); switch(popt->index) { case QEMU_OPTION_no_kvm_irqchip: { olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "kernel_irqchip=off", false); case QEMU_OPTION_cpu: cpu_model = optarg; case QEMU_OPTION_hda: char buf[256]; if (cyls == 0) snprintf(buf, sizeof(buf), "%s", HD_OPTS); else snprintf(buf, sizeof(buf), "%s,cyls=%d,heads=%d,secs=%d%s", HD_OPTS , cyls, heads, secs, translation == BIOS_ATA_TRANSLATION_LBA ? ",trans=lba" : translation == BIOS_ATA_TRANSLATION_NONE ? ",trans=none" : ""); drive_add(IF_DEFAULT, 0, optarg, buf); case QEMU_OPTION_hdb: case QEMU_OPTION_hdc: case QEMU_OPTION_hdd: drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg, HD_OPTS); case QEMU_OPTION_drive: if (drive_def(optarg) == NULL) { case QEMU_OPTION_set: if (qemu_set_option(optarg) != 0) case QEMU_OPTION_global: if (qemu_global_option(optarg) != 0) case QEMU_OPTION_mtdblock: drive_add(IF_MTD, -1, optarg, MTD_OPTS); case QEMU_OPTION_sd: drive_add(IF_SD, -1, optarg, SD_OPTS); case QEMU_OPTION_pflash: drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS); case QEMU_OPTION_snapshot: snapshot = 1; case QEMU_OPTION_hdachs: const char *p; p = optarg; cyls = strtol(p, (char **)&p, 0); if (cyls < 1 || cyls > 16383) goto chs_fail; if (*p != ',') goto chs_fail; p++; heads = strtol(p, (char **)&p, 0); if (heads < 1 || heads > 16) goto chs_fail; if (*p != ',') goto chs_fail; p++; secs = strtol(p, (char **)&p, 0); if (secs < 1 || secs > 63) goto chs_fail; if (*p == ',') { p++; if (!strcmp(p, "large")) { translation = BIOS_ATA_TRANSLATION_LARGE; } else if (!strcmp(p, "rechs")) { translation = BIOS_ATA_TRANSLATION_RECHS; } else if (!strcmp(p, "none")) { translation = BIOS_ATA_TRANSLATION_NONE; } else if (!strcmp(p, "lba")) { translation = BIOS_ATA_TRANSLATION_LBA; } else if (!strcmp(p, "auto")) { translation = BIOS_ATA_TRANSLATION_AUTO; } else { goto chs_fail; } else if (*p != '\0') { chs_fail: error_report("invalid physical CHS format"); if (hda_opts != NULL) { qemu_opt_set_number(hda_opts, "cyls", cyls, &error_abort); qemu_opt_set_number(hda_opts, "heads", heads, &error_abort); qemu_opt_set_number(hda_opts, "secs", secs, &error_abort); if (translation == BIOS_ATA_TRANSLATION_LARGE) { qemu_opt_set(hda_opts, "trans", "large", &error_abort); } else if (translation == BIOS_ATA_TRANSLATION_RECHS) { qemu_opt_set(hda_opts, "trans", "rechs", &error_abort); } else if (translation == BIOS_ATA_TRANSLATION_LBA) { qemu_opt_set(hda_opts, "trans", "lba", &error_abort); } else if (translation == BIOS_ATA_TRANSLATION_NONE) { qemu_opt_set(hda_opts, "trans", "none", &error_abort); case QEMU_OPTION_numa: opts = qemu_opts_parse_noisily(qemu_find_opts("numa"), optarg, true); if (!opts) { case QEMU_OPTION_display: display_type = select_display(optarg); case QEMU_OPTION_nographic: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "graphics=off", false); nographic = true; display_type = DT_NONE; case QEMU_OPTION_curses: #ifdef CONFIG_CURSES display_type = DT_CURSES; #else error_report("curses support is disabled"); #endif case QEMU_OPTION_portrait: graphic_rotate = 90; case QEMU_OPTION_rotate: graphic_rotate = strtol(optarg, (char **) &optarg, 10); if (graphic_rotate != 0 && graphic_rotate != 90 && graphic_rotate != 180 && graphic_rotate != 270) { error_report("only 90, 180, 270 deg rotation is available"); case QEMU_OPTION_kernel: qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg, &error_abort); case QEMU_OPTION_initrd: qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg, &error_abort); case QEMU_OPTION_append: qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg, &error_abort); case QEMU_OPTION_dtb: qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg, &error_abort); case QEMU_OPTION_cdrom: drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS); case QEMU_OPTION_boot: opts = qemu_opts_parse_noisily(qemu_find_opts("boot-opts"), optarg, true); if (!opts) { case QEMU_OPTION_fda: case QEMU_OPTION_fdb: drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda, optarg, FD_OPTS); case QEMU_OPTION_no_fd_bootchk: fd_bootchk = 0; case QEMU_OPTION_netdev: default_net = 0; if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) { case QEMU_OPTION_net: default_net = 0; if (net_client_parse(qemu_find_opts("net"), optarg) == -1) { #ifdef CONFIG_LIBISCSI case QEMU_OPTION_iscsi: opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"), optarg, false); if (!opts) { #endif #ifdef CONFIG_SLIRP case QEMU_OPTION_tftp: error_report("The -tftp option is deprecated. " "Please use '-netdev user,tftp=...' instead."); legacy_tftp_prefix = optarg; case QEMU_OPTION_bootp: error_report("The -bootp option is deprecated. " "Please use '-netdev user,bootfile=...' instead."); legacy_bootp_filename = optarg; case QEMU_OPTION_redir: error_report("The -redir option is deprecated. " "Please use '-netdev user,hostfwd=...' instead."); if (net_slirp_redir(optarg) < 0) #endif case QEMU_OPTION_bt: add_device_config(DEV_BT, optarg); case QEMU_OPTION_audio_help: AUD_help (); exit (0); case QEMU_OPTION_soundhw: select_soundhw (optarg); case QEMU_OPTION_h: help(0); case QEMU_OPTION_version: version(); exit(0); case QEMU_OPTION_m: opts = qemu_opts_parse_noisily(qemu_find_opts("memory"), optarg, true); if (!opts) { exit(EXIT_FAILURE); #ifdef CONFIG_TPM case QEMU_OPTION_tpmdev: if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) { #endif case QEMU_OPTION_mempath: mem_path = optarg; case QEMU_OPTION_mem_prealloc: mem_prealloc = 1; case QEMU_OPTION_d: log_mask = optarg; case QEMU_OPTION_D: log_file = optarg; case QEMU_OPTION_DFILTER: qemu_set_dfilter_ranges(optarg, &error_fatal); case QEMU_OPTION_s: add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT); case QEMU_OPTION_gdb: add_device_config(DEV_GDB, optarg); case QEMU_OPTION_L: if (is_help_option(optarg)) { list_data_dirs = true; } else if (data_dir_idx < ARRAY_SIZE(data_dir)) { data_dir[data_dir_idx++] = optarg; case QEMU_OPTION_bios: qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", optarg, &error_abort); case QEMU_OPTION_singlestep: singlestep = 1; case QEMU_OPTION_S: autostart = 0; case QEMU_OPTION_k: keyboard_layout = optarg; case QEMU_OPTION_localtime: rtc_utc = 0; case QEMU_OPTION_vga: vga_model = optarg; default_vga = 0; case QEMU_OPTION_g: const char *p; int w, h, depth; p = optarg; w = strtol(p, (char **)&p, 10); if (w <= 0) { graphic_error: error_report("invalid resolution or depth"); if (*p != 'x') goto graphic_error; p++; h = strtol(p, (char **)&p, 10); if (h <= 0) goto graphic_error; if (*p == 'x') { p++; depth = strtol(p, (char **)&p, 10); if (depth != 8 && depth != 15 && depth != 16 && depth != 24 && depth != 32) goto graphic_error; } else if (*p == '\0') { depth = graphic_depth; } else { goto graphic_error; graphic_width = w; graphic_height = h; graphic_depth = depth; case QEMU_OPTION_echr: char *r; term_escape_char = strtol(optarg, &r, 0); if (r == optarg) printf("Bad argument to echr\n"); case QEMU_OPTION_monitor: default_monitor = 0; if (strncmp(optarg, "none", 4)) { monitor_parse(optarg, "readline", false); case QEMU_OPTION_qmp: monitor_parse(optarg, "control", false); default_monitor = 0; case QEMU_OPTION_qmp_pretty: monitor_parse(optarg, "control", true); default_monitor = 0; case QEMU_OPTION_mon: opts = qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg, true); if (!opts) { default_monitor = 0; case QEMU_OPTION_chardev: opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), optarg, true); if (!opts) { case QEMU_OPTION_fsdev: olist = qemu_find_opts("fsdev"); if (!olist) { error_report("fsdev support is disabled"); opts = qemu_opts_parse_noisily(olist, optarg, true); if (!opts) { case QEMU_OPTION_virtfs: { QemuOpts *fsdev; QemuOpts *device; const char *writeout, *sock_fd, *socket; olist = qemu_find_opts("virtfs"); if (!olist) { error_report("virtfs support is disabled"); opts = qemu_opts_parse_noisily(olist, optarg, true); if (!opts) { if (qemu_opt_get(opts, "fsdriver") == NULL || qemu_opt_get(opts, "mount_tag") == NULL) { error_report("Usage: -virtfs fsdriver,mount_tag=tag"); fsdev = qemu_opts_create(qemu_find_opts("fsdev"), qemu_opt_get(opts, "mount_tag"), 1, NULL); if (!fsdev) { error_report("duplicate fsdev id: %s", qemu_opt_get(opts, "mount_tag")); writeout = qemu_opt_get(opts, "writeout"); if (writeout) { #ifdef CONFIG_SYNC_FILE_RANGE qemu_opt_set(fsdev, "writeout", writeout, &error_abort); #else error_report("writeout=immediate not supported " "on this platform"); #endif qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"), &error_abort); qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"), &error_abort); qemu_opt_set(fsdev, "security_model", qemu_opt_get(opts, "security_model"), &error_abort); socket = qemu_opt_get(opts, "socket"); if (socket) { qemu_opt_set(fsdev, "socket", socket, &error_abort); sock_fd = qemu_opt_get(opts, "sock_fd"); if (sock_fd) { qemu_opt_set(fsdev, "sock_fd", sock_fd, &error_abort); qemu_opt_set_bool(fsdev, "readonly", qemu_opt_get_bool(opts, "readonly", 0), &error_abort); device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort); qemu_opt_set(device, "fsdev", qemu_opt_get(opts, "mount_tag"), &error_abort); qemu_opt_set(device, "mount_tag", qemu_opt_get(opts, "mount_tag"), &error_abort); case QEMU_OPTION_virtfs_synth: { QemuOpts *fsdev; QemuOpts *device; fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", 1, NULL); if (!fsdev) { error_report("duplicate option: %s", "virtfs_synth"); qemu_opt_set(fsdev, "fsdriver", "synth", &error_abort); device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort); qemu_opt_set(device, "fsdev", "v_synth", &error_abort); qemu_opt_set(device, "mount_tag", "v_synth", &error_abort); case QEMU_OPTION_serial: add_device_config(DEV_SERIAL, optarg); default_serial = 0; if (strncmp(optarg, "mon:", 4) == 0) { default_monitor = 0; case QEMU_OPTION_watchdog: if (watchdog) { error_report("only one watchdog option may be given"); return 1; watchdog = optarg; case QEMU_OPTION_watchdog_action: if (select_watchdog_action(optarg) == -1) { error_report("unknown -watchdog-action parameter"); case QEMU_OPTION_virtiocon: add_device_config(DEV_VIRTCON, optarg); default_virtcon = 0; if (strncmp(optarg, "mon:", 4) == 0) { default_monitor = 0; case QEMU_OPTION_parallel: add_device_config(DEV_PARALLEL, optarg); default_parallel = 0; if (strncmp(optarg, "mon:", 4) == 0) { default_monitor = 0; case QEMU_OPTION_debugcon: add_device_config(DEV_DEBUGCON, optarg); case QEMU_OPTION_loadvm: loadvm = optarg; case QEMU_OPTION_full_screen: full_screen = 1; case QEMU_OPTION_no_frame: no_frame = 1; case QEMU_OPTION_alt_grab: alt_grab = 1; case QEMU_OPTION_ctrl_grab: ctrl_grab = 1; case QEMU_OPTION_no_quit: no_quit = 1; case QEMU_OPTION_sdl: #ifdef CONFIG_SDL display_type = DT_SDL; #else error_report("SDL support is disabled"); #endif case QEMU_OPTION_pidfile: pid_file = optarg; case QEMU_OPTION_win2k_hack: win2k_install_hack = 1; case QEMU_OPTION_rtc_td_hack: { static GlobalProperty slew_lost_ticks = { .driver = "mc146818rtc", .property = "lost_tick_policy", .value = "slew", }; qdev_prop_register_global(&slew_lost_ticks); case QEMU_OPTION_acpitable: opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"), optarg, true); if (!opts) { acpi_table_add(opts, &error_fatal); case QEMU_OPTION_smbios: opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"), optarg, false); if (!opts) { smbios_entry_add(opts, &error_fatal); case QEMU_OPTION_fwcfg: opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"), optarg, true); if (opts == NULL) { case QEMU_OPTION_enable_kvm: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=kvm", false); case QEMU_OPTION_enable_hax: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=hax", false); case QEMU_OPTION_M: case QEMU_OPTION_machine: olist = qemu_find_opts("machine"); opts = qemu_opts_parse_noisily(olist, optarg, true); if (!opts) { case QEMU_OPTION_no_kvm: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=tcg", false); case QEMU_OPTION_no_kvm_pit: { error_report("warning: ignoring deprecated option"); case QEMU_OPTION_no_kvm_pit_reinjection: { static GlobalProperty kvm_pit_lost_tick_policy = { .driver = "kvm-pit", .property = "lost_tick_policy", .value = "discard", }; error_report("warning: deprecated, replaced by " "-global kvm-pit.lost_tick_policy=discard"); qdev_prop_register_global(&kvm_pit_lost_tick_policy); case QEMU_OPTION_accel: accel_opts = qemu_opts_parse_noisily(qemu_find_opts("accel"), optarg, true); optarg = qemu_opt_get(accel_opts, "accel"); olist = qemu_find_opts("machine"); if (strcmp("kvm", optarg) == 0) { qemu_opts_parse_noisily(olist, "accel=kvm", false); } else if (strcmp("xen", optarg) == 0) { qemu_opts_parse_noisily(olist, "accel=xen", false); } else if (strcmp("tcg", optarg) == 0) { qemu_opts_parse_noisily(olist, "accel=tcg", false); } else { if (!is_help_option(optarg)) { error_printf("Unknown accelerator: %s", optarg); error_printf("Supported accelerators: kvm, xen, tcg\n"); case QEMU_OPTION_usb: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "usb=on", false); case QEMU_OPTION_usbdevice: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "usb=on", false); add_device_config(DEV_USB, optarg); case QEMU_OPTION_device: if (!qemu_opts_parse_noisily(qemu_find_opts("device"), optarg, true)) { case QEMU_OPTION_smp: if (!qemu_opts_parse_noisily(qemu_find_opts("smp-opts"), optarg, true)) { case QEMU_OPTION_vnc: vnc_parse(optarg, &error_fatal); case QEMU_OPTION_no_acpi: acpi_enabled = 0; case QEMU_OPTION_no_hpet: no_hpet = 1; case QEMU_OPTION_balloon: if (balloon_parse(optarg) < 0) { error_report("unknown -balloon argument %s", optarg); case QEMU_OPTION_no_reboot: no_reboot = 1; case QEMU_OPTION_no_shutdown: no_shutdown = 1; case QEMU_OPTION_show_cursor: cursor_hide = 0; case QEMU_OPTION_uuid: if (qemu_uuid_parse(optarg, &qemu_uuid) < 0) { error_report("failed to parse UUID string: wrong format"); qemu_uuid_set = true; case QEMU_OPTION_option_rom: if (nb_option_roms >= MAX_OPTION_ROMS) { error_report("too many option ROMs"); opts = qemu_opts_parse_noisily(qemu_find_opts("option-rom"), optarg, true); if (!opts) { option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile"); option_rom[nb_option_roms].bootindex = qemu_opt_get_number(opts, "bootindex", -1); if (!option_rom[nb_option_roms].name) { error_report("Option ROM file is not specified"); nb_option_roms++; case QEMU_OPTION_semihosting: semihosting.enabled = true; semihosting.target = SEMIHOSTING_TARGET_AUTO; case QEMU_OPTION_semihosting_config: semihosting.enabled = true; opts = qemu_opts_parse_noisily(qemu_find_opts("semihosting-config"), optarg, false); if (opts != NULL) { semihosting.enabled = qemu_opt_get_bool(opts, "enable", true); const char *target = qemu_opt_get(opts, "target"); if (target != NULL) { if (strcmp("native", target) == 0) { semihosting.target = SEMIHOSTING_TARGET_NATIVE; } else if (strcmp("gdb", target) == 0) { semihosting.target = SEMIHOSTING_TARGET_GDB; } else if (strcmp("auto", target) == 0) { semihosting.target = SEMIHOSTING_TARGET_AUTO; } else { error_report("unsupported semihosting-config %s", optarg); } else { semihosting.target = SEMIHOSTING_TARGET_AUTO; qemu_opt_foreach(opts, add_semihosting_arg, &semihosting, NULL); } else { error_report("unsupported semihosting-config %s", optarg); case QEMU_OPTION_tdf: error_report("warning: ignoring deprecated option"); case QEMU_OPTION_name: opts = qemu_opts_parse_noisily(qemu_find_opts("name"), optarg, true); if (!opts) { case QEMU_OPTION_prom_env: if (nb_prom_envs >= MAX_PROM_ENVS) { error_report("too many prom variables"); prom_envs[nb_prom_envs] = optarg; nb_prom_envs++; case QEMU_OPTION_old_param: old_param = 1; case QEMU_OPTION_clock: case QEMU_OPTION_startdate: configure_rtc_date_offset(optarg, 1); case QEMU_OPTION_rtc: opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg, false); if (!opts) { configure_rtc(opts); case QEMU_OPTION_tb_size: tcg_tb_size = strtol(optarg, NULL, 0); if (tcg_tb_size < 0) { tcg_tb_size = 0; case QEMU_OPTION_icount: icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"), optarg, true); if (!icount_opts) { case QEMU_OPTION_incoming: if (!incoming) { runstate_set(RUN_STATE_INMIGRATE); incoming = optarg; case QEMU_OPTION_only_migratable: only_migratable = 1; case QEMU_OPTION_nodefaults: has_defaults = 0; case QEMU_OPTION_xen_domid: if (!(xen_available())) { error_report("Option not supported for this target"); xen_domid = atoi(optarg); case QEMU_OPTION_xen_create: if (!(xen_available())) { error_report("Option not supported for this target"); xen_mode = XEN_CREATE; case QEMU_OPTION_xen_attach: if (!(xen_available())) { error_report("Option not supported for this target"); xen_mode = XEN_ATTACH; case QEMU_OPTION_trace: g_free(trace_file); trace_file = trace_opt_parse(optarg); case QEMU_OPTION_readconfig: int ret = qemu_read_config_file(optarg); if (ret < 0) { error_report("read config %s: %s", optarg, strerror(-ret)); case QEMU_OPTION_spice: olist = qemu_find_opts("spice"); if (!olist) { error_report("spice support is disabled"); opts = qemu_opts_parse_noisily(olist, optarg, false); if (!opts) { display_remote++; case QEMU_OPTION_writeconfig: FILE *fp; if (strcmp(optarg, "-") == 0) { fp = stdout; } else { fp = fopen(optarg, "w"); if (fp == NULL) { error_report("open %s: %s", optarg, strerror(errno)); qemu_config_write(fp); if (fp != stdout) { fclose(fp); case QEMU_OPTION_qtest: qtest_chrdev = optarg; case QEMU_OPTION_qtest_log: qtest_log = optarg; case QEMU_OPTION_sandbox: opts = qemu_opts_parse_noisily(qemu_find_opts("sandbox"), optarg, true); if (!opts) { case QEMU_OPTION_add_fd: #ifndef _WIN32 opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"), optarg, false); if (!opts) { #else error_report("File descriptor passing is disabled on this " "platform"); #endif case QEMU_OPTION_object: opts = qemu_opts_parse_noisily(qemu_find_opts("object"), optarg, true); if (!opts) { case QEMU_OPTION_realtime: opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"), optarg, false); if (!opts) { enable_mlock = qemu_opt_get_bool(opts, "mlock", true); case QEMU_OPTION_msg: opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg, false); if (!opts) { configure_msg(opts); case QEMU_OPTION_dump_vmstate: if (vmstate_dump_file) { error_report("only one '-dump-vmstate' " "option may be given"); vmstate_dump_file = fopen(optarg, "w"); if (vmstate_dump_file == NULL) { error_report("open %s: %s", optarg, strerror(errno)); default: os_parse_cmd_args(popt->index, optarg); loc_set_none(); replay_configure(icount_opts); qemu_tcg_configure(accel_opts, &error_fatal); machine_class = select_machine(); set_memory_options(&ram_slots, &maxram_size, machine_class); os_daemonize(); if (pid_file && qemu_create_pidfile(pid_file) != 0) { error_report("could not acquire pid file: %s", strerror(errno)); if (qemu_init_main_loop(&main_loop_err)) { error_report_err(main_loop_err); if (qemu_opts_foreach(qemu_find_opts("sandbox"), parse_sandbox, NULL, NULL)) { if (qemu_opts_foreach(qemu_find_opts("name"), parse_name, NULL, NULL)) { #ifndef _WIN32 if (qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, NULL)) { if (qemu_opts_foreach(qemu_find_opts("add-fd"), cleanup_add_fd, NULL, NULL)) { #endif current_machine = MACHINE(object_new(object_class_get_name( OBJECT_CLASS(machine_class)))); if (machine_help_func(qemu_get_machine_opts(), current_machine)) { exit(0); object_property_add_child(object_get_root(), "machine", OBJECT(current_machine), &error_abort); if (machine_class->minimum_page_bits) { if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) { g_assert_not_reached(); cpu_exec_init_all(); if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); if (cpu_model && is_help_option(cpu_model)) { list_cpus(stdout, &fprintf, cpu_model); exit(0); if (!trace_init_backends()) { trace_init_file(trace_file); if (log_file) { qemu_set_log_filename(log_file, &error_fatal); if (log_mask) { int mask; mask = qemu_str_to_log_mask(log_mask); if (!mask) { qemu_print_log_usage(stdout); qemu_set_log(mask); } else { qemu_set_log(0); if (data_dir_idx < ARRAY_SIZE(data_dir)) { data_dir[data_dir_idx] = os_find_datadir(); if (data_dir[data_dir_idx] != NULL) { data_dir_idx++; if (data_dir_idx < ARRAY_SIZE(data_dir)) { data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR; if (list_data_dirs) { for (i = 0; i < data_dir_idx; i++) { printf("%s\n", data_dir[i]); exit(0); smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); machine_class->max_cpus = machine_class->max_cpus ?: 1; if (max_cpus > machine_class->max_cpus) { error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " "supported by machine '%s' (%d)", max_cpus, machine_class->name, machine_class->max_cpus); if (machine_class->default_machine_opts) { qemu_opts_set_defaults(qemu_find_opts("machine"), machine_class->default_machine_opts, 0); qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, NULL); qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, NULL); if (!vga_model && !default_vga) { vga_interface_type = VGA_DEVICE; if (!has_defaults || machine_class->no_serial) { default_serial = 0; if (!has_defaults || machine_class->no_parallel) { default_parallel = 0; if (!has_defaults || !machine_class->use_virtcon) { default_virtcon = 0; if (!has_defaults || !machine_class->use_sclp) { default_sclp = 0; if (!has_defaults || machine_class->no_floppy) { default_floppy = 0; if (!has_defaults || machine_class->no_cdrom) { default_cdrom = 0; if (!has_defaults || machine_class->no_sdcard) { default_sdcard = 0; if (!has_defaults) { default_monitor = 0; default_net = 0; default_vga = 0; if (is_daemonized()) { if (nographic && (default_parallel || default_serial || default_monitor || default_virtcon)) { error_report("-nographic cannot be used with -daemonize"); #ifdef CONFIG_CURSES if (display_type == DT_CURSES) { error_report("curses display cannot be used with -daemonize"); #endif if (nographic) { if (default_parallel) add_device_config(DEV_PARALLEL, "null"); if (default_serial && default_monitor) { add_device_config(DEV_SERIAL, "mon:stdio"); } else if (default_virtcon && default_monitor) { add_device_config(DEV_VIRTCON, "mon:stdio"); } else if (default_sclp && default_monitor) { add_device_config(DEV_SCLP, "mon:stdio"); } else { if (default_serial) add_device_config(DEV_SERIAL, "stdio"); if (default_virtcon) add_device_config(DEV_VIRTCON, "stdio"); if (default_sclp) { add_device_config(DEV_SCLP, "stdio"); if (default_monitor) monitor_parse("stdio", "readline", false); } else { if (default_serial) add_device_config(DEV_SERIAL, "vc:80Cx24C"); if (default_parallel) add_device_config(DEV_PARALLEL, "vc:80Cx24C"); if (default_monitor) monitor_parse("vc:80Cx24C", "readline", false); if (default_virtcon) add_device_config(DEV_VIRTCON, "vc:80Cx24C"); if (default_sclp) { add_device_config(DEV_SCLP, "vc:80Cx24C"); #if defined(CONFIG_VNC) if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { display_remote++; #endif if (display_type == DT_DEFAULT && !display_remote) { #if defined(CONFIG_GTK) display_type = DT_GTK; #elif defined(CONFIG_SDL) display_type = DT_SDL; #elif defined(CONFIG_COCOA) display_type = DT_COCOA; #elif defined(CONFIG_VNC) vnc_parse("localhost:0,to=99,id=default", &error_abort); #else display_type = DT_NONE; #endif if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) { error_report("-no-frame, -alt-grab and -ctrl-grab are only valid " "for SDL, ignoring option"); if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) { error_report("-no-quit is only valid for GTK and SDL, " "ignoring option"); if (display_type == DT_GTK) { early_gtk_display_init(request_opengl); if (display_type == DT_SDL) { sdl_display_early_init(request_opengl); qemu_console_early_init(); if (request_opengl == 1 && display_opengl == 0) { #if defined(CONFIG_OPENGL) error_report("OpenGL is not supported by the display"); #else error_report("OpenGL support is disabled"); #endif page_size_init(); socket_init(); if (qemu_opts_foreach(qemu_find_opts("object"), user_creatable_add_opts_foreach, object_create_initial, NULL)) { if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, NULL)) { #ifdef CONFIG_VIRTFS if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, NULL)) { #endif if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, NULL)) { exit(0); machine_opts = qemu_get_machine_opts(); if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine, NULL)) { object_unref(OBJECT(current_machine)); configure_accelerator(current_machine); if (qtest_chrdev) { qtest_init(qtest_chrdev, qtest_log, &error_fatal); machine_opts = qemu_get_machine_opts(); kernel_filename = qemu_opt_get(machine_opts, "kernel"); initrd_filename = qemu_opt_get(machine_opts, "initrd"); kernel_cmdline = qemu_opt_get(machine_opts, "append"); bios_name = qemu_opt_get(machine_opts, "firmware"); opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { boot_order = qemu_opt_get(opts, "order"); if (boot_order) { validate_bootdevices(boot_order, &error_fatal); boot_once = qemu_opt_get(opts, "once"); if (boot_once) { validate_bootdevices(boot_once, &error_fatal); boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu); boot_strict = qemu_opt_get_bool(opts, "strict", false); if (!boot_order) { boot_order = machine_class->default_boot_order; if (!kernel_cmdline) { kernel_cmdline = ""; current_machine->kernel_cmdline = (char *)kernel_cmdline; linux_boot = (kernel_filename != NULL); if (!linux_boot && *kernel_cmdline != '\0') { error_report("-append only allowed with -kernel option"); if (!linux_boot && initrd_filename != NULL) { error_report("-initrd only allowed with -kernel option"); if (semihosting_enabled() && !semihosting_get_argc() && kernel_filename) { semihosting_arg_fallback(kernel_filename, kernel_cmdline); os_set_line_buffering(); qemu_spice_init(); cpu_ticks_init(); if (icount_opts) { if (!tcg_enabled()) { error_report("-icount is not allowed with hardware virtualization"); } else if (qemu_tcg_mttcg_enabled()) { error_report("-icount does not currently work with MTTCG"); configure_icount(icount_opts, &error_abort); qemu_opts_del(icount_opts); if (default_net) { QemuOptsList *net = qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); #ifdef CONFIG_SLIRP qemu_opts_set(net, NULL, "type", "user", &error_abort); #endif colo_info_init(); if (net_init_clients() < 0) { if (qemu_opts_foreach(qemu_find_opts("object"), user_creatable_add_opts_foreach, object_create_delayed, NULL)) { #ifdef CONFIG_TPM if (tpm_init() < 0) { #endif if (foreach_device_config(DEV_BT, bt_parse)) if (!xen_enabled()) { if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) { error_report("at most 2047 MB RAM can be simulated"); blk_mig_init(); ram_mig_init(); if (machine_class->units_per_default_bus) { override_max_devs(machine_class->block_default_type, machine_class->units_per_default_bus); while (!QSIMPLEQ_EMPTY(&bdo_queue)) { BlockdevOptions_queue *bdo = QSIMPLEQ_FIRST(&bdo_queue); QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry); loc_push_restore(&bdo->loc); qmp_blockdev_add(bdo->bdo, &error_fatal); loc_pop(&bdo->loc); qapi_free_BlockdevOptions(bdo->bdo); g_free(bdo); if (snapshot || replay_mode != REPLAY_MODE_NONE) { qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, NULL); if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine_class->block_default_type, NULL)) { default_drive(default_cdrom, snapshot, machine_class->block_default_type, 2, CDROM_OPTS); default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); parse_numa_opts(machine_class); if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, NULL)) { if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0) if (foreach_device_config(DEV_SCLP, sclp_parse) < 0) { if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) if (default_vga) { if (machine_class->default_display) { vga_model = machine_class->default_display; } else if (vga_interface_available(VGA_CIRRUS)) { vga_model = "cirrus"; } else if (vga_interface_available(VGA_STD)) { vga_model = "std"; if (vga_model) { select_vgahw(vga_model); if (watchdog) { i = select_watchdog(watchdog); if (i > 0) exit (i == 1 ? 1 : 0); machine_register_compat_props(current_machine); qemu_opts_foreach(qemu_find_opts("global"), global_init_func, NULL, NULL); replay_checkpoint(CHECKPOINT_INIT); qdev_machine_init(); current_machine->ram_size = ram_size; current_machine->maxram_size = maxram_size; current_machine->ram_slots = ram_slots; current_machine->boot_order = boot_order; current_machine->cpu_model = cpu_model; machine_class->init(current_machine); realtime_init(); audio_init(); if (hax_enabled()) { hax_sync_vcpus(); if (qemu_opts_foreach(qemu_find_opts("fw_cfg"), parse_fw_cfg, fw_cfg_find(), NULL) != 0) { if (machine_usb(current_machine)) { if (foreach_device_config(DEV_USB, usb_parse) < 0) igd_gfx_passthru(); rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, NULL)) { cpu_synchronize_all_post_init(); numa_post_machine_init(); rom_reset_order_override(); scsi_legacy_handle_cmdline(); drive_check_orphaned(); if (!default_net) { net_check_clients(); if (boot_once) { qemu_boot_set(boot_once, &error_fatal); qemu_register_reset(restore_boot_order, g_strdup(boot_order)); ds = init_displaystate(); switch (display_type) { case DT_CURSES: curses_display_init(ds, full_screen); case DT_SDL: sdl_display_init(ds, full_screen, no_frame); case DT_COCOA: cocoa_display_init(ds, full_screen); case DT_GTK: gtk_display_init(ds, full_screen, grab_on_hover); default: os_setup_signal_handling(); #ifdef CONFIG_VNC qemu_opts_foreach(qemu_find_opts("vnc"), vnc_init_func, NULL, NULL); #endif if (using_spice) { qemu_spice_display_init(); if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { qdev_machine_creation_done(); qemu_register_reset(qbus_reset_all_fn, sysbus_get_default()); qemu_run_machine_init_done_notifiers(); if (rom_check_and_register_reset() != 0) { error_report("rom check and register reset failed"); replay_start(); replay_checkpoint(CHECKPOINT_RESET); qemu_system_reset(VMRESET_SILENT); register_global_state(); if (replay_mode != REPLAY_MODE_NONE) { replay_vmstate_init(); } else if (loadvm) { if (load_vmstate(loadvm) < 0) { autostart = 0; qdev_prop_check_globals(); if (vmstate_dump_file) { dump_vmstate_json_to_file(vmstate_dump_file); return 0; if (incoming) { Error *local_err = NULL; qemu_start_incoming_migration(incoming, &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); } else if (autostart) { vm_start(); os_setup_post(); main_loop(); replay_disable_events(); iothread_stop_all(); bdrv_close_all(); pause_all_vcpus(); res_free(); net_cleanup(); audio_cleanup(); monitor_cleanup(); qemu_chr_cleanup(); return 0;
1threat
void ff_free_parser_state(AVFormatContext *s, AVParserState *state) { int i; AVParserStreamState *ss; if (!state) return; for (i = 0; i < state->nb_streams; i++) { ss = &state->stream_states[i]; if (ss->parser) av_parser_close(ss->parser); av_free_packet(&ss->cur_pkt); } free_packet_list(state->packet_buffer); free_packet_list(state->raw_packet_buffer); av_free(state->stream_states); av_free(state); }
1threat
How to read the text between two string from a text file using c#? : <p><strong>My Text File:</strong></p> <pre><code> Users of Yamaha: (Total of 1 bike issued; Total of 1 bike in use) bike details 1001 Dinesh , start Fri 1/13 8:55 Users of Hero: (Total of 1 bike issued; Total of 1 bike in use) bike details 1002 Monika, start Fri 1/13 9:55 Users of Honda: (Total of 2 bike issued; Total of 1 bike in use) bike details 1003 Monikadinesh, start Fri 1/13 5:55 </code></pre> <p>Here I want to Extract the line between two strings.Here I want to Append the line into a string. I want to extract the Line between two <strong>Users of</strong>.</p> <p>My Extracted String will be like this :</p> <pre><code>//**The content lie between two users of** (Total of 1 bike issued; Total of 1 bike in use)Append it in multi array. bike details 1001 Dinesh , start Fri 1/13 8:55 </code></pre> <p>I don't know how to Solve my problem.Help me to solve this.Thanks in advance</p>
0debug
Index out of bounds error ArrayList : <pre><code> for (int i = 0; i &lt; totalArray.size(); i++){ studentNumber.add(Long.parseLong(totalArray.get(i * 3))) lastName.add(totalArray.get((i * 3) + 1)); firstName.add(totalArray.get((i * 3) + 2)); </code></pre> <p>I'm not sure what is going on here. I've getting an index out of bounds error on this code. totalArray.size() is 42 however I'm getting the error at index 42 with the second line (parseLong).</p>
0debug
void helper_check_iob(CPUX86State *env, uint32_t t0) { check_io(env, t0, 1); }
1threat
make image clickable and on click open corresponding text file in new window : <p>when date is clicked on Image it should open new tab and load that date txt file in new tab for example when 28/03/2019 is clicked in new tab 28/03/2019.txt should open<code>image dates should be clickable and on click specific text file should get open</code>`</p>
0debug
static unsigned syborg_virtio_get_features(void *opaque) { unsigned ret = 0; ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); return ret; }
1threat
static void hid_keyboard_process_keycode(HIDState *hs) { uint8_t hid_code, index, key; int i, keycode, slot; if (hs->n == 0) { return; slot = hs->head & QUEUE_MASK; QUEUE_INCR(hs->head); hs->n--; keycode = hs->kbd.keycodes[slot]; key = keycode & 0x7f; index = key | ((hs->kbd.modifiers & (1 << 8)) >> 1); hid_code = hid_usage_keys[index]; hs->kbd.modifiers &= ~(1 << 8); switch (hid_code) { case 0x00: return; case 0xe0: assert(key == 0x1d); if (hs->kbd.modifiers & (1 << 9)) { hs->kbd.modifiers ^= (1 << 8) | (1 << 9); return; case 0xe1 ... 0xe7: if (keycode & (1 << 7)) { hs->kbd.modifiers &= ~(1 << (hid_code & 0x0f)); return; case 0xe8 ... 0xe9: hs->kbd.modifiers |= 1 << (hid_code & 0x0f); return; case 0xea ... 0xef: abort(); default: break; if (keycode & (1 << 7)) { for (i = hs->kbd.keys - 1; i >= 0; i--) { if (hs->kbd.key[i] == hid_code) { hs->kbd.key[i] = hs->kbd.key[-- hs->kbd.keys]; hs->kbd.key[hs->kbd.keys] = 0x00; break; if (i < 0) { return; } else { for (i = hs->kbd.keys - 1; i >= 0; i--) { if (hs->kbd.key[i] == hid_code) { break; if (i < 0) { if (hs->kbd.keys < sizeof(hs->kbd.key)) { hs->kbd.key[hs->kbd.keys++] = hid_code; } else { return;
1threat
Is it better to delete files from a folder over 30 days old using a C# program, or some sort of Batch script? : <p>I'm unfamiliar with creating batch files. I really don't get how they work or what they can do. What I do know is how to write a c# program. </p> <p>If I want to have an automated process that runs probably once a day to delete files older than 30 days, would it be better to make a batch script, or some sort of task that runs the c# program?</p> <p>Should the program keep track of files it knows will expire tomorrow and just delete by name? Or should it scan the whole folder every day? Seems like a waste to do that, but it makes it very simple.</p> <p>I know it can be done both ways and there's a lot of material on both, but what I really want to know is what's the difference?</p>
0debug
How to nagivate from one tabpage to another tabpage of tabcontrol in C # using some keyevent : i want to use key like arrow key or any other alphabet to move tab from one to next and from next to back. Example : suppose my tabcontrol has 5 tab page, when i am in tab one i immidiately want to move to 2 and from second to third and son on. and vice-versa. i have searched but not got proper resourse. hope u will help me
0debug
static void qemu_coroutine_thread_cleanup(void *opaque) { CoroutineThreadState *s = opaque; Coroutine *co; Coroutine *tmp; QLIST_FOREACH_SAFE(co, &s->pool, pool_next, tmp) { g_free(DO_UPCAST(CoroutineUContext, base, co)->stack); g_free(co); } g_free(s); }
1threat
What do "Enable Load" and "Include In Report Refresh" mean/do? : <p>In Power Query, when I right-click on the name of a query (in the left-most pane of Power Query's window) I see selections for "Enable Load" and "Include In Report Refresh." </p> <p>I cannot find an explanation of what these two selections actually mean and do. I'd definitely appreciate a brief tutorial.</p>
0debug
app with eclipse ,botton not work : i m new on java programmer i follow some book about java program and particulary eclipse. i write on easy program but the function of botton not work well, this is my code MainActivity.java import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.os.Build; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()) .commit(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } } activity.java import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.os.Build; public class activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button b = (Button) findViewById(R.id.btnRecipe); b.setOnClickListener(new OnClickListener(){ @SuppressWarnings("unused") public void onclick(View v){ startActivity(activity.this, recipe.class); } private void startActivity(activity activity, Class<recipe> class1) { // TODO Auto-generated method stub } @Override public void onClick(View arg0) { // TODO Auto-generated method stub } }); } private void setContentView(int activityMain) { // TODO Auto-generated method stub } private Button findViewById(int btnrecipe) { // TODO Auto-generated method stub return null; } recipe.java import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.os.Build; public class recipe extends MainActivity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.recipe); } } activity_main.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.helloandroidword.MainActivity" tools:ignore="MergeRootFrame" /> fragment_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.helloandroidword.MainActivity$PlaceholderFragment" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:id="@+id/btnRecipe" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="20dp" android:text="Button" /> </RelativeLayout> recipe.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="27dp" android:layout_marginTop="54dp" android:text="ingredinti" android:textAppearance="?android:attr/textAppearanceLarge" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginTop="81dp" android:text="acqua" android:textAppearance="?android:attr/textAppearanceSmall" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView2" android:layout_centerVertical="true" android:text="sale" android:textAppearance="?android:attr/textAppearanceSmall" /> </RelativeLayout> AndroidManifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.helloandroidword" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.helloandroidword.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity-alias android:name=".recipe"/> </application> </manifest> thank all
0debug
Angular 2 binding to maxlength of input or texarea : <p>I can render the following Angular 2 component containing an input with a maxlength set:</p> <pre><code>@Component({ selector: 'app', template: '&lt;input maxlength="10"&gt;', }) export class App { } </code></pre> <p>This works fine. However, if I try to set the maxlength via a binding, like this:</p> <pre><code>@Component({ selector: 'app', template: '&lt;input [maxlength]="maxLength"&gt;', }) export class App { maxLength = 10; } </code></pre> <p>Or like this:</p> <pre><code> template: '&lt;input maxlength="{{maxLength}}"&gt;', </code></pre> <p>I get the following error:</p> <pre><code>"Template parse errors: Can't bind to 'maxlength' since it isn't a known property of 'input'." </code></pre> <p>Why? <code>maxlength</code> is a perfectly valid property of an input control.</p> <p>Here's a <a href="http://plnkr.co/edit/cxb10urctYezQUuPGyTj?p=preview" rel="noreferrer">live example</a> (open console to see error).</p>
0debug
How to find hierarchical tree last nodes c# : <p>I want to find last items of hierarchical tree.</p> <pre><code>class Node { public int Id { get; set; } public int ParentId { get; set; } public string Name { get; set; } } </code></pre> <p><a href="https://i.stack.imgur.com/Ldz0p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ldz0p.png" alt="enter image description here"></a></p> <pre><code> var list = new List&lt;Node&gt; { new Node {Id = 1, ParentId = 0, Name = "N 1"}, new Node {Id = 2, ParentId = 1, Name = "N 1.1"}, new Node {Id = 3, ParentId = 1, Name = "N 1.2"}, new Node {Id = 4, ParentId = 2, Name = "N 1.1.1"}, new Node {Id = 5, ParentId = 2, Name = "N 1.1.2"}, new Node {Id = 6, ParentId = 2, Name = "N 1.1.3"} }; </code></pre> <p>is this possible with c# or linq query?</p>
0debug
MVC ASP.NET Object reference not set to an instance of an object : I am trying to display information of the current logged in user. In **AccountController** I added the following ActionResult: public class AccountController : Controller { private ApplicationSignInManager _signInManager; private ApplicationUserManager _userManager; public AccountController() { } //....... public ActionResult Profile() { var userId = User.Identity.GetUserId(); if(userId == null) { return RedirectToAction("Login", "AccountControler"); } else { ApplicationUser user = _userManager.FindByIdAsync(userId).Result; return View(user); } } However, I get the following Exception User-Unhandled: *Object reference not set to an instance of an object. _userManager was null*
0debug
what is the difference between of scanf (β€œ%s",a) scanf("%s[^\n]",a) and puts(a) for Strings in c programming? : what is the difference between of scanf (β€œ%s",&a) scanf("%s[^\n]",a) and puts(a) in c programming? scanf("%s[^\n]",a); scanf("%s",a); puts(a); what is the main difference between the three types of Character Array Input?
0debug
Which CRMs allow two-way conversational SMS/TXT messaging? : <p>I am looking for a CRM like Klaviyo that supports 2-way SMS txt messaging. Most I come across only seem to do 1-way messaging.</p> <p>Anyone know of one that is decent and supports 2-way SMS txt messaging?</p>
0debug
static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) { SmackerContext *smk = s->priv_data; int flags; int ret; int i; int frame_size = 0; int palchange = 0; if (s->pb->eof_reached || smk->cur_frame >= smk->frames) return AVERROR_EOF; if(smk->curstream < 0) { avio_seek(s->pb, smk->nextpos, 0); frame_size = smk->frm_size[smk->cur_frame] & (~3); flags = smk->frm_flags[smk->cur_frame]; if(flags & SMACKER_PAL){ int size, sz, t, off, j, pos; uint8_t *pal = smk->pal; uint8_t oldpal[768]; memcpy(oldpal, pal, 768); size = avio_r8(s->pb); size = size * 4 - 1; frame_size -= size; frame_size--; sz = 0; pos = avio_tell(s->pb) + size; while(sz < 256){ t = avio_r8(s->pb); if(t & 0x80){ sz += (t & 0x7F) + 1; pal += ((t & 0x7F) + 1) * 3; } else if(t & 0x40){ off = avio_r8(s->pb); j = (t & 0x3F) + 1; if (off + j > 0x100) { av_log(s, AV_LOG_ERROR, "Invalid palette update, offset=%d length=%d extends beyond palette size\n", off, j); return AVERROR_INVALIDDATA; } off *= 3; while(j-- && sz < 256) { *pal++ = oldpal[off + 0]; *pal++ = oldpal[off + 1]; *pal++ = oldpal[off + 2]; sz++; off += 3; } } else { *pal++ = smk_pal[t]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; sz++; } } avio_seek(s->pb, pos, 0); palchange |= 1; } flags >>= 1; smk->curstream = -1; for(i = 0; i < 7; i++) { if(flags & 1) { uint32_t size; uint8_t *tmpbuf; size = avio_rl32(s->pb) - 4; if (!size || size > frame_size) { av_log(s, AV_LOG_ERROR, "Invalid audio part size\n"); return AVERROR_INVALIDDATA; } frame_size -= size; frame_size -= 4; smk->curstream++; tmpbuf = av_realloc(smk->bufs[smk->curstream], size); if (!tmpbuf) return AVERROR(ENOMEM); smk->bufs[smk->curstream] = tmpbuf; smk->buf_sizes[smk->curstream] = size; ret = avio_read(s->pb, smk->bufs[smk->curstream], size); if(ret != size) return AVERROR(EIO); smk->stream_id[smk->curstream] = smk->indexes[i]; } flags >>= 1; } if (frame_size < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, frame_size + 769)) return AVERROR(ENOMEM); if(smk->frm_size[smk->cur_frame] & 1) palchange |= 2; pkt->data[0] = palchange; memcpy(pkt->data + 1, smk->pal, 768); ret = avio_read(s->pb, pkt->data + 769, frame_size); if(ret != frame_size) return AVERROR(EIO); pkt->stream_index = smk->videoindex; pkt->pts = smk->cur_frame; pkt->size = ret + 769; smk->cur_frame++; smk->nextpos = avio_tell(s->pb); } else { if (smk->stream_id[smk->curstream] < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, smk->buf_sizes[smk->curstream])) return AVERROR(ENOMEM); memcpy(pkt->data, smk->bufs[smk->curstream], smk->buf_sizes[smk->curstream]); pkt->size = smk->buf_sizes[smk->curstream]; pkt->stream_index = smk->stream_id[smk->curstream]; pkt->pts = smk->aud_pts[smk->curstream]; smk->aud_pts[smk->curstream] += AV_RL32(pkt->data); smk->curstream--; } return 0; }
1threat
How to get started with github projects? : <p>I can do programming well.But when I go see some project on github I don't understand how I can make contribution or modify the project.As there are so many files in the project.so please help me find a proper path to get started.</p>
0debug
How can I change base fork on GitHub? : <p>I've forked a repo to create a new project. The new project is now indipendent and I want to change the <strong>base fork</strong> to the <strong>head fork</strong> when creating PRs by default, in order to avoid mistakes.</p> <p><a href="https://i.stack.imgur.com/fvE22.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fvE22.png" alt="enter image description here"></a></p> <p>How can I do that on GitHub?</p>
0debug
Unreacable code @ Cell cell = cellIterator.next(); : Help please. I am coding a program to format the contents of an excel file. Eclipse is saying that the code is unreachable and I don't understand why.Where did I go wrong? Thanks for the help. :) private String formatExcel(File excel) { this.statusLabel.setText("formatting..."); try { FileInputStream file = new FileInputStream(excel); try { this.workbook = WorkbookFactory.create(file); } catch (InvalidFormatException ex) { file.close(); } int excelType = 0; if ((this.workbook instanceof HSSFWorkbook)) { excelType = 1; } int sheetNum = 0; try { sheetNum = Integer.parseInt(this.sheetNumber.getText()); } catch (NumberFormatException e) { file.close(); } if ((sheetNum < 1) || (sheetNum > this.workbook.getNumberOfSheets())) { file.close(); return "Please input a valid sheet number."; } Sheet sheet = this.workbook.getSheetAt(sheetNum - 1); sheet.setZoom(17, 20); Iterator<Row> rowIterator = sheet.iterator(); int startRow = Integer.MAX_VALUE; Iterator<Cell> cellIterator; for (; rowIterator.hasNext(); cellIterator.hasNext()) { Row row = (Row)rowIterator.next(); cellIterator = row.cellIterator(); continue; Cell cell = (Cell)cellIterator.next(); switch (cell.getCellType()) { case 4: break; case 0: break; case 1: if (cell.getStringCellValue().trim().equalsIgnoreCase("Condition Code")) { startRow = cell.getRowIndex(); } if ((cell.getRowIndex() > startRow + 1) && (cell.getColumnIndex() > 0) && (cell.getColumnIndex() < 5)) { if (excelType == 0) { cell.setCellValue(formatCellXSSF( cell.getStringCellValue(), cell.getColumnIndex())); } else { cell.setCellValue(formatCellHSSF( cell.getStringCellValue(), cell.getColumnIndex())); } } if (!cell.getStringCellValue().trim().equalsIgnoreCase("<<Test Data>>")) { if (!cell.getStringCellValue().trim().equalsIgnoreCase("<<Screenshots>>")) { break; } } break; } } sheet.autoSizeColumn(5); file.close(); FileOutputStream out = new FileOutputStream(excel); this.workbook.write(out); out.close(); return ""; } catch (FileNotFoundException ex) { return "Error. File is open. Please close it first."; } catch (IOException ex) {} return "Cannot format file because it is open. Please close it first."; }
0debug
OpenAI Gym Atari on Windows : <p>I'm having issues installing OpenAI Gym Atari environment on Windows 10. I have successfully installed and used OpenAI Gym already on the same system. </p> <p>It keeps tripping up when trying to run a makefile.</p> <p>I am running the command <code>pip install gym[atari]</code></p> <p>Here is the error:</p> <p><a href="https://i.stack.imgur.com/Sa2qb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Sa2qb.png" alt="enter image description here"></a></p> <p>and here is what I currently have on my system...<code>cmake</code> and <code>make</code> are both clearly installed.</p> <p><a href="https://i.stack.imgur.com/FHqfP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FHqfP.png" alt="enter image description here"></a></p>
0debug
static void kvmppc_host_cpu_initfn(Object *obj) { assert(kvm_enabled()); }
1threat
Python doctest: skip a test conditionally : <p>I know how to skip a doctest using <code># doctest: +SKIP</code>, but I can't figure out how to skip a test <em>sometimes</em>, based on a runtime condition. For example:</p> <pre><code>&gt;&gt;&gt; if os.path.isfile("foo"): ... open("foo").readlines() ... else: ... pass # doctest: +SKIP ['hello', 'world'] </code></pre> <p>That's the sort of thing I want to do. I would also accept a solution which runs the test, but changes the expected result to an exception with traceback if the condition is not met (i.e. run the test unconditionally but modify the expected result).</p>
0debug
How can I avoid NSInternalInconsistencyException when tapping on UI elements with XCTest? : <p>Since upgrading to xcode 9 some of my UI tests have started throwing an <code>NSInternalInconsistencyException</code> with the message </p> <blockquote> <p>Activity cannot be used after its scope has completed</p> </blockquote> <p>The problem occurs when I call <code>tap()</code> on an <code>XCUIElement</code>. I can see that the element is a valid button, which is enabled.</p> <p>Any help on fixing or working around this would be much appreciated!</p> <p>The top of the stack trace for the exception is:</p> <pre><code>0 CoreFoundation 0x00000001035ad1cb __exceptionPreprocess + 171 1 libobjc.A.dylib 0x0000000102f0ff41 objc_exception_throw + 48 2 CoreFoundation 0x00000001035b2362 +[NSException raise:format:arguments:] + 98 3 Foundation 0x00000001029b4089 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193 4 XCTest 0x00000001027d4018 -[XCActivityRecord _synchronized_ensureValid] + 153 5 XCTest 0x00000001027d3b0b -[XCActivityRecord _synchronized_addAttachment:] + 39 6 XCTest 0x00000001027d3c98 -[XCActivityRecord addAttachment:] + 37 7 XCTest 0x00000001027c0935 -[XCActivityRecord(UITesting) attachAutomaticScreenshot] + 265 8 XCTest 0x00000001027f84b3 __43-[XCUIElement resolveHandleUIInterruption:]_block_invoke + 1465 9 XCTest 0x0000000102814788 -[XCTContext _runActivityNamed:type:block:] + 185 10 XCTest 0x00000001027f7eed -[XCUIElement resolveHandleUIInterruption:] + 139 11 XCTest 0x000000010282b5d1 __63-[XCUIElement(XCUIElementEventSynthesis) _dispatchEvent:block:]_block_invoke + 81 12 XCTest 0x0000000102814788 -[XCTContext _runActivityNamed:type:block:] + 185 13 XCTest 0x000000010282b500 -[XCUIElement(XCUIElementEventSynthesis) _dispatchEvent:block:] + 315 14 XCTest 0x000000010282d242 -[XCUIElement(XCUIElementTouchEvents) tap] + </code></pre>
0debug
Java HashMap.put throwing NullPointerException with "new" keyword : <p>I have checked everywhere for a solution to this problem and simply cannot find one despite its apparent simplicity.</p> <p>I keep getting a <code>NullPointerException</code> when calling <code>myFunction()</code>:</p> <pre><code>private static Map&lt;String, Map&lt;String, Integer&gt;&gt; data; public Class() { data = new Map&lt;String, Map&lt;String, Integer&gt;(); } public static void myFunction(String key, String val0, int val1) { boolean createNewEntry = false; if(null == data) { createNewEntry = true; } else if(!data.containsKey(key)) { createNewEntry = true; } if(createNewEntry) { data.put(key, new HashMap&lt;String, Integer&gt;()); // This throws a NullPointerException. } data.get(key).put(val0, data.get(key).get(val0) + val1); } </code></pre> <p>The stack trace (with some project-specific data removed) is as follows:</p> <pre><code>Could not pass [Event] to [JAR file] v1.0.0 org.[parent].event.EventException ... (irrelevant) Caused by: java.lang.NullPointerException at net.[package name].[class].myFunction([source file].java:93) at net.[package name].[class].otherFunction([source file].java(108) at net.[package name].[other class].anotherFunction([other file].java(65) at net.[package name].[main class].on[Event]([main file].java:97) ~[?:?] at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:[versioning number]] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:[versioning number]] at org.[a different package name].plugin.java.JavaPluginLoader$1.execute([a file].java:301) ~[[versioning number]:[more data]] ... 15 more </code></pre> <p>Thank you in advance for any insight into this problem.</p>
0debug
Spring Security show home page only after succes login : <p>I would like to show user home page only after succes login.</p> <p>I mean, when somebody will hit the url for application like "ht'tp://localhost:8081/example", I want to redirect him to "ht'tp://localhost:8081/example/login" and only after loging in, user will see default home page which will be on "url/example" where he can do some actions or logout.</p> <p>Using example from mkyong <a href="http://www.mkyong.com/spring-security/spring-security-hibernate-annotation-example/" rel="nofollow">http://www.mkyong.com/spring-security/spring-security-hibernate-annotation-example/</a>.</p> <p>Didn't find answer on stack, maybe someone will help me with this.</p>
0debug
Parse error: syntax error, unexpected '$author' (T_VARIABLE) : <p>my php file:</p> <pre><code> if($operation=='upload'){ if(isset($data -&gt; paper) &amp;&amp; !empty($data -&gt; paper) &amp;&amp; isset($data -&gt; paper -&gt; author) &amp;&amp; isset($data -&gt; paper -&gt; description) &amp;&amp; isset($data -&gt; paper -&gt; title))ο½› $author = $data -&gt; paper -&gt; author; $description= $data -&gt; paper -&gt; description; $title = $data -&gt; paper -&gt; title; echo $fun -&gt; uploadPaper($author,$description,$title); } </code></pre> <p>json</p> <pre><code> { "operation": "upload", "paper": { "author": "Mark Watson", "description": "The book writing about AI by Mark Waton", "title": "Practical Artificial Intelligence Programming With Java" } } </code></pre> <p>when i send json to server by post method,there is a error:</p> <p>Parse error: syntax error, unexpected '$author' (T_VARIABLE) in D:\xampp\htdocs\server\index.php on line 78</p> <p>i really don't know what is happening!please tell me</p>
0debug
def min_jumps(arr, n): jumps = [0 for i in range(n)] if (n == 0) or (arr[0] == 0): return float('inf') jumps[0] = 0 for i in range(1, n): jumps[i] = float('inf') for j in range(i): if (i <= j + arr[j]) and (jumps[j] != float('inf')): jumps[i] = min(jumps[i], jumps[j] + 1) break return jumps[n-1]
0debug
SQLSever query excute : select top(1) Tb_Customer.ID from Tb_Customer inner join Tb_Agency_Eshterak on Tb_Customer.ID=Tb_Agency_Eshterak.CustomerID where Tb_Agency_Eshterak.TypeE=2 ORDER BY ((CONVERT(decimal(10),Tb_Customer.Lat)-'36.828381258846065')(CONVERT(decimal(10),Tb_Customer.Lat)-'36.828381258846065')) + ((CONVERT(decimal(10),Tb_Customer.Lng) - '54.454983147717144')(CONVERT(decimal(10),Tb_Customer.Lng) - '54.454983147717144')) ASc This Query Have Any Problem? I Cant Excute it In Sql Server This Is Emergency Thanks
0debug
Creating BaseView class in SwiftUI : <p>Lately started learning/developing apps with SwiftUI and seems pretty easy to build the UI components. However, struggling creating a BaseView in SwiftUI. My idea is to have the common UI controls like background , navigation , etc in BaseView and just subclass other SwiftUI views to have the base components automatically.</p>
0debug
How to itterate through int? : I'm confused on how i can iterate through my int, and then put the result in a int vector.. I'm needing to do this for a game, help would be very much appreciated.. honestly, i have no idea how to make this function, that will iterate through int... cout << "\n PLEASE ENTER A 4 DIGIT BINARY! OR PROGRAM WILL EXIT \n\n\t"; cin >> binaryCin; evaluateNum(binaryCin); void MasterMind::evaluateNum(int &bin) { //Need to itterate through binarycin, and then but it in a vector<int>.. }
0debug
In numpy, what does selection by [:,None] do? : <p>I'm taking the Udacity course on deep learning and I came across the following code:</p> <pre><code>def reformat(dataset, labels): dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32) # Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...] labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32) return dataset, labels </code></pre> <p>What does <code>labels[:,None]</code> actually do here?</p>
0debug
How to vertically center text next to absolute container? : <p>I'd like to vertically center this text next to the image to get a result like this: <a href="https://i.stack.imgur.com/pxqXZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pxqXZ.png" alt="img"></a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.container { position: absolute; width: 50%; } .span { vertical-align:middle; display: inline; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt; &lt;div class="container"&gt; &lt;img style="width: 100%" src="http://placehold.it/150x50"/&gt; &lt;span class="span"&gt;should be vertically centered next to image&lt;/span&gt; &lt;/div&gt; &lt;/p&gt;</code></pre> </div> </div> </p> <p><strong>How to edit my code to center this text next to the ABSOLUTE container?</strong></p> <p>Any help would be very appreciated. Thanks.</p>
0debug
BlockDriverState *bdrv_new(const char *device_name) { BlockDriverState *bs; bs = g_malloc0(sizeof(BlockDriverState)); QLIST_INIT(&bs->dirty_bitmaps); pstrcpy(bs->device_name, sizeof(bs->device_name), device_name); if (device_name[0] != '\0') { QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list); } bdrv_iostatus_disable(bs); notifier_list_init(&bs->close_notifiers); notifier_with_return_list_init(&bs->before_write_notifiers); qemu_co_queue_init(&bs->throttled_reqs[0]); qemu_co_queue_init(&bs->throttled_reqs[1]); bs->refcnt = 1; return bs; }
1threat
Create a functioning Response object : <p>For testing purposes I'm trying to create a Response() object in python but it proves harder then it sounds.</p> <p>i tried this:</p> <pre><code>from requests.models import Response the_response = Response() the_response.code = "expired" the_response.error_type = "expired" the_response.status_code = 400 </code></pre> <p>but when I attempted <code>the_response.json()</code> i got an error because the function tries to get <code>len(self.content)</code> and <code>a.content</code> is null. So I set <code>a._content = "{}"</code> but then I get an encoding error, so I have to change <code>a.encoding</code>, but then it fails to decode the content.... this goes on and on. Is there a simple way to create a Response object that's functional and has an arbitrary status_code and content?</p>
0debug
How can i remove last and first apostrophe ( ' ) from string : <p>How can i remove last and first apostrophe ( ' ) from string.</p> <p>I have the string is <code>"'name'"</code> and i need to change to <code>"name"</code> i don't need the apostrophe symbol ('). </p>
0debug
How to dockerize Jupyter lab : <p>I'm trying to dockerize the <a href="https://github.com/jupyterlab/jupyterlab" rel="noreferrer">Jupyter Lab</a> and so I tried to create a <code>Dockerfile</code> as below,<br></p> <pre><code>FROM python:3.6 WORKDIR /jup RUN pip install jupyter -U &amp;&amp; pip install jupyterlab EXPOSE 8888 ENTRYPOINT ["jupyter", "lab"] </code></pre> <p><br> and run the commands, <code>docker build . -t jupyter</code> then <code>docker run jupyter</code>. But unfortunately I got some error as below<br></p> <pre><code>[I 07:56:34.123 LabApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret Traceback (most recent call last): File "/usr/local/bin/jupyter-lab", line 11, in &lt;module&gt; sys.exit(main()) File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance app.initialize(argv) File "&lt;decorator-gen-7&gt;", line 2, in initialize File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error return method(app, *args, **kwargs) File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1507, in initialize self.init_webapp() File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1297, in init_webapp self.http_server.listen(port, self.ip) File "/usr/local/lib/python3.6/site-packages/tornado/tcpserver.py", line 142, in listen sockets = bind_sockets(port, address=address) File "/usr/local/lib/python3.6/site-packages/tornado/netutil.py", line 197, in bind_sockets sock.bind(sockaddr) OSError: [Errno 99] Cannot assign requested address </code></pre> <p><br> How can I dockerize <code>jupyter lab</code> ? [ by solving this error ]</p>
0debug
Android: Not able to get serialized bundle in an activity : I have a class `public class Alarm implements Serializable {`. This has a method in it: public void schedule(Context context) { setAlarmActive(true); Intent myIntent = new Intent(context, AlarmAlertBroadcastReciever.class); Bundle bundle = new Bundle(); bundle.putSerializable("alarm", this); myIntent.putExtras(bundle); //myIntent.putExtra("alarm", this); Alarm alarm = (Alarm) bundle.getSerializable("alarm"); if(alarm !=null){ Log.d("Alarmdebug", "alatm is not null"); } PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, myIntent,PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, getAlarmTime().getTimeInMillis(), pendingIntent); } Elsewhere I have this code. Which is not able to get the serialized extras. This is invoked but `alarm` is always null. Bundle bundle = intent.getExtras(); final Alarm alarm = (Alarm) bundle.getSerializable("alarm"); if(alarm==null){ Log.d("Alarmdebug", "alarm is null 2"); } Can you please tell me what is the issue with this code? I tried the solution here: https://stackoverflow.com/questions/14333449/passing-data-through-intent-using-serializable but it doesn't work for me. Thank you
0debug
static int msrle_decode_pal4(AVCodecContext *avctx, AVFrame *pic, GetByteContext *gb) { unsigned char rle_code; unsigned char extra_byte, odd_pixel; unsigned char stream_byte; int pixel_ptr = 0; int line = avctx->height - 1; int i; while (line >= 0 && pixel_ptr <= avctx->width) { if (bytestream2_get_bytes_left(gb) <= 0) { av_log(avctx, AV_LOG_ERROR, "MS RLE: bytestream overrun, %dx%d left\n", avctx->width - pixel_ptr, line); return AVERROR_INVALIDDATA; } rle_code = stream_byte = bytestream2_get_byteu(gb); if (rle_code == 0) { stream_byte = bytestream2_get_byte(gb); if (stream_byte == 0) { line--; pixel_ptr = 0; } else if (stream_byte == 1) { return 0; } else if (stream_byte == 2) { stream_byte = bytestream2_get_byte(gb); pixel_ptr += stream_byte; stream_byte = bytestream2_get_byte(gb); avpriv_request_sample(avctx, "Unused stream byte %X", stream_byte); } else { odd_pixel = stream_byte & 1; rle_code = (stream_byte + 1) / 2; extra_byte = rle_code & 0x01; if (pixel_ptr + 2*rle_code - odd_pixel > avctx->width || bytestream2_get_bytes_left(gb) < rle_code) { av_log(avctx, AV_LOG_ERROR, "MS RLE: frame/stream ptr just went out of bounds (copy)\n"); return AVERROR_INVALIDDATA; } for (i = 0; i < rle_code; i++) { if (pixel_ptr >= avctx->width) break; stream_byte = bytestream2_get_byteu(gb); pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte >> 4; pixel_ptr++; if (i + 1 == rle_code && odd_pixel) break; if (pixel_ptr >= avctx->width) break; pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte & 0x0F; pixel_ptr++; } if (extra_byte) bytestream2_skip(gb, 1); } } else { if (pixel_ptr + rle_code > avctx->width + 1) { av_log(avctx, AV_LOG_ERROR, "MS RLE: frame ptr just went out of bounds (run) %d %d %d\n", pixel_ptr, rle_code, avctx->width); return AVERROR_INVALIDDATA; } stream_byte = bytestream2_get_byte(gb); for (i = 0; i < rle_code; i++) { if (pixel_ptr >= avctx->width) break; if ((i & 1) == 0) pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte >> 4; else pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte & 0x0F; pixel_ptr++; } } } if (bytestream2_get_bytes_left(gb)) { av_log(avctx, AV_LOG_ERROR, "MS RLE: ended frame decode with %d bytes left over\n", bytestream2_get_bytes_left(gb)); return AVERROR_INVALIDDATA; } return 0; }
1threat
static void guess_mv(MpegEncContext *s){ uint8_t fixed[s->mb_stride * s->mb_height]; #define MV_FROZEN 3 #define MV_CHANGED 2 #define MV_UNCHANGED 1 const int mb_stride = s->mb_stride; const int mb_width = s->mb_width; const int mb_height= s->mb_height; int i, depth, num_avail; int mb_x, mb_y, mot_step, mot_stride; set_mv_strides(s, &mot_step, &mot_stride); num_avail=0; for(i=0; i<s->mb_num; i++){ const int mb_xy= s->mb_index2xy[ i ]; int f=0; int error= s->error_status_table[mb_xy]; if(IS_INTRA(s->current_picture.mb_type[mb_xy])) f=MV_FROZEN; if(!(error&MV_ERROR)) f=MV_FROZEN; fixed[mb_xy]= f; if(f==MV_FROZEN) num_avail++; } if((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <= mb_width/2){ for(mb_y=0; mb_y<s->mb_height; mb_y++){ for(mb_x=0; mb_x<s->mb_width; mb_x++){ const int mb_xy= mb_x + mb_y*s->mb_stride; if(IS_INTRA(s->current_picture.mb_type[mb_xy])) continue; if(!(s->error_status_table[mb_xy]&MV_ERROR)) continue; s->mv_dir = s->last_picture.data[0] ? MV_DIR_FORWARD : MV_DIR_BACKWARD; s->mb_intra=0; s->mv_type = MV_TYPE_16X16; s->mb_skipped=0; s->dsp.clear_blocks(s->block[0]); s->mb_x= mb_x; s->mb_y= mb_y; s->mv[0][0][0]= 0; s->mv[0][0][1]= 0; decode_mb(s, 0); } } return; } for(depth=0;; depth++){ int changed, pass, none_left; none_left=1; changed=1; for(pass=0; (changed || pass<2) && pass<10; pass++){ int mb_x, mb_y; int score_sum=0; changed=0; for(mb_y=0; mb_y<s->mb_height; mb_y++){ for(mb_x=0; mb_x<s->mb_width; mb_x++){ const int mb_xy= mb_x + mb_y*s->mb_stride; int mv_predictor[8][2]={{0}}; int ref[8]={0}; int pred_count=0; int j; int best_score=256*256*256*64; int best_pred=0; const int mot_index= (mb_x + mb_y*mot_stride) * mot_step; int prev_x, prev_y, prev_ref; if((mb_x^mb_y^pass)&1) continue; if(fixed[mb_xy]==MV_FROZEN) continue; assert(!IS_INTRA(s->current_picture.mb_type[mb_xy])); assert(s->last_picture_ptr && s->last_picture_ptr->data[0]); j=0; if(mb_x>0 && fixed[mb_xy-1 ]==MV_FROZEN) j=1; if(mb_x+1<mb_width && fixed[mb_xy+1 ]==MV_FROZEN) j=1; if(mb_y>0 && fixed[mb_xy-mb_stride]==MV_FROZEN) j=1; if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]==MV_FROZEN) j=1; if(j==0) continue; j=0; if(mb_x>0 && fixed[mb_xy-1 ]==MV_CHANGED) j=1; if(mb_x+1<mb_width && fixed[mb_xy+1 ]==MV_CHANGED) j=1; if(mb_y>0 && fixed[mb_xy-mb_stride]==MV_CHANGED) j=1; if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]==MV_CHANGED) j=1; if(j==0 && pass>1) continue; none_left=0; if(mb_x>0 && fixed[mb_xy-1]){ mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_step][0]; mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_step][1]; ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy-1)]; pred_count++; } if(mb_x+1<mb_width && fixed[mb_xy+1]){ mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_step][0]; mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_step][1]; ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy+1)]; pred_count++; } if(mb_y>0 && fixed[mb_xy-mb_stride]){ mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][0]; mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][1]; ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy-s->mb_stride)]; pred_count++; } if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*mot_step][0]; mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*mot_step][1]; ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy+s->mb_stride)]; pred_count++; } if(pred_count==0) continue; if(pred_count>1){ int sum_x=0, sum_y=0, sum_r=0; int max_x, max_y, min_x, min_y, max_r, min_r; for(j=0; j<pred_count; j++){ sum_x+= mv_predictor[j][0]; sum_y+= mv_predictor[j][1]; sum_r+= ref[j]; if(j && ref[j] != ref[j-1]) goto skip_mean_and_median; } mv_predictor[pred_count][0] = sum_x/j; mv_predictor[pred_count][1] = sum_y/j; ref [pred_count] = sum_r/j; if(pred_count>=3){ min_y= min_x= min_r= 99999; max_y= max_x= max_r=-99999; }else{ min_x=min_y=max_x=max_y=min_r=max_r=0; } for(j=0; j<pred_count; j++){ max_x= FFMAX(max_x, mv_predictor[j][0]); max_y= FFMAX(max_y, mv_predictor[j][1]); max_r= FFMAX(max_r, ref[j]); min_x= FFMIN(min_x, mv_predictor[j][0]); min_y= FFMIN(min_y, mv_predictor[j][1]); min_r= FFMIN(min_r, ref[j]); } mv_predictor[pred_count+1][0] = sum_x - max_x - min_x; mv_predictor[pred_count+1][1] = sum_y - max_y - min_y; ref [pred_count+1] = sum_r - max_r - min_r; if(pred_count==4){ mv_predictor[pred_count+1][0] /= 2; mv_predictor[pred_count+1][1] /= 2; ref [pred_count+1] /= 2; } pred_count+=2; } skip_mean_and_median: pred_count++; if (!fixed[mb_xy]) { if (s->avctx->codec_id == CODEC_ID_H264) { } else { ff_thread_await_progress((AVFrame *) s->last_picture_ptr, mb_y, 0); } if (!s->last_picture.motion_val[0] || !s->last_picture.ref_index[0]) goto skip_last_mv; prev_x = s->last_picture.motion_val[0][mot_index][0]; prev_y = s->last_picture.motion_val[0][mot_index][1]; prev_ref = s->last_picture.ref_index[0][4*mb_xy]; } else { prev_x = s->current_picture.motion_val[0][mot_index][0]; prev_y = s->current_picture.motion_val[0][mot_index][1]; prev_ref = s->current_picture.ref_index[0][4*mb_xy]; } mv_predictor[pred_count][0]= prev_x; mv_predictor[pred_count][1]= prev_y; ref [pred_count] = prev_ref; pred_count++; s->mv_dir = MV_DIR_FORWARD; s->mb_intra=0; s->mv_type = MV_TYPE_16X16; s->mb_skipped=0; s->dsp.clear_blocks(s->block[0]); s->mb_x= mb_x; s->mb_y= mb_y; for(j=0; j<pred_count; j++){ int score=0; uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0]; s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1]; if(ref[j]<0) continue; decode_mb(s, ref[j]); if(mb_x>0 && fixed[mb_xy-1]){ int k; for(k=0; k<16; k++) score += FFABS(src[k*s->linesize-1 ]-src[k*s->linesize ]); } if(mb_x+1<mb_width && fixed[mb_xy+1]){ int k; for(k=0; k<16; k++) score += FFABS(src[k*s->linesize+15]-src[k*s->linesize+16]); } if(mb_y>0 && fixed[mb_xy-mb_stride]){ int k; for(k=0; k<16; k++) score += FFABS(src[k-s->linesize ]-src[k ]); } if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ int k; for(k=0; k<16; k++) score += FFABS(src[k+s->linesize*15]-src[k+s->linesize*16]); } if(score <= best_score){ best_score= score; best_pred= j; } } score_sum+= best_score; s->mv[0][0][0]= mv_predictor[best_pred][0]; s->mv[0][0][1]= mv_predictor[best_pred][1]; for(i=0; i<mot_step; i++) for(j=0; j<mot_step; j++){ s->current_picture.motion_val[0][mot_index+i+j*mot_stride][0]= s->mv[0][0][0]; s->current_picture.motion_val[0][mot_index+i+j*mot_stride][1]= s->mv[0][0][1]; } decode_mb(s, ref[best_pred]); if(s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y){ fixed[mb_xy]=MV_CHANGED; changed++; }else fixed[mb_xy]=MV_UNCHANGED; } } } if(none_left) return; for(i=0; i<s->mb_num; i++){ int mb_xy= s->mb_index2xy[i]; if(fixed[mb_xy]) fixed[mb_xy]=MV_FROZEN; } } }
1threat
nano editor on OS X - How to type M-U for undo? : <p>I am using nano 2.5.3 on OS X Yosemite, and I see commands at the bottom such as:</p> <p>M-U Undo M-E Redo</p> <p>So far, I have not been able to figure out which key or keys that <code>M</code> is referring to. What would be <code>M</code> on OS X?</p>
0debug
how to Send automated SMS using API? : I have this condition to scheduled my sms.(ERROR) but the sms im using is POST method I need to be automated. and send sms to the number of the current id. i dont know how to get the number of the current id and send the message. here is my code: I NEED HELP $duedate = ""; $date_now=date("Y-m-d"); date_default_timezone_set('Asia/Manila'); $date_now = strtotime($date_now); $duedate= strtotime($duedate); if ($duedate<=$date_now) { function itexmo($number,$message,$apicode) { $url = 'https://www.itexmo.com/php_api/api.php'; $itexmo = array('1' => $number, '2' => $message, '3' => $apicode); $param = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($itexmo), ), ); $context = stream_context_create($param); return file_get_contents($url, false, $context);} if ($_POST){ $number = $number; $name = $name; $api = "API"; $text = $name." : ".$number; if(!empty($_POST['name']) && ($_POST['number']) && ($_POST['msg'])){ $result = itexmo($number,$text,$api); if ($result == ""){ echo "iTexMo: No response from server!!! Please check the METHOD used (CURL or CURL-LESS). If you are using CURL then try CURL-LESS and vice versa. Please CONTACT US for help. "; }else if ($result == 0){ echo "Message Sent!"; } else{ echo "Error Num ". $result . " was encountered!"; } } } }
0debug
Typescript Equivalent of package scope? : <p>Is there a way in TypeScript to allow one file to access methods in another file, but not make them globally accessible? </p> <p>The use case for this is having a large class with some private methods that are dangerous and shouldn't be publicly exposed to be potentially used anywhere in the codebase. I want to be able to write the methods that access them in another file to allow logically grouping them without them all being in a single giant class.</p> <p>Ideally, something like Java's package scope would let me declare that the two files can access each others' dangerous methods but not anyone else. Is there any TypeScript language feature that allows this? </p> <p>Example: </p> <p>Class A has methods <code>d1</code> through <code>d100</code> that are all dangerous and shouldn't be globally accessible. </p> <p>Class B has methods <code>s1</code> through <code>s100</code> that are safe for public consumption within the project. Each <code>s</code> method calls through to a <code>d</code> method after doing some safety checking. Class B needs to have access to all of the <code>d</code> methods.</p> <p>Class C wants to call any of the <code>s</code> methods and should be able to, but shouldn't be able to call any of the <code>d</code> methods.</p> <p>However, as I understand Typescript, if I export any of the <code>d</code> methods so that B can call them, they are then accessible to C as well. If this were Java, I would put A and B in the same package and make the <code>d</code> methods package scope. </p> <p>There doesn't seem to be any parallel to this in TypeScript, but is there anything that simulates the goals of 1) being able to break the functionality in to separate files but 2) limiting who can call the methods?</p> <p>(Yes, I know once it's compiled down to Javascript all bets are off. The goal is to just use TypeScript as a static checker to verify the contracts at compile time.)</p>
0debug
POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->desc = "e5500 core"; pcc->init_proc = init_proc_e5500; pcc->check_pow = check_pow_none; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_WRTEE | PPC_RFDI | PPC_RFMCI | PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_CACHE_DCBA | PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | PPC_FLOAT_STFIWX | PPC_WAIT | PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | PPC_64B | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206; pcc->msr_mask = (1ull << MSR_CM) | (1ull << MSR_GS) | (1ull << MSR_UCLE) | (1ull << MSR_CE) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PX) | (1ull << MSR_RI); pcc->mmu_model = POWERPC_MMU_BOOKE206; pcc->excp_model = POWERPC_EXCP_BOOKE; pcc->bus_model = PPC_FLAGS_INPUT_BookE; pcc->bfd_mach = bfd_mach_ppc_e500; pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; }
1threat
I need help finding small errors in my python code : <p>I wrote this program, and I've been having a bunch of issues. I don't have very much experience with python, so I'm sure I made a bunch of dumb syntax errors. Please just help me find all of the errors in my code!</p> <pre><code>import string num_ltr = [] ltr_num = [] num = 1 for ltr in string.ascii_lowercase: num_ltr[num] = ltr ltr_num[ltr] = num num += 1 def print_menu(): return '1. Translate a string to numbers' return '2. Translate numbers to a string' return '3. Quit' def ltr_to_num(s, ltr_num): for char in s: print ltr_num[char] print def num_to_ltr(num_ltr, s): num_list = s.split() sentence = 0 for num in num_list: if num.isdigit(): sentence = num_ltr[num] else: sentence += num user_choice = 0 while user_choice != 3: print print_menu() user_choice = raw_input("&gt; ") if user_choice = 1: s = raw_input('Enter a sentence: ') num_to_ltr(s,num_ltr) elif user_choice = 2: s = raw_input('Enter the numbers separated by spaces: ') num_to_ltr(s,num_ltr) elif user_choice != 3: print "I don't recognize that choice." print "Goodbye!" </code></pre>
0debug
Is c# compatible with autocad lt? : <p>I've looked for this question several times but there's no answer. Lisp is a language that is exclusive to the full version of autocad, I wonder if c# is as well or if I can run c# on a lt version of autocad.</p>
0debug
Discrd JS reaction.emoji returns undefined : i need to get a specific reaction from a specific message. the problem is when i read any reaction they return undefined. `client.on('messageReactionAdd', (reaction, user) => { console.log(reaction.emoji); }`
0debug
Exception insert record to SQL in C# by Stored Procedure : [enter image description here][1] [1]: https://i.stack.imgur.com/G8xRM.png I'm trying to insert a supplier to SQL but it always throw the exception in line "cmd.ExecuteNonQuery()". Really need some helps!!
0debug
STATIC void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) { MOVQ_ZERO(mm7); SET_RND(mm6); __asm__ volatile( "movq (%1), %%mm0 \n\t" "movq 1(%1), %%mm4 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm4, %%mm5 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpckhbw %%mm7, %%mm1 \n\t" "punpckhbw %%mm7, %%mm5 \n\t" "paddusw %%mm0, %%mm4 \n\t" "paddusw %%mm1, %%mm5 \n\t" "xor %%"REG_a", %%"REG_a" \n\t" "add %3, %1 \n\t" ".p2align 3 \n\t" "1: \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq 1(%1, %%"REG_a"), %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpckhbw %%mm7, %%mm1 \n\t" "punpckhbw %%mm7, %%mm3 \n\t" "paddusw %%mm2, %%mm0 \n\t" "paddusw %%mm3, %%mm1 \n\t" "paddusw %%mm6, %%mm4 \n\t" "paddusw %%mm6, %%mm5 \n\t" "paddusw %%mm0, %%mm4 \n\t" "paddusw %%mm1, %%mm5 \n\t" "psrlw $2, %%mm4 \n\t" "psrlw $2, %%mm5 \n\t" "packuswb %%mm5, %%mm4 \n\t" "movq %%mm4, (%2, %%"REG_a") \n\t" "add %3, %%"REG_a" \n\t" "movq (%1, %%"REG_a"), %%mm2 \n\t" "movq 1(%1, %%"REG_a"), %%mm4 \n\t" "movq %%mm2, %%mm3 \n\t" "movq %%mm4, %%mm5 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpckhbw %%mm7, %%mm3 \n\t" "punpckhbw %%mm7, %%mm5 \n\t" "paddusw %%mm2, %%mm4 \n\t" "paddusw %%mm3, %%mm5 \n\t" "paddusw %%mm6, %%mm0 \n\t" "paddusw %%mm6, %%mm1 \n\t" "paddusw %%mm4, %%mm0 \n\t" "paddusw %%mm5, %%mm1 \n\t" "psrlw $2, %%mm0 \n\t" "psrlw $2, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "add %3, %%"REG_a" \n\t" "subl $2, %0 \n\t" "jnz 1b \n\t" :"+g"(h), "+S"(pixels) :"D"(block), "r"((x86_reg)line_size) :REG_a, "memory"); }
1threat
static inline void gen_outs(DisasContext *s, TCGMemOp ot) { if (s->base.tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_string_movl_A0_ESI(s); gen_op_ld_v(s, ot, cpu_T0, cpu_A0); tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_EDX]); tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff); tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T0); gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32); gen_op_movl_T0_Dshift(ot); gen_op_add_reg_T0(s->aflag, R_ESI); gen_bpt_io(s, cpu_tmp2_i32, ot); if (s->base.tb->cflags & CF_USE_ICOUNT) { gen_io_end(); } }
1threat
static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) { BFIContext *bfi = s->priv_data; AVIOContext *pb = s->pb; int ret, audio_offset, video_offset, chunk_size, audio_size = 0; if (bfi->nframes == 0 || pb->eof_reached) { return AVERROR(EIO); if (!bfi->avflag) { uint32_t state = 0; while(state != MKTAG('S','A','V','I')){ if (pb->eof_reached) return AVERROR(EIO); state = 256*state + avio_r8(pb); chunk_size = avio_rl32(pb); avio_rl32(pb); audio_offset = avio_rl32(pb); avio_rl32(pb); video_offset = avio_rl32(pb); audio_size = video_offset - audio_offset; bfi->video_size = chunk_size - video_offset; ret = av_get_packet(pb, pkt, audio_size); if (ret < 0) return ret; pkt->pts = bfi->audio_frame; bfi->audio_frame += ret; } else if (bfi->video_size > 0) { ret = av_get_packet(pb, pkt, bfi->video_size); if (ret < 0) return ret; pkt->pts = bfi->video_frame; bfi->video_frame += ret / bfi->video_size; bfi->nframes--; } else { ret = AVERROR(EAGAIN); bfi->avflag = !bfi->avflag; pkt->stream_index = bfi->avflag; return ret;
1threat
C# Regex not matching correctly : Alright, so I got piece of code. var getStatusInfo = message.ToString(); Console.Write(getStatusInfo); Regex getStatus = new Regex("[A-Za-z]"); string getStatus2 = getStatus.Match(getStatusInfo).Value; getStatus2 = getStatus2.Replace("addstatus", ""); SuicideStatusMagic = getStatus2; Bot.SteamFriends.SendChatMessage(OtherSID, type, "Status added!: " + SuicideStatusMagic); How it works is. You type to bot: addstatus swag, then it should show: Status added: Swag, but what it shows it status added: a What could be the issue?
0debug
check box with tableview in swift : I am new to swift programming [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/6DCcA.png Tableview with two check boxes [out ,Absent] check /uncheck working fine. Note1: out/absent any one of the check box checked after array data append and pass the data to function, out =>checked==> Array data append ==> Data pass to function absent =>checked==> data append ==> Data pass to function individival working well. note 2: if I can click the Out box, out box data append to array and pass to function immediately I want change the check box of Absent then clear the Appended out Data and send the Absent data to the function out==>checked===>data append==>changetoAbsent==>cleartheoutdata=>>append the Absent data pls help me .....! this is the code var InCheckec = [Bool]() var OutCheckec = [Bool]() var AbsentCheckec = [Bool]() var upStudentId = [String]() var upAttendanceID = [String]() var upStatus : String = "" var upStaffId : String = "" var UPstatusTest = [String]() var inButtoncount : Int = 0 @IBAction func InButttonClick(_ sender: UIButton) { status = "1" snackbar.backgroundColor = UIColor(red: CGFloat(0x00)/255 ,green: CGFloat(0xB1)/255 ,blue: CGFloat(0xB1)/255 ,alpha: 1.0) let prefs:UserDefaults = UserDefaults.standard StaffID = prefs.value(forKey: "STAFFID") as! String let position: CGPoint = sender.convert(CGPoint(x: 10, y: 20), to: self.TableView) let indexPath = self.TableView.indexPathForRow(at: position) let _: UITableViewCell = TableView.cellForRow(at: indexPath!)! _ = (indexPath! as NSIndexPath).row let buttontag = sender.tag if (sender.isSelected == true) { InCheckec[buttontag] = false inButtoncount -= 1 if(inButtoncount == 0) { snackbar.dismiss() upStaffId.removeAll() upStudentId.removeAll() upAttendanceID.removeAll() } else{ upStudentId.removeLast() upAttendanceID.removeLast() UPstatusTest.removeLast() } } else { snackbar.backgroundColor = UIColor(red: CGFloat(0x00)/255 ,green: CGFloat(0xB1)/255 ,blue: CGFloat(0xB1)/255 ,alpha: 1.0) InCheckec[buttontag] = true inButtoncount += 1 currentSnackbar = snackbar snackbar.show() let kid = attendanceInfo[(indexPath?.row)!] as AttendanceInfo upStudentId.append(kid.studentId!) upAttendanceID.append(kid.attendanceId) UPstatusTest.append(status) upStaffId = StaffID } self.TableView.reloadRows(at: [indexPath!], with: UITableViewRowAnimation.none) } @IBAction func OUTBUTTON(_ sender: UIButton) { snackbar.backgroundColor = UIColor(red: CGFloat(0x00)/255 ,green: CGFloat(0xB1)/255 ,blue: CGFloat(0xB1)/255 ,alpha: 1.0) status = "2" let buttontag = sender.tag let position: CGPoint = sender.convert(CGPoint(x: 10, y: 20), to: self.TableView) let indexPath = self.TableView.indexPathForRow(at: position) if (sender.isSelected == true) { OutCheckec[buttontag] = false inButtoncount -= 1 if(inButtoncount == 0) { snackbar.dismiss() upStudentId.removeAll() upAttendanceID.removeAll() UPstatusTest.removeAll() } else{ upStudentId.removeLast() UPstatusTest.removeLast() upAttendanceID.removeLast() } } else { OutCheckec[buttontag] = true AbsentCheckec[buttontag] = false print("buttontab value",buttontag) inButtoncount += 1 snackbar.show() let kid = attendanceInfo[(indexPath?.row)!] as AttendanceInfo upStudentId.append(kid.studentId!) upAttendanceID.append(kid.attendanceId) UPstatusTest.append(status) upStaffId = StaffID } self.TableView.reloadRows(at: [indexPath!], with: UITableViewRowAnimation.none) } @IBAction func ABSENTBUTTON(_ sender: UIButton) { status = "3" snackbar.backgroundColor = UIColor(red: CGFloat(0x00)/255 ,green: CGFloat(0xB1)/255 ,blue: CGFloat(0xB1)/255 ,alpha: 1.0) let buttontag = sender.tag let position: CGPoint = sender.convert(CGPoint(x: 10, y: 20), to: self.TableView) let indexPath = self.TableView.indexPathForRow(at: position) if (sender.isSelected == true) { AbsentCheckec[buttontag] = false inButtoncount -= 1 if(inButtoncount == 0) { snackbar.dismiss() upStudentId.removeAll() upAttendanceID.removeAll() UPstatusTest.removeAll() } else{ upStudentId.removeLast() UPstatusTest.removeLast() upAttendanceID.removeLast() } } else { AbsentCheckec[buttontag] = true OutCheckec[buttontag] = false inButtoncount += 1 snackbar.show() let kid = attendanceInfo[(indexPath?.row)!] as AttendanceInfo upStudentId.append(kid.studentId!) upAttendanceID.append(kid.attendanceId) UPstatusTest.append(status) upStaffId = StaffID } self.TableView.reloadRows(at: [indexPath!], with: UITableViewRowAnimation.none) } snack bar for perform send Action data pass to function lazy var snackbar = TTGSnackbar(message: "Attendance Update !", duration: .long, actionText: "SEND") { (snackbar) in self.activityIndicatorView.startAnimating() self.updateArray(_upstatus:UPstatusTest,UPStudentId:upStudentId,UPAttendanceID:upAttendanceID,UPStaffId:upStaffId,inBcount:inButtoncount) UPstatusTest.removeAll() upStudentId.removeAll() upAttendanceID.removeAll() inButtoncount = 0 } After append data pass to function func updateArray(_upstatus:[String],UPStudentId:[String],UPAttendanceID:[String],UPStaffId:String,inBcount:Int) { for i in 0..<inBcount { var errorCode = "1" _ = "Failed" var request = URLRequest(url: URL(string: "updateattendance", relativeTo: URL(string: serverURL+"/rkapi/api/"))!) let session = URLSession.shared request.httpMethod = "POST" let bodyData = "status=\(_upstatus[i])&staffId=\(UPStaffId)&studentId=\(UPStudentId[i])&attendanceId=\(upAttendanceID[i])" print("body data \(bodyData)") request.httpBody = bodyData.data(using: String.Encoding.utf8); let task = session.dataTask(with: request, completionHandler: { (data, response, error) in do { if data != nil { if let jsonData = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as? NSDictionary { errorCode = String(describing: jsonData["errorCode"]!) if(errorCode == "0") { self.getAttendances() } } } else { self.displayAlert("Raksha Data", message: "Data Not Available. Please try again") } } catch _ as NSError { } }) task.resume() } }
0debug
Waving line in css : <p>I need to do a wavy line animation in css.</p> <p>I would like it to look something like this:</p> <p><a href="https://i.stack.imgur.com/3BV68.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3BV68.jpg" alt="wavy line"></a></p> <p>My code:</p> <pre><code>&lt;div class="wrapper"&gt; &lt;div class="line"&gt;&lt;/div&gt; &lt;/div&gt; .wrapper { width: 100%; height: 500px; background: #fff; float: left; position: relative; } .line { width: 100%; height: 2px; background: url('http://tiny .pl/gjhxv') left top repeat-x; position: absolute; top: 50%; left: 0; } </code></pre> <p><a href="https://jsfiddle.net/agxx3ysk/" rel="nofollow noreferrer">https://jsfiddle.net/agxx3ysk/</a></p>
0debug
how to access value from array json object - javascript : <p>I am beginner please help me to get value from the below array json object.</p> <pre><code>[{"Category":"HI","Sub Category":"AQ HIOP"}, {"Category":"2HJ","Sub Category":"AS HIOP"}, {"Category":"3HJ","Sub Category":"AT HIOP"}, {"Category":"4Hj","Sub Category":"AP HIOP"}, {"Category":"5HJ","Sub Category":"AN HIOP"}, ] </code></pre> <p>I would just need the value of Sub Category</p> <p>Thanks in Advance.</p>
0debug
Why do templates specialisations need to be inlined? : <p>I am referring to this answer:</p> <p><a href="https://stackoverflow.com/a/4447057/930315">https://stackoverflow.com/a/4447057/930315</a></p> <p>I ran into a similar issue as the OP of the cited question, having a function</p> <pre><code>template&lt;typename T&gt; void func(T&amp; val); </code></pre> <p>and its specialization</p> <pre><code>template&lt;&gt; void func&lt;mytype&gt;(mytype&amp; val); </code></pre> <p>resulted in a duplicate symbols linker error (the methods are implemented in a '.tpp' file that is included at the end of my header). adding <code>inline</code> to the specialised function resolved the issue. Why?</p>
0debug
static int execute_code(AVCodecContext * avctx, int c) { AnsiContext *s = avctx->priv_data; int ret, i, width, height; switch(c) { case 'A': s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0); break; case 'B': s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height); break; case 'C': s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH); break; case 'D': s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0); break; case 'H': case 'f': s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0; s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0; break; case 'h': case 'l': if (s->nb_args < 2) s->args[0] = DEFAULT_SCREEN_MODE; switch(s->args[0]) { case 0: case 1: case 4: case 5: case 13: case 19: s->font = ff_cga_font; s->font_height = 8; width = 40<<3; height = 25<<3; break; case 2: case 3: s->font = ff_vga16_font; s->font_height = 16; width = 80<<3; height = 25<<4; break; case 6: case 14: s->font = ff_cga_font; s->font_height = 8; width = 80<<3; height = 25<<3; break; case 7: break; case 15: case 16: s->font = ff_cga_font; s->font_height = 8; width = 80<<3; height = 43<<3; break; case 17: case 18: s->font = ff_cga_font; s->font_height = 8; width = 80<<3; height = 60<<4; break; default: avpriv_request_sample(avctx, "Unsupported screen mode"); } if (width != avctx->width || height != avctx->height) { av_frame_unref(s->frame); ret = ff_set_dimensions(avctx, width, height); if (ret < 0) return ret; ret = ff_get_buffer(avctx, s->frame, AV_GET_BUFFER_FLAG_REF); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } s->frame->pict_type = AV_PICTURE_TYPE_I; s->frame->palette_has_changed = 1; memcpy(s->frame->data[1], ff_cga_palette, 16 * 4); erase_screen(avctx); } else if (c == 'l') { erase_screen(avctx); } break; case 'J': switch (s->args[0]) { case 0: erase_line(avctx, s->x, avctx->width - s->x); if (s->y < avctx->height - s->font_height) memset(s->frame->data[0] + (s->y + s->font_height)*s->frame->linesize[0], DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame->linesize[0]); break; case 1: erase_line(avctx, 0, s->x); if (s->y > 0) memset(s->frame->data[0], DEFAULT_BG_COLOR, s->y * s->frame->linesize[0]); break; case 2: erase_screen(avctx); } break; case 'K': switch(s->args[0]) { case 0: erase_line(avctx, s->x, avctx->width - s->x); break; case 1: erase_line(avctx, 0, s->x); break; case 2: erase_line(avctx, 0, avctx->width); } break; case 'm': if (s->nb_args == 0) { s->nb_args = 1; s->args[0] = 0; } for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) { int m = s->args[i]; if (m == 0) { s->attributes = 0; s->fg = DEFAULT_FG_COLOR; s->bg = DEFAULT_BG_COLOR; } else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) { s->attributes |= 1 << (m - 1); } else if (m >= 30 && m <= 38) { s->fg = ansi_to_cga[m - 30]; } else if (m == 39) { s->fg = ansi_to_cga[DEFAULT_FG_COLOR]; } else if (m >= 40 && m <= 47) { s->bg = ansi_to_cga[m - 40]; } else if (m == 49) { s->fg = ansi_to_cga[DEFAULT_BG_COLOR]; } else { avpriv_request_sample(avctx, "Unsupported rendition parameter"); } } break; case 'n': case 'R': break; case 's': s->sx = s->x; s->sy = s->y; break; case 'u': s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH); s->y = av_clip(s->sy, 0, avctx->height - s->font_height); break; default: avpriv_request_sample(avctx, "Unknown escape code"); break; } return 0; }
1threat
void list_cpus(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...), const char *optarg) { #if defined(cpu_list_id) cpu_list_id(f, cpu_fprintf, optarg); #elif defined(cpu_list) cpu_list(f, cpu_fprintf); #endif }
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
i want to open further intents when the user clicks on the Array list but every time i click on a list item the same activity opens up. : package com.example.husnainali.carinfo; //sdifjisdjisdjvdsjouvhsdovuhsdovhdsovhsdohv8eo8vo8 import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; import java.util.ArrayList; public class McLarenActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.word_list); //this the arraylist and i want to open further activities when a user clicks on a single arraylist an activity about it opens but currently when i click the 1 and 2 list open the same activity opens up. final ArrayList<Word> words = new ArrayList<Word>(); words.add(new Word("2017", "720 S", R.drawable.mclaren2017720s)); words.add(new Word("2015", "675lt", R.drawable.mclaren2015675lt)); words.add(new Word("2015", "P1 GTR", R.drawable.mclaren2015p1gtr)); words.add(new Word("2013", "P1", R.drawable.mclaren2013p1)); words.add(new Word("1994", "F1", R.drawable.mclaren1994f1)); WordAdapter adapter = new WordAdapter(this, words); ListView listView = (ListView) findViewById(R.id.list); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long 1) { // the word item clicked Word word = words.get(0); Intent i = new Intent(McLarenActivity.this, mclaren720s.class); startActivity(i); } }); //these are the set on clicker i have used but some how they are not working correctly listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { // the word item clicked Word word = words.get(1); Intent i = new Intent(McLarenActivity.this, mclaren675lt.class); startActivity(i); } }); //dvsuoudvhousdhvousdhvoudshvousdhvousdhvouds package com.example.husnainali.carinfo; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ImageView; import android.widget.ListView; import java.util.ArrayList; public class mclaren675lt extends AppCompatActivity { //this is the second word on the list @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mclaren675lt); ImageView mclaren720simage = (ImageView) findViewById(R.id.mclaren675ltimage); final ArrayList<Word> words = new ArrayList<Word>(); words.add(new Word(" engine." + "4.0-litre (3993 cc) twin-turbo V8 engine.", "Engine", R.mipmap.enginelogo)); words.add(new Word(" 0–100km/h in 2.9 seconds.\n" + "Max Speed:341km/h", "Performance", R.mipmap.performancelogocircular)); words.add(new Word(" $291,564\n" + "Β£208,600", "Price", R.mipmap.dollarlogocircular)); secondWordAdapter adapter = new secondWordAdapter(this, words); ListView listView = (ListView) findViewById(R.id.mclaren675ltlist); listView.setAdapter(adapter); } } package com.example.husnainali.carinfo; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ImageView; import android.widget.ListView; import java.util.ArrayList; public class mclaren720s extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.second_list_item); ImageView mclaren720simage = (ImageView) findViewById(R.id.mclaren720simage); final ArrayList<Word> words = new ArrayList<Word>(); words.add(new Word("M840T engine." + "4.0-litre (3993 cc) twin-turbo V8 engine.", "Engine", R.mipmap.enginelogo)); words.add(new Word(" 0–100km/h in 2.9 seconds.\n"+ "Max Speed:341km/h", "Performance", R.mipmap.performancelogocircular)); words.add(new Word(" $291,564\n"+ "Β£208,600", "Price", R.mipmap.dollarlogocircular)); secondWordAdapter adapter = new secondWordAdapter(this, words); ListView listView = (ListView) findViewById(R.id.secondlist); listView.setAdapter(adapter); } } //fsfehieyshfyesfsifgyiisdhfyhsdhfsd //for activity mclaren 675lt <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/mclaren675ltimage" android:src="@drawable/mclaren675ltimage" android:layout_width="480dp" android:layout_height="240dp" android:layout_gravity="center" /> <ListView android:id="@+id/mclaren675ltlist" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" /> </LinearLayout> //sdhofuhsdiufhisduhfids <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:padding="16dp"> //for secondlistitem <ImageView android:id="@+id/image" android:layout_width="120dp" android:layout_height="140dp" android:src="@mipmap/ic_launcher"/> <LinearLayout android:id="@+id/text_container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingLeft="16dp"> <TextView android:id="@+id/Model_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="25dp" tools:text="458" /> <TextView android:id="@+id/Year_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="italic" android:textSize="20dp" tools:text="2011" /> </LinearLayout> </LinearLayout> //for activity mclaren 720s <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/mclaren720simage" android:src="@drawable/mclaren720simage" android:layout_width="480dp" android:layout_height="240dp" android:layout_gravity="center" /> <ListView android:id="@+id/secondlist" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" /> </LinearLayout> //ixywxysxyxbsybxysbcysbciwybiwbciwbyiwbciywbcyiwbicybwyibcydbdu package com.example.husnainali.carinfo; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; public class secondWordAdapter extends ArrayAdapter<Word> { public secondWordAdapter(Context context, ArrayList<Word> words) { super(context, 0, words); } @Override public View getView(int position, View convertView, ViewGroup parent) { View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate( R.layout.secondlistitem, parent, false); } TextView modelTextView = (TextView) listItemView.findViewById(R.id.Model_text_view); modelTextView.setText(currentWord.getModelTranslation()); TextView yearTextView = (TextView) listItemView.findViewById(R.id.Year_text_view); yearTextView.setText(currentWord.getYearTranslation()); ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); imageView.setImageResource(currentWord.getImageResourceId()); return listItemView; } } //sdiyssiygsygdygisyybyicbsybbyybsiyfisbsybiiysbyibsybfysbsiybsiybsiybsiybfyisbifsbfyibfsiyfbsifysbfyifbsyfbsyfsbfyibsiyfbsfybfsiybtwiwunucnwoecnowencownecuonewocnoweuncouwencuocybywbuweucwbeycebiyewciyvecywevewiwycvyweicvtviwycwncwuonwenoucnwodkskslslncuweneucnusncunwiecysbdysbcyiwebciybiwyebc//
0debug
static void *kqemu_vmalloc(size_t size) { static int phys_ram_fd = -1; static int phys_ram_size = 0; void *ptr; #if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) int map_anon = MAP_ANON; #else int map_anon = 0; const char *tmpdir; char phys_ram_file[1024]; #ifdef CONFIG_SOLARIS struct statvfs stfs; #else struct statfs stfs; #endif if (!size) { abort (); } if (phys_ram_fd < 0) { tmpdir = getenv("QEMU_TMPDIR"); if (!tmpdir) #ifdef CONFIG_SOLARIS tmpdir = "/tmp"; if (statvfs(tmpdir, &stfs) == 0) { #else tmpdir = "/dev/shm"; if (statfs(tmpdir, &stfs) == 0) { #endif int64_t free_space; int ram_mb; free_space = (int64_t)stfs.f_bavail * stfs.f_bsize; if ((ram_size + 8192 * 1024) >= free_space) { ram_mb = (ram_size / (1024 * 1024)); fprintf(stderr, "You do not have enough space in '%s' for the %d MB of QEMU virtual RAM.\n", tmpdir, ram_mb); if (strcmp(tmpdir, "/dev/shm") == 0) { fprintf(stderr, "To have more space available provided you have enough RAM and swap, do as root:\n" "mount -o remount,size=%dm /dev/shm\n", ram_mb + 16); } else { fprintf(stderr, "Use the '-m' option of QEMU to diminish the amount of virtual RAM or use the\n" "QEMU_TMPDIR environment variable to set another directory where the QEMU\n" "temporary RAM file will be opened.\n"); } fprintf(stderr, "Or disable the accelerator module with -no-kqemu\n"); exit(1); } } snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX", tmpdir); phys_ram_fd = mkstemp(phys_ram_file); if (phys_ram_fd < 0) { fprintf(stderr, "warning: could not create temporary file in '%s'.\n" "Use QEMU_TMPDIR to select a directory in a tmpfs filesystem.\n" "Using '/tmp' as fallback.\n", tmpdir); snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX", "/tmp"); phys_ram_fd = mkstemp(phys_ram_file); if (phys_ram_fd < 0) { fprintf(stderr, "Could not create temporary memory file '%s'\n", phys_ram_file); exit(1); } } unlink(phys_ram_file); } size = (size + 4095) & ~4095; ftruncate(phys_ram_fd, phys_ram_size + size); #endif ptr = mmap(NULL, size, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED, phys_ram_fd, phys_ram_size); if (ptr == MAP_FAILED) { fprintf(stderr, "Could not map physical memory\n"); exit(1); } phys_ram_size += size; return ptr; }
1threat
static int inline get_mb_score(MpegEncContext * s, int mx, int my, int src_index, int ref_index) { MotionEstContext * const c= &s->me; const int size= 0; const int h= 16; const int penalty_factor= c->mb_penalty_factor; const int flags= c->mb_flags; const int qpel= flags & FLAG_QPEL; const int mask= 1+2*qpel; me_cmp_func cmp_sub, chroma_cmp_sub; int d; LOAD_COMMON cmp_sub= s->dsp.mb_cmp[size]; chroma_cmp_sub= s->dsp.mb_cmp[size+1]; assert(!c->skip); assert(c->avctx->me_sub_cmp != c->avctx->mb_cmp); d= cmp(s, mx>>(qpel+1), my>>(qpel+1), mx&mask, my&mask, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags); if(mx || my || size>0) d += (mv_penalty[mx - pred_x] + mv_penalty[my - pred_y])*penalty_factor; return d; }
1threat
void avcodec_free_context(AVCodecContext **pavctx) { AVCodecContext *avctx = *pavctx; if (!avctx) return; avcodec_close(avctx); av_freep(&avctx->extradata); av_freep(&avctx->subtitle_header); av_freep(pavctx); }
1threat
Regarding the string format in python, what does '[%s]' mean ? : I saw a line of code: re.compile('[%s]' % re.escape(string.punctuation)) But I have no idea about the function of '[%s]' Could anyone help me please? Thank You!
0debug
BigInteger(..).longValue() in Rust : In Java I can do this: new BigInteger(arrayOfBytes).longValue() How can I do that same thing in Rust? That is, given an array of bytes, how can I convert it into what's in java `longValue`?
0debug
It looks same algorithm but different output : The code looks same algorithm but different output. When you uncomment ``` #k = data.index(mn) #data[i], data[k] = data[k], data[I] ``` and also comment out ``` data[i], data[data.index(mn)] = data[data.index(mn)], data[i] ``` the data will be successfully sorted. I cannot figure out the difference of two way. ``` data = [-1.48, 4.96, 7.84, -4.27, 0.83, 0.31, -0.18, 3.57, 1.48, 5.34, 9.12, 7.98, -0.75, 2.22, -1.16, 6.53, -5.38, 1.63, -2.85, 7.89, -5.96, -8.23, 8.76, -2.97, 4.57, 5.21, 9.43, 3.12, 6.52, 1.58 ] #sort2 for i in range(30): mn = data[i] for j in data[i:]: if j < mn: mn = j else: pass #k = data.index(mn) #data[i], data[k] = data[k], data[i] data[i], data[data.index(mn)] = data[data.index(mn)], data[i] print('ascending order2:') print(data) ```
0debug
Failed to get D-Bus connection: Operation not permitted : <p>I'm trying to install ambari 2.6 on a docker centos7 image but in the the ambari setup step and exactly while intializing the postgresql db I receive this error: </p> <blockquote> <p>Failed to get D-Bus connection: Operation not permitted</p> </blockquote> <p>I've got this error every time I try to run a serice on my docker image.</p> <p>I tried every solution in the net but nothing worked yet.</p> <p>Does any one have an idea how to resolve this ? </p> <p>Thank you in advance</p>
0debug
void ff_put_h264_qpel16_mc30_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hz_qrt_16w_msa(src - 2, stride, dst, stride, 16, 1); }
1threat
Convert date string to year/month/day : <p>Ajax getResponseHeader("Last-Modified") returns a date string in the following format:</p> <pre><code>Thu Oct 13 2016 13:05:17 GMT+0200 (Paris, Madrid, sommartid) </code></pre> <p>Is it possible with javascript to get the year, month and day so I can store them in separate variables?</p>
0debug
Number of files in directory : <p>I am on Windows 10. I currently doing a group assignment that deals with a lot of images. I want to know when I click on an image if there is a way for the file explorer to tell me that this is "X" (for example 10th) item in this directory. I only see the total number of items on the bottom left corner of the file explorer screen. I know it sounds very nooby haha.</p>
0debug
How to add a wordpress post title to url? : <p>I need to add a post title to the url, each word separated by a dash "-"</p> <p>example: <a href="https://example.com/url.php?s=" rel="nofollow noreferrer">https://example.com/url.php?s=</a></p> <p>add title: <a href="https://example.com/url.php?s=Hello-World" rel="nofollow noreferrer">https://example.com/url.php?s=Hello-World</a></p> <p>(Sample title of the post: "Hello World!")</p> <p>Is it possible? Can someone do this</p>
0debug
(Python with Selenium) Find XPath on page : Can anyone know how I can find the XPath button on the page https://freerice.com/game in the upper right corner? I write a program in python with selenium and I would like him to click this button.
0debug
static void decode_422_bitstream(HYuvContext *s, int count) { int i; count /= 2; if (count >= (get_bits_left(&s->gb)) / (31 * 4)) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } for (; i < count; i++) s->temp[0][2 * i ] = s->temp[1][i] = s->temp[0][2 * i + 1] = s->temp[2][i] = 128; } else { for (i = 0; i < count; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } } }
1threat
int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){ MpegEncContext * const s = &h->s; int i; h->mmco_index= 0; if(h->nal_unit_type == NAL_IDR_SLICE){ s->broken_link= get_bits1(gb) -1; if(get_bits1(gb)){ h->mmco[0].opcode= MMCO_LONG; h->mmco[0].long_arg= 0; h->mmco_index= 1; } }else{ if(get_bits1(gb)){ for(i= 0; i<MAX_MMCO_COUNT; i++) { MMCOOpcode opcode= get_ue_golomb_31(gb); h->mmco[i].opcode= opcode; if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){ h->mmco[i].short_pic_num= (h->curr_pic_num - get_ue_golomb(gb) - 1) & (h->max_pic_num - 1); } if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ unsigned int long_arg= get_ue_golomb_31(gb); if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode); return -1; } h->mmco[i].long_arg= long_arg; } if(opcode > (unsigned)MMCO_LONG){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); return -1; } if(opcode == MMCO_END) break; } h->mmco_index= i; }else{ ff_generate_sliding_window_mmcos(h); } } return 0; }
1threat
static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) { char buffer[PATH_MAX]; if (strncmp(name, "user.virtfs.", 12) == 0) { errno = EACCES; return -1; } return lsetxattr(rpath(ctx, path, buffer), name, value, size, flags); }
1threat
static KVMSlot *kvm_lookup_slot(KVMState *s, target_phys_addr_t start_addr) { int i; for (i = 0; i < ARRAY_SIZE(s->slots); i++) { KVMSlot *mem = &s->slots[i]; if (start_addr >= mem->start_addr && start_addr < (mem->start_addr + mem->memory_size)) return mem; } return NULL; }
1threat
Insert a Row inside a Column in Flutter : <p>My UI screen is basically rendered using a Column Widget and inside this widget, I am inserting all the other UI components. One of these happens to be a Row ( consisting of 2 text fields). This is the Row Widget :</p> <pre><code>var phoneNumber = new Row( children: &lt;Widget&gt;[ new Padding( padding: const EdgeInsets.all(20.0), child: countryCodePicker, ), new Padding( padding: const EdgeInsets.all(20.0), child: mobileNumber, ), ], ); </code></pre> <p>The Main UI Screen being :</p> <pre><code> return SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: &lt;Widget&gt;[ customerName, emailAddress, // new Container( // child: deliveryOptionRow, // ), mobileNumber, countryCodePicker, templateMessagesDropDown, templateMessageTextField, sendGoogleReview, ], ) ); </code></pre> <p>I see this exception when I add the Row to the Column</p> <pre><code> The following RenderObject was being processed when the exception was fired: flutter: _RenderListTile#06b03 relayoutBoundary=up11 NEEDS-LAYOUT NEEDS-PAINT flutter: creator: _ListTile ← MediaQuery ← Padding ← SafeArea ← Semantics ← Listener ← _GestureSemantics ← flutter: RawGestureDetector ← GestureDetector ← InkWell ← ListTile ← ListTileTheme ← β‹― flutter: parentData: offset=Offset(0.0, 0.0) (can use size) flutter: constraints: BoxConstraints(unconstrained) flutter: size: MISSING flutter: This RenderObject had the following descendants (showing up to depth 5): flutter: _RenderRadio#302a4 relayoutBoundary=up12 NEEDS-PAINT flutter: RenderParagraph#58a45 NEEDS-LAYOUT NEEDS-PAINT </code></pre> <p>What would be the best way to add the row inside the main UI screen. </p>
0debug
How to check if string has at least 6 characters, one capital letter and one number? - Javascript : <p>as the title says I would like to check if a string contain at least 6 characters, one capital letter and one number, is required to use a <code>regex</code> or there is a simplier way to achieve this?</p> <p>Example of string: <code>Hello7</code></p> <p>I need help to create the regex to do this, can you give me some help? at least how to say that I required minimum a specific number of characters, thanks.</p>
0debug
how to normalize input data for models in tensorflow : <p>My training data are saved in 3 files, each file is too large and cannot fit into memory.For each training example, the data are two dimensionality (2805 rows and 222 columns, the 222nd column is for label) and are numerical values. I would like to normalize the data before feeding into models for training. Below is my code for input_pipeline, and the data has not been normalized before creating dataset. Is there some functions in tensorflow that can do normalization for my case? </p> <pre><code>dataset = tf.data.TextLineDataset([file1, file2, file3]) # combine 2805 lines into a single example dataset = dataset.batch(2805) def parse_example(line_batch): record_defaults = [[1.0] for col in range(0, 221)] record_defaults.append([1]) content = tf.decode_csv(line_batch, record_defaults = record_defaults, field_delim = '\t') features = tf.stack(content[0:221]) features = tf.transpose(features) label = content[-1][-1] label = tf.one_hot(indices = tf.cast(label, tf.int32), depth = 2) return features, label dataset = dataset.map(parse_example) dataset = dataset.shuffle(1000) # batch multiple examples dataset = dataset.batch(batch_size) dataset = dataset.repeat(num_epochs) iterator = dataset.make_one_shot_iterator() data_batch, label_batch = iterator.get_next() </code></pre>
0debug
Is it safe to put database login details in my App? : <p>Can reverse engineering it can make it easy to hack? Any another way to do it safely?</p> <p>I'm talking about both android and iOS apps.</p>
0debug
static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename) { uint32_t magic; if (buf_size < 4) return 0; magic = be32_to_cpu(*(uint32_t *)buf); if (magic == VMDK3_MAGIC || magic == VMDK4_MAGIC) { return 100; } else { const char *p = (const char *)buf; const char *end = p + buf_size; while (p < end) { if (*p == '#') { while (p < end && *p != '\n') { p++; } p++; continue; } if (*p == ' ') { while (p < end && *p == ' ') { p++; } if (p < end && *p == '\r') { p++; } if (p == end || *p != '\n') { return 0; } p++; continue; } if (end - p >= strlen("version=X\n")) { if (strncmp("version=1\n", p, strlen("version=1\n")) == 0 || strncmp("version=2\n", p, strlen("version=2\n")) == 0) { return 100; } } if (end - p >= strlen("version=X\r\n")) { if (strncmp("version=1\r\n", p, strlen("version=1\r\n")) == 0 || strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0) { return 100; } } return 0; } return 0; } }
1threat
Javascript string size limit: 256 MB for me - is it the same for all browsers? : <p>Curious about what was the maximum string length I could get in Javascript, I tested it myself, today, on my Firefox 43.0.1, running in Windows 7. I was able to construct a string with length <code>2^28 - 1</code>, but when I tried to create a string with one more char, <a href="http://getfirebug.com/" rel="noreferrer">Firebug</a> showed me the <em>"allocation size overflow"</em> error, meaning the string must be less than 256 MB.</p> <p><strong>Is this the same thing for all browsers, all computers, all operational systems, or it depends?</strong></p> <p>I created the following snippet to find out the limit:</p> <pre><code>(function() { strings = ["z"]; try { while(true) { strings.push(strings[strings.length - 1] + strings[strings.length - 1]); } } catch(err) { var k = strings.length - 2; while(k &gt;= 0) { try { strings.push(strings[strings.length - 1] + strings[k]); k--; } catch(err) {} } console.log("The maximum string length is " + strings[strings.length - 1].length); } })(); </code></pre> <p>If you are running a different browser/OS, I would like to see your results. My result was <em>The maximum string length is 268435455</em>.</p> <p><strong>P.S.:</strong> I searched around for an answer, but the most recent topic I found was from 2011, so I am looking for a more up-to-date information.</p>
0debug
my code says segmantation fault when i run it can someone help me? : <p>}<a href="https://i.stack.imgur.com/R015I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R015I.png" alt="enter image description here"></a></p> <p>but when I run it it says segmentation fault and apart from that, I don't know if the code is correct.</p> <p><a href="https://i.stack.imgur.com/Ncy8R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ncy8R.png" alt="enter image description here"></a></p>
0debug
Javascript date format issue 2018-04-11T17:47:00+0200 : <p>I have such date format as <code>2018-04-11T17:47:00+0200</code></p> <p>What format is? </p> <p>And how to generate it dynamically till the end of day?</p> <p>for example </p> <pre><code> var end = new Date(); end.setHours(23,59,59,999); </code></pre>
0debug
static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size, uint32_t node, bool dedicated_hp_event_source, Error **errp) { sPAPRDRConnector *drc; uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE; int i, fdt_offset, fdt_size; void *fdt; uint64_t addr = addr_start; for (i = 0; i < nr_lmbs; i++) { drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr / SPAPR_MEMORY_BLOCK_SIZE); g_assert(drc); fdt = create_device_tree(&fdt_size); fdt_offset = spapr_populate_memory_node(fdt, node, addr, SPAPR_MEMORY_BLOCK_SIZE); spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp); addr += SPAPR_MEMORY_BLOCK_SIZE; if (!dev->hotplugged) { sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE); drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOLATED); } } if (dev->hotplugged) { if (dedicated_hp_event_source) { drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr_start / SPAPR_MEMORY_BLOCK_SIZE); spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB, nr_lmbs, spapr_drc_index(drc)); } else { spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB, nr_lmbs); } } }
1threat
Passing array (c++) : Code: #include <stdio.h> #include <string.h> #include <malloc.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <iostream> using namespace std; void case1(); void case2(); void case3(); void case4(); void case5(); //Global variables const int MAXROW = 5; const int MAXCOL = 5; int main() { char selection; do //menu { cout << "\n\nMENU\n"; cout << "1. Enter array 5,5 \n"; cout << "2. Find max and min: \n"; cout << "3. Average of negatives: \n"; cout << "4. Product of numbers different from 0 \n"; cout << "5. Output: \n"; cout << "6. Exit.\n\n"; cin >> selection; switch (selection) { case '1': { system("cls"); case1(); } break; case '2': { //system("cls"); case2(); } break; case '3': { //system("cls"); case3(); } break; case '4': { //system("cls"); case4(); } break; case '5': { //system("cls"); case5(); } break; } } while (selection != '6'); return 0; } void case1() { int A[MAXROW][MAXCOL] = { 0 }; for (int r = 0; r < MAXROW; ++r) for (int c = 0; c < MAXCOL; ++c) { cout << "\n A[" << r << "][" << c << "]= "; cin >> A[r][c]; } } void case2() { int newarr[MAXROW + 1][MAXCOL + 1] = { 0 }; int max[MAXCOL] = { 0 }; for (int r = 0; r < MAXROW; ++r) { int minr = A[r][0]; for (int c = 0; c < MAXCOL; ++c) { newarr[r][c] = A[r][c]; if (minr > A[r][c]) minr = A[r][c]; if (max[c] < A[r][c]) max[c] = A[r][c]; } newarr[r][MAXCOL] = minr; } for (int c = 0; c < MAXCOL; ++c) newarr[MAXROW][c] = max[c]; for (int r = 0; r < MAXROW + 1; ++r) { for (int c = 0; c < MAXCOL + 1; ++c) newarr[r][c] ? cout << newarr[r][c] << "\t" : cout << " \t"; cout << "\n"; } { //Function to find average of negatives void case3(); { int negNumber = 0; double average = 0; for (int r = 0; r < 6; ++r) { for (int c = 0; c < 6; ++c) { if (newarr[r][c] < 0) { ++negNumber; average += newarr[r][c]; } } } if (negNumber > 0) { average /= negNumber; cout << "Average of negatives: \n" << average; } else cout << "No negatives.\n"; } void case4(); {//Function to find product of numbers different from 0 int count = 0; int product = 1; bool f = false; for (int r = 0; r < 6; ++r) for (int c = 0; c < 6; ++c) if (newarr[r][c] != 0) { ++count; product *= newarr[r][c]; f = true; } if (count != 0) cout << "\n Product of numbers different from 0 is: \n" << product << endl; else cout << "All elements are = 0"; } void case5(); { for (int r = 0; r < MAXROW + 1; ++r) { for (int c = 0; c < MAXCOL + 1; ++c) newarr[r][c] ? cout << newarr[r][c] << "\t" : cout << " \t"; cout << "\n"; } } } As you can see in case1() is the input array. What I wonder how to use this array in all other functions(case2,case3,case4,case5). I also define several global variables but i want to put them in the function case1(). (const int MAXROW = 5; const int MAXCOL = 5;) How will this happen? How to call them in the menu? For now my error list is full with "'A': undeclared identifier".
0debug
x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) { struct x11_grab *s = s1->priv_data; Display *dpy = s->dpy; XImage *image = s->image; int x_off = s->x_off; int y_off = s->y_off; int64_t curtime, delay; struct timespec ts; s->time_frame += INT64_C(1000000); for(;;) { curtime = av_gettime(); delay = s->time_frame * av_q2d(s->time_base) - curtime; if (delay <= 0) { if (delay < INT64_C(-1000000) * av_q2d(s->time_base)) { s->time_frame += INT64_C(1000000); } break; } ts.tv_sec = delay / 1000000; ts.tv_nsec = (delay % 1000000) * 1000; nanosleep(&ts, NULL); } av_init_packet(pkt); pkt->data = image->data; pkt->size = s->frame_size; pkt->pts = curtime; if(s->use_shm) { if (!XShmGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off, AllPlanes)) { av_log (s1, AV_LOG_INFO, "XShmGetImage() failed\n"); } } else { if (!xget_zpixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off)) { av_log (s1, AV_LOG_INFO, "XGetZPixmap() failed\n"); } } if(!s->nomouse){ paint_mouse_pointer(image, s); } return s->frame_size; }
1threat