problem
stringlengths
26
131k
labels
class label
2 classes
Probability Distribution Function : I have a set of raw data and I have to identify the distribution of that data. What is the easiest way to plot a probability distribution function? I have tried fitting it in normal distribution. But I am more curious to know which distribution does the data carry within itself ? I have no code to show my progress as I have failed to find any functions in python that will allow me to test the distribution of the dataset. I do not want to slice the data and force it to fit in may be normal or skew distribution. Is any way to determine the distribution of the dataset ? Any suggestion appreciated. Is this any correct approach ? [Example][1] This is something close what I am looking for but again it fits the data into normal distribution. [Example][2] [1]: http://stackoverflow.com/questions/7062936/probability-distribution-function-in-python [2]: http://stackoverflow.com/questions/23251759/how-to-determine-what-is-the-probability-distribution-function-from-a-numpy-arra
0debug
How to play a simple audio file (Java)? : <p>The question basically explains itself. I want to take an audio file (I can use any format really) and have Java output sound from it when called on.</p>
0debug
Regarding tree traversal : <p>Tried code for tree traversal but I'm not getting the expected output.</p> <pre><code>tree* insertion(int data) { tree *ptr=new tree(); ptr-&gt;data=data; ptr-&gt;left=NULL; ptr-&gt;right=NULL; } void preorder(tree* root) { if(root==NULL) return; cout&lt;&lt;root-&gt;data&lt;&lt;" "; preorder(root-&gt;left); preorder(root-&gt;right); } void postorder(tree* root) { if(root==NULL) return; preorder(root-&gt;left); preorder(root-&gt;right); cout&lt;&lt;root-&gt;data&lt;&lt;" "; } void inorder(tree* root) { if(root==NULL) return; preorder(root-&gt;left); cout&lt;&lt;root-&gt;data&lt;&lt;" "; preorder(root-&gt;right); } </code></pre> <p>expected output: (a) Inorder (Left, Root, Right) : 4 2 5 1 3 (b) Preorder (Root, Left, Right) : 1 2 4 5 3 (c) Postorder (Left, Right, Root) : 4 5 2 3 1</p> <p>My output: Preorder traversal : 1 2 4 5 3 Postorder traversal : 2 4 5 3 1 Inorder traversal : 2 4 5 1 3</p>
0debug
int cpu_load(QEMUFile *f, void *opaque, int version_id) { CPUCRISState *env = opaque; int i; int s; int mmu; for (i = 0; i < 16; i++) env->regs[i] = qemu_get_be32(f); for (i = 0; i < 16; i++) env->pregs[i] = qemu_get_be32(f); env->pc = qemu_get_be32(f); env->ksp = qemu_get_be32(f); env->dslot = qemu_get_be32(f); env->btaken = qemu_get_be32(f); env->btarget = qemu_get_be32(f); env->cc_op = qemu_get_be32(f); env->cc_mask = qemu_get_be32(f); env->cc_dest = qemu_get_be32(f); env->cc_src = qemu_get_be32(f); env->cc_result = qemu_get_be32(f); env->cc_size = qemu_get_be32(f); env->cc_x = qemu_get_be32(f); for (s = 0; s < 4; i++) { for (i = 0; i < 16; i++) env->sregs[s][i] = qemu_get_be32(f); } env->mmu_rand_lfsr = qemu_get_be32(f); for (mmu = 0; mmu < 2; mmu++) { for (s = 0; s < 4; i++) { for (i = 0; i < 16; i++) { env->tlbsets[mmu][s][i].lo = qemu_get_be32(f); env->tlbsets[mmu][s][i].hi = qemu_get_be32(f); } } } return 0; }
1threat
static unsigned int dec_move_pm(DisasContext *dc) { TCGv t0; int memsize; memsize = preg_sizes[dc->op2]; DIS(fprintf (logfile, "move.%c $p%u, [$r%u%s\n", memsize_char(memsize), dc->op2, dc->op1, dc->postinc ? "+]" : "]")); if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, dc->op2); cris_flush_cc_state(dc); gen_store(dc, cpu_R[dc->op1], t0, memsize); tcg_temp_free(t0); cris_cc_mask(dc, 0); if (dc->postinc) tcg_gen_addi_tl(cpu_R[dc->op1], cpu_R[dc->op1], memsize); return 2; }
1threat
Don't let GUI be freezed with parallel.for due to the reading of a big array : I'm trying to get a big string text array from a TextBox where lines are string[]. It works but the problem is that with big datas in input the GUI of program is freezed for a moment while it processes the entire size of the array (differently from async functions which don't let GUI to lag). To avoid the freeze i'm trying to use parallel for but the result seems the same... How can i fix this? string[] text= new string[textBox.Lines.Length + 1]; if (textBox.Lines.Length > 0) { Parallel.For(0, textBox.Lines.Length, x => { text[x] = textBox.Lines[x]; }); }
0debug
how to change the text of one button by clicking a second button in java : public class myJPanel6 extends JPanel implements ActionListene { myJButton b1, b2; student st1; String s1; public myJPanel6() { setLayout(new GridLayout(1,1)); student st1 = new student("Michael", "Robinson", 20); b1 = new myJButton(st1.getName()); b1.addActionListener(this); add(b1); b2 = new myJButton(st1.WhatIsUp()); b2.addActionListener(this); add(b2); } @Override public void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { s1=st1.WhatIsUp(); b2.setText(s1); } }` hello all!! i want to change the text of one button when i click on the second button, but it's do nothing, i don't know what is the problem in it. if anyone will help me as soon as possible then i would be really thankful and will appreciate every effort.
0debug
static void ppc_spapr_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; int i; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); target_phys_addr_t rma_alloc_size, rma_size; uint32_t initrd_base; long kernel_size, initrd_size, fw_size; long pteg_shift = 17; char *filename; spapr = g_malloc0(sizeof(*spapr)); QLIST_INIT(&spapr->phbs); cpu_ppc_hypercall = emulate_spapr_hypercall; rma_alloc_size = kvmppc_alloc_rma("ppc_spapr.rma", sysmem); if (rma_alloc_size == -1) { hw_error("qemu: Unable to create RMA\n"); exit(1); } if (rma_alloc_size && (rma_alloc_size < ram_size)) { rma_size = rma_alloc_size; } else { rma_size = ram_size; } spapr->fdt_addr = MIN(rma_size, 0x80000000) - FDT_MAX_SIZE; spapr->rtas_addr = spapr->fdt_addr - RTAS_MAX_SIZE; if (cpu_model == NULL) { cpu_model = kvm_enabled() ? "host" : "POWER7"; } for (i = 0; i < smp_cpus; i++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } cpu_ppc_tb_init(env, TIMEBASE_FREQ); qemu_register_reset((QEMUResetHandler *)&cpu_reset, env); env->hreset_vector = 0x60; env->hreset_excp_prefix = 0; env->gpr[3] = env->cpu_index; } spapr->ram_limit = ram_size; if (spapr->ram_limit > rma_alloc_size) { ram_addr_t nonrma_base = rma_alloc_size; ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size; memory_region_init_ram(ram, "ppc_spapr.ram", nonrma_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, nonrma_base, ram); } spapr->htab_size = 1ULL << (pteg_shift + 7); spapr->htab = qemu_memalign(spapr->htab_size, spapr->htab_size); for (env = first_cpu; env != NULL; env = env->next_cpu) { env->external_htab = spapr->htab; env->htab_base = -1; env->htab_mask = spapr->htab_size - 1; env->spr[SPR_SDR1] = (unsigned long)spapr->htab | ((pteg_shift + 7) - 18); env->spr[SPR_HIOR] = 0; if (kvm_enabled()) { kvmppc_set_papr(env); } } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); spapr->rtas_size = load_image_targphys(filename, spapr->rtas_addr, ram_size - spapr->rtas_addr); if (spapr->rtas_size < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", filename); exit(1); } g_free(filename); spapr->icp = xics_system_init(XICS_IRQS); spapr->next_irq = 16; spapr->vio_bus = spapr_vio_bus_init(); for (i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { spapr_vty_create(spapr->vio_bus, SPAPR_VTY_BASE_ADDRESS + i, serial_hds[i]); } } spapr_create_phb(spapr, "pci", SPAPR_PCI_BUID, SPAPR_PCI_MEM_WIN_ADDR, SPAPR_PCI_MEM_WIN_SIZE, SPAPR_PCI_IO_WIN_ADDR); for (i = 0; i < nb_nics; i++) { NICInfo *nd = &nd_table[i]; if (!nd->model) { nd->model = g_strdup("ibmveth"); } if (strcmp(nd->model, "ibmveth") == 0) { spapr_vlan_create(spapr->vio_bus, 0x1000 + i, nd); } else { pci_nic_init_nofail(&nd_table[i], nd->model, NULL); } } for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) { spapr_vscsi_create(spapr->vio_bus, 0x2000 + i); } if (kernel_filename) { uint64_t lowaddr = 0; kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, ram_size - KERNEL_LOAD_ADDR); } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } spapr->entry_point = KERNEL_LOAD_ADDR; } else { if (rma_size < (MIN_RMA_SLOF << 20)) { fprintf(stderr, "qemu: pSeries SLOF firmware requires >= " "%ldM guest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF); exit(1); } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, FW_FILE_NAME); fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE); if (fw_size < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", filename); exit(1); } g_free(filename); spapr->entry_point = 0x100; initrd_base = 0; initrd_size = 0; for (env = first_cpu; env != NULL; env = env->next_cpu) { env->halted = 1; } } spapr->fdt_skel = spapr_create_fdt_skel(cpu_model, rma_size, initrd_base, initrd_size, boot_device, kernel_cmdline, pteg_shift + 7); assert(spapr->fdt_skel != NULL); qemu_register_reset(spapr_reset, spapr); }
1threat
Want to print string contains 3 letters followed by 7 digits : <p>I am having an String like this </p> <pre><code>"ATS0657882\nPRX1686559\n name: something,hello" </code></pre> <p>Now i want to do is only get the "ATS0657882","PRX1686559", and so on,</p> <p>How can i do this, i used lot of ways but i cant find the solution.</p>
0debug
static void device_set_realized(Object *obj, bool value, Error **errp) { DeviceState *dev = DEVICE(obj); DeviceClass *dc = DEVICE_GET_CLASS(dev); HotplugHandler *hotplug_ctrl; BusState *bus; Error *local_err = NULL; bool unattached_parent = false; static int unattached_count; int ret; if (dev->hotplugged && !dc->hotpluggable) { error_setg(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj)); return; if (value && !dev->realized) { if (!obj->parent) { gchar *name = g_strdup_printf("device[%d]", unattached_count++); object_property_add_child(container_get(qdev_get_machine(), "/unattached"), name, obj, &error_abort); unattached_parent = true; g_free(name); hotplug_ctrl = qdev_get_hotplug_handler(dev); if (hotplug_ctrl) { hotplug_handler_pre_plug(hotplug_ctrl, dev, &local_err); if (local_err != NULL) { if (dc->realize) { dc->realize(dev, &local_err); if (local_err != NULL) { DEVICE_LISTENER_CALL(realize, Forward, dev); if (hotplug_ctrl) { hotplug_handler_plug(hotplug_ctrl, dev, &local_err); if (local_err != NULL) { goto post_realize_fail; if (qdev_get_vmsd(dev)) { if (vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, dev->instance_id_alias, dev->alias_required_for_version, &local_err) < 0) { goto post_realize_fail; QLIST_FOREACH(bus, &dev->child_bus, sibling) { object_property_set_bool(OBJECT(bus), true, "realized", &local_err); if (local_err != NULL) { goto child_realize_fail; if (dev->hotplugged) { device_reset(dev); dev->pending_deleted_event = false; } else if (!value && dev->realized) { Error **local_errp = NULL; QLIST_FOREACH(bus, &dev->child_bus, sibling) { local_errp = local_err ? NULL : &local_err; object_property_set_bool(OBJECT(bus), false, "realized", local_errp); if (qdev_get_vmsd(dev)) { vmstate_unregister(dev, qdev_get_vmsd(dev), dev); if (dc->unrealize) { local_errp = local_err ? NULL : &local_err; dc->unrealize(dev, local_errp); dev->pending_deleted_event = true; DEVICE_LISTENER_CALL(unrealize, Reverse, dev); if (local_err != NULL) { dev->realized = value; return; child_realize_fail: QLIST_FOREACH(bus, &dev->child_bus, sibling) { object_property_set_bool(OBJECT(bus), false, "realized", NULL); if (qdev_get_vmsd(dev)) { vmstate_unregister(dev, qdev_get_vmsd(dev), dev); post_realize_fail: if (dc->unrealize) { dc->unrealize(dev, NULL); fail: error_propagate(errp, local_err); if (unattached_parent) { object_unparent(OBJECT(dev)); unattached_count--;
1threat
AVRational av_d2q(double d, int max) { AVRational a; #define LOG2 0.69314718055994530941723212145817656807550013436025 int exponent; int64_t den; if (isnan(d)) return (AVRational) { 0,0 }; if (isinf(d)) return (AVRational) { d < 0 ? -1 : 1, 0 }; exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); den = 1LL << (61 - exponent); av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); return a; }
1threat
QEMUSizedBuffer *qsb_create(const uint8_t *buffer, size_t len) { QEMUSizedBuffer *qsb; size_t alloc_len, num_chunks, i, to_copy; size_t chunk_size = (len > QSB_MAX_CHUNK_SIZE) ? QSB_MAX_CHUNK_SIZE : QSB_CHUNK_SIZE; num_chunks = DIV_ROUND_UP(len ? len : QSB_CHUNK_SIZE, chunk_size); alloc_len = num_chunks * chunk_size; qsb = g_try_new0(QEMUSizedBuffer, 1); if (!qsb) { return NULL; } qsb->iov = g_try_new0(struct iovec, num_chunks); if (!qsb->iov) { g_free(qsb); return NULL; } qsb->n_iov = num_chunks; for (i = 0; i < num_chunks; i++) { qsb->iov[i].iov_base = g_try_malloc0(chunk_size); if (!qsb->iov[i].iov_base) { qsb_free(qsb); return NULL; } qsb->iov[i].iov_len = chunk_size; if (buffer) { to_copy = (len - qsb->used) > chunk_size ? chunk_size : (len - qsb->used); memcpy(qsb->iov[i].iov_base, &buffer[qsb->used], to_copy); qsb->used += to_copy; } } qsb->size = alloc_len; return qsb; }
1threat
What will happened when deno will come : <p>What will be happening with react or webpack, which use node js, when deno will come and not exist node js.<br> Then also will express die?</p>
0debug
Making some sort of n00b mistake here - "The name 'var' does not exist in the current context" : So I'm a beginner with c# experimenting with the Microsoft.Office.Interop.Excel reference, and I've ran into an issue. Here's my main form: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.Office.Interop.Excel; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void Form1_Load(object sender, EventArgs e) { var BankAccounts = new List<Account> { new Account { ID = 345, Balance = 541.27 }, new Account { ID = 123, Balance = -127.44 } }; } public void button1_Click(object sender, EventArgs e) { ThisAddIn.DisplayInExcel(BankAccounts, (Account, cell) => // This multiline lambda expression sets custom processing rules // for the bankAccounts. { cell.Value = Account.ID; cell.Offset[0, 1].Value = Account.Balance; if (Account.Balance < 0) { cell.Interior.Color = 255; cell.Offset[0, 1].Interior.Color = 255; } }); } } } Returns the error: > The name 'BankAccounts' does not exist in the current context I can't understand how this is happening, could someone please help me fix this and perhaps explain what's caused it? Thanks a lot!
0debug
How to convert Var to ArrayList : Connot convert from var to ArrayList This is my model class to access the datagrid row details. public class pojo { public string Prefix { get; set; } public int Year { get; set; } public int Quarter { get; set; } public int SerialNo { get; set; } public string From { get; set; } public string To { get; set; } public string PeriodName { get; set; } } got all the cell values by using the below code... I read the row details from datagrid(calendarmstrDG) by using the below format how to convert var to Arraylist..? var rowdata = calendarmstrDG.SelectedItem as pojo;
0debug
Change the text in summary order (Prestashop 1.6.1.17) : Bonjour, I build a website based on Prestashop 1.6.1.17. I'd like to change the text circled in red in the summary order : [http://terrepourtous.free.fr/Issue2.jpg][1] To be exact, I'd like to replace "Total produits ()" by "Total produits" (without "()"). Could you help me ? Thanks ! [1]: https://i.stack.imgur.com/N7ZnY.jpg
0debug
Is it possible to use the computed properties to compute another properties in Vue? : <p>If I have a two computed properties like this,</p> <pre><code>computed: { id: function(){ return this.$route.query.id; }, hasId: function(){ return this.$route.query.id !== undefined; } } </code></pre> <p>how can I use <code>id</code> to compute <code>hasId</code> like this pseudo-code?</p> <pre><code>computed: { id: function(){ return this.$route.query.id; }, hasId: function(){ return id !== undefined; } } </code></pre>
0debug
static int xan_unpack_luma(const uint8_t *src, const int src_size, uint8_t *dst, const int dst_size) { int tree_size, eof; const uint8_t *tree; int bits, mask; int tree_root, node; const uint8_t *dst_end = dst + dst_size; const uint8_t *src_end = src + src_size; tree_size = *src++; eof = *src++; tree = src - eof * 2 - 2; tree_root = eof + tree_size; src += tree_size * 2; node = tree_root; bits = *src++; mask = 0x80; for (;;) { int bit = !!(bits & mask); mask >>= 1; node = tree[node*2 + bit]; if (node == eof) break; if (node < eof) { *dst++ = node; if (dst > dst_end) break; node = tree_root; } if (!mask) { bits = *src++; if (src > src_end) break; mask = 0x80; } } return dst != dst_end; }
1threat
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Use .net core with legacy .net framework dlls : <p>Can I use .net core with legacy .net framework dlls? The answer seems to be no... but I can only find resources referring to <strong>project.json, which doesn't exist anymore.</strong></p> <p>I created a new .net core library and tried to reference a legacy .net framework DLL. When I tried to call into the DLL, vs2017 complained that I didn't have the Stream object is was looking for.</p> <p>It suggested I reference either mscorlib.dll or installa Nuget package. </p> <p>The quick help failed to reference mscorlib.dll. If I manually referenced it, I get the following error:</p> <blockquote> <p>The type 'TargetFrameworkAttribute' exists in both 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' C:\Users...\AppData\Local\Temp.NETCoreApp,Version=v1.1.AssemblyAttributes.cs</p> </blockquote> <p>The NuGet package is Microsoft.NETFx2.0. The quick help fails to install it. If I run it from the command line:</p> <pre><code>&gt; PM&gt; install-package microsoft.netfx20 GET &gt; https://api.nuget.org/v3/registration2-gz/microsoft.netfx20/index.json &gt; OK &gt; https://api.nuget.org/v3/registration2-gz/microsoft.netfx20/index.json &gt; 46ms Restoring packages for ... Install-Package : Package &gt; Microsoft.NetFX20 1.0.3 is not compatible with netcoreapp1.1 &gt; (.NETCoreApp,Version=v1.1). Package Microsoft.NetFX20 1.0.3 supports: &gt; net20 (.NETFramework,Version=v2.0)At line:1 char:1 &gt; + install-package microsoft.netfx20 &gt; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &gt; + CategoryInfo : NotSpecified: (:) [Install-Package], Exception &gt; + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand &gt; Install-Package : One or more packages are incompatible with &gt; .NETCoreApp,Version=v1.1.At line:1 char:1 &gt; + install-package microsoft.netfx20 &gt; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &gt; + CategoryInfo : NotSpecified: (:) [Install-Package], Exception &gt; + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand &gt; Install-Package : Package restore failed. Rolling back package changes &gt; for .At line:1 char:1 &gt; + install-package microsoft.netfx20 &gt; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &gt; + CategoryInfo : NotSpecified: (:) [Install-Package], Exception &gt; + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand &gt; Time Elapsed: 00:00:00.8035644 </code></pre>
0debug
int virtio_scsi_common_exit(VirtIOSCSICommon *vs) { VirtIODevice *vdev = VIRTIO_DEVICE(vs); g_free(vs->cmd_vqs); virtio_cleanup(vdev); return 0; }
1threat
static int nbd_negotiate_handle_info(NBDClient *client, uint16_t myflags, Error **errp) { int rc; char name[NBD_MAX_NAME_SIZE + 1]; NBDExport *exp; uint16_t requests; uint16_t request; uint32_t namelen; bool sendname = false; bool blocksize = false; uint32_t sizes[3]; char buf[sizeof(uint64_t) + sizeof(uint16_t)]; const char *msg; if (client->optlen < sizeof(namelen) + sizeof(requests)) { msg = "overall request too short"; goto invalid; } if (nbd_read(client->ioc, &namelen, sizeof(namelen), errp) < 0) { return -EIO; } be32_to_cpus(&namelen); client->optlen -= sizeof(namelen); if (namelen > client->optlen - sizeof(requests) || (client->optlen - namelen) % 2) { msg = "name length is incorrect"; goto invalid; } if (namelen >= sizeof(name)) { msg = "name too long for qemu"; goto invalid; } if (nbd_read(client->ioc, name, namelen, errp) < 0) { return -EIO; } name[namelen] = '\0'; client->optlen -= namelen; trace_nbd_negotiate_handle_export_name_request(name); if (nbd_read(client->ioc, &requests, sizeof(requests), errp) < 0) { return -EIO; } be16_to_cpus(&requests); client->optlen -= sizeof(requests); trace_nbd_negotiate_handle_info_requests(requests); if (requests != client->optlen / sizeof(request)) { msg = "incorrect number of requests for overall length"; goto invalid; } while (requests--) { if (nbd_read(client->ioc, &request, sizeof(request), errp) < 0) { return -EIO; } be16_to_cpus(&request); client->optlen -= sizeof(request); trace_nbd_negotiate_handle_info_request(request, nbd_info_lookup(request)); switch (request) { case NBD_INFO_NAME: sendname = true; break; case NBD_INFO_BLOCK_SIZE: blocksize = true; break; } } assert(client->optlen == 0); exp = nbd_export_find(name); if (!exp) { return nbd_negotiate_send_rep_err(client, NBD_REP_ERR_UNKNOWN, errp, "export '%s' not present", name); } if (sendname) { rc = nbd_negotiate_send_info(client, NBD_INFO_NAME, namelen, name, errp); if (rc < 0) { return rc; } } if (exp->description) { size_t len = strlen(exp->description); rc = nbd_negotiate_send_info(client, NBD_INFO_DESCRIPTION, len, exp->description, errp); if (rc < 0) { return rc; } } sizes[0] = (client->opt == NBD_OPT_INFO || blocksize) ? BDRV_SECTOR_SIZE : 1; sizes[1] = 4096; sizes[2] = MIN(blk_get_max_transfer(exp->blk), NBD_MAX_BUFFER_SIZE); trace_nbd_negotiate_handle_info_block_size(sizes[0], sizes[1], sizes[2]); cpu_to_be32s(&sizes[0]); cpu_to_be32s(&sizes[1]); cpu_to_be32s(&sizes[2]); rc = nbd_negotiate_send_info(client, NBD_INFO_BLOCK_SIZE, sizeof(sizes), sizes, errp); if (rc < 0) { return rc; } trace_nbd_negotiate_new_style_size_flags(exp->size, exp->nbdflags | myflags); stq_be_p(buf, exp->size); stw_be_p(buf + 8, exp->nbdflags | myflags); rc = nbd_negotiate_send_info(client, NBD_INFO_EXPORT, sizeof(buf), buf, errp); if (rc < 0) { return rc; } if (client->opt == NBD_OPT_INFO && !blocksize) { return nbd_negotiate_send_rep_err(client, NBD_REP_ERR_BLOCK_SIZE_REQD, errp, "request NBD_INFO_BLOCK_SIZE to " "use this export"); } rc = nbd_negotiate_send_rep(client, NBD_REP_ACK, errp); if (rc < 0) { return rc; } if (client->opt == NBD_OPT_GO) { client->exp = exp; QTAILQ_INSERT_TAIL(&client->exp->clients, client, next); nbd_export_get(client->exp); rc = 1; } return rc; invalid: if (nbd_drop(client->ioc, client->optlen, errp) < 0) { return -EIO; } return nbd_negotiate_send_rep_err(client, NBD_REP_ERR_INVALID, errp, "%s", msg); }
1threat
static int ahci_dma_set_inactive(IDEDMA *dma) { AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); DPRINTF(ad->port_no, "dma done\n"); ahci_write_fis_d2h(ad, NULL); ad->dma_cb = NULL; ad->check_bh = qemu_bh_new(ahci_check_cmd_bh, ad); qemu_bh_schedule(ad->check_bh); return 0; }
1threat
CNN Image Recognition with Regression Output on Tensorflow : <p>I want to predict the estimated wait time based on images using a CNN. So I would imagine that this would use a CNN to output a regression type output using a loss function of RMSE which is what I am using right now, but it is not working properly.</p> <p>Can someone point out examples that use CNN image recognition to output a scalar/regression output (instead of a class output) similar to wait time so that I can use their techniques to get this to work because I haven't been able to find a suitable example.</p> <p>All of the CNN examples that I found are for the MSINT data and distinguishing between cats and dogs which output a class output, not a number/scalar output of wait time.</p> <p>Can someone give me an example using tensorflow of a CNN giving a scalar or regression output based on image recognition. </p> <p>Thanks so much! I am honestly super stuck and am getting no progress and it has been over two weeks working on this same problem.</p>
0debug
java mongodb driver how do you catch exceptions? : <p>I want to be able to detect if a mongo server is available from the java driver for the purpose of reacting to any abnormal events as one would in JDBC land etc. It all works fine when the server is up but I am struggling to understand why it is so difficult to detect errors. I have a feeling its because the mongo client runs in a different thread and it doesn't re throw to me or something?</p> <pre><code>try { MongoClient mongoClient = new MongoClient("localhost", 27017); MongoDatabase db = mongoClient.getDatabase("mydb"); // if db is down or error getting people collection handle it in catch block MongoCollection&lt;Document&gt; people = commentarr.getCollection("people"); } catch (Exception e) { // handle server down or failed query here. } </code></pre> <p>The result is </p> <pre><code>INFO: Exception in monitor thread while connecting to server localhost:27017 </code></pre> <p>With the resulting stack trace containing a few different exceptions which I have tried to catch but my catch blocks still didn't do anything.</p> <pre><code>com.mongodb.MongoSocketOpenException: Exception opening socket Caused by: java.net.ConnectException: Connection refused </code></pre> <p>I am using the java mongodb driver 3.0.4, most posts I read are from an older API with hacks like <code>MongoClient.getDatabaseNames()</code> which throws a <code>MongoException</code> if errors, except this is deprecated now and replaced with <code>MongoClient.listDatabaseNames()</code> which doesn't have the same error throwing semantics.</p> <p>Is there a way to just execute a mongo query from the java driver in a try catch block and actually have the exception caught?</p>
0debug
uint32_t HELPER(rrbe)(uint32_t r1, uint64_t r2) { if (r2 > ram_size) { return 0; } #if 0 env->storage_keys[r2 / TARGET_PAGE_SIZE] &= ~SK_REFERENCED; #endif return 0; }
1threat
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MpegEncContext *s = avctx->priv_data; int ret; AVFrame *pict = data; s->flags = avctx->flags; s->flags2 = avctx->flags2; if (buf_size == 0) { if (s->low_delay == 0 && s->next_picture_ptr) { if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0) return ret; s->next_picture_ptr = NULL; *got_frame = 1; } return 0; } if (s->flags & CODEC_FLAG_TRUNCATED) { int next; if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4) { next = ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size); } else if (CONFIG_H263_DECODER && s->codec_id == AV_CODEC_ID_H263) { next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size); } else { av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n"); return AVERROR(ENOSYS); } if (ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0) return buf_size; } if (s->bitstream_buffer_size && (s->divx_packed || buf_size < 20)) ret = init_get_bits8(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); else ret = init_get_bits8(&s->gb, buf, buf_size); s->bitstream_buffer_size = 0; if (ret < 0) return ret; if (!s->context_initialized) if ((ret = ff_MPV_common_init(s)) < 0) return ret; if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { int i = ff_find_unused_picture(s, 0); if (i < 0) return i; s->current_picture_ptr = &s->picture[i]; } if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { ret = ff_wmv2_decode_picture_header(s); } else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) { ret = ff_msmpeg4_decode_picture_header(s); } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { if (s->avctx->extradata_size && s->picture_number == 0) { GetBitContext gb; ret = init_get_bits8(&gb, s->avctx->extradata, s->avctx->extradata_size); if (ret < 0) return ret; ff_mpeg4_decode_picture_header(avctx->priv_data, &gb); } ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb); } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) { ret = ff_intel_h263_decode_picture_header(s); } else if (CONFIG_FLV_DECODER && s->h263_flv) { ret = ff_flv_decode_picture_header(s); } else { ret = ff_h263_decode_picture_header(s); } if (ret == FRAME_SKIPPED) return get_consumed_bytes(s, buf_size); if (ret < 0) { av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); return ret; } avctx->has_b_frames = !s->low_delay; #define SET_QPEL_FUNC(postfix1, postfix2) \ s->dsp.put_ ## postfix1 = ff_put_ ## postfix2; \ s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2; \ s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; if (s->workaround_bugs & FF_BUG_STD_QPEL) { SET_QPEL_FUNC(qpel_pixels_tab[0][5], qpel16_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][7], qpel16_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][9], qpel16_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][5], qpel8_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][7], qpel8_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][9], qpel8_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c) } if (s->width != avctx->coded_width || s->height != avctx->coded_height || s->context_reinit) { s->context_reinit = 0; ret = ff_set_dimensions(avctx, s->width, s->height); if (ret < 0) return ret; if ((ret = ff_MPV_common_frame_size_change(s))) return ret; } if (s->codec_id == AV_CODEC_ID_H263 || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I) s->gob_index = ff_h263_get_gob_height(s); s->current_picture.f.pict_type = s->pict_type; s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) return get_consumed_bytes(s, buf_size); if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return get_consumed_bytes(s, buf_size); if (s->next_p_frame_damaged) { if (s->pict_type == AV_PICTURE_TYPE_B) return get_consumed_bytes(s, buf_size); else s->next_p_frame_damaged = 0; } if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) { s->me.qpel_put = s->dsp.put_qpel_pixels_tab; s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab; } else { s->me.qpel_put = s->dsp.put_no_rnd_qpel_pixels_tab; s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab; } if ((ret = ff_MPV_frame_start(s, avctx)) < 0) return ret; if (!s->divx_packed && !avctx->hwaccel) ff_thread_finish_setup(avctx); if (avctx->hwaccel) { ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer); if (ret < 0 ) return ret; } ff_mpeg_er_frame_start(s); if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { ret = ff_wmv2_decode_secondary_picture_header(s); if (ret < 0) return ret; if (ret == 1) goto intrax8_decoded; } s->mb_x = 0; s->mb_y = 0; ret = decode_slice(s); while (s->mb_y < s->mb_height) { if (s->msmpeg4_version) { if (s->slice_height == 0 || s->mb_x != 0 || (s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0) break; } else { int prev_x = s->mb_x, prev_y = s->mb_y; if (ff_h263_resync(s) < 0) break; if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x) s->er.error_occurred = 1; } if (s->msmpeg4_version < 4 && s->h263_pred) ff_mpeg4_clean_buffers(s); if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA; } if (s->msmpeg4_version && s->msmpeg4_version < 4 && s->pict_type == AV_PICTURE_TYPE_I) if (!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0) s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR; assert(s->bitstream_buffer_size == 0); if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) ff_mpeg4_frame_end(avctx, buf, buf_size); intrax8_decoded: ff_er_frame_end(&s->er); if (avctx->hwaccel) { ret = avctx->hwaccel->end_frame(avctx); if (ret < 0) return ret; } ff_MPV_frame_end(s); if (!s->divx_packed && avctx->hwaccel) ff_thread_finish_setup(avctx); assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); assert(s->current_picture.f.pict_type == s->pict_type); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr); } else if (s->last_picture_ptr != NULL) { if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr); } if (s->last_picture_ptr || s->low_delay) *got_frame = 1; if (ret && (avctx->err_recognition & AV_EF_EXPLODE)) return ret; else return get_consumed_bytes(s, buf_size); }
1threat
static void invalid_array_comma(void) { QObject *obj = qobject_from_json("[32,}", NULL); g_assert(obj == NULL); }
1threat
Fastest way to generate a random-like unique string with random length in Python 3 : <p>I know how to create random string, like:</p> <pre><code>''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(N)) </code></pre> <p>However, there should be no duplicates so what I am currently just checking if the key already exists in a list, like shown in the following code:</p> <pre><code>import secrets import string import numpy as np amount_of_keys = 40000 keys = [] for i in range(0,amount_of_keys): N = np.random.randint(12,20) n_key = ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(N)) if not n_key in keys: keys.append(n_key) </code></pre> <p>Which is okay for a small amount of keys like <code>40000</code>, however the problem does not scale well the more keys there are. So I am wondering if there is a faster way to get to the result for even more keys, like <code>999999</code></p>
0debug
How can I get randomly generated numbers between 0 to 99 with 0 and 99 included? : <p>Use a random number function to randomly generate 10 integers between 0 and 99 with 0 and 99 included</p>
0debug
static void debugcon_ioport_write(void *opaque, hwaddr addr, uint64_t val, unsigned width) { DebugconState *s = opaque; unsigned char ch = val; #ifdef DEBUG_DEBUGCON printf(" [debugcon: write addr=0x%04" HWADDR_PRIx " val=0x%02" PRIx64 "]\n", addr, val); #endif qemu_chr_fe_write(s->chr, &ch, 1); }
1threat
Converting and adding variables in ruby : puts 'Hello mate what is thy first name?' name1 = gets.chomp puts 'Your name is ' + name1 + ' eh? What is thy middle name?' name2 = gets.chomp puts 'What is your last name then ' + name1 + '?' name3 = gets.chomp Puts 'Oh! So your full name is ' + name1 + ' ' + name2 + ' ' + name3 + ' ?' puts 'That is lovey!' puts 'did you know there are ' ' + name1.length.to_i + '+' + 'name2.length.to_i + '+' + name3.length.to_i + '' in your full name I am fairly new to this and I am having trouble with taking a gets.chomp defined variable and either adding it to another variable or adding it to an integer. Any Ideas?
0debug
This view is not constrained : <p>I get the following error and I am using Android studio 2.2 Preview 3. I searched Google but couldn't find any resources.</p> <pre><code>Error: This view is not constrained, it only has design time positions, so it will jump to (0,0) unless you add constraints </code></pre> <p><a href="https://i.stack.imgur.com/nCbmX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nCbmX.png" alt="enter image description here"></a></p> <pre><code>&lt;TextView android:layout_width="384dp" android:layout_height="207dp" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/calc_default_display" android:id="@+id/textView" android:background="#ffffff" android:layout_margin="0dp" android:gravity="bottom|end" android:textSize="70sp" android:nestedScrollingEnabled="false" android:maxLines="2" android:maxLength="17" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="0dp" /&gt; </code></pre>
0debug
how to add or replace textfield input text to picker view text in swift3 : I'm doing adding an array of strings to pickerview.When scrolling picker text changes in a text field.But I need to add and replace in that array text when I type in the text field
0debug
Using 1 login screen activity for different activities on Android Studio : i'm currently developing an Android app in Android Studio and i'm trying to use only one login screen for two different screens instead of using two login screens which will use the phone memory more. I tried using if and else statements where if button 1 was clicked then send to screen 1. Below is my code: public void userLogin() { String userEmail = email.getText().toString(); String userPass = password.getText().toString(); if(TextUtils.isEmpty(userEmail)){ Toast.makeText(LoginActivity.this, "Please Enter Email", Toast.LENGTH_SHORT).show(); } if(TextUtils.isEmpty(userPass)){ Toast.makeText(LoginActivity.this, "Please Enter Password", Toast.LENGTH_SHORT).show(); } auth.signInWithEmailAndPassword(userEmail, userPass) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if(task.isSuccessful()){ progressDialog.dismiss(); finish(); if (mainactivity.type == 1) { Toast.makeText(LoginActivity.this, "Login Successful", Toast.LENGTH_SHORT).show(); startActivity(new Intent(LoginActivity.this, EmployeeActivity.class)); } if(mainactivity.type == 2){ Toast.makeText(LoginActivity.this, "Login Successful", Toast.LENGTH_SHORT).show(); startActivity(new Intent(LoginActivity.this, AdminActivity.class)); } }else{ Toast.makeText(LoginActivity.this, "ERROR: Invalid Email or Password", Toast.LENGTH_SHORT).show(); progressDialog.dismiss(); } } }); } Any help would be much appreciated as i'm totally new to app development.
0debug
How to call a function of a class from a for loop in python : I have a list which contains functions of a class, i want to iterate through that list and call the function. i have created an object for the class a=class1() list_functions=['add("pavan",9)', 'add("pavan2",9:10)', 'add("pavan3",9:30)', 'add("pavan4",9:40)', ''] my for loop will be for i in range(len(list_functions)): a.[list_functions[i]] But this gives me an error.
0debug
static int ogg_write_trailer(AVFormatContext *s) { int i; for (i = 0; i < s->nb_streams; i++) ogg_buffer_page(s, s->streams[i]->priv_data); ogg_write_pages(s, 1); for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; OGGStreamContext *oggstream = st->priv_data; if (st->codec->codec_id == CODEC_ID_FLAC || st->codec->codec_id == CODEC_ID_SPEEX) { av_free(oggstream->header[0]); } av_freep(&st->priv_data); } return 0; }
1threat
VSCode: How do you autoformat on save? : <p>In Visual Studio Code, how do you automatically format your source code when the file is saved?</p>
0debug
How to play sound in a docker container : <p>I'm trying to dockerize a text to speech application for sharing the code with other developers, however the issue I am having right now is the docker container cannot find the sound card on my host machine. </p> <p>When I try to play a wav file in my docker container</p> <pre><code>root@3e9ef1e869ea:/# aplay Alesis-Fusion-Acoustic-Bass-C2.wav ALSA lib confmisc.c:768:(parse_card) cannot find card '0' ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default aplay: main:722: audio open error: No such file or directory </code></pre> <p>I guess that the main problem is docker container is unable reach the sound card on my host. </p> <p>So far I have </p> <ol> <li>I installed alsa-utils and most of the alsa dependencies within my docker container. </li> <li>Added <code>--group-add audio</code> while running the container by specifying <code>docker run --group-add audio -t -i self/debian /bin/bash</code></li> </ol> <p>I am not sure if this is even possible with docker(I'm not exactly sure of how hardware resources such as sound cards are shared with containers). I'm using a debian container on a Mac OS Yosemite host. </p>
0debug
how to push array to json object in angular : // i have an obj like below let obj = {staff_changes: []}; // testcase-1 success for (let i = 0; i < 4; i++) { obj.staff_changes.push({ id: 'staff'+i }); } // testcase -2 failed let obj = {staff_changes: []}; for (let i = 0; i < 4; i++) { obj.staff_changes.push({ id: i, newStaff.push({ id: 'staff'+i }); }); } console.log(obj); in testcase2 i am trying to push an array with name 'newStaff' even it is not present in obj. in console obj with 4 items is displaying but 'newStaff' is not pushing to obj. it is my application requirement please help me
0debug
C# - How to use start arguments : <p>I would like to use start arguments when launching my program. Eg:</p> <pre><code>c:\my.exe -arg1 </code></pre> <p>Like some programs use arguments like:</p> <pre><code>-silent </code></pre> <p>If searched for information but could not find anything to help. Thanks!</p>
0debug
MissingPluginException while using plugin for flutter : <p>I am trying to use the plugin </p> <pre><code>_launchURL(url) async { await launch("www.google.com"); } </code></pre> <p>I have put "www.google.com" just for debugging purposes.</p> <p>The error I get is MissingPluginException :</p> <pre><code>E/flutter ( 8299): MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher) E/flutter ( 8299): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7) E/flutter ( 8299): &lt;asynchronous suspension&gt; E/flutter ( 8299): #1 launch (package:url_launcher/url_launcher.dart:47:19) E/flutter ( 8299): #2 _launchURL (file:///Users/matejsimunic/Work/dart/suhail/lib/main.dart:834:9) E/flutter ( 8299): &lt;asynchronous suspension&gt; E/flutter ( 8299): #3 _TripDetailBodyState.build.&lt;anonymous closure&gt; (file:///Users/matejsimunic/Work/dart/suhail/lib/main.dart:818:19) E/flutter ( 8299): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:494:14) E/flutter ( 8299): #5 _InkResponseState.build.&lt;anonymous closure&gt; (package:flutter/src/material/ink_well.dart:549:30) E/flutter ( 8299): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24) E/flutter ( 8299): #7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9) E/flutter ( 8299): #8 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:94:7) E/flutter ( 8299): #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9) E/flutter ( 8299): #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12) E/flutter ( 8299): #11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11) E/flutter ( 8299): #12 _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19) E/flutter ( 8299): #13 _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22) E/flutter ( 8299): #14 _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7) E/flutter ( 8299): #15 _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7) E/flutter ( 8299): #16 _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7) E/flutter ( 8299): #17 _invoke1 (dart:ui/hooks.dart:134:13) E/flutter ( 8299): #18 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5) </code></pre> <p>restarting the app from ide doesn't work.</p>
0debug
Angular Materials 7.1.1 not working with Angular 7 : I am using the latest versions of Angular Materials and Angular. I have followed this guide to install -> https://material.angular.io/guide/getting-started. I have tried this example -> https://stackblitz.com/angular/jamkkvgbkjkg?file=app%2Finput-overview-example.ts I created the project using Visual Studio Code. Everything is straight forward but the controls do not render. https://github.com/jarninjanas/stackoverflow.git
0debug
what's the simplest way to create a div table with a centered header? : <p>I need to create a div table (display:table, table-row, etc) with a centered header on top and a 1px border all the way around. What is the simplest way to do this?</p>
0debug
Extracting a sub array from PySpark DataFrame column : <p>I wish to remove the last element of the array from this DataFrame. We have this <a href="https://stackoverflow.com/questions/40134975/selecting-a-range-of-elements-in-an-array-spark-sql/40136386">link</a> demonstrating the same thing, but with <code>UDFs</code> and that I wish to avoid. Is there is simple way to do this - something like <code>list[:2]</code>?</p> <pre><code>data = [(['cat','dog','sheep'],),(['bus','truck','car'],),(['ice','pizza','pasta'],)] df = sqlContext.createDataFrame(data,['data']) df.show() +-------------------+ | data| +-------------------+ | [cat, dog, sheep]| | [bus, truck, car]| |[ice, pizza, pasta]| +-------------------+ </code></pre> <p>Expected DataFrame:</p> <pre><code>+--------------+ | data| +--------------+ | [cat, dog]| | [bus, truck]| | [ice, pizza]| +--------------+ </code></pre>
0debug
Making sure an email has not been used before in a registration form : <p>So I am trying to make sure in my registration that an email has not already been used and store in my database. How do i do this? So far I have go to the point of using an SQL statement to check the database for any results and if there are any then it should do... but I don't know what it should do.</p>
0debug
What kind of knowledge and technologies needed to develop an specific mobile app? : <p>I had chosen to develop an mobile app for my final year project. The app is an parenting application that help parent to monitor and control screen time of their children and it have some function such as: - Send notification to the parent mobile device when the child start to use the device. - Lock the phone at certain time or by choice. - Location tracking (optional) - Report on use-time.</p> <p>I'm familiar with basic Java and Android programming.</p> <p>So what are the other knowledge (technology, mechanism, etc) that i will needed to develop this app.</p>
0debug
long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) { long ret; struct stat st; struct statfs stfs; void *p; #ifdef DEBUG gemu_log("syscall %d", num); #endif switch(num) { case TARGET_NR_exit: #ifdef HAVE_GPROF _mcleanup(); #endif gdb_exit(cpu_env, arg1); _exit(arg1); ret = 0; break; case TARGET_NR_read: page_unprotect_range(arg2, arg3); p = lock_user(arg2, arg3, 0); ret = get_errno(read(arg1, p, arg3)); unlock_user(p, arg2, ret); break; case TARGET_NR_write: p = lock_user(arg2, arg3, 1); ret = get_errno(write(arg1, p, arg3)); unlock_user(p, arg2, 0); break; case TARGET_NR_open: p = lock_user_string(arg1); ret = get_errno(open(path(p), target_to_host_bitmask(arg2, fcntl_flags_tbl), arg3)); unlock_user(p, arg1, 0); break; case TARGET_NR_close: ret = get_errno(close(arg1)); break; case TARGET_NR_brk: ret = do_brk(arg1); break; case TARGET_NR_fork: ret = get_errno(do_fork(cpu_env, SIGCHLD, 0)); break; #ifdef TARGET_NR_waitpid case TARGET_NR_waitpid: { int status; ret = get_errno(waitpid(arg1, &status, arg3)); if (!is_error(ret) && arg2) tput32(arg2, status); } break; #endif #ifdef TARGET_NR_creat case TARGET_NR_creat: p = lock_user_string(arg1); ret = get_errno(creat(p, arg2)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_link: { void * p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); ret = get_errno(link(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; case TARGET_NR_unlink: p = lock_user_string(arg1); ret = get_errno(unlink(p)); unlock_user(p, arg1, 0); break; case TARGET_NR_execve: { char **argp, **envp; int argc, envc; target_ulong gp; target_ulong guest_argp; target_ulong guest_envp; target_ulong addr; char **q; argc = 0; guest_argp = arg2; for (gp = guest_argp; tgetl(gp); gp++) argc++; envc = 0; guest_envp = arg3; for (gp = guest_envp; tgetl(gp); gp++) envc++; argp = alloca((argc + 1) * sizeof(void *)); envp = alloca((envc + 1) * sizeof(void *)); for (gp = guest_argp, q = argp; ; gp += sizeof(target_ulong), q++) { addr = tgetl(gp); if (!addr) break; *q = lock_user_string(addr); } *q = NULL; for (gp = guest_envp, q = envp; ; gp += sizeof(target_ulong), q++) { addr = tgetl(gp); if (!addr) break; *q = lock_user_string(addr); } *q = NULL; p = lock_user_string(arg1); ret = get_errno(execve(p, argp, envp)); unlock_user(p, arg1, 0); for (gp = guest_argp, q = argp; *q; gp += sizeof(target_ulong), q++) { addr = tgetl(gp); unlock_user(*q, addr, 0); } for (gp = guest_envp, q = envp; *q; gp += sizeof(target_ulong), q++) { addr = tgetl(gp); unlock_user(*q, addr, 0); } } break; case TARGET_NR_chdir: p = lock_user_string(arg1); ret = get_errno(chdir(p)); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_time case TARGET_NR_time: { time_t host_time; ret = get_errno(time(&host_time)); if (!is_error(ret) && arg1) tputl(arg1, host_time); } break; #endif case TARGET_NR_mknod: p = lock_user_string(arg1); ret = get_errno(mknod(p, arg2, arg3)); unlock_user(p, arg1, 0); break; case TARGET_NR_chmod: p = lock_user_string(arg1); ret = get_errno(chmod(p, arg2)); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_break case TARGET_NR_break: goto unimplemented; #endif #ifdef TARGET_NR_oldstat case TARGET_NR_oldstat: goto unimplemented; #endif case TARGET_NR_lseek: ret = get_errno(lseek(arg1, arg2, arg3)); break; #ifdef TARGET_NR_getxpid case TARGET_NR_getxpid: #else case TARGET_NR_getpid: #endif ret = get_errno(getpid()); break; case TARGET_NR_mount: { void *p2, *p3; p = lock_user_string(arg1); p2 = lock_user_string(arg2); p3 = lock_user_string(arg3); ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, (const void *)arg5)); unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0); break; } #ifdef TARGET_NR_umount case TARGET_NR_umount: p = lock_user_string(arg1); ret = get_errno(umount(p)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_stime case TARGET_NR_stime: { time_t host_time; host_time = tgetl(arg1); ret = get_errno(stime(&host_time)); } break; #endif case TARGET_NR_ptrace: goto unimplemented; #ifdef TARGET_NR_alarm case TARGET_NR_alarm: ret = alarm(arg1); break; #endif #ifdef TARGET_NR_oldfstat case TARGET_NR_oldfstat: goto unimplemented; #endif #ifdef TARGET_NR_pause case TARGET_NR_pause: ret = get_errno(pause()); break; #endif #ifdef TARGET_NR_utime case TARGET_NR_utime: { struct utimbuf tbuf, *host_tbuf; struct target_utimbuf *target_tbuf; if (arg2) { lock_user_struct(target_tbuf, arg2, 1); tbuf.actime = tswapl(target_tbuf->actime); tbuf.modtime = tswapl(target_tbuf->modtime); unlock_user_struct(target_tbuf, arg2, 0); host_tbuf = &tbuf; } else { host_tbuf = NULL; } p = lock_user_string(arg1); ret = get_errno(utime(p, host_tbuf)); unlock_user(p, arg1, 0); } break; #endif case TARGET_NR_utimes: { struct timeval *tvp, tv[2]; if (arg2) { target_to_host_timeval(&tv[0], arg2); target_to_host_timeval(&tv[1], arg2 + sizeof (struct target_timeval)); tvp = tv; } else { tvp = NULL; } p = lock_user_string(arg1); ret = get_errno(utimes(p, tvp)); unlock_user(p, arg1, 0); } break; #ifdef TARGET_NR_stty case TARGET_NR_stty: goto unimplemented; #endif #ifdef TARGET_NR_gtty case TARGET_NR_gtty: goto unimplemented; #endif case TARGET_NR_access: p = lock_user_string(arg1); ret = get_errno(access(p, arg2)); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_nice case TARGET_NR_nice: ret = get_errno(nice(arg1)); break; #endif #ifdef TARGET_NR_ftime case TARGET_NR_ftime: goto unimplemented; #endif case TARGET_NR_sync: sync(); ret = 0; break; case TARGET_NR_kill: ret = get_errno(kill(arg1, arg2)); break; case TARGET_NR_rename: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); ret = get_errno(rename(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; case TARGET_NR_mkdir: p = lock_user_string(arg1); ret = get_errno(mkdir(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_rmdir: p = lock_user_string(arg1); ret = get_errno(rmdir(p)); unlock_user(p, arg1, 0); break; case TARGET_NR_dup: ret = get_errno(dup(arg1)); break; case TARGET_NR_pipe: { int host_pipe[2]; ret = get_errno(pipe(host_pipe)); if (!is_error(ret)) { #if defined(TARGET_MIPS) CPUMIPSState *env = (CPUMIPSState*)cpu_env; env->gpr[3][env->current_tc] = host_pipe[1]; ret = host_pipe[0]; #else tput32(arg1, host_pipe[0]); tput32(arg1 + 4, host_pipe[1]); #endif } } break; case TARGET_NR_times: { struct target_tms *tmsp; struct tms tms; ret = get_errno(times(&tms)); if (arg1) { tmsp = lock_user(arg1, sizeof(struct target_tms), 0); tmsp->tms_utime = tswapl(host_to_target_clock_t(tms.tms_utime)); tmsp->tms_stime = tswapl(host_to_target_clock_t(tms.tms_stime)); tmsp->tms_cutime = tswapl(host_to_target_clock_t(tms.tms_cutime)); tmsp->tms_cstime = tswapl(host_to_target_clock_t(tms.tms_cstime)); } if (!is_error(ret)) ret = host_to_target_clock_t(ret); } break; #ifdef TARGET_NR_prof case TARGET_NR_prof: goto unimplemented; #endif #ifdef TARGET_NR_signal case TARGET_NR_signal: goto unimplemented; #endif case TARGET_NR_acct: p = lock_user_string(arg1); ret = get_errno(acct(path(p))); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_umount2 case TARGET_NR_umount2: p = lock_user_string(arg1); ret = get_errno(umount2(p, arg2)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_lock case TARGET_NR_lock: goto unimplemented; #endif case TARGET_NR_ioctl: ret = do_ioctl(arg1, arg2, arg3); break; case TARGET_NR_fcntl: ret = get_errno(do_fcntl(arg1, arg2, arg3)); break; #ifdef TARGET_NR_mpx case TARGET_NR_mpx: goto unimplemented; #endif case TARGET_NR_setpgid: ret = get_errno(setpgid(arg1, arg2)); break; #ifdef TARGET_NR_ulimit case TARGET_NR_ulimit: goto unimplemented; #endif #ifdef TARGET_NR_oldolduname case TARGET_NR_oldolduname: goto unimplemented; #endif case TARGET_NR_umask: ret = get_errno(umask(arg1)); break; case TARGET_NR_chroot: p = lock_user_string(arg1); ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); break; case TARGET_NR_ustat: goto unimplemented; case TARGET_NR_dup2: ret = get_errno(dup2(arg1, arg2)); break; #ifdef TARGET_NR_getppid case TARGET_NR_getppid: ret = get_errno(getppid()); break; #endif case TARGET_NR_getpgrp: ret = get_errno(getpgrp()); break; case TARGET_NR_setsid: ret = get_errno(setsid()); break; #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { #if !defined(TARGET_MIPS) struct target_old_sigaction *old_act; struct target_sigaction act, oact, *pact; if (arg2) { lock_user_struct(old_act, arg2, 1); act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; act.sa_restorer = old_act->sa_restorer; unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { lock_user_struct(old_act, arg3, 0); old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0]; old_act->sa_flags = oact.sa_flags; old_act->sa_restorer = oact.sa_restorer; unlock_user_struct(old_act, arg3, 1); } #else struct target_sigaction act, oact, *pact, *old_act; if (arg2) { lock_user_struct(old_act, arg2, 1); act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); act.sa_flags = old_act->sa_flags; unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { lock_user_struct(old_act, arg3, 0); old_act->_sa_handler = oact._sa_handler; old_act->sa_flags = oact.sa_flags; old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; old_act->sa_mask.sig[1] = 0; old_act->sa_mask.sig[2] = 0; old_act->sa_mask.sig[3] = 0; unlock_user_struct(old_act, arg3, 1); } #endif } break; #endif case TARGET_NR_rt_sigaction: { struct target_sigaction *act; struct target_sigaction *oact; if (arg2) lock_user_struct(act, arg2, 1); else act = NULL; if (arg3) lock_user_struct(oact, arg3, 0); else oact = NULL; ret = get_errno(do_sigaction(arg1, act, oact)); if (arg2) unlock_user_struct(act, arg2, 0); if (arg3) unlock_user_struct(oact, arg3, 1); } break; #ifdef TARGET_NR_sgetmask case TARGET_NR_sgetmask: { sigset_t cur_set; target_ulong target_set; sigprocmask(0, NULL, &cur_set); host_to_target_old_sigset(&target_set, &cur_set); ret = target_set; } break; #endif #ifdef TARGET_NR_ssetmask case TARGET_NR_ssetmask: { sigset_t set, oset, cur_set; target_ulong target_set = arg1; sigprocmask(0, NULL, &cur_set); target_to_host_old_sigset(&set, &target_set); sigorset(&set, &set, &cur_set); sigprocmask(SIG_SETMASK, &set, &oset); host_to_target_old_sigset(&target_set, &oset); ret = target_set; } break; #endif #ifdef TARGET_NR_sigprocmask case TARGET_NR_sigprocmask: { int how = arg1; sigset_t set, oldset, *set_ptr; if (arg2) { switch(how) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -EINVAL; goto fail; } p = lock_user(arg2, sizeof(target_sigset_t), 1); target_to_host_old_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; } else { how = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(arg1, set_ptr, &oldset)); if (!is_error(ret) && arg3) { p = lock_user(arg3, sizeof(target_sigset_t), 0); host_to_target_old_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } } break; #endif case TARGET_NR_rt_sigprocmask: { int how = arg1; sigset_t set, oldset, *set_ptr; if (arg2) { switch(how) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -EINVAL; goto fail; } p = lock_user(arg2, sizeof(target_sigset_t), 1); target_to_host_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; } else { how = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(how, set_ptr, &oldset)); if (!is_error(ret) && arg3) { p = lock_user(arg3, sizeof(target_sigset_t), 0); host_to_target_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigpending case TARGET_NR_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { p = lock_user(arg1, sizeof(target_sigset_t), 0); host_to_target_old_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } } break; #endif case TARGET_NR_rt_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { p = lock_user(arg1, sizeof(target_sigset_t), 0); host_to_target_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigsuspend case TARGET_NR_sigsuspend: { sigset_t set; p = lock_user(arg1, sizeof(target_sigset_t), 1); target_to_host_old_sigset(&set, p); unlock_user(p, arg1, 0); ret = get_errno(sigsuspend(&set)); } break; #endif case TARGET_NR_rt_sigsuspend: { sigset_t set; p = lock_user(arg1, sizeof(target_sigset_t), 1); target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); ret = get_errno(sigsuspend(&set)); } break; case TARGET_NR_rt_sigtimedwait: { sigset_t set; struct timespec uts, *puts; siginfo_t uinfo; p = lock_user(arg1, sizeof(target_sigset_t), 1); target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); if (arg3) { puts = &uts; target_to_host_timespec(puts, arg3); } else { puts = NULL; } ret = get_errno(sigtimedwait(&set, &uinfo, puts)); if (!is_error(ret) && arg2) { p = lock_user(arg2, sizeof(target_sigset_t), 0); host_to_target_siginfo(p, &uinfo); unlock_user(p, arg2, sizeof(target_sigset_t)); } } break; case TARGET_NR_rt_sigqueueinfo: { siginfo_t uinfo; p = lock_user(arg3, sizeof(target_sigset_t), 1); target_to_host_siginfo(&uinfo, p); unlock_user(p, arg1, 0); ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); } break; #ifdef TARGET_NR_sigreturn case TARGET_NR_sigreturn: ret = do_sigreturn(cpu_env); break; #endif case TARGET_NR_rt_sigreturn: ret = do_rt_sigreturn(cpu_env); break; case TARGET_NR_sethostname: p = lock_user_string(arg1); ret = get_errno(sethostname(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_setrlimit: { int resource = arg1; struct target_rlimit *target_rlim; struct rlimit rlim; lock_user_struct(target_rlim, arg2, 1); rlim.rlim_cur = tswapl(target_rlim->rlim_cur); rlim.rlim_max = tswapl(target_rlim->rlim_max); unlock_user_struct(target_rlim, arg2, 0); ret = get_errno(setrlimit(resource, &rlim)); } break; case TARGET_NR_getrlimit: { int resource = arg1; struct target_rlimit *target_rlim; struct rlimit rlim; ret = get_errno(getrlimit(resource, &rlim)); if (!is_error(ret)) { lock_user_struct(target_rlim, arg2, 0); rlim.rlim_cur = tswapl(target_rlim->rlim_cur); rlim.rlim_max = tswapl(target_rlim->rlim_max); unlock_user_struct(target_rlim, arg2, 1); } } break; case TARGET_NR_getrusage: { struct rusage rusage; ret = get_errno(getrusage(arg1, &rusage)); if (!is_error(ret)) { host_to_target_rusage(arg2, &rusage); } } break; case TARGET_NR_gettimeofday: { struct timeval tv; ret = get_errno(gettimeofday(&tv, NULL)); if (!is_error(ret)) { host_to_target_timeval(arg1, &tv); } } break; case TARGET_NR_settimeofday: { struct timeval tv; target_to_host_timeval(&tv, arg1); ret = get_errno(settimeofday(&tv, NULL)); } break; #ifdef TARGET_NR_select case TARGET_NR_select: { struct target_sel_arg_struct *sel; target_ulong inp, outp, exp, tvp; long nsel; lock_user_struct(sel, arg1, 1); nsel = tswapl(sel->n); inp = tswapl(sel->inp); outp = tswapl(sel->outp); exp = tswapl(sel->exp); tvp = tswapl(sel->tvp); unlock_user_struct(sel, arg1, 0); ret = do_select(nsel, inp, outp, exp, tvp); } break; #endif case TARGET_NR_symlink: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); ret = get_errno(symlink(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; #ifdef TARGET_NR_oldlstat case TARGET_NR_oldlstat: goto unimplemented; #endif case TARGET_NR_readlink: { void *p2; p = lock_user_string(arg1); p2 = lock_user(arg2, arg3, 0); ret = get_errno(readlink(path(p), p2, arg3)); unlock_user(p2, arg2, ret); unlock_user(p, arg1, 0); } break; #ifdef TARGET_NR_uselib case TARGET_NR_uselib: goto unimplemented; #endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: p = lock_user_string(arg1); ret = get_errno(swapon(p, arg2)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_reboot: goto unimplemented; #ifdef TARGET_NR_readdir case TARGET_NR_readdir: goto unimplemented; #endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_M68K) { target_ulong *v; target_ulong v1, v2, v3, v4, v5, v6; v = lock_user(arg1, 6 * sizeof(target_ulong), 1); v1 = tswapl(v[0]); v2 = tswapl(v[1]); v3 = tswapl(v[2]); v4 = tswapl(v[3]); v5 = tswapl(v[4]); v6 = tswapl(v[5]); unlock_user(v, arg1, 0); ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), v5, v6)); } #else ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6)); #endif break; #endif #ifdef TARGET_NR_mmap2 case TARGET_NR_mmap2: #if defined(TARGET_SPARC) || defined(TARGET_MIPS) #define MMAP_SHIFT 12 #else #define MMAP_SHIFT TARGET_PAGE_BITS #endif ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6 << MMAP_SHIFT)); break; #endif case TARGET_NR_munmap: ret = get_errno(target_munmap(arg1, arg2)); break; case TARGET_NR_mprotect: ret = get_errno(target_mprotect(arg1, arg2, arg3)); break; #ifdef TARGET_NR_mremap case TARGET_NR_mremap: ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); break; #endif #ifdef TARGET_NR_msync case TARGET_NR_msync: ret = get_errno(msync(g2h(arg1), arg2, arg3)); break; #endif #ifdef TARGET_NR_mlock case TARGET_NR_mlock: ret = get_errno(mlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_munlock case TARGET_NR_munlock: ret = get_errno(munlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_mlockall case TARGET_NR_mlockall: ret = get_errno(mlockall(arg1)); break; #endif #ifdef TARGET_NR_munlockall case TARGET_NR_munlockall: ret = get_errno(munlockall()); break; #endif case TARGET_NR_truncate: p = lock_user_string(arg1); ret = get_errno(truncate(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_ftruncate: ret = get_errno(ftruncate(arg1, arg2)); break; case TARGET_NR_fchmod: ret = get_errno(fchmod(arg1, arg2)); break; case TARGET_NR_getpriority: ret = get_errno(getpriority(arg1, arg2)); break; case TARGET_NR_setpriority: ret = get_errno(setpriority(arg1, arg2, arg3)); break; #ifdef TARGET_NR_profil case TARGET_NR_profil: goto unimplemented; #endif case TARGET_NR_statfs: p = lock_user_string(arg1); ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs: if (!is_error(ret)) { struct target_statfs *target_stfs; lock_user_struct(target_stfs, arg2, 0); put_user(stfs.f_type, &target_stfs->f_type); put_user(stfs.f_bsize, &target_stfs->f_bsize); put_user(stfs.f_blocks, &target_stfs->f_blocks); put_user(stfs.f_bfree, &target_stfs->f_bfree); put_user(stfs.f_bavail, &target_stfs->f_bavail); put_user(stfs.f_files, &target_stfs->f_files); put_user(stfs.f_ffree, &target_stfs->f_ffree); put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); put_user(stfs.f_namelen, &target_stfs->f_namelen); unlock_user_struct(target_stfs, arg2, 1); } break; case TARGET_NR_fstatfs: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs; #ifdef TARGET_NR_statfs64 case TARGET_NR_statfs64: p = lock_user_string(arg1); ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs64: if (!is_error(ret)) { struct target_statfs64 *target_stfs; lock_user_struct(target_stfs, arg3, 0); put_user(stfs.f_type, &target_stfs->f_type); put_user(stfs.f_bsize, &target_stfs->f_bsize); put_user(stfs.f_blocks, &target_stfs->f_blocks); put_user(stfs.f_bfree, &target_stfs->f_bfree); put_user(stfs.f_bavail, &target_stfs->f_bavail); put_user(stfs.f_files, &target_stfs->f_files); put_user(stfs.f_ffree, &target_stfs->f_ffree); put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); put_user(stfs.f_namelen, &target_stfs->f_namelen); unlock_user_struct(target_stfs, arg3, 0); } break; case TARGET_NR_fstatfs64: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; #endif #ifdef TARGET_NR_ioperm case TARGET_NR_ioperm: goto unimplemented; #endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: ret = do_socketcall(arg1, arg2); break; #endif #ifdef TARGET_NR_accept case TARGET_NR_accept: ret = do_accept(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: ret = do_bind(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: ret = do_connect(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: ret = do_getpeername(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: ret = do_getsockname(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_listen case TARGET_NR_listen: ret = get_errno(listen(arg1, arg2)); break; #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_recvfrom case TARGET_NR_recvfrom: ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_recvmsg case TARGET_NR_recvmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 0); break; #endif #ifdef TARGET_NR_send case TARGET_NR_send: ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_sendmsg case TARGET_NR_sendmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 1); break; #endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: ret = get_errno(shutdown(arg1, arg2)); break; #endif #ifdef TARGET_NR_socket case TARGET_NR_socket: ret = do_socket(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_socketpair case TARGET_NR_socketpair: ret = do_socketpair(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_setsockopt case TARGET_NR_setsockopt: ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); break; #endif case TARGET_NR_syslog: p = lock_user_string(arg2); ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); unlock_user(p, arg2, 0); break; case TARGET_NR_setitimer: { struct itimerval value, ovalue, *pvalue; if (arg2) { pvalue = &value; target_to_host_timeval(&pvalue->it_interval, arg2); target_to_host_timeval(&pvalue->it_value, arg2 + sizeof(struct target_timeval)); } else { pvalue = NULL; } ret = get_errno(setitimer(arg1, pvalue, &ovalue)); if (!is_error(ret) && arg3) { host_to_target_timeval(arg3, &ovalue.it_interval); host_to_target_timeval(arg3 + sizeof(struct target_timeval), &ovalue.it_value); } } break; case TARGET_NR_getitimer: { struct itimerval value; ret = get_errno(getitimer(arg1, &value)); if (!is_error(ret) && arg2) { host_to_target_timeval(arg2, &value.it_interval); host_to_target_timeval(arg2 + sizeof(struct target_timeval), &value.it_value); } } break; case TARGET_NR_stat: p = lock_user_string(arg1); ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; case TARGET_NR_lstat: p = lock_user_string(arg1); ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; case TARGET_NR_fstat: { ret = get_errno(fstat(arg1, &st)); do_stat: if (!is_error(ret)) { struct target_stat *target_st; lock_user_struct(target_st, arg2, 0); #if defined(TARGET_MIPS) || defined(TARGET_SPARC64) target_st->st_dev = tswap32(st.st_dev); #else target_st->st_dev = tswap16(st.st_dev); #endif target_st->st_ino = tswapl(st.st_ino); #if defined(TARGET_PPC) || defined(TARGET_MIPS) target_st->st_mode = tswapl(st.st_mode); target_st->st_uid = tswap32(st.st_uid); target_st->st_gid = tswap32(st.st_gid); #elif defined(TARGET_SPARC64) target_st->st_mode = tswap32(st.st_mode); target_st->st_uid = tswap32(st.st_uid); target_st->st_gid = tswap32(st.st_gid); #else target_st->st_mode = tswap16(st.st_mode); target_st->st_uid = tswap16(st.st_uid); target_st->st_gid = tswap16(st.st_gid); #endif #if defined(TARGET_MIPS) target_st->st_nlink = tswapl(st.st_nlink); target_st->st_rdev = tswapl(st.st_rdev); #elif defined(TARGET_SPARC64) target_st->st_nlink = tswap32(st.st_nlink); target_st->st_rdev = tswap32(st.st_rdev); #else target_st->st_nlink = tswap16(st.st_nlink); target_st->st_rdev = tswap16(st.st_rdev); #endif target_st->st_size = tswapl(st.st_size); target_st->st_blksize = tswapl(st.st_blksize); target_st->st_blocks = tswapl(st.st_blocks); target_st->target_st_atime = tswapl(st.st_atime); target_st->target_st_mtime = tswapl(st.st_mtime); target_st->target_st_ctime = tswapl(st.st_ctime); unlock_user_struct(target_st, arg2, 1); } } break; #ifdef TARGET_NR_olduname case TARGET_NR_olduname: goto unimplemented; #endif #ifdef TARGET_NR_iopl case TARGET_NR_iopl: goto unimplemented; #endif case TARGET_NR_vhangup: ret = get_errno(vhangup()); break; #ifdef TARGET_NR_idle case TARGET_NR_idle: goto unimplemented; #endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: ret = do_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0); break; #endif case TARGET_NR_wait4: { int status; target_long status_ptr = arg2; struct rusage rusage, *rusage_ptr; target_ulong target_rusage = arg4; if (target_rusage) rusage_ptr = &rusage; else rusage_ptr = NULL; ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr)); if (!is_error(ret)) { if (status_ptr) tputl(status_ptr, status); if (target_rusage) { host_to_target_rusage(target_rusage, &rusage); } } } break; #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: p = lock_user_string(arg1); ret = get_errno(swapoff(p)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_sysinfo: { struct target_sysinfo *target_value; struct sysinfo value; ret = get_errno(sysinfo(&value)); if (!is_error(ret) && arg1) { lock_user_struct(target_value, arg1, 0); __put_user(value.uptime, &target_value->uptime); __put_user(value.loads[0], &target_value->loads[0]); __put_user(value.loads[1], &target_value->loads[1]); __put_user(value.loads[2], &target_value->loads[2]); __put_user(value.totalram, &target_value->totalram); __put_user(value.freeram, &target_value->freeram); __put_user(value.sharedram, &target_value->sharedram); __put_user(value.bufferram, &target_value->bufferram); __put_user(value.totalswap, &target_value->totalswap); __put_user(value.freeswap, &target_value->freeswap); __put_user(value.procs, &target_value->procs); __put_user(value.totalhigh, &target_value->totalhigh); __put_user(value.freehigh, &target_value->freehigh); __put_user(value.mem_unit, &target_value->mem_unit); unlock_user_struct(target_value, arg1, 1); } } break; #ifdef TARGET_NR_ipc case TARGET_NR_ipc: ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif case TARGET_NR_fsync: ret = get_errno(fsync(arg1)); break; case TARGET_NR_clone: ret = get_errno(do_fork(cpu_env, arg1, arg2)); break; #ifdef __NR_exit_group case TARGET_NR_exit_group: gdb_exit(cpu_env, arg1); ret = get_errno(exit_group(arg1)); break; #endif case TARGET_NR_setdomainname: p = lock_user_string(arg1); ret = get_errno(setdomainname(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_uname: { struct new_utsname * buf; lock_user_struct(buf, arg1, 0); ret = get_errno(sys_uname(buf)); if (!is_error(ret)) { strcpy (buf->machine, UNAME_MACHINE); if (qemu_uname_release && *qemu_uname_release) strcpy (buf->release, qemu_uname_release); } unlock_user_struct(buf, arg1, 1); } break; #ifdef TARGET_I386 case TARGET_NR_modify_ldt: ret = get_errno(do_modify_ldt(cpu_env, arg1, arg2, arg3)); break; #if !defined(TARGET_X86_64) case TARGET_NR_vm86old: goto unimplemented; case TARGET_NR_vm86: ret = do_vm86(cpu_env, arg1, arg2); break; #endif #endif case TARGET_NR_adjtimex: goto unimplemented; #ifdef TARGET_NR_create_module case TARGET_NR_create_module: #endif case TARGET_NR_init_module: case TARGET_NR_delete_module: #ifdef TARGET_NR_get_kernel_syms case TARGET_NR_get_kernel_syms: #endif goto unimplemented; case TARGET_NR_quotactl: goto unimplemented; case TARGET_NR_getpgid: ret = get_errno(getpgid(arg1)); break; case TARGET_NR_fchdir: ret = get_errno(fchdir(arg1)); break; #ifdef TARGET_NR_bdflush case TARGET_NR_bdflush: goto unimplemented; #endif #ifdef TARGET_NR_sysfs case TARGET_NR_sysfs: goto unimplemented; #endif case TARGET_NR_personality: ret = get_errno(personality(arg1)); break; #ifdef TARGET_NR_afs_syscall case TARGET_NR_afs_syscall: goto unimplemented; #endif #ifdef TARGET_NR__llseek case TARGET_NR__llseek: { #if defined (__x86_64__) ret = get_errno(lseek(arg1, ((uint64_t )arg2 << 32) | arg3, arg5)); tput64(arg4, ret); #else int64_t res; ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); tput64(arg4, res); #endif } break; #endif case TARGET_NR_getdents: #if TARGET_LONG_SIZE != 4 goto unimplemented; #warning not supported #elif TARGET_LONG_SIZE == 4 && HOST_LONG_SIZE == 8 { struct target_dirent *target_dirp; struct dirent *dirp; long count = arg3; dirp = malloc(count); if (!dirp) return -ENOMEM; ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct dirent *de; struct target_dirent *tde; int len = ret; int reclen, treclen; int count1, tnamelen; count1 = 0; de = dirp; target_dirp = lock_user(arg2, count, 0); tde = target_dirp; while (len > 0) { reclen = de->d_reclen; treclen = reclen - (2 * (sizeof(long) - sizeof(target_long))); tde->d_reclen = tswap16(treclen); tde->d_ino = tswapl(de->d_ino); tde->d_off = tswapl(de->d_off); tnamelen = treclen - (2 * sizeof(target_long) + 2); if (tnamelen > 256) tnamelen = 256; strncpy(tde->d_name, de->d_name, tnamelen); de = (struct dirent *)((char *)de + reclen); len -= reclen; tde = (struct target_dirent *)((char *)tde + treclen); count1 += treclen; } ret = count1; } unlock_user(target_dirp, arg2, ret); free(dirp); } #else { struct dirent *dirp; long count = arg3; dirp = lock_user(arg2, count, 0); ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct dirent *de; int len = ret; int reclen; de = dirp; while (len > 0) { reclen = de->d_reclen; if (reclen > len) break; de->d_reclen = tswap16(reclen); tswapls(&de->d_ino); tswapls(&de->d_off); de = (struct dirent *)((char *)de + reclen); len -= reclen; } } unlock_user(dirp, arg2, ret); } #endif break; #ifdef TARGET_NR_getdents64 case TARGET_NR_getdents64: { struct dirent64 *dirp; long count = arg3; dirp = lock_user(arg2, count, 0); ret = get_errno(sys_getdents64(arg1, dirp, count)); if (!is_error(ret)) { struct dirent64 *de; int len = ret; int reclen; de = dirp; while (len > 0) { reclen = de->d_reclen; if (reclen > len) break; de->d_reclen = tswap16(reclen); tswap64s(&de->d_ino); tswap64s(&de->d_off); de = (struct dirent64 *)((char *)de + reclen); len -= reclen; } } unlock_user(dirp, arg2, ret); } break; #endif #ifdef TARGET_NR__newselect case TARGET_NR__newselect: ret = do_select(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_poll case TARGET_NR_poll: { struct target_pollfd *target_pfd; unsigned int nfds = arg2; int timeout = arg3; struct pollfd *pfd; unsigned int i; target_pfd = lock_user(arg1, sizeof(struct target_pollfd) * nfds, 1); pfd = alloca(sizeof(struct pollfd) * nfds); for(i = 0; i < nfds; i++) { pfd[i].fd = tswap32(target_pfd[i].fd); pfd[i].events = tswap16(target_pfd[i].events); } ret = get_errno(poll(pfd, nfds, timeout)); if (!is_error(ret)) { for(i = 0; i < nfds; i++) { target_pfd[i].revents = tswap16(pfd[i].revents); } ret += nfds * (sizeof(struct target_pollfd) - sizeof(struct pollfd)); } unlock_user(target_pfd, arg1, ret); } break; #endif case TARGET_NR_flock: ret = get_errno(flock(arg1, arg2)); break; case TARGET_NR_readv: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); lock_iovec(vec, arg2, count, 0); ret = get_errno(readv(arg1, vec, count)); unlock_iovec(vec, arg2, count, 1); } break; case TARGET_NR_writev: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); lock_iovec(vec, arg2, count, 1); ret = get_errno(writev(arg1, vec, count)); unlock_iovec(vec, arg2, count, 0); } break; case TARGET_NR_getsid: ret = get_errno(getsid(arg1)); break; #if defined(TARGET_NR_fdatasync) case TARGET_NR_fdatasync: ret = get_errno(fdatasync(arg1)); break; #endif case TARGET_NR__sysctl: return -ENOTDIR; case TARGET_NR_sched_setparam: { struct sched_param *target_schp; struct sched_param schp; lock_user_struct(target_schp, arg2, 1); schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg2, 0); ret = get_errno(sched_setparam(arg1, &schp)); } break; case TARGET_NR_sched_getparam: { struct sched_param *target_schp; struct sched_param schp; ret = get_errno(sched_getparam(arg1, &schp)); if (!is_error(ret)) { lock_user_struct(target_schp, arg2, 0); target_schp->sched_priority = tswap32(schp.sched_priority); unlock_user_struct(target_schp, arg2, 1); } } break; case TARGET_NR_sched_setscheduler: { struct sched_param *target_schp; struct sched_param schp; lock_user_struct(target_schp, arg3, 1); schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg3, 0); ret = get_errno(sched_setscheduler(arg1, arg2, &schp)); } break; case TARGET_NR_sched_getscheduler: ret = get_errno(sched_getscheduler(arg1)); break; case TARGET_NR_sched_yield: ret = get_errno(sched_yield()); break; case TARGET_NR_sched_get_priority_max: ret = get_errno(sched_get_priority_max(arg1)); break; case TARGET_NR_sched_get_priority_min: ret = get_errno(sched_get_priority_min(arg1)); break; case TARGET_NR_sched_rr_get_interval: { struct timespec ts; ret = get_errno(sched_rr_get_interval(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } } break; case TARGET_NR_nanosleep: { struct timespec req, rem; target_to_host_timespec(&req, arg1); ret = get_errno(nanosleep(&req, &rem)); if (is_error(ret) && arg2) { host_to_target_timespec(arg2, &rem); } } break; #ifdef TARGET_NR_query_module case TARGET_NR_query_module: goto unimplemented; #endif #ifdef TARGET_NR_nfsservctl case TARGET_NR_nfsservctl: goto unimplemented; #endif case TARGET_NR_prctl: switch (arg1) { case PR_GET_PDEATHSIG: { int deathsig; ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); if (!is_error(ret) && arg2) tput32(arg2, deathsig); } break; default: ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); break; } break; #ifdef TARGET_NR_pread case TARGET_NR_pread: page_unprotect_range(arg2, arg3); p = lock_user(arg2, arg3, 0); ret = get_errno(pread(arg1, p, arg3, arg4)); unlock_user(p, arg2, ret); break; case TARGET_NR_pwrite: p = lock_user(arg2, arg3, 1); ret = get_errno(pwrite(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_getcwd: p = lock_user(arg1, arg2, 0); ret = get_errno(sys_getcwd1(p, arg2)); unlock_user(p, arg1, ret); break; case TARGET_NR_capget: goto unimplemented; case TARGET_NR_capset: goto unimplemented; case TARGET_NR_sigaltstack: goto unimplemented; case TARGET_NR_sendfile: goto unimplemented; #ifdef TARGET_NR_getpmsg case TARGET_NR_getpmsg: goto unimplemented; #endif #ifdef TARGET_NR_putpmsg case TARGET_NR_putpmsg: goto unimplemented; #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0)); break; #endif #ifdef TARGET_NR_ugetrlimit case TARGET_NR_ugetrlimit: { struct rlimit rlim; ret = get_errno(getrlimit(arg1, &rlim)); if (!is_error(ret)) { struct target_rlimit *target_rlim; lock_user_struct(target_rlim, arg2, 0); target_rlim->rlim_cur = tswapl(rlim.rlim_cur); target_rlim->rlim_max = tswapl(rlim.rlim_max); unlock_user_struct(target_rlim, arg2, 1); } break; } #endif #ifdef TARGET_NR_truncate64 case TARGET_NR_truncate64: p = lock_user_string(arg1); ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_ftruncate64 case TARGET_NR_ftruncate64: ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: p = lock_user_string(arg1); ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat64; #endif #ifdef TARGET_NR_lstat64 case TARGET_NR_lstat64: p = lock_user_string(arg1); ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat64; #endif #ifdef TARGET_NR_fstat64 case TARGET_NR_fstat64: { ret = get_errno(fstat(arg1, &st)); do_stat64: if (!is_error(ret)) { #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { struct target_eabi_stat64 *target_st; lock_user_struct(target_st, arg2, 1); memset(target_st, 0, sizeof(struct target_eabi_stat64)); put_user(st.st_dev, &target_st->st_dev); put_user(st.st_ino, &target_st->st_ino); #ifdef TARGET_STAT64_HAS_BROKEN_ST_INO put_user(st.st_ino, &target_st->__st_ino); #endif put_user(st.st_mode, &target_st->st_mode); put_user(st.st_nlink, &target_st->st_nlink); put_user(st.st_uid, &target_st->st_uid); put_user(st.st_gid, &target_st->st_gid); put_user(st.st_rdev, &target_st->st_rdev); put_user(st.st_size, &target_st->st_size); put_user(st.st_blksize, &target_st->st_blksize); put_user(st.st_blocks, &target_st->st_blocks); put_user(st.st_atime, &target_st->target_st_atime); put_user(st.st_mtime, &target_st->target_st_mtime); put_user(st.st_ctime, &target_st->target_st_ctime); unlock_user_struct(target_st, arg2, 0); } else #endif { struct target_stat64 *target_st; lock_user_struct(target_st, arg2, 1); memset(target_st, 0, sizeof(struct target_stat64)); put_user(st.st_dev, &target_st->st_dev); put_user(st.st_ino, &target_st->st_ino); #ifdef TARGET_STAT64_HAS_BROKEN_ST_INO put_user(st.st_ino, &target_st->__st_ino); #endif put_user(st.st_mode, &target_st->st_mode); put_user(st.st_nlink, &target_st->st_nlink); put_user(st.st_uid, &target_st->st_uid); put_user(st.st_gid, &target_st->st_gid); put_user(st.st_rdev, &target_st->st_rdev); put_user(st.st_size, &target_st->st_size); put_user(st.st_blksize, &target_st->st_blksize); put_user(st.st_blocks, &target_st->st_blocks); put_user(st.st_atime, &target_st->target_st_atime); put_user(st.st_mtime, &target_st->target_st_mtime); put_user(st.st_ctime, &target_st->target_st_ctime); unlock_user_struct(target_st, arg2, 0); } } } break; #endif #ifdef USE_UID16 case TARGET_NR_lchown: p = lock_user_string(arg1); ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); break; case TARGET_NR_getuid: ret = get_errno(high2lowuid(getuid())); break; case TARGET_NR_getgid: ret = get_errno(high2lowgid(getgid())); break; case TARGET_NR_geteuid: ret = get_errno(high2lowuid(geteuid())); break; case TARGET_NR_getegid: ret = get_errno(high2lowgid(getegid())); break; case TARGET_NR_setreuid: ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); break; case TARGET_NR_setregid: ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); break; case TARGET_NR_getgroups: { int gidsetsize = arg1; uint16_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (!is_error(ret)) { target_grouplist = lock_user(arg2, gidsetsize * 2, 0); for(i = 0;i < gidsetsize; i++) target_grouplist[i] = tswap16(grouplist[i]); unlock_user(target_grouplist, arg2, gidsetsize * 2); } } break; case TARGET_NR_setgroups: { int gidsetsize = arg1; uint16_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(arg2, gidsetsize * 2, 1); for(i = 0;i < gidsetsize; i++) grouplist[i] = tswap16(target_grouplist[i]); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(gidsetsize, grouplist)); } break; case TARGET_NR_fchown: ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); break; #ifdef TARGET_NR_setresuid case TARGET_NR_setresuid: ret = get_errno(setresuid(low2highuid(arg1), low2highuid(arg2), low2highuid(arg3))); break; #endif #ifdef TARGET_NR_getresuid case TARGET_NR_getresuid: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { tput16(arg1, tswap16(high2lowuid(ruid))); tput16(arg2, tswap16(high2lowuid(euid))); tput16(arg3, tswap16(high2lowuid(suid))); } } break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_setresgid: ret = get_errno(setresgid(low2highgid(arg1), low2highgid(arg2), low2highgid(arg3))); break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_getresgid: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { tput16(arg1, tswap16(high2lowgid(rgid))); tput16(arg2, tswap16(high2lowgid(egid))); tput16(arg3, tswap16(high2lowgid(sgid))); } } break; #endif case TARGET_NR_chown: p = lock_user_string(arg1); ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); break; case TARGET_NR_setuid: ret = get_errno(setuid(low2highuid(arg1))); break; case TARGET_NR_setgid: ret = get_errno(setgid(low2highgid(arg1))); break; case TARGET_NR_setfsuid: ret = get_errno(setfsuid(arg1)); break; case TARGET_NR_setfsgid: ret = get_errno(setfsgid(arg1)); break; #endif #ifdef TARGET_NR_lchown32 case TARGET_NR_lchown32: p = lock_user_string(arg1); ret = get_errno(lchown(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_getuid32 case TARGET_NR_getuid32: ret = get_errno(getuid()); break; #endif #ifdef TARGET_NR_getgid32 case TARGET_NR_getgid32: ret = get_errno(getgid()); break; #endif #ifdef TARGET_NR_geteuid32 case TARGET_NR_geteuid32: ret = get_errno(geteuid()); break; #endif #ifdef TARGET_NR_getegid32 case TARGET_NR_getegid32: ret = get_errno(getegid()); break; #endif #ifdef TARGET_NR_setreuid32 case TARGET_NR_setreuid32: ret = get_errno(setreuid(arg1, arg2)); break; #endif #ifdef TARGET_NR_setregid32 case TARGET_NR_setregid32: ret = get_errno(setregid(arg1, arg2)); break; #endif #ifdef TARGET_NR_getgroups32 case TARGET_NR_getgroups32: { int gidsetsize = arg1; uint32_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (!is_error(ret)) { target_grouplist = lock_user(arg2, gidsetsize * 4, 0); for(i = 0;i < gidsetsize; i++) target_grouplist[i] = tswap32(grouplist[i]); unlock_user(target_grouplist, arg2, gidsetsize * 4); } } break; #endif #ifdef TARGET_NR_setgroups32 case TARGET_NR_setgroups32: { int gidsetsize = arg1; uint32_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(arg2, gidsetsize * 4, 1); for(i = 0;i < gidsetsize; i++) grouplist[i] = tswap32(target_grouplist[i]); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(gidsetsize, grouplist)); } break; #endif #ifdef TARGET_NR_fchown32 case TARGET_NR_fchown32: ret = get_errno(fchown(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_setresuid32 case TARGET_NR_setresuid32: ret = get_errno(setresuid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresuid32 case TARGET_NR_getresuid32: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { tput32(arg1, tswap32(ruid)); tput32(arg2, tswap32(euid)); tput32(arg3, tswap32(suid)); } } break; #endif #ifdef TARGET_NR_setresgid32 case TARGET_NR_setresgid32: ret = get_errno(setresgid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresgid32 case TARGET_NR_getresgid32: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { tput32(arg1, tswap32(rgid)); tput32(arg2, tswap32(egid)); tput32(arg3, tswap32(sgid)); } } break; #endif #ifdef TARGET_NR_chown32 case TARGET_NR_chown32: p = lock_user_string(arg1); ret = get_errno(chown(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_setuid32 case TARGET_NR_setuid32: ret = get_errno(setuid(arg1)); break; #endif #ifdef TARGET_NR_setgid32 case TARGET_NR_setgid32: ret = get_errno(setgid(arg1)); break; #endif #ifdef TARGET_NR_setfsuid32 case TARGET_NR_setfsuid32: ret = get_errno(setfsuid(arg1)); break; #endif #ifdef TARGET_NR_setfsgid32 case TARGET_NR_setfsgid32: ret = get_errno(setfsgid(arg1)); break; #endif case TARGET_NR_pivot_root: goto unimplemented; #ifdef TARGET_NR_mincore case TARGET_NR_mincore: goto unimplemented; #endif #ifdef TARGET_NR_madvise case TARGET_NR_madvise: ret = get_errno(0); break; #endif #if TARGET_LONG_BITS == 32 case TARGET_NR_fcntl64: { int cmd; struct flock64 fl; struct target_flock64 *target_fl; #ifdef TARGET_ARM struct target_eabi_flock64 *target_efl; #endif switch(arg2){ case TARGET_F_GETLK64: cmd = F_GETLK64; break; case TARGET_F_SETLK64: cmd = F_SETLK64; break; case TARGET_F_SETLKW64: cmd = F_SETLK64; break; default: cmd = arg2; break; } switch(arg2) { case TARGET_F_GETLK64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { lock_user_struct(target_efl, arg3, 1); fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswapl(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { lock_user_struct(target_fl, arg3, 1); fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswapl(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); if (ret == 0) { #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { lock_user_struct(target_efl, arg3, 0); target_efl->l_type = tswap16(fl.l_type); target_efl->l_whence = tswap16(fl.l_whence); target_efl->l_start = tswap64(fl.l_start); target_efl->l_len = tswap64(fl.l_len); target_efl->l_pid = tswapl(fl.l_pid); unlock_user_struct(target_efl, arg3, 1); } else #endif { lock_user_struct(target_fl, arg3, 0); target_fl->l_type = tswap16(fl.l_type); target_fl->l_whence = tswap16(fl.l_whence); target_fl->l_start = tswap64(fl.l_start); target_fl->l_len = tswap64(fl.l_len); target_fl->l_pid = tswapl(fl.l_pid); unlock_user_struct(target_fl, arg3, 1); } } break; case TARGET_F_SETLK64: case TARGET_F_SETLKW64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { lock_user_struct(target_efl, arg3, 1); fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswapl(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { lock_user_struct(target_fl, arg3, 1); fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswapl(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); break; default: ret = get_errno(do_fcntl(arg1, cmd, arg3)); break; } break; } #endif #ifdef TARGET_NR_cacheflush case TARGET_NR_cacheflush: ret = 0; break; #endif #ifdef TARGET_NR_security case TARGET_NR_security: goto unimplemented; #endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: ret = TARGET_PAGE_SIZE; break; #endif case TARGET_NR_gettid: ret = get_errno(gettid()); break; #ifdef TARGET_NR_readahead case TARGET_NR_readahead: goto unimplemented; #endif #ifdef TARGET_NR_setxattr case TARGET_NR_setxattr: case TARGET_NR_lsetxattr: case TARGET_NR_fsetxattr: case TARGET_NR_getxattr: case TARGET_NR_lgetxattr: case TARGET_NR_fgetxattr: case TARGET_NR_listxattr: case TARGET_NR_llistxattr: case TARGET_NR_flistxattr: case TARGET_NR_removexattr: case TARGET_NR_lremovexattr: case TARGET_NR_fremovexattr: goto unimplemented_nowarn; #endif #ifdef TARGET_NR_set_thread_area case TARGET_NR_set_thread_area: #ifdef TARGET_MIPS ((CPUMIPSState *) cpu_env)->tls_value = arg1; ret = 0; break; #else goto unimplemented_nowarn; #endif #endif #ifdef TARGET_NR_get_thread_area case TARGET_NR_get_thread_area: goto unimplemented_nowarn; #endif #ifdef TARGET_NR_getdomainname case TARGET_NR_getdomainname: goto unimplemented_nowarn; #endif #ifdef TARGET_NR_clock_gettime case TARGET_NR_clock_gettime: { struct timespec ts; ret = get_errno(clock_gettime(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } break; } #endif #ifdef TARGET_NR_clock_getres case TARGET_NR_clock_getres: { struct timespec ts; ret = get_errno(clock_getres(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } break; } #endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: ret = get_errno(set_tid_address((int *) arg1)); break; #endif #ifdef TARGET_NR_tkill case TARGET_NR_tkill: ret = get_errno(sys_tkill((int)arg1, (int)arg2)); break; #endif #ifdef TARGET_NR_tgkill case TARGET_NR_tgkill: ret = get_errno(sys_tgkill((int)arg1, (int)arg2, (int)arg3)); break; #endif #ifdef TARGET_NR_set_robust_list case TARGET_NR_set_robust_list: goto unimplemented_nowarn; #endif default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); #if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn: #endif ret = -ENOSYS; break; } fail: #ifdef DEBUG gemu_log(" = %ld\n", ret); #endif return ret; }
1threat
How to import custom module in julia : <p>I have a module I wrote here:</p> <pre><code># Hello.jl module Hello function foo return 1 end end </code></pre> <p>and</p> <pre><code># Main.jl using Hello foo() </code></pre> <p>When I run the <code>Main</code> module:</p> <pre><code>$ julia ./Main.jl </code></pre> <p>I get this error:</p> <pre><code>ERROR: LoadError: ArgumentError: Hello not found in path in require at ./loading.jl:249 in include at ./boot.jl:261 in include_from_node1 at ./loading.jl:320 in process_options at ./client.jl:280 in _start at ./client.jl:378 while loading /Main.jl, in expression starting on line 1 </code></pre>
0debug
static void scsi_dma_restart_bh(void *opaque) { SCSIDevice *s = opaque; SCSIRequest *req, *next; qemu_bh_delete(s->bh); s->bh = NULL; QTAILQ_FOREACH_SAFE(req, &s->requests, next, next) { scsi_req_ref(req); if (req->retry) { req->retry = false; switch (req->cmd.mode) { case SCSI_XFER_FROM_DEV: case SCSI_XFER_TO_DEV: scsi_req_continue(req); break; case SCSI_XFER_NONE: assert(!req->sg); scsi_req_dequeue(req); scsi_req_enqueue(req); break; } } scsi_req_unref(req); } }
1threat
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; BlockIOLimit io_limits; int snapshot = 0; bool copy_on_read; int ret; translation = BIOS_ATA_TRANSLATION_AUTO; media = MEDIA_DISK; bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++) ; if (type == IF_COUNT) { error_report("unsupported bus type '%s'", buf); return NULL; } } else { type = default_to_scsi ? IF_SCSI : IF_IDE; pstrcpy(devname, sizeof(devname), if_name[type]); } max_devs = if_max_devs[type]; if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { error_report("invalid physical cyls number"); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { error_report("invalid physical heads number"); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { error_report("invalid physical secs number"); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls, heads and secs", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid translation type", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { error_report("CHS can't be set with media=%s", buf); return NULL; } media = MEDIA_CDROM; } else { error_report("'%s' invalid media", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { } else { error_report("invalid aio option"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { error_report("'%s' invalid format", buf); return NULL; } } io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "bps", 0); io_limits.bps[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "bps_rd", 0); io_limits.bps[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "bps_wr", 0); io_limits.iops[BLOCK_IO_LIMIT_TOTAL] = qemu_opt_get_number(opts, "iops", 0); io_limits.iops[BLOCK_IO_LIMIT_READ] = qemu_opt_get_number(opts, "iops_rd", 0); io_limits.iops[BLOCK_IO_LIMIT_WRITE] = qemu_opt_get_number(opts, "iops_wr", 0); if (!do_check_io_limits(&io_limits)) { error_report("bps(iops) and bps_rd/bps_wr(iops_rd/iops_wr) " "cannot be used at the same time"); return NULL; } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); return NULL; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); return NULL; } if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); return NULL; } dinfo = g_malloc0(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = g_strdup(buf); } else { dinfo->id = g_malloc0(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->opts = opts; dinfo->refcount = 1; if (serial) { pstrcpy(dinfo->serial, sizeof(dinfo->serial), serial); } QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); bdrv_set_io_limits(dinfo->bdrv, &io_limits); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: dinfo->media_cd = 1; break; } break; case IF_SD: case IF_FLOPPY: case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(opts, "driver", "virtio-blk-s390"); } else { qemu_opt_set(opts, "driver", "virtio-blk-pci"); } qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; default: abort(); } if (!file || !*file) { return dinfo; } if (snapshot) { bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (copy_on_read) { bdrv_flags |= BDRV_O_COPY_ON_READ; } if (runstate_check(RUN_STATE_INMIGRATE)) { bdrv_flags |= BDRV_O_INCOMING; } if (media == MEDIA_CDROM) { ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE && type != IF_PFLASH) { error_report("readonly not supported by this bus type"); goto err; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv); if (ret < 0) { error_report("could not open disk image %s: %s", file, strerror(-ret)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; err: bdrv_delete(dinfo->bdrv); g_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); g_free(dinfo); return NULL; }
1threat
UWP app with restful GET : I am very new to C# but I need to write an UWP app to run on a Raspberry Pi with Windows 10 IoT. I have a bluetooth dongle connected to the Pi, the app needs to send an On-Command to a Philipps Hue Ligthscrip with a restful GET when the button is pressed. I've tried to Google myself through Stack Overflow, Microsoft's repositories and thousands of other sites, no luck. There must be something possible with HttpClient (https://docs.microsoft.com/en-us/windows/uwp/networking/httpclient) but I could not figure out how to send GET... Thanks Dominik
0debug
Space Indentation Expected in ng lint : <p>I keep getting error <strong>"space indentation expected"</strong> while running <strong>ng lint</strong>. It is a quite amount of lines that having the same issue in my application. How can I solve this warning? Is anyone having face the similar issue ?</p>
0debug
Remove element by the text inside : <p>how can I remove an element using jquery by the text in the element.</p> <pre><code>&lt;a href="/"&gt;Link1&lt;/a&gt; </code></pre> <p>I dont want to remove the element by class or ID. I want to do something like this:</p> <pre><code>$('a').html('Link1').remove() </code></pre> <p>Can you help me with this?</p>
0debug
Is there an API for voice recognition of a person used for authentication : <p>I am very new to API's and searches alot but doesn't find any thing related, I want an API for voice recognition in which the frequency of voice for a user is stored and then used as a bio-metric authentication for that user. for example a user is to register giving his voice as an input, it will be processed using an API and stores the frequency or pitch of the user to somewhere then the same user when tries to login he/she has to provide his voice, it will be match with the one given at the time of registration, if it matches user will be authenticated. Please help me out</p>
0debug
using new[] with lambda : <pre><code>protected override IEnumerable&lt;string&gt; Attributes =&gt; new [] { IntercationAttributes.State }; </code></pre> <p>Can somebody explain me what is happening here. Why we have new[] with lambda expression. I have seen it for the first time.</p>
0debug
How to make Internet browser? : <p>I made a simple browser app using Webview, but Existing android Browser apps like Chrome, Microsoft Edge, Firefox.</p> <p>How are these apps made? Simply same using Webview??</p>
0debug
static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref, AVIOInterruptCB *int_cb) { AVOpenCallback open_func = c->fc->open_cb; if (!open_func) open_func = ffio_open2_wrapper; if (ref->nlvl_to > 0 && ref->nlvl_from > 0 && ref->path[0] != '/') { char filename[1025]; const char *src_path; int i, l; src_path = strrchr(src, '/'); if (src_path) src_path++; else src_path = src; for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--) if (ref->path[l] == '/') { if (i == ref->nlvl_to - 1) break; else i++; } if (i == ref->nlvl_to - 1 && src_path - src < sizeof(filename)) { memcpy(filename, src, src_path - src); filename[src_path - src] = 0; for (i = 1; i < ref->nlvl_from; i++) av_strlcat(filename, "../", sizeof(filename)); av_strlcat(filename, ref->path + l + 1, sizeof(filename)); if (!c->use_absolute_path && !c->fc->open_cb) if(strstr(ref->path + l + 1, "..") || ref->nlvl_from > 1) return AVERROR(ENOENT); if (strlen(filename) + 1 == sizeof(filename)) return AVERROR(ENOENT); if (!open_func(c->fc, pb, filename, AVIO_FLAG_READ, int_cb, NULL)) return 0; } } else if (c->use_absolute_path) { av_log(c->fc, AV_LOG_WARNING, "Using absolute path on user request, " "this is a possible security issue\n"); if (!open_func(c->fc, pb, ref->path, AVIO_FLAG_READ, int_cb, NULL)) return 0; } else if (c->fc->open_cb) { if (!open_func(c->fc, pb, ref->path, AVIO_FLAG_READ, int_cb, NULL)) return 0; } else { av_log(c->fc, AV_LOG_ERROR, "Absolute path %s not tried for security reasons, " "set demuxer option use_absolute_path to allow absolute paths\n", ref->path); } return AVERROR(ENOENT); }
1threat
python - Duplicate rows x number of times based on a value in a column : <p>I have a pandas dataframe of bookings at a hotel. Each row is a booking, like this:</p> <pre><code>Name Arrival Departure RoomNights Trent Cotchin 29/10/2017 2/11/2017 4 Dustin Martin 1/11/2017 4/11/2017 3 Alex Rance 2/11/2017 3/11/2017 1 </code></pre> <p>I want to use python to convert so that each row becomes a roomnight. The output would look like this:</p> <pre><code>Name Arrival Departure RoomNights RoomNight Date Trent Cotchin 29/10/2017 2/11/2017 4 29/10/2017 Trent Cotchin 29/10/2017 2/11/2017 4 30/10/2017 Trent Cotchin 29/10/2017 2/11/2017 4 31/10/2017 Trent Cotchin 29/10/2017 2/11/2017 4 1/11/2017 Dustin Martin 1/11/2017 4/11/2017 3 1/11/2017 Dustin Martin 1/11/2017 4/11/2017 3 2/11/2017 Dustin Martin 1/11/2017 4/11/2017 3 3/11/2017 Alex Rance 2/11/2017 3/11/2017 1 2/11/2017 </code></pre> <p>This allows me to easily sum the total number of roomnights for any given day/month.</p>
0debug
ValueChanges on FormControl triggers when Form.enable, even with emitEvent: false : <p>With Angular (4.x) I use ReactiveForms and I've subscribed to valueChanges on my FormControl ("input") like so:</p> <pre><code>export class App { version:string; formControl = new FormControl('default', []); form = this.fb.group({ input: this.formControl, input2: ('',[]) }); constructor(private fb: FormBuilder) { this.version = `Angular v${VERSION.full}` } ngOnInit() { this.formControl.valueChanges.subscribe(value =&gt; doSomething(value)); } </code></pre> <p>So now I can react on changes on the value of my FormControl, but I of course fill the values of the form from somewhere to start with, so I use <code>form.patchValue(data)</code> to do so.</p> <p>Since this is not a userchange, I don't want to react on it, so add the flag <code>emitEvent: false</code>, like: <code>this.form.patchValue(data, {emitEvent: false})</code>.</p> <p>Which works as expected.</p> <p>Now I have some logic that when the form is loading, I set the whole form to disabled, <code>this.form.disable({ emitEvent: false })</code>, and when finished loading it sets the whole form to enabled again: <code>this.form.disable({ emitEvent: false })</code></p> <p>But I also have logic that depending on different flags sets the FormControl to enabled/disabled: <code>this.formControl.enable( {emitEvent: false});</code></p> <hr> <p>The problem I'm now see is that when the <strong><code>Form</code></strong>, changes status, it triggers the <strong><code>FormControl.valueChanges</code></strong>, even though I provide the <code>emitEvent: false</code> flag.</p> <p>Is this the expected behavior, or a bug? I expected no event to be triggered at all when providing the flag?</p> <p>I've made a plunk where this can be tested here: <a href="https://plnkr.co/edit/RgyDItYtEfzlLVB6P5f3?p=preview" rel="noreferrer">https://plnkr.co/edit/RgyDItYtEfzlLVB6P5f3?p=preview</a></p>
0debug
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; FLVContext *flv = s->priv_data; AVIOContext *ioc; AMFDataType amf_type; char str_val[256]; double num_val; num_val = 0; ioc = s->pb; amf_type = avio_r8(ioc); switch (amf_type) { case AMF_DATA_TYPE_NUMBER: num_val = av_int2double(avio_rb64(ioc)); break; case AMF_DATA_TYPE_BOOL: num_val = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: if ((vstream || astream) && key && ioc->seekable && !strcmp(KEYFRAMES_TAG, key) && depth == 1) if (parse_keyframes_index(s, ioc, vstream ? vstream : astream, max_pos) < 0) av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n"); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; case AMF_DATA_TYPE_MIXEDARRAY: avio_skip(ioc, 4); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int arraylen, i; arraylen = avio_rb32(ioc); for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) if (amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) return -1; } break; case AMF_DATA_TYPE_DATE: avio_skip(ioc, 8 + 2); break; default: return -1; } if (key) { if (depth == 1) { acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; if (amf_type == AMF_DATA_TYPE_NUMBER || amf_type == AMF_DATA_TYPE_BOOL) { if (!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) vcodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) acodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "datastream")) { AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA); if (!st) return AVERROR(ENOMEM); st->codec->codec_id = AV_CODEC_ID_TEXT; } else if (flv->trust_metadata) { if (!strcmp(key, "videocodecid") && vcodec) { flv_set_video_codec(s, vstream, num_val, 0); } else if (!strcmp(key, "audiocodecid") && acodec) { int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET; flv_set_audio_codec(s, astream, acodec, id); } else if (!strcmp(key, "audiosamplerate") && acodec) { acodec->sample_rate = num_val; } else if (!strcmp(key, "audiosamplesize") && acodec) { acodec->bits_per_coded_sample = num_val; } else if (!strcmp(key, "stereo") && acodec) { acodec->channels = num_val + 1; acodec->channel_layout = acodec->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; } else if (!strcmp(key, "width") && vcodec) { vcodec->width = num_val; } else if (!strcmp(key, "height") && vcodec) { vcodec->height = num_val; } } } } if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 && ((!acodec && !strcmp(key, "audiocodecid")) || (!vcodec && !strcmp(key, "videocodecid")))) s->ctx_flags &= ~AVFMTCTX_NOHEADER; if (!strcmp(key, "duration") || !strcmp(key, "filesize") || !strcmp(key, "width") || !strcmp(key, "height") || !strcmp(key, "videodatarate") || !strcmp(key, "framerate") || !strcmp(key, "videocodecid") || !strcmp(key, "audiodatarate") || !strcmp(key, "audiosamplerate") || !strcmp(key, "audiosamplesize") || !strcmp(key, "stereo") || !strcmp(key, "audiocodecid") || !strcmp(key, "datastream")) return 0; s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; if (amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_STRING) av_dict_set(&s->metadata, key, str_val, 0); } return 0; }
1threat
static void qemu_rdma_dump_id(const char *who, struct ibv_context *verbs) { struct ibv_port_attr port; if (ibv_query_port(verbs, 1, &port)) { error_report("Failed to query port information"); return; } printf("%s RDMA Device opened: kernel name %s " "uverbs device name %s, " "infiniband_verbs class device path %s, " "infiniband class device path %s, " "transport: (%d) %s\n", who, verbs->device->name, verbs->device->dev_name, verbs->device->dev_path, verbs->device->ibdev_path, port.link_layer, (port.link_layer == IBV_LINK_LAYER_INFINIBAND) ? "Infiniband" : ((port.link_layer == IBV_LINK_LAYER_ETHERNET) ? "Ethernet" : "Unknown")); }
1threat
static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms, uint64_t cumulative_shared_perms, Error **errp) { BlockDriver *drv = bs->drv; BdrvChild *c; int ret; if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) && bdrv_is_read_only(bs)) { error_setg(errp, "Block node is read-only"); return -EPERM; } if (!drv) { return 0; } if (drv->bdrv_check_perm) { return drv->bdrv_check_perm(bs, cumulative_perms, cumulative_shared_perms, errp); } if (!drv->bdrv_child_perm) { assert(QLIST_EMPTY(&bs->children)); return 0; } QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; drv->bdrv_child_perm(bs, c, c->role, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); ret = bdrv_child_check_perm(c, cur_perm, cur_shared, errp); if (ret < 0) { return ret; } } return 0; }
1threat
alert('Hello ' + user_input);
1threat
IISExpress shows up as host for browser in visual studio and messes up everything how to get back to local : All of a sudden after I installed Microsoft edge on windows 10 gd Visual Studio is using IIS Express when run debug a web application and it is messing up everything. How do I get back to normal so that stupid $%^&& IISExpress is not used anymore. [enter image description here][1] [1]: https://i.stack.imgur.com/l6a2u.png
0debug
void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, bool is_write) { hwaddr addr, granularity; IOMMUTLBEntry iotlb; granularity = memory_region_iommu_get_min_page_size(mr); for (addr = 0; addr < memory_region_size(mr); addr += granularity) { iotlb = mr->iommu_ops->translate(mr, addr, is_write); if (iotlb.perm != IOMMU_NONE) { n->notify(n, &iotlb); } if ((addr + granularity) < addr) { break; } } }
1threat
static int is_cpuid_supported(void) { return 1; }
1threat
void cpu_dump_state(CPUXtensaState *env, FILE *f, fprintf_function cpu_fprintf, int flags) { int i, j; cpu_fprintf(f, "PC=%08x\n\n", env->pc); for (i = j = 0; i < 256; ++i) { if (sregnames[i]) { cpu_fprintf(f, "%s=%08x%c", sregnames[i], env->sregs[i], (j++ % 4) == 3 ? '\n' : ' '); } } cpu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n"); for (i = j = 0; i < 256; ++i) { if (uregnames[i]) { cpu_fprintf(f, "%s=%08x%c", uregnames[i], env->uregs[i], (j++ % 4) == 3 ? '\n' : ' '); } } cpu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n"); for (i = 0; i < 16; ++i) { cpu_fprintf(f, "A%02d=%08x%c", i, env->regs[i], (i % 4) == 3 ? '\n' : ' '); } cpu_fprintf(f, "\n"); for (i = 0; i < env->config->nareg; ++i) { cpu_fprintf(f, "AR%02d=%08x%c", i, env->phys_regs[i], (i % 4) == 3 ? '\n' : ' '); } if (xtensa_option_enabled(env->config, XTENSA_OPTION_FP_COPROCESSOR)) { cpu_fprintf(f, "\n"); for (i = 0; i < 16; ++i) { cpu_fprintf(f, "F%02d=%08x (%+10.8e)%c", i, float32_val(env->fregs[i]), *(float *)&env->fregs[i], (i % 2) == 1 ? '\n' : ' '); } } }
1threat
static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx) { AVBufferRef *hw_frames_ref; AVHWFramesContext *frames_ctx = NULL; int err = 0; if (!(hw_frames_ref = av_hwframe_ctx_alloc(hw_device_ctx))) { fprintf(stderr, "Failed to create VAAPI frame context.\n"); return -1; } frames_ctx = (AVHWFramesContext *)(hw_frames_ref->data); frames_ctx->format = AV_PIX_FMT_VAAPI; frames_ctx->sw_format = AV_PIX_FMT_NV12; frames_ctx->width = width; frames_ctx->height = height; frames_ctx->initial_pool_size = 20; if ((err = av_hwframe_ctx_init(hw_frames_ref)) < 0) { fprintf(stderr, "Failed to initialize VAAPI frame context." "Error code: %s\n",av_err2str(err)); return err; } ctx->hw_frames_ctx = av_buffer_ref(hw_frames_ref); if (!ctx->hw_frames_ctx) err = AVERROR(ENOMEM); return err; }
1threat
How to Create a string array by spliting a string? : <p>I am kinda stuck at the moment, i have a string of numbers which i dynamically get them from database, the range of numbers can be between 1 to 1 milion, something like this :</p> <pre><code>string str = "10000,68866225,77885525,3,787"; </code></pre> <p>i need to create an array from it, i have tried this:</p> <pre><code>string[] strArr = { str.Replace(",", "").Split(',') }; </code></pre> <p>but it doesnt work anyone has any solution i am all ours. Basically it needs to be like this:</p> <pre><code>string[] strArr = { "10000","68866225","77885525","3","787" }; </code></pre>
0debug
Access Lovoo API using Python : <p>I am hoping to make use of the lovoo API, but don't really know how to start. After running Charles proxy and looking at the traffic, I have come to the following conclusion:</p> <p>First a <code>GET</code> to <code>https://api.lovoo.com/oauth/requestToken?</code> is sent as soon as a user logs on through the app (iPhone):</p> <pre><code> GET /oauth/requestToken? HTTP/1.1 Host api.lovoo.com User-Agent LOVOO/612 (iPhone; iOS 10.2; Scale/3.00) kissapi-app-idfv 1EC7A8E5-DF16-4E14-8EC9-98DD4772F903 tz Europe/xxx kissapi-device-model iPhone 6s Plus kissapi-app-version 3.17.0 kissapi-new-oauth 1 kissapi-device iphone kissapi-app lovoo wifi true kissapi-adv-id 00000000-0000-0000-0000-000000000000 Connection keep-alive kissapi-app-id 7F947A460DAFCA88556B2F35A6D78A3E Authorization OAuth oauth_callback="oob", oauth_consumer_key="an.email%40gmail.com", oauth_nonce="A32CCA91-FB7A-4AA3-8314-0A9A6E67045E", oauth_signature="Sq8KTg%2FhVIGBaWgWXprPluczOs4%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1487017515", oauth_version="1.0" Accept-Language en-CH;q=1, de-CH;q=0.9 kissapi-adv-on false kissapi-version 1.20.0 kissapi-update-user-hash 6ea2bd15ea41d0dc8c2615589e2d52ec Accept */* kissapi-device-os 10.2 Accept-Encoding gzip, deflate kissapi-sync-enabled 1 </code></pre> <p>This also gives following token: <code>oauth_token=44d83e8ef50f&amp;oauth_token_secret=37998f6c6ef2e618</code></p> <p>This is followed by another <code>GET</code> to <code>https://api.lovoo.com/oauth/accessToken?</code>:</p> <pre><code>GET /oauth/accessToken? HTTP/1.1 Host api.lovoo.com User-Agent LOVOO/612 (iPhone; iOS 10.2; Scale/3.00) kissapi-app-idfv 1EC7A8E5-DF16-4E14-8EC9-98DD4772F903 tz Europe/xxx kissapi-device-model iPhone 6s Plus kissapi-app-version 3.17.0 kissapi-new-oauth 1 kissapi-device iphone kissapi-app lovoo wifi true kissapi-adv-id 00000000-0000-0000-0000-000000000000 Connection keep-alive kissapi-app-id 7F947A460DAFCA88556B2F35A6D78A3E Authorization OAuth oauth_consumer_key="an.email%40gmail.com", oauth_nonce="080328C9-0A53-4971-85E7-65A43F12DC09", oauth_signature="Km0vd8xtHaQmRgkrGLsiljel13o%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1487017515", oauth_token="44d83e8ef50f", oauth_version="1.0" Accept-Language en-CH;q=1, de-CH;q=0.9 kissapi-adv-on false kissapi-version 1.20.0 kissapi-update-user-hash 6ea2bd15ea41d0dc8c2615589e2d52ec Accept */* kissapi-device-os 10.2 Accept-Encoding gzip, deflate kissapi-sync-enabled 1 </code></pre> <p>And provides the following token: <code>oauth_token=60c8977c8fe9509f&amp;oauth_token_secret=549619c0ef4c4be7d7cb898e</code></p> <p>Now, a request to <code>https://api.lovoo.com/init</code> can be made:</p> <pre><code>GET /init HTTP/1.1 Host api.lovoo.com User-Agent LOVOO/612 (iPhone; iOS 10.2; Scale/3.00) kissapi-app-idfv 1EC7A8E5-DF16-4E14-8EC9-98DD4772F903 tz Europe/xxx kissapi-device-model iPhone 6s Plus kissapi-app-version 3.17.0 kissapi-new-oauth 1 kissapi-device iphone kissapi-app lovoo wifi true kissapi-adv-id 00000000-0000-0000-0000-000000000000 Connection keep-alive kissapi-app-id 7F947A460DAFCA88556B2F35A6D78A3E Authorization OAuth oauth_consumer_key="an.email%40gmail.com", oauth_nonce="B622CE9C-DA3D-435C-939A-C58B83DBE85C", oauth_signature="0irvAsilrrdCCdLfu%2F0XSj7THlc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1487017515", oauth_token="60c8977c8fe9509f", oauth_version="1.0" Accept-Language en-CH;q=1, de-CH;q=0.9 kissapi-adv-on false kissapi-version 1.20.0 kissapi-update-user-hash 6ea2bd15ea41d0dc8c2615589e2d52ec Accept */* kissapi-device-os 10.2 Accept-Encoding gzip, deflate kissapi-sync-enabled 1 </code></pre> <p>These are the headers I captured, but I don't know how to send them and get the <code>Oauth</code> authentication working, espescially with <code>oauth_nonce</code>.</p> <p><a href="https://github.com/requests/requests-oauthlib" rel="noreferrer">requests-oauthlib</a> seems to support it, but I don't know which of the token correspond to which variable:</p> <pre><code>from requests_oauthlib import OAuth1Session lovoo = OAuth1Session('client_key', client_secret='client_secret', resource_owner_key='resource_owner_key', resource_owner_secret='resource_owner_secret') url = 'https://api.lovoo.com/init' r = lovoo.get(url) </code></pre>
0debug
static int swf_write_packet(AVFormatContext *s, int stream_index, const uint8_t *buf, int size, int64_t pts) { AVCodecContext *codec = &s->streams[stream_index]->codec; if (codec->codec_type == CODEC_TYPE_AUDIO) return swf_write_audio(s, buf, size); else return swf_write_video(s, codec, buf, size); }
1threat
Detect tap on GMSPolyline in Swift? : <p>I'm struggling with detecting a tap on a GMSPolyline drawn on my Google map, it works just fine with GMSpolygones, but the same approach doesn't seem to work with polyline. My current approach, which works for polygones, is: </p> <pre><code>if (GMSGeometryContainsLocation(coordinate, polygon.path!, false)) { ... } </code></pre> <p>Any suggestions how to detect taps on a polyline? Or just close to it?</p>
0debug
Programming in 'C' : How to clear the char array for the next string : <p>I try to write a code that can read a text file in a specific order. The Problem is that the strings overwrite the last string in the Array, but I want that the array is cleared for the next string, however I don't know how to do this.</p> <p>Here is the text file:</p> <pre><code>@str_hello_world_test={hello world!test} @str_hello_world={hello world} </code></pre> <p>And the output is here:</p> <pre><code>symbol:str_hello_world_test²` string:hello world!testtest²` hello world!testtest²` symbol:str_hello_worldttest²` string:hello worldorldttest²` hello worldorldttest²` </code></pre> <p>And my Code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #define MAXBUF 255 //prototypes void readingFile(FILE* fp); char* readingSymbol(FILE* fp); char* readingString(FILE* fp); int main(void) { FILE* fp; char directory[MAXBUF]; puts("Geben sie ein Verzeichnis ein: "); gets(directory); fp = fopen(directory, "r"); readingFile(fp); system("pause"); return EXIT_SUCCESS; } void readingFile(FILE* fp){ int c; while((c = fgetc(fp)) != EOF){ char* symbol = readingSymbol(fp); char* string = readingString(fp); printf("%s\n", symbol); } return; } char* readingSymbol(FILE* fp){ int c; int i = 0; char symbol[MAXBUF]; while((c = fgetc(fp)) != '='){ if(c == '@'){ continue; } else{ symbol[i] = (char)c; i++; } } printf("symbol:%s\n", symbol); return symbol; } char* readingString(FILE* fp){ int c; int i = 0; char str[MAXBUF]; while((c = fgetc(fp)) != '}'){ if(c == '='){ continue; } else if(c == '{'){ continue; } else{ str[i] = (char)c; i++; } } printf("string:%s\n\n", str); return str; } </code></pre>
0debug
static void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr, int insn, int rd) { TCGv_i32 r_asi, r_size; TCGv lo = gen_load_gpr(dc, rd + 1); TCGv_i64 t64 = tcg_temp_new_i64(); tcg_gen_concat_tl_i64(t64, lo, hi); r_asi = gen_get_asi(dc, insn); r_size = tcg_const_i32(8); gen_helper_st_asi(cpu_env, addr, t64, r_asi, r_size); tcg_temp_free_i32(r_size); tcg_temp_free_i32(r_asi); tcg_temp_free_i64(t64); }
1threat
static void gen_check_cpenable(DisasContext *dc, unsigned cp) { if (option_enabled(dc, XTENSA_OPTION_COPROCESSOR) && !(dc->cpenable & (1 << cp))) { gen_exception_cause(dc, COPROCESSOR0_DISABLED + cp); dc->is_jmp = DISAS_UPDATE; } }
1threat
Why does Retrofit enqueue produce null point exception? : <p>I have created my own test JSON and try to incorporate it into my <code>Android</code> app using <code>Retrofit</code> but for some reason I can´t seem to understand I get a <code>Null Point Exception</code> when trying to fetch the <code>JSON</code>. </p> <p>I have created JSON that looks something like this:</p> <pre><code>[{"date":"2019/01/01","availability":"available"},{"date":"2019/01/02","availability":"closed"},{"date":"2019/01/03","availability":"closed"}] </code></pre> <p>And so on...</p> <p>Then I have set up both the <code>Retrofit</code> code and the <code>Room</code> database code.</p> <p>Here is the <code>Retrofit</code> code from the main class:</p> <pre><code>public class MainActivity extends AppCompatActivity { MainRepository mainRepository; Call&lt;List&lt;RFVariables&gt;&gt; getRFPosts; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_main ); getRFPosts = mainRepository.getGetPosts(); getRFPosts.enqueue( new Callback&lt;List&lt;RFVariables&gt;&gt;() { @Override public void onResponse(Call&lt;List&lt;RFVariables&gt;&gt; call, Response&lt;List&lt;RFVariables&gt;&gt; response) { List&lt;RFVariables&gt; myResponse = response.body(); if(myResponse != null) { for(RFVariables item: myResponse) { Log.d("TAG", item.getDate()); } } } @Override public void onFailure(Call&lt;List&lt;RFVariables&gt;&gt; call, Throwable t) { } } ); </code></pre> <p>It crashes on the <code>getRFPosts = mainRepository.getGetPosts();</code> line with the error <code>Attempt to invoke interface method 'void retrofit2.Call.enqueue(retrofit2.Callback)' on a null object reference at com.slothmode.sunnyatsea.MainActivity.onCreate(MainActivity.java:25)</code></p> <p>The repository code looks like this:</p> <pre><code>private Retrofit retrofitObject; private RFCalls retrofitRepository; private Call&lt;List&lt;RFVariables&gt;&gt; getPosts; public MainRepository(Application application) { this.retrofitObject = new Retrofit.Builder() .baseUrl( "https://api.myjson.com/bins/" ) .addConverterFactory( GsonConverterFactory.create() ) .build(); this.retrofitRepository = this.retrofitObject.create( RFCalls.class ); this.getPosts = this.retrofitRepository.findPosts(); } public Call&lt;List&lt;RFVariables&gt;&gt; getGetPosts() { return getPosts; } </code></pre> <p>I have done this successfully before, so not sure what's mising this time around. Seems like an exact replica of my other successful projects. What am I missing? Let me know if there is more code I should show. Thanks in advance. Really stuck here.</p>
0debug
Macro to find cells with value and replacing with value of adjacent cell : I want to search for all cells in a column that are 0000000000. If a cell is equal to 000000000, I want to replace the cell with the value of the cell to the left (previous column, same row) help please!
0debug
Main.c:3:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token : <p>In this simple program to find whether a number is even or odd it keeps howing the error Main.c:3:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘<strong>attribute</strong>’ before ‘{’ token. Please help.</p> <pre><code>#include&lt;stdio.h&gt; int main{ int n; scanf("%d",&amp;n); if(n%2==0) printf("%d is an even number",n); else printf("%d is an odd number",n); return 0; } </code></pre>
0debug
Find gradle path on Ubuntu : <p>I have gradle installed on my Ubuntu 15.10 System.I want to find the location where it is.<br> I am following this (<a href="https://docs.gradle.org/current/userguide/tutorial_java_projects.html" rel="noreferrer">https://docs.gradle.org/current/userguide/tutorial_java_projects.html</a>) article.Here it is given that sample program can be found at <code>samples/java/quickstart</code>.<br> I want to open this sample program and for this I want to find location of gradle on my system.</p>
0debug
static void gen_neon_unzip_u8(TCGv t0, TCGv t1) { TCGv rd, rm, tmp; rd = new_tmp(); rm = new_tmp(); tmp = new_tmp(); tcg_gen_andi_i32(rd, t0, 0xff); tcg_gen_shri_i32(tmp, t0, 8); tcg_gen_andi_i32(tmp, tmp, 0xff00); tcg_gen_or_i32(rd, rd, tmp); tcg_gen_shli_i32(tmp, t1, 16); tcg_gen_andi_i32(tmp, tmp, 0xff0000); tcg_gen_or_i32(rd, rd, tmp); tcg_gen_shli_i32(tmp, t1, 8); tcg_gen_andi_i32(tmp, tmp, 0xff000000); tcg_gen_or_i32(rd, rd, tmp); tcg_gen_shri_i32(rm, t0, 8); tcg_gen_andi_i32(rm, rm, 0xff); tcg_gen_shri_i32(tmp, t0, 16); tcg_gen_andi_i32(tmp, tmp, 0xff00); tcg_gen_or_i32(rm, rm, tmp); tcg_gen_shli_i32(tmp, t1, 8); tcg_gen_andi_i32(tmp, tmp, 0xff0000); tcg_gen_or_i32(rm, rm, tmp); tcg_gen_andi_i32(tmp, t1, 0xff000000); tcg_gen_or_i32(t1, rm, tmp); tcg_gen_mov_i32(t0, rd); dead_tmp(tmp); dead_tmp(rm); dead_tmp(rd); }
1threat
int estimate_motion(MpegEncContext * s, int mb_x, int mb_y, int *mx_ptr, int *my_ptr) { UINT8 *pix, *ppix; int sum, varc, vard, mx, my, range, dmin, xx, yy; int xmin, ymin, xmax, ymax; int rel_xmin, rel_ymin, rel_xmax, rel_ymax; int pred_x=0, pred_y=0; int P[5][2]; const int shift= 1+s->quarter_sample; range = 8 * (1 << (s->f_code - 1)); if (s->out_format == FMT_H263 && !s->h263_msmpeg4) range = range * 2; if (s->unrestricted_mv) { xmin = -16; ymin = -16; if (s->h263_plus) range *= 2; if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4){ xmax = s->mb_width*16; ymax = s->mb_height*16; }else { xmax = s->width; ymax = s->height; } } else { xmin = 0; ymin = 0; xmax = s->mb_width*16 - 16; ymax = s->mb_height*16 - 16; } switch(s->full_search) { case ME_ZERO: default: no_motion_search(s, &mx, &my); dmin = 0; break; case ME_FULL: dmin = full_motion_search(s, &mx, &my, range, xmin, ymin, xmax, ymax); break; case ME_LOG: dmin = log_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax); break; case ME_PHODS: dmin = phods_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax); break; case ME_X1: case ME_EPZS: rel_xmin= xmin - s->mb_x*16; rel_xmax= xmax - s->mb_x*16; rel_ymin= ymin - s->mb_y*16; rel_ymax= ymax - s->mb_y*16; if(s->out_format == FMT_H263){ static const int off[4]= {2, 1, 1, -1}; const int mot_stride = s->block_wrap[0]; const int mot_xy = s->block_index[0]; P[0][0] = s->motion_val[mot_xy ][0]; P[0][1] = s->motion_val[mot_xy ][1]; P[1][0] = s->motion_val[mot_xy - 1][0]; P[1][1] = s->motion_val[mot_xy - 1][1]; if(P[1][0] > (rel_xmax<<shift)) P[1][0]= (rel_xmax<<shift); if ((s->mb_y == 0 || s->first_slice_line || s->first_gob_line)) { pred_x = P[1][0]; pred_y = P[1][1]; } else { P[2][0] = s->motion_val[mot_xy - mot_stride ][0]; P[2][1] = s->motion_val[mot_xy - mot_stride ][1]; P[3][0] = s->motion_val[mot_xy - mot_stride + off[0] ][0]; P[3][1] = s->motion_val[mot_xy - mot_stride + off[0] ][1]; if(P[2][1] > (rel_ymax<<shift)) P[2][1]= (rel_ymax<<shift); if(P[3][0] < (rel_xmin<<shift)) P[3][0]= (rel_xmin<<shift); if(P[3][1] > (rel_ymax<<shift)) P[3][1]= (rel_ymax<<shift); P[4][0]= pred_x = mid_pred(P[1][0], P[2][0], P[3][0]); P[4][1]= pred_y = mid_pred(P[1][1], P[2][1], P[3][1]); } }else { const int xy= s->mb_y*s->mb_width + s->mb_x; pred_x= s->last_mv[0][0][0]; pred_y= s->last_mv[0][0][1]; P[0][0]= s->mv_table[0][xy ]; P[0][1]= s->mv_table[1][xy ]; if(s->mb_x == 0){ P[1][0]= 0; P[1][1]= 0; }else{ P[1][0]= s->mv_table[0][xy-1]; P[1][1]= s->mv_table[1][xy-1]; if(P[1][0] > (rel_xmax<<shift)) P[1][0]= (rel_xmax<<shift); } if (!(s->mb_y == 0 || s->first_slice_line || s->first_gob_line)) { P[2][0] = s->mv_table[0][xy - s->mb_width]; P[2][1] = s->mv_table[1][xy - s->mb_width]; P[3][0] = s->mv_table[0][xy - s->mb_width+1]; P[3][1] = s->mv_table[1][xy - s->mb_width+1]; if(P[2][1] > (rel_ymax<<shift)) P[2][1]= (rel_ymax<<shift); if(P[3][0] > (rel_xmax<<shift)) P[3][0]= (rel_xmax<<shift); if(P[3][0] < (rel_xmin<<shift)) P[3][0]= (rel_xmin<<shift); if(P[3][1] > (rel_ymax<<shift)) P[3][1]= (rel_ymax<<shift); P[4][0]= mid_pred(P[1][0], P[2][0], P[3][0]); P[4][1]= mid_pred(P[1][1], P[2][1], P[3][1]); } } dmin = epzs_motion_search(s, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax); mx+= s->mb_x*16; my+= s->mb_y*16; break; } xx = mb_x * 16; yy = mb_y * 16; pix = s->new_picture[0] + (yy * s->linesize) + xx; ppix = s->last_picture[0] + (my * s->linesize) + mx; sum = pix_sum(pix, s->linesize); varc = pix_norm1(pix, s->linesize); vard = pix_norm(pix, ppix, s->linesize); vard = vard >> 8; sum = sum >> 8; varc = (varc >> 8) - (sum * sum); s->mb_var[s->mb_width * mb_y + mb_x] = varc; s->avg_mb_var += varc; s->mc_mb_var += vard; #if 0 printf("varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n", varc, s->avg_mb_var, sum, vard, mx - xx, my - yy); #endif if (vard <= 64 || vard < varc) { if (s->full_search != ME_ZERO) { halfpel_motion_search(s, &mx, &my, dmin, xmin, ymin, xmax, ymax, pred_x, pred_y); } else { mx -= 16 * s->mb_x; my -= 16 * s->mb_y; } *mx_ptr = mx; *my_ptr = my; return 0; } else { *mx_ptr = 0; *my_ptr = 0; return 1; } }
1threat
Differences between netflix.feign & openfeign : <h2>Introduction</h2> <p>I recently used netflix feign along with ribbon which was quite useful. </p> <p>An Example of this is:</p> <pre><code>@FeignClient(name = "ldap-proxy") public interface LdapProxyClient { @RequestMapping(path = "/ldap-proxy/v1/users/{userNameOrEMail}", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) LdapUser search(@PathVariable("userNameOrEMail") String userNameOrEMail); } </code></pre> <p>However, at some point I thought that instead of having to code all these definitions by hand (for an existing webservice), that I should see if a tool existed.</p> <p>I stumbled across <code>https://github.com/swagger-api/swagger-codegen</code>and saw that there are examples in which clients are generated, e.g. <a href="https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/java/feign" rel="noreferrer">https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/java/feign</a> .</p> <p>However, once I looked closely at the imports I noticed the following: </p> <p><code>import feign.Feign;</code></p> <p>Netflix's opensource solution on the other hand has package names: <code>org.springframework.cloud.netflix.feign</code>.</p> <p>Additionally, I noticed that both use ribbon if available, but Netflix's notation is much cleaner with a lot happenning in the background. E.g. the <code>@FeignClient</code> annotation class javadoc states:</p> <blockquote> <ul> <li>Annotation for interfaces declaring that a REST client with that interface should be * created (e.g. for autowiring into another component). If ribbon is available it will be * used to load balance the backend requests, and the load balancer can be configured * using a <code>@RibbonClient</code> with the same name (i.e. value) as the feign client.</li> </ul> </blockquote> <p>However in the <code>Feign.feign</code> documentation (at <a href="https://github.com/OpenFeign/feign" rel="noreferrer">https://github.com/OpenFeign/feign</a> ) I see:</p> <blockquote> <p>RibbonClient overrides URL resolution of Feign's client, adding smart routing and resiliency capabilities provided by Ribbon.</p> <p>Integration requires you to pass your ribbon client name as the host part of the url, for example myAppProd.</p> </blockquote> <pre><code>&gt; MyService api = &gt; Feign.builder().client(RibbonClient.create()).target(MyService.class, &gt; "https://myAppProd"); </code></pre> <h2>So my questions are:</h2> <ol> <li>what is the history/relationship and differences between the two?</li> <li>what are the pros and cons of each?</li> </ol> <p>Are they completely different projects with no relation, or did netflix just fork/utilize OpenFeign and modify it to be within their integrated cloud solution? Essentially, did netflix just acquire and integrate different technologies like Discovery, ribbon, and feign from open-source projects?</p>
0debug
Show Specific Value : <p>This is the code i try but when i select an item it show some array ouput i just want the specific value that i selected. like white-house</p> <pre><code> &lt;select id="item"&gt; &lt;option value=""&gt;Please select&lt;/option&gt; &lt;option value="white-house"&gt;The White House&lt;/option&gt; &lt;/select&gt; &lt;div id="results"&gt;&lt;/div&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; function makeAjaxRequest(opts){ $.ajax({ type: "POST", data: { opts: opts }, url: "tryonly.php", success: function(res) { $("#results").html("&lt;p&gt; " + res + "&lt;/p&gt;"); } }); } $("#item").on("change", function(){ var selected = $(this).val(); makeAjaxRequest(selected); }); &lt;/script&gt; </code></pre> <p>In php code</p> <pre><code>&lt;?php echo '&lt;pre&gt;'; print_r($_POST); echo '&lt;/pre&gt;'; ?&gt; </code></pre> <p>the output when i select item </p> <pre><code>Array ( [opts] =&gt; white-house ) </code></pre>
0debug
Is there a way to parse JSON with java? : <p>Here is what I have so far:</p> <pre><code> public Bitmap getAlbumCover(Context context, String song, String artist) { this.context = context; song = song.replace(" ", "%20"); artist = artist.replace(" ", "%20"); try { conn = new URL("https://api.spotify.com/v1/search?q=track" + song + ":%20artist:" + artist + "&amp;type=track)").openConnection(); } catch (IOException e) { e.printStackTrace(); } if (conn != null) conn.setDoOutput(true); try { reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); } catch (IOException e) { e.printStackTrace(); } if (reader != null) { // Read Server Response String line2 = null; try { while ((line2 = reader.readLine()) != null) { sb.append(line2); } } catch (IOException e) { e.printStackTrace(); } try { json = new JSONArray(sb.toString()); } catch (JSONException e) { e.printStackTrace(); } } JSONParser parser= new JSONParser(); try { JSONObject jsonObject = (JSONObject) parser.parse(reader); try { array = (JSONArray) jsonObject.get("items"); } catch (JSONException e) { e.printStackTrace(); } // take each value from the json array separately } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } </code></pre> <p>The JSON I am using is located here: <a href="https://api.spotify.com/v1/search?q=track:Ready%20To%20Fall%20artist:rise%20against%20&amp;type=track" rel="nofollow">https://api.spotify.com/v1/search?q=track:Ready%20To%20Fall%20artist:rise%20against%20&amp;type=track</a></p> <p>I am trying to get the image url located in the images array and the preview_track url located in items.</p>
0debug
Add hashmap values in hashmap inside arraylist without duplicate in android : Set of values present in HashMap<key,value>.How to add HashMap value in HashMap<key,value> inside array list by avoiding duplicate value in android.
0debug
Getting address of class member function and calling it from pointer : <p>Trying to make LCD screen library for Arduino. Made a class "ScreenHandlerClass". This has S1_stat() and S2_stat() functions that will write different things on LCD screen. There's a "statScreenPointer", that I'm trying to make to call functions, however it does not work properly.</p> <p>I tried to follow this guide: <a href="https://stackoverflow.com/questions/25453259/calling-member-function-pointers">Calling Member Function Pointers</a> That's the closest solution to my problem. I tried:</p> <p>this->*statScreenPointer</p> <pre><code>Error compiling project sources ScreenHandler.cpp: 14:26: error: invalid use of non-static member function this-&gt;*statScreenPointer </code></pre> <p>Other I tried: this->*statScreenPointer()</p> <pre><code>Error compiling project sources ScreenHandler.cpp: 14:27: error: must use '.*' or '-&gt;*' to call pointer-to-member function in '((ScreenHandlerClass*)this)-&gt;ScreenHandlerClass::statScreenPointer (...)', e.g. '(... -&gt;* ((ScreenHandlerClass*)this)-&gt;ScreenHandlerClass::statScreenPointer) (...) this-&gt;*statScreenPointer() Build failed for project 'v1' </code></pre> <p>CODE:</p> <pre><code>// ScreenHandler.h #ifndef _SCREENHANDLER_h #define _SCREENHANDLER_h #include "arduino.h" #include "debug.h" #include "vezerles.h" #include "EncoderHandler.h" #include &lt;LiquidCrystal_I2C.h&gt; extern EncoderHandlerClass encoder; extern LiquidCrystal_I2C lcd; enum screenType { S1, S2 }; extern screenType screen; class ScreenHandlerClass { private: void logic(); void (ScreenHandlerClass::*statScreenPointer)(); public: ScreenHandlerClass(); void init(); void handle(); void S1_stat(); void S2_stat(); }; #endif </code></pre> <pre><code>// ScreenHandler.cpp #include "ScreenHandler.h" screenType screen; ScreenHandlerClass::ScreenHandlerClass() {} void ScreenHandlerClass::init() { statScreenPointer = &amp;ScreenHandlerClass::S1_stat; this-&gt;*statScreenPointer; // ----&gt; how to call this properly? lcd.setCursor(0, 1); lcd.print("init"); // this is DISPLAYED } void ScreenHandlerClass::handle() { logic(); } void ScreenHandlerClass::logic() { // some logic for lcd screen switching } void ScreenHandlerClass::S1_stat() { lcd.setCursor(0, 0); lcd.print("S1_stat"); // this is NOT DISPLAYED } void ScreenHandlerClass::S2_stat() { // some other text for lcd } </code></pre> <pre><code>// v1.ino #include "debug.h" #include "global.h" #include &lt;TimerOne.h&gt; #include &lt;LiquidCrystal_I2C.h&gt; #include "MillisTimer.h" #include "vezerles.h" #include "lcd.h" #include "EncoderHandler.h" #include "ScreenHandler.h" extern EncoderHandlerClass encoder; ScreenHandlerClass scrh; LiquidCrystal_I2C lcd(0x3F, 20, 4); void setup() { Serial.begin(9600); encoder.initButton(PIND, PD4, 500); lcd.init(); lcd.backlight(); scrh.init(); } void loop() { // some code } </code></pre>
0debug
static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr) { sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu); uint64_t tce; #ifdef DEBUG_TCE fprintf(stderr, "spapr_tce_translate liobn=0x%" PRIx32 " addr=0x" DMA_ADDR_FMT "\n", tcet->liobn, addr); #endif if (tcet->bypass) { return (IOMMUTLBEntry) { .target_as = &address_space_memory, .iova = 0, .translated_addr = 0, .addr_mask = ~(hwaddr)0, .perm = IOMMU_RW, }; } if (addr >= tcet->window_size) { #ifdef DEBUG_TCE fprintf(stderr, "spapr_tce_translate out of bounds\n"); #endif return (IOMMUTLBEntry) { .perm = IOMMU_NONE }; } tce = tcet->table[addr >> SPAPR_TCE_PAGE_SHIFT].tce; #ifdef DEBUG_TCE fprintf(stderr, " -> *paddr=0x%llx, *len=0x%llx\n", (tce & ~SPAPR_TCE_PAGE_MASK), SPAPR_TCE_PAGE_MASK + 1); #endif return (IOMMUTLBEntry) { .target_as = &address_space_memory, .iova = addr & ~SPAPR_TCE_PAGE_MASK, .translated_addr = tce & ~SPAPR_TCE_PAGE_MASK, .addr_mask = SPAPR_TCE_PAGE_MASK, .perm = tce, }; }
1threat
static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ MpegEncContext * const s = &h->s; AVCodecContext * const avctx= s->avctx; int buf_index=0; #if 0 int i; for(i=0; i<32; i++){ printf("%X ", buf[i]); } #endif for(;;){ int consumed; int dst_length; int bit_length; uint8_t *ptr; for(; buf_index + 3 < buf_size; buf_index++){ if(buf[buf_index] == 0 && buf[buf_index+1] == 0 && buf[buf_index+2] == 1) break; } if(buf_index+3 >= buf_size) break; buf_index+=3; ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, buf_size - buf_index); if(ptr[dst_length - 1] == 0) dst_length--; bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1); if(s->avctx->debug&FF_DEBUG_STARTCODE){ av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length); } buf_index += consumed; if(h->nal_ref_idc < s->hurry_up) continue; switch(h->nal_unit_type){ case NAL_IDR_SLICE: idr(h); case NAL_SLICE: init_get_bits(&s->gb, ptr, bit_length); h->intra_gb_ptr= h->inter_gb_ptr= &s->gb; s->data_partitioning = 0; if(decode_slice_header(h) < 0) return -1; if(h->redundant_pic_count==0) decode_slice(h); break; case NAL_DPA: init_get_bits(&s->gb, ptr, bit_length); h->intra_gb_ptr= h->inter_gb_ptr= NULL; s->data_partitioning = 1; if(decode_slice_header(h) < 0) return -1; break; case NAL_DPB: init_get_bits(&h->intra_gb, ptr, bit_length); h->intra_gb_ptr= &h->intra_gb; break; case NAL_DPC: init_get_bits(&h->inter_gb, ptr, bit_length); h->inter_gb_ptr= &h->inter_gb; if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning) decode_slice(h); break; case NAL_SEI: break; case NAL_SPS: init_get_bits(&s->gb, ptr, bit_length); decode_seq_parameter_set(h); if(s->flags& CODEC_FLAG_LOW_DELAY) s->low_delay=1; avctx->has_b_frames= !s->low_delay; break; case NAL_PPS: init_get_bits(&s->gb, ptr, bit_length); decode_picture_parameter_set(h); break; case NAL_PICTURE_DELIMITER: break; case NAL_FILTER_DATA: break; } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; } if(!s->current_picture_ptr) return buf_index; h->prev_frame_num_offset= h->frame_num_offset; h->prev_frame_num= h->frame_num; if(s->current_picture_ptr->reference){ h->prev_poc_msb= h->poc_msb; h->prev_poc_lsb= h->poc_lsb; } if(s->current_picture_ptr->reference) execute_ref_pic_marking(h, h->mmco, h->mmco_index); else assert(h->mmco_index==0); ff_er_frame_end(s); if( h->disable_deblocking_filter_idc != 1 ) { filter_frame( h ); } MPV_frame_end(s); return buf_index; }
1threat
Matplotlib set_color_cycle versus set_prop_cycle : <p>One of my favorite things to do in Matplotlib is to set the color-cycle to match some colormap, in order to produce line-plots that have a nice progression of colors across the lines. Like this one:</p> <p><a href="https://i.stack.imgur.com/vaoiJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vaoiJ.png" alt="enter image description here"></a></p> <p>Previously, this was one line of code using <code>set_color_cycle</code>:</p> <pre><code>ax.set_color_cycle([plt.cm.spectral(i) for i in np.linspace(0, 1, num_lines)]) </code></pre> <p>But, recently I see a warning:</p> <pre><code>MatplotlibDeprecationWarning: The set_color_cycle attribute was deprecated in version 1.5. Use set_prop_cycle instead. </code></pre> <p>Using <code>set_prop_cycle</code>, I can achieve the same result, but I need to <code>import cycler</code>, and the syntax is less compact:</p> <pre><code>from cycler import cycler colors = [plt.cm.spectral(i) for i in np.linspace(0, 1, num_lines)] ax.set_prop_cycle(cycler('color', colors)) </code></pre> <p>So, my questions are: </p> <p>Am I using <code>set_prop_cycle</code> correctly? (and in the most efficient way?)</p> <p>Is there an easier way to set the color-cycle to a colormap? In other words, is there some mythical function like this? </p> <pre><code>ax.set_colorcycle_to_colormap('jet', nlines=30) </code></pre> <p>Here is the code for the complete example:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt ax = plt.subplot(111) num_lines = 30 colors = [plt.cm.spectral(i) for i in np.linspace(0, 1, num_lines)] # old way: ax.set_color_cycle(colors) # new way: from cycler import cycler ax.set_prop_cycle(cycler('color', colors)) for n in range(num_lines): x = np.linspace(0,10,500) y = np.sin(x)+n ax.plot(x, y, lw=3) plt.show() </code></pre>
0debug
Whats the meaning of mock test using Mockito : <p>When using mockito, I guess i'm supposed to use when().thenreturn to customize the return value, even that's different from the real method. I just got confused that if everything is mocked (or fake?), how does mockito work to test if the method truly works well?</p>
0debug
Saving content from textare to a div : https://jsfiddle.net/vm8gbedb/2/ My Question is. How can i be able to use the textarea to save a note on "to do" div by creating a div inside it? For it to save to i have to create a database for it? <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Sticky Dashboard</title> <link rel="stylesheet" type="text/css" href="index.css"> <script src="index.js"></script> <link href="https://fonts.googleapis.com/css?family=Ranga" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet"> </head> <body> <nav> <h1 id="headline">Sticky note </h1> <div class="container-nav"> <textarea id="submit-content"></textarea> <input type="button" onclick="addNote()" name="Post" class="submit-note" value="Post note"> </div> </nav> <main> <div class="container"> <div class="column column-one" id="column-one"> <h2>To do</h2> </div> <div class="column column-two" id="column-two"> <h2>Ongoing</h2> </div> <div class="column column-three" id="column-three"> <h2>Done</h2> </div> </div> </main> <footer> <div id="footer"> <p id="footertext"> </p> </div> </footer> </body> </html>
0debug
How do I window removeEventListener using React useEffect : <p>In React Hooks documents it is shown how to removeEventListener during the component's cleanup phase. <a href="https://reactjs.org/docs/hooks-reference.html#conditionally-firing-an-effect" rel="noreferrer">https://reactjs.org/docs/hooks-reference.html#conditionally-firing-an-effect</a></p> <p>In my use case, I am trying to removeEventListener conditional to a state property of the functional component.</p> <p>Here's an example where the component is never unmounted but the event listener should be removed:</p> <pre><code>function App () { const [collapsed, setCollapsed] = React.useState(true); React.useEffect( () =&gt; { if (collapsed) { window.removeEventListener('keyup', handleKeyUp); // Not the same "handleKeyUp" :( } else { window.addEventListener('keyup', handleKeyUp); } }, [collapsed] ); function handleKeyUp(event) { console.log(event.key); switch (event.key) { case 'Escape': setCollapsed(true); break; } } return collapsed ? ( &lt;a href="javascript:;" onClick={()=&gt;setCollapsed(false)}&gt;Search&lt;/a&gt; ) : ( &lt;span&gt; &lt;input placeholder="Search" autoFocus /&gt;&amp;nbsp; &lt;a href="javascript:;"&gt;This&lt;/a&gt;&amp;nbsp; &lt;a href="javascript:;"&gt;That&lt;/a&gt;&amp;nbsp; &lt;input placeholder="Refinement" /&gt; &lt;/span&gt; ); } ReactDOM.render(&lt;App /&gt;, document.body.appendChild(document.createElement('div'))); </code></pre> <p>(Live sample at <a href="https://codepen.io/caqu/pen/xBeBMN" rel="noreferrer">https://codepen.io/caqu/pen/xBeBMN</a>)</p> <p>The problem I see is that the <code>handleKeyUp</code> reference inside <code>removeEventListener</code> is changing every time the component renders. The function <code>handleKeyUp</code> needs a reference to <code>setCollapsed</code> so it must be enclosed by <code>App</code>. Moving <code>handleKeyUp</code> inside <code>useEffect</code> also seems to fire multiple times and lose the reference to the original <code>handleKeyUp</code>.</p> <p>How can I conditionally window.removeEventListener using React Hooks without unmounting the component?</p>
0debug
please help, why isn't this function working? : I have been trying to get this simple function to work by using this callback but I don't understand what I am doing wrong. I want to invoke a function when the scrolltop is greater than zero. I am new to programming - it might seem like a stupid question but I can't figure it out. Is it a formatting issue? function alertme() { var $window = $(window); var window_top = $window.scrollTop(0); if (window_top > 0) { alert("alertme"); }; };
0debug
Pandas filling missing dates and values within group : <p>I've a data frame that looks like the following</p> <pre><code>x = pd.DataFrame({'user': ['a','a','b','b'], 'dt': ['2016-01-01','2016-01-02', '2016-01-05','2016-01-06'], 'val': [1,33,2,1]}) </code></pre> <p>What I would like to be able to do is find the minimum and maximum date within the date column and expand that column to have all the dates there while simultaneously filling in <code>0</code> for the <code>val</code> column. So the desired output is</p> <pre><code> dt user val 0 2016-01-01 a 1 1 2016-01-02 a 33 2 2016-01-03 a 0 3 2016-01-04 a 0 4 2016-01-05 a 0 5 2016-01-06 a 0 6 2016-01-01 b 0 7 2016-01-02 b 0 8 2016-01-03 b 0 9 2016-01-04 b 0 10 2016-01-05 b 2 11 2016-01-06 b 1 </code></pre> <p>I've tried the solution mentioned <a href="https://stackoverflow.com/questions/19324453/add-missing-dates-to-pandas-dataframe">here</a> and <a href="https://stackoverflow.com/questions/27241795/fill-missing-dates-by-group-in-pandas">here</a> but they aren't what I'm after. Any pointers much appreciated.</p>
0debug
static void test_dynamic_globalprop_subprocess(void) { MyType *mt; static GlobalProperty props[] = { { TYPE_DYNAMIC_PROPS, "prop1", "101", true }, { TYPE_DYNAMIC_PROPS, "prop2", "102", true }, { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true }, { TYPE_UNUSED_HOTPLUG, "prop4", "104", false }, { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true }, { TYPE_NONDEVICE, "prop6", "106", true }, {} }; int all_used; qdev_prop_register_global_list(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); all_used = qdev_prop_check_globals(); g_assert_cmpuint(all_used, ==, 1); g_assert(!props[0].not_used); g_assert(!props[1].not_used); g_assert(props[2].not_used); g_assert(!props[3].not_used); g_assert(props[4].not_used); g_assert(props[5].not_used); }
1threat
Trouble Converting VHDL to Verilog : I am trying to convert the vhdl code below to verilog, and it is not working properly. I have already done most of it, but I think I may have converted the VHDL keyword others incorrectly. Could anyone please help? ## VHDL Code ## entity debounce is Port ( clk : in STD_LOGIC; i : in STD_LOGIC; o : out STD_LOGIC); end debounce; architecture Behavioral of debounce is signal c : unsigned(23 downto 0); begin process(clk) begin if rising_edge(clk) then if i = '1' then if c = x"FFFFFF" then o <= '1'; else o <= '0'; end if; c <= c+1; else c <= (others => '0'); --LINE IN QUESTION o <= '0'; end if; end if; end process; end Behavioral; ## My Verilog Code ## module debounce(input clk, input i, output o); reg unsigned [23:0] c; reg out_temp; always @(posedge clk)begin if(i == 1)begin if(c==24'hFFFFFF)begin out_temp = 1'b1; end else begin out_temp = 1'b0; end c = c+1'b1; end else begin c = 1'b0; // LINE IN QUESTION out_temp = 1'b0; end end assign o = out_temp; endmodule
0debug
Creating a program that will tell a user what month it will be x months from now ( C++) : <p>I am completely stuck / lost. I need to write a program that will tell a user what month it will be in x amount of months from March. I need a point in the right direction to start me off.</p> <p>I am still learning c++, so I'm trying to keep it as basic as possible. Any help will be a lifesaver !! </p> <p>Example:</p> <p>User enters 6, the result would display September.</p> <p>User enters 239, the result would be February. </p>
0debug
How to read data into TensorFlow batches from example queue? : <p>How do I get TensorFlow example queues into proper batches for training?</p> <p>I've got some images and labels:</p> <pre><code>IMG_6642.JPG 1 IMG_6643.JPG 2 </code></pre> <p>(feel free to suggest another label format; I think I may need another dense to sparse step...)</p> <p>I've read through quite a few tutorials but don't quite have it all together yet. Here's what I have, with comments indicating the steps required from TensorFlow's <a href="https://www.tensorflow.org/versions/r0.8/how_tos/reading_data/index.html#reading-from-files" rel="noreferrer">Reading Data</a> page.</p> <ol> <li>The list of filenames (optional steps removed for the sake of simplicity)</li> <li>Filename queue</li> <li>A Reader for the file format</li> <li>A decoder for a record read by the reader</li> <li>Example queue</li> </ol> <p>And after the example queue I need to get this queue into batches for training; that's where I'm stuck...</p> <p><strong>1. List of filenames</strong></p> <p><code>files = tf.train.match_filenames_once('*.JPG')</code></p> <p><strong>4. Filename queue</strong></p> <p><code>filename_queue = tf.train.string_input_producer(files, num_epochs=None, shuffle=True, seed=None, shared_name=None, name=None)</code></p> <p><strong>5. A reader</strong></p> <p><code>reader = tf.TextLineReader() key, value = reader.read(filename_queue)</code></p> <p><strong>6. A decoder</strong></p> <p><code>record_defaults = [[""], [1]] col1, col2 = tf.decode_csv(value, record_defaults=record_defaults) </code> (I don't think I need this step below because I already have my label in a tensor but I include it anyways)</p> <p><code>features = tf.pack([col2])</code></p> <p>The documentation page has an example to run one image, not get the images and labels into batches:</p> <p><code> for i in range(1200): # Retrieve a single instance: example, label = sess.run([features, col5]) </code></p> <p>And then below it has a batching section:</p> <pre><code>def read_my_file_format(filename_queue): reader = tf.SomeReader() key, record_string = reader.read(filename_queue) example, label = tf.some_decoder(record_string) processed_example = some_processing(example) return processed_example, label def input_pipeline(filenames, batch_size, num_epochs=None): filename_queue = tf.train.string_input_producer( filenames, num_epochs=num_epochs, shuffle=True) example, label = read_my_file_format(filename_queue) # min_after_dequeue defines how big a buffer we will randomly sample # from -- bigger means better shuffling but slower start up and more # memory used. # capacity must be larger than min_after_dequeue and the amount larger # determines the maximum we will prefetch. Recommendation: # min_after_dequeue + (num_threads + a small safety margin) * batch_size min_after_dequeue = 10000 capacity = min_after_dequeue + 3 * batch_size example_batch, label_batch = tf.train.shuffle_batch( [example, label], batch_size=batch_size, capacity=capacity, min_after_dequeue=min_after_dequeue) return example_batch, label_batch </code></pre> <p>My question is: <strong>how do I use the above example code with the code I have above?</strong> I need <em>batches</em> to work with, and most of the tutorials come with mnist batches already.</p> <pre><code>with tf.Session() as sess: sess.run(init) # Training cycle for epoch in range(training_epochs): total_batch = int(mnist.train.num_examples/batch_size) # Loop over all batches for i in range(total_batch): batch_xs, batch_ys = mnist.train.next_batch(batch_size) </code></pre>
0debug
Can't find the bug/probleem in my program : <p>I'm making my first project c++. It's a simple temperature converter.</p> <p>I made a test section [code 1] with if statements. the if statement would compare the user input. for example if you user typed c and then k(Celsius-Kelvin). it should run the function[code 2] CtoK(); but i doesn't it runs all function why does it do this?</p> <p>It try to use return but i didn't(it also didn't gave a error so i kept it)</p> <p>If you guys see something else pls say it <a href="http://pastebin.com/5sGZVKhu" rel="nofollow">Code on pastebin</a></p> <p>Also thinks to keep it mind: Just stated to learn C++ Not native English so if there are spelling and grammar mistakes please say it so i can learn form it</p> <p>[code 1]</p> <pre><code>void whatToWhat(char firstDegrees, char secondDegrees) { if (firstDegrees == 'C' || 'c') {// tests if the user want form c to f if (secondDegrees == 'F' || 'f') { CtoF(); } }if (firstDegrees == 'C' || 'c') {// tests if the user want form c to k if (secondDegrees == 'K' || 'k') { CtoK(); } }if (firstDegrees == 'F' || 'f') {// tests if the user want form f to c if (secondDegrees == 'C' || 'c') { FtoC(); } }if (firstDegrees == 'F' || 'f') {// tests if the user want form f to k if (secondDegrees == 'K' || 'k') { FtoK(); } }if (firstDegrees == 'K' || 'k') {// tests if the user want form k to f if (secondDegrees == 'F' || 'f') { KtoF(); } }if (firstDegrees == 'K' || 'k') {// tests if the user want form k to c if (secondDegrees == 'C' || 'c') { KtoC(); } } } </code></pre> <p>[code 2]</p> <pre><code> void CtoF() {// c to f furmula double input; cout &lt;&lt; "Enter a number[Celsius-Fahrenheit]" &lt;&lt; endl; cin &gt;&gt; input; cout &lt;&lt; "it's " &lt;&lt; input * 1.8 + 32 &lt;&lt; " Fahrenheit " &lt;&lt; endl; return; } void CtoK() {// c to k furmula double input; cout &lt;&lt; "Enter a number[Celsius-Kelvin]" &lt;&lt; endl; cin &gt;&gt; input; cout &lt;&lt; "it's " &lt;&lt; input + 273.15 &lt;&lt; " Kelvin " &lt;&lt; endl; return; } void FtoC() {//f to c furmula double input; cout &lt;&lt; "Enter a number[Fahrenheit-Celsius]" &lt;&lt; endl; cin &gt;&gt; input; cout &lt;&lt; "it's " &lt;&lt; input / 1.8 - 32 &lt;&lt; " Celsius " &lt;&lt; endl; } void FtoK() {//f to k furmula double input; cout &lt;&lt; "Enter a number[Fahrenheit-Kelvin]" &lt;&lt; endl; cin &gt;&gt; input; cout &lt;&lt; "it's " &lt;&lt; input / 1.8 - 32 + 273.15 &lt;&lt; " Kelvin " &lt;&lt; endl; return; } void KtoF() {// k to f furmula double input; cout &lt;&lt; "Enter a number[Kelvin-Fahrenheit]" &lt;&lt; endl; cin &gt;&gt; input; cout &lt;&lt; "it's " &lt;&lt; (input - 273.15) * 1.8 + 32 &lt;&lt; " Fahrenheit " &lt;&lt; endl; } void KtoC() {// k to c furmula double input; cout &lt;&lt; "Enter a number[Kelvin-Celsius]" &lt;&lt; endl; cin &gt;&gt; input; cout &lt;&lt; "it's " &lt;&lt;273.15 - input &lt;&lt; " Celsius " &lt;&lt; endl; return; } </code></pre>
0debug